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

天行健 君子當自強而不息

頂點坐標變換(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>
            亚洲国产一区视频| 黑人一区二区| 99re8这里有精品热视频免费| 麻豆国产精品一区二区三区 | 99在线|亚洲一区二区| 男人的天堂成人在线| 美女999久久久精品视频| 亚洲电影观看| 亚洲黄一区二区三区| 欧美另类在线播放| 亚洲欧美日韩国产一区二区三区| 亚洲性视频网址| 影音先锋久久精品| 亚洲精品一区久久久久久| 欧美性大战久久久久| 久久精品夜色噜噜亚洲aⅴ| 久久亚洲综合网| 一区二区三区日韩精品| 亚洲欧美一区二区在线观看| 在线成人黄色| 日韩一级大片| 国一区二区在线观看| 亚洲国产成人av好男人在线观看| 欧美性jizz18性欧美| 久久亚洲国产精品一区二区 | 亚洲欧美国产三级| 亚洲国产经典视频| 一区二区三区福利| 激情久久一区| 一区二区三区四区国产精品| 国产一区二区三区高清播放| 亚洲激情二区| 国产有码一区二区| 亚洲精品综合久久中文字幕| 国产又爽又黄的激情精品视频 | 欧美一区二区在线看| 免费成人高清在线视频| 亚洲免费影院| 欧美成在线视频| 久久全球大尺度高清视频| 欧美日韩大片| 欧美成人精品在线播放| 国产日韩视频一区二区三区| 日韩视频一区二区在线观看 | 99视频精品| 久久亚洲图片| 久久综合网hezyo| 国产精品成人观看视频国产奇米| 欧美成人中文字幕| 国产夜色精品一区二区av| 一个人看的www久久| 99精品福利视频| 美日韩精品免费观看视频| 久久成人在线| 国产精品国产精品| 日韩亚洲在线| 99爱精品视频| 欧美福利电影网| 亚洲二区三区四区| 91久久黄色| 免费日韩一区二区| 亚洲国产mv| 亚洲精品男同| 免费一级欧美片在线观看| 玖玖在线精品| 在线电影国产精品| 久久综合一区| 欧美国产亚洲精品久久久8v| 亚洲大片在线| 老司机一区二区| 欧美国产视频在线观看| 亚洲国产一区二区三区在线播| 久久久亚洲高清| 欧美成人免费视频| 日韩亚洲欧美在线观看| 欧美日本不卡视频| 一区二区三区精品国产| 午夜久久tv| 国产一区二区三区电影在线观看| 性视频1819p久久| 亚洲国产精品传媒在线观看| 欧美成人国产| 亚洲精品一区二区网址 | 在线精品视频一区二区三四| 麻豆精品精品国产自在97香蕉| 亚洲国产精品一区| 亚洲特黄一级片| 国产精品一区二区三区四区| 欧美一区二区三区四区在线| 久久亚洲风情| 在线视频亚洲欧美| 国产精品一区二区三区四区| 久久久久se| 亚洲精品久久久久中文字幕欢迎你 | 国产精品丝袜久久久久久app| 欧美一区二区三区四区在线观看| 欧美国产另类| 亚洲女同同性videoxma| 国内精品嫩模av私拍在线观看 | 欧美在线影院| 亚洲精品日产精品乱码不卡| 性18欧美另类| 亚洲国产日韩欧美一区二区三区| 欧美国产日韩在线| 午夜久久影院| 日韩视频中文字幕| 可以免费看不卡的av网站| 日韩视频在线观看国产| 国产喷白浆一区二区三区| 欧美/亚洲一区| 亚洲嫩草精品久久| 亚洲激情国产精品| 久久裸体艺术| 亚洲欧美日韩精品久久久久| 91久久在线观看| 国产日韩精品入口| 欧美日韩三级视频| 麻豆精品视频| 欧美一区二区三区的| 一本色道久久综合| 亚洲黑丝在线| 欧美国产日韩精品| 老司机67194精品线观看| 亚洲欧美日韩国产综合| 亚洲精品免费在线观看| 精品999久久久| 国产精品一区二区久久久| 欧美日韩免费观看中文| 欧美大胆a视频| 久久夜色精品国产噜噜av| 性8sex亚洲区入口| 亚洲校园激情| 亚洲午夜激情网页| 亚洲精选在线| 亚洲精品影院| 亚洲乱码精品一二三四区日韩在线| 久久综合伊人77777蜜臀| 性色av一区二区三区| 午夜在线一区| 香蕉久久精品日日躁夜夜躁| 亚洲一区成人| 亚洲影院免费观看| 亚洲欧美日韩精品久久亚洲区 | 亚洲国产欧美在线人成| 老**午夜毛片一区二区三区| 久久嫩草精品久久久久| 久久国产一二区| 亚洲电影第三页| 一区免费在线| 在线成人免费视频| 亚洲国产精品嫩草影院| 亚洲国产日韩在线| 亚洲精品欧美专区| 亚洲伦理在线| 正在播放亚洲一区| 亚洲宅男天堂在线观看无病毒| 亚洲免费在线视频一区 二区| 亚洲一区综合| 欧美亚洲免费高清在线观看| 久久不射2019中文字幕| 久久久久久91香蕉国产| 欧美.com| 99re6这里只有精品视频在线观看| 亚洲精品在线免费观看视频| 在线一区免费观看| 香蕉av福利精品导航| 久久久久久久久久久久久女国产乱 | 农村妇女精品| 亚洲人成网站精品片在线观看| 99国产精品久久久久久久| 亚洲一区欧美二区| 久久久国产一区二区三区| 欧美韩国日本一区| 国产精品高潮久久| 一区二区三区在线免费观看| 亚洲精品一区在线| 亚洲欧美日韩综合| 欧美xart系列高清| 99re66热这里只有精品3直播 | 亚洲午夜精品在线| 久久久久国产精品一区| 欧美日韩国产在线播放| 国产日本精品| 一本久道久久综合婷婷鲸鱼| 性18欧美另类| 亚洲激情综合| 欧美一区二区三区视频在线观看 | 在线视频亚洲一区| 久久久亚洲欧洲日产国码αv| 欧美全黄视频| 在线观看视频免费一区二区三区| 一区二区高清在线| 免费不卡在线观看av| 亚洲欧美成人一区二区在线电影| 免费欧美高清视频| 国产一区av在线| 亚洲欧美成人网| 亚洲精品护士| 久久综合网络一区二区| 国产欧美精品日韩区二区麻豆天美 |