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

天行健 君子當自強而不息

頂點坐標變換(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 閱讀(1744) 評論(0)  編輯 收藏 引用

公告

導航

統計

常用鏈接

隨筆分類(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>
            久久综合精品一区| 久热综合在线亚洲精品| 亚洲免费影视| 久久激情中文| 欧美激情va永久在线播放| 亚洲经典视频在线观看| 亚洲国产黄色| 亚洲欧美一区二区三区在线| 久久精品国产v日韩v亚洲 | 亚洲视频一区在线| 欧美专区福利在线| 亚洲高清成人| 亚洲欧美999| 欧美国产第一页| 国产日韩欧美精品一区| 亚洲精品小视频在线观看| 欧美影院午夜播放| 亚洲精品中文字幕有码专区| 欧美一站二站| 欧美亚州韩日在线看免费版国语版| 国产日韩欧美91| 亚洲网站在线看| 欧美激情精品久久久久久大尺度| 亚洲欧美日韩在线| 欧美人成在线视频| 亚洲电影专区| 久久久久中文| 亚洲欧美在线看| 欧美日韩一区二区三区免费| 91久久久精品| 狂野欧美激情性xxxx| 亚洲欧美视频在线观看| 欧美日韩国产区| 亚洲区免费影片| 美女图片一区二区| 久久精品理论片| 国产曰批免费观看久久久| 亚洲欧美经典视频| 99热精品在线| 欧美日韩一二三区| 99国产麻豆精品| 欧美阿v一级看视频| 久久久99免费视频| 伊人久久噜噜噜躁狠狠躁| 欧美在线日韩在线| 香蕉乱码成人久久天堂爱免费| 国产精品久久久久久久一区探花 | 在线观看欧美日本| 久久亚洲私人国产精品va| 欧美怡红院视频| 国产亚洲精品一区二区| 久久本道综合色狠狠五月| 午夜精品久久久| 黄色成人在线免费| 欧美成人精品在线| 欧美激情综合在线| 夜夜嗨av一区二区三区网页| 99re热精品| 国产精品一区二区在线观看不卡| 亚洲欧美日韩精品久久奇米色影视| 一本一道久久综合狠狠老精东影业 | 国产精品成人一区二区网站软件| 亚洲桃色在线一区| 亚洲一区日韩| 国产一区视频在线观看免费| 麻豆精品在线视频| 欧美精品99| 午夜在线精品偷拍| 欧美一区亚洲二区| 亚洲激情在线激情| 99在线精品视频| 国产一区二区剧情av在线| 欧美风情在线| 国产精品狼人久久影院观看方式| 久久国产一区| 欧美激情2020午夜免费观看| 亚洲主播在线| 久久午夜色播影院免费高清| 99精品国产在热久久下载| 亚洲一区二区综合| 亚洲第一精品夜夜躁人人爽| 日韩天堂在线观看| 激情久久综艺| 99精品免费视频| 精品999在线播放| 亚洲日本中文字幕区| 国产亚洲成年网址在线观看| 亚洲国产精品传媒在线观看| 国产欧美一区二区精品婷婷 | 欧美在线观看天堂一区二区三区| 另类av导航| 小处雏高清一区二区三区| 另类欧美日韩国产在线| 亚洲免费一级电影| 欧美电影免费观看网站| 久久久久久久久久久久久女国产乱| 欧美国产精品| 噜噜噜躁狠狠躁狠狠精品视频 | 欧美一级片久久久久久久| 91久久精品美女高潮| 午夜精品视频| 夜夜爽www精品| 久久全球大尺度高清视频| 亚洲女优在线| 欧美另类一区| 亚洲动漫精品| 一区二区在线视频| 午夜精品亚洲一区二区三区嫩草| 一本色道久久综合一区 | 亚洲国产高清aⅴ视频| 国产一区二区三区四区老人| 在线视频日韩| 一道本一区二区| 免费h精品视频在线播放| 久久久久久久久久久久久9999| 欧美三级第一页| 日韩一区二区精品葵司在线| 99riav国产精品| 女同性一区二区三区人了人一| 久久婷婷综合激情| 国产亚洲一区在线播放| 午夜精品免费在线| 欧美一区成人| 国产乱码精品一区二区三区忘忧草| 日韩午夜精品视频| 在线视频欧美日韩| 欧美日韩的一区二区| 亚洲精选视频在线| 夜夜嗨av一区二区三区四区| 欧美精品免费播放| 亚洲精选国产| 亚洲欧美日韩综合| 国产伦精品一区二区三区免费迷| 亚洲午夜在线观看| 欧美专区在线观看一区| 国产三区精品| 久久久国产精品一区二区中文 | 亚洲国产成人一区| 男男成人高潮片免费网站| 亚洲电影在线免费观看| 在线性视频日韩欧美| 欧美日韩亚洲一区二区| 亚洲专区免费| 久久久亚洲一区| 亚洲国产一区在线| 欧美日韩精品一本二本三本| 亚洲一区二区三区免费视频 | 亚洲欧洲精品一区二区三区| 欧美国产大片| 亚洲一区二区三区免费视频| 久久深夜福利免费观看| 亚洲精品乱码久久久久| 国产精品久久久久久久9999| 欧美亚洲日本国产| 欧美激情按摩在线| 亚洲欧美日韩一区在线观看| 一区二区视频在线观看| 欧美精品尤物在线| 欧美在线观看日本一区| 亚洲国产精品久久人人爱蜜臀 | 欧美一区二区三区另类| 在线高清一区| 欧美午夜一区二区三区免费大片 | 久久久久久综合| 日韩特黄影片| 国产一区二区日韩精品| 欧美老女人xx| 久久精品一本| av不卡在线看| 欧美激情一二区| 欧美一区二区三区四区在线观看| 亚洲国产中文字幕在线观看| 国产精品另类一区| 欧美成ee人免费视频| 欧美亚洲一级片| 亚洲精品国产日韩| 免费成人黄色片| 欧美在线一二三四区| 艳妇臀荡乳欲伦亚洲一区| 在线欧美电影| 国产一区二区三区自拍| 国产精品国产a级| 欧美精品自拍| 老司机精品久久| 羞羞答答国产精品www一本| av成人老司机| 91久久中文字幕| 欧美gay视频激情| 久久久免费精品视频| 亚洲欧美中日韩| 亚洲午夜性刺激影院| 91久久久久久久久| 亚洲国产天堂久久国产91| 狠狠爱www人成狠狠爱综合网| 国产伦精品一区二区三区免费迷 | 午夜久久tv| 亚洲自拍另类| 亚洲欧美国产另类| 亚洲欧美福利一区二区| 午夜一区不卡|