青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當自強而不息

頂點坐標變換(6)

視區變換

視區(視口)變換是Direct3D頂點變換流水線的最后一步,它通過定義視區信息(屏幕顯示區域的實際寬和高等參數),完成頂點裁剪以及將頂點坐標從投影坐標變換為最終顯示的以像素為單位的屏幕坐標等操作。裁剪過程保證不渲染完全在觀察平截面以外的對象,還確保對于與觀察平截面相交的對象,可以如下方式進行渲染:即在視口指定范圍以外的部分不繪制像素。

 

1、定義視區

視區結構D3DVIEWPORT9定義了Direct3D用以進行視區變換的各項參數:

Defines the window dimensions of a render-target surface onto which a 3D volume projects.

typedef struct D3DVIEWPORT9 {
DWORD X;
DWORD Y;
DWORD Width;
DWORD Height;
float MinZ;
float MaxZ;
} D3DVIEWPORT9, *LPD3DVIEWPORT9;

Members

X
Pixel coordinate of the upper-left corner of the viewport on the render-target surface. Unless you want to render to a subset of the surface, this member can be set to 0.
Y
Pixel coordinate of the upper-left corner of the viewport on the render-target surface. Unless you want to render to a subset of the surface, this member can be set to 0.
Width
Width dimension of the clip volume, in pixels. Unless you are rendering only to a subset of the surface, this member should be set to the width dimension of the render-target surface.
Height
Height dimension of the clip volume, in pixels. Unless you are rendering only to a subset of the surface, this member should be set to the height dimension of the render-target surface.
MinZ
Together with MaxZ, value describing the range of depth values into which a scene is to be rendered, the minimum and maximum values of the clip volume. Most applications set this value to 0.0. Clipping is performed after applying the projection matrix.
MaxZ
Together with MinZ, value describing the range of depth values into which a scene is to be rendered, the minimum and maximum values of the clip volume. Most applications set this value to 1.0. Clipping is performed after applying the projection matrix.

Remarks

The X, Y, Width, and Height members describe the position and dimensions of the viewport on the render-target surface. Usually, applications render to the entire target surface; when rendering on a 640 x 480 surface, these members should be 0, 0, 640, and 480, respectively. The MinZ and MaxZ are typically set to 0.0 and 1.0 but can be set to other values to achieve specific effects. For example, you might set them both to 0.0 to force the system to render objects to the foreground of a scene, or both to 1.0 to force the objects into the background.

When the viewport parameters for a device change (because of a call to the IDirect3DDevice9::SetViewport method), the driver builds a new transformation matrix.

 

2、視區設置

使用函數IDirect3DDevice9::SetViewport()設置Direct3D的視區,其聲明如下:

HRESULT SetViewport(
CONST D3DVIEWPORT9 * pViewport
);

SetViewport()的作用相當于把投影空間的頂點P(x, y, z, 1)乘以下面的矩陣:

因此,屏幕上的二維坐標P'(x', y')的坐標等于:

x' = x * width/2 + startx + width/2

y' = y * (-height/2) + starty + height/2

z' = z * (maxz - minz) + minz

這些坐標被Direct3D用來進行裁剪。

與SetViewport()相對應,可以通過函數IDirect3DDevice9::GetViewport()獲得當前視區的相關信息,該函數聲明如下:

Retrieves the viewport parameters currently set for the device.

HRESULT GetViewport(
D3DVIEWPORT9 * pViewport
);

Parameters

pViewport
[out] Pointer to a D3DVIEWPORT9 structure, representing the returned viewport parameters.

Return Values

If the method succeeds, the return value is D3D_OK. D3DERR_INVALIDCALL is returned if the pViewport parameter is invalid.

Remarks

Typically, methods that return state will not work on a device that is created using D3DCREATE_PUREDEVICE. This method however, will work even on a pure device.

 

3、清空視區

一般情況下,在繪制每一幀圖形前都要先清空視區,即清空渲染目標表面上的視區矩形的內容:顏色緩沖區、深度緩沖區或者模板緩沖區。使用函數IDirect3DDevice9::Clear()來清空視區,該函數聲明如下:

Clears one or more surfaces such as a render target, multiple render targets, a stencil buffer, and a depth buffer.

HRESULT Clear(
DWORD Count,
CONST D3DRECT * pRects,
DWORD Flags,
D3DCOLOR Color,
float Z,
DWORD Stencil
);

Parameters

Count
[in] Number of rectangles in the array at pRects. Must be set to 0 if pRects is NULL. May not be 0 if pRects is a valid pointer.
pRects
[in] Pointer to an array of D3DRECT structures that describe the rectangles to clear. Set a rectangle to the dimensions of the rendering target to clear the entire surface. Each rectangle uses screen coordinates that correspond to points on the render target. Coordinates are clipped to the bounds of the viewport rectangle. To indicate that the entire viewport rectangle is to be cleared, set this parameter to NULL and Count to 0.
Flags
[in] Combination of one or more D3DCLEAR flags that specify the surface(s) that will be cleared.
Color
[in] Clear a render target to this ARGB color.
Z
[in] Clear the depth buffer to this new z value which ranges from 0 to 1. See remarks.
Stencil
[in] Clear the stencil buffer to this new value which ranges from 0 to 2n - 1 (n is the bit depth of the stencil buffer). See remarks.

Return Values

If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be: D3DERR_INVALIDCALL.

Remarks

Use this method to clear a surface including: a render target, all render targets in an MRT, a stencil buffer, or a depth buffer. Flags determines how many surfaces are cleared. Use pRects to clear a subset of a surface defined by an array of rectangles.

IDirect3DDevice9::Clear will fail if you:

  • Try to clear either the depth buffer or the stencil buffer of a render target that does not have an attached depth buffer.
  • Try to clear the stencil buffer when the depth buffer does not contain stencil data.

D3DCLEAR

These flags identify a surface to reset when calling IDirect3DDevice9::Clear.

#define Description
D3DCLEAR_STENCIL Clear the stencil buffer.
D3DCLEAR_TARGET Clear a render target, or all targets in a multiple render target. See Multiple Render Targets (Direct3D 9).
D3DCLEAR_ZBUFFER Clear the depth buffer.

 

獲取Direct3D坐標變換矩陣

在Direct3D中,可以通過IDirect3DDevice9::GetTransform()獲取當前的世界變換矩陣、觀察變換矩陣以及投影變換矩陣,該函數聲明如下:

Retrieves a matrix describing a transformation state.

HRESULT GetTransform(
D3DTRANSFORMSTATETYPE State,
D3DMATRIX * pMatrix
);

Parameters

State
[in] Device state variable that is being modified. This parameter can be any member of the D3DTRANSFORMSTATETYPE enumerated type, or the D3DTS_WORLDMATRIX macro.
pMatrix
[out] Pointer to a D3DMATRIX structure, describing the returned transformation state.

Return Values

If the method succeeds, the return value is D3D_OK. D3DERR_INVALIDCALL if one of the arguments is invalid.

Remarks

This method will not return device state for a device that is created using D3DCREATE_PUREDEVICE. If you want to use this method, you must create your device with any of the other flag values in D3DCREATE.


posted on 2008-05-02 13:54 lovedday 閱讀(1754) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            裸体一区二区三区| 亚洲欧美一区二区视频| 欧美在线视频不卡| 久久精品视频网| 欧美一区二区在线| 欧美大片免费观看| 亚洲免费av片| 亚洲精品国产视频| 欧美成人伊人久久综合网| 日韩午夜在线| 亚洲图片欧洲图片av| 国产欧美亚洲一区| 免费观看欧美在线视频的网站| 亚洲资源av| 午夜视黄欧洲亚洲| 黄色欧美日韩| 亚洲精品1234| 亚洲图片你懂的| 精品动漫3d一区二区三区| 欧美风情在线观看| 欧美日韩理论| 久久久夜夜夜| 欧美激情精品久久久久久久变态| 国产精品99久久久久久久久 | …久久精品99久久香蕉国产 | 久久国产夜色精品鲁鲁99| 久久久久久久激情视频| 91久久精品国产91久久性色tv| 日韩视频免费观看| 国产综合自拍| 日韩视频免费观看高清在线视频 | 国语精品中文字幕| 亚洲欧洲日产国码二区| 国产美女精品免费电影| 欧美激情按摩在线| 国产情人综合久久777777| 欧美激情欧美狂野欧美精品| 欧美天天在线| 男女激情久久| 国产午夜精品在线观看| 亚洲欧洲视频| 亚洲高清视频一区二区| 亚洲一区视频在线| 99伊人成综合| 久久一区中文字幕| 久久精品国产成人| 欧美日韩一本到| 亚洲国产高潮在线观看| 国产在线高清精品| 亚洲午夜伦理| 亚洲天堂av在线免费观看| 麻豆亚洲精品| 老司机久久99久久精品播放免费| 国产精品裸体一区二区三区| 亚洲精品免费看| 亚洲欧洲日本mm| 久久久青草青青国产亚洲免观| 午夜精品久久一牛影视| 欧美日韩精品| 日韩一区二区高清| 99精品国产在热久久| 欧美gay视频| 欧美激情在线免费观看| 在线精品视频免费观看 | 麻豆精品精华液| 国内精品久久久久影院色| 亚洲小说春色综合另类电影| 亚洲男同1069视频| 国产精品嫩草影院av蜜臀| 亚洲视频一二三| 午夜精品福利电影| 亚洲精品免费网站| 亚洲视频大全| 欧美视频不卡| 亚洲午夜视频在线| 欧美日韩一二区| 99精品欧美一区二区三区| 一区二区三区回区在观看免费视频| 欧美99久久| 亚洲日本成人在线观看| 在线亚洲免费| 国产人成精品一区二区三| 午夜精品一区二区在线观看| 久久久国产精品一区二区三区| 国产亚洲午夜高清国产拍精品| 久久不射中文字幕| 欧美激情亚洲激情| 中文国产亚洲喷潮| 国产欧美日韩一区二区三区| 午夜精品一区二区三区四区 | 亚洲人成网在线播放| 女主播福利一区| 99一区二区| 久久久久久一区| 亚洲破处大片| 亚洲精品欧美专区| 香蕉久久夜色| 在线成人h网| 欧美日韩一区二区三区四区在线观看 | 国产欧美日韩麻豆91| 久久国产一二区| 亚洲人体大胆视频| 欧美视频中文在线看| 亚洲欧美影音先锋| 欧美wwwwww| 午夜精品久久久久久久男人的天堂 | 久久久91精品国产| 最新国产拍偷乱拍精品| 欧美在线免费观看视频| 亚洲国产精品一区二区尤物区| 欧美日韩中文在线| 久久美女性网| 亚洲综合日韩| 亚洲激情在线观看视频免费| 欧美一区综合| 一个人看的www久久| 欧美亚洲一级| 中日韩高清电影网| 欧美激情免费在线| 久久亚洲电影| 欧美亚洲在线观看| 在线一区亚洲| 亚洲激情欧美激情| 国内精品久久久久久久影视麻豆 | 久久精视频免费在线久久完整在线看 | 在线观看欧美日韩| 国产精品揄拍500视频| 欧美国产日韩在线观看| 久久精品人人爽| 午夜国产不卡在线观看视频| 亚洲高清不卡| 激情国产一区| 国产婷婷色一区二区三区| 欧美日韩在线电影| 欧美精品啪啪| 欧美激情女人20p| 欧美国产视频一区二区| 久久久人人人| 久久理论片午夜琪琪电影网| 午夜精品久久久久久久白皮肤| 日韩手机在线导航| 日韩视频免费观看高清完整版| 亚洲国产日韩精品| 亚洲大片在线观看| 亚洲观看高清完整版在线观看| 美女91精品| 美女主播一区| 欧美激情久久久| 亚洲电影观看| 亚洲精品欧美激情| 亚洲精品久久久久久久久久久久 | 欧美一区二区免费视频| 午夜国产精品影院在线观看| 亚洲亚洲精品三区日韩精品在线视频| 99国产精品视频免费观看一公开| 91久久黄色| 日韩一级免费观看| 亚洲性夜色噜噜噜7777| 欧美一级黄色网| 久久久噜噜噜久久| 蜜臀av一级做a爰片久久| 免费在线成人| 欧美日韩精品二区| 国产欧美精品久久| 狠狠爱成人网| 亚洲免费高清视频| 亚洲欧美日韩综合| 久久久精品国产免大香伊| 在线电影院国产精品| 伊人成人在线| 一本一道久久综合狠狠老精东影业 | 久久精品国产第一区二区三区| 久久久夜精品| 亚洲人体一区| 欧美亚洲在线| 欧美二区在线播放| 国产精品久久久一区麻豆最新章节 | 亚洲欧洲日韩女同| 在线亚洲一区| 久久久久久久网| 欧美日韩视频不卡| 国模大胆一区二区三区| 亚洲精品一区二区三区婷婷月| 亚洲视频一区在线| 久久一区二区精品| 亚洲美女网站| 久久精品在线视频| 欧美视频在线不卡| 性娇小13――14欧美| 欧美成年人网站| 国产欧美日韩精品丝袜高跟鞋| 亚洲黄色在线视频| 欧美一级视频免费在线观看| 欧美激情第4页| 欧美一级久久久久久久大片| 欧美激情一二三区| 在线观看日韩| 久久精品中文| 亚洲一区二区精品视频| 欧美成人精品三级在线观看|