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

天行健 君子當自強而不息

高級著色語言HLSL入門(2)

16.2 編譯HLSL 著色器

16.2.1 常量表

每個著色器有一個常量表,用來保存它的變量。D3DX庫通過ID3DXConstantTable接口,提供給應用程序訪問著色器的常量表。通過這個接口我們能夠在應用程序中設置著色器源代碼中的變量。

我們現在描述ID3DXConstantTable接口的方法列表的實現,全部的列表請查閱Direct3D文檔。

16.2.1.1 取得常量句柄

為了在應用程序中設置著色器中的一個特定變量,需要有一種方法去引用它,我們能夠在應用程序中用D3DXHANDLE引用一個在著色器中的變量,下面的方法返回一個著色器中的變量的D3DXHANDLE,使用時,需要傳遞一個變量的名字作為參數:

D3DXHANDLE ID3DXConstantTable::GetConstantByName(

     D3DXHANDLE hConstant, // scope of constant

     LPCSTR pName          // name of constant

);

Hconstant——我們要取得的父結構中變量句柄的D3DXHANDLE標識。例如,如果我們想獲得一個特定數據結構中單一數據成員的句柄,我們可以傳遞結構實例的句柄。如果我們獲得一個頂級變量的句柄,給這個參數設為NULL。

PName——我們想獲得的句柄的著色器代碼中的變量的名字。

Gets a constant by looking up its name.

D3DXHANDLE GetConstantByName(
D3DXHANDLE hConstant,
LPCSTR pName
);

Parameters

hConstant
[in] Unique identifier to the parent data structure. If the constant is a top-level parameter (there is no parent data structure), use NULL.
pName
[in] Name of the constant.

Return Values

Returns a unique identifier to the constant.

例如,如果在著色器中變量的名字為ViewProjMatrix,并且這是頂級變量,我們這么寫:

// 取得著色器中ViewProjMatrix變量的句柄

D3DXHANDLE h0;

h0 = ConstTable->GetConstantByName(0, "ViewProjMatrix");

 

16.2.1.2 設置常量

一旦應用程序有了一個D3DXHANDLE,要引用著色器代碼中的具體變量,我們可以在應用程序中使用ID3DXConstantTable::SetXXX方法設置變量。如果我們想設置一個向量數組類型的變量,方法名是SetVectorArray。

ID3DXConstantTable::SetXXX的一般語法是:

HRESULT ID3DXConstantTable::SetXXX(

     LPDIRECT3DDEVICE9 pDevice,

     D3DXHANDLE hConstant,

     XXX value

);

PDevice:常量表所關聯的設備的指針。

HConstant:我們正在設置的變量句柄的引用。

Value:我們要把變量設置成的值,XXX是我們設置的要替換的變量類型名,對于有些類型(bool, int, float),傳遞變量值的COPY,另外一些類型(vectors, matrices, structures),傳遞值的指針。

 

下面的列表描述了我們能用ID3DXConstantTable接口設置的類型列表。這里假定我們有一個有效的設備,和一個有效句柄。

SetBool—Used to set a Boolean value. Sample call:

bool b = true;

ConstTable->SetBool(Device, handle, b);

Sets a Boolean value.

HRESULT SetBool(
LPDIRECT3DDEVICE9 pDevice,
D3DXHANDLE hConstant,
BOOL b
);

Parameters

pDevice
[in] Pointer to an IDirect3DDevice9 interface, representing the device associated with the constant table.
hConstant
[in] Unique identifier to the constant. See D3DXHANDLE.
b
[in] Boolean value.

Return Values

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


SetBoolArray—Used to set a Boolean array. Sample call:

bool b[3] = {true, false, true};

ConstTable->SetBoolArray(Device, handle, b, 3);

Sets an array of Boolean values.

HRESULT SetBoolArray(
LPDIRECT3DDEVICE9 pDevice,
D3DXHANDLE hConstant,
CONST BOOL* pB,
UINT Count
);

Parameters

pDevice
[in] Pointer to an IDirect3DDevice9 interface, representing the device associated with the constant table.
hConstant
[in] Unique identifier to the array of constants. See D3DXHANDLE.
pB
[in] Array of Boolean values.
Count
[in] Number of Boolean values in the array.

Return Values

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


SetFloat—Used to set a float. Sample call:

float f = 3.14f;

ConstTable->SetFloat(Device, handle, f);

 

Sets a floating-point number.

HRESULT SetFloat(
LPDIRECT3DDEVICE9 pDevice,
D3DXHANDLE hConstant,
FLOAT f
);

Parameters

pDevice
[in] Pointer to an IDirect3DDevice9 interface, representing the device associated with the constant table.
hConstant
[in] Unique identifier to the constant. See D3DXHANDLE.
f
[in] Floating-point number.

Return Values

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


SetFloatArray—Used to set a float array. Sample call:

float f[2] = {1.0f, 2.0f};

ConstTable->SetFloatArray(Device, handle, f, 2);

Sets an array of floating-point numbers.

HRESULT SetFloatArray(
LPDIRECT3DDEVICE9 pDevice,
D3DXHANDLE hConstant,
CONST FLOAT* pf,
UINT Count
);

Parameters

pDevice
[in] Pointer to an IDirect3DDevice9 interface, representing the device associated with the constant table.
hConstant
[in] Unique identifier to the array of constants. See D3DXHANDLE.
pf
[in] Array of floating-point numbers.
Count
[in] Number of floating-point values in the array.

Return Values

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


SetInt—Used to set an integer. Sample call:

int x = 4;

ConstTable->SetInt(Device, handle, x);

Sets an integer value.

HRESULT SetInt(
LPDIRECT3DDEVICE9 pDevice,
D3DXHANDLE hConstant,
INT n
);

Parameters

pDevice
[in] Pointer to an IDirect3DDevice9 interface, representing the device associated with the constant table.
hConstant
[in] Unique identifier to the constant. See D3DXHANDLE.
n
[in] Integer.

Return Values

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

 

SetMatrix—Used to set a 4 × 4 matrix. Sample call:

D3DXMATRIX M(…);

ConstTable->SetMatrix(Device, handle, &M);

Sets a nontransposed matrix.

HRESULT SetMatrix(
LPDIRECT3DDEVICE9 pDevice,
D3DXHANDLE hConstant,
CONST D3DXMATRIX* pMatrix
);

Parameters

pDevice
[in] Pointer to an IDirect3DDevice9 interface, representing the device associated with the constant table.
hConstant
[in] Unique identifier to the matrix of constants. See D3DXHANDLE.
pMatrix
[in] Pointer to a nontransposed matrix. See D3DXMATRIX.

Return Values

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


SetMatrixArray—Used to set a 4 × 4 matrix array. Sample call:

D3DXMATRIX M[4];

// ...Initialize matrices

ConstTable->SetMatrixArray(Device, handle, M, 4);

Sets an array of nontransposed matrices.

HRESULT SetMatrixArray(
LPDIRECT3DDEVICE9 pDevice,
D3DXHANDLE hConstant,
CONST D3DXMATRIX* pMatrix,
UINT Count
);

Parameters

pDevice
[in] Pointer to an IDirect3DDevice9 interface, representing the device associated with the constant table.
hConstant
[in] Unique identifier to the array of constant matrices.
pMatrix
[in] Array of nontransposed matrices.
Count
[in] Number of matrices in the array.

Return Values

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


SetMatrixPointerArray—Used to set an array of 4 × 4 matrix pointers. Sample call:

D3DXMATRIX* M[4];

// ...Allocate and initialize matrix pointers

ConstTable->SetMatrixPointerArray(Device, handle, M, 4);

Sets an array of pointers to nontransposed matrices.

HRESULT SetMatrixPointerArray(
LPDIRECT3DDEVICE9 pDevice,
D3DXHANDLE hConstant,
CONST D3DXMATRIX ** ppMatrix,
UINT Count
);

Parameters

pDevice
[in] Pointer to an IDirect3DDevice9 interface, representing the device associated with the constant table.
hConstant
[in] Unique identifier to an array of constant matrices.
ppMatrix
[in] Array of pointers to nontransposed matrices.
Count
[in] Number of matrices in the array.

Return Values

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

Remarks

A nontransposed matrix contains row-major data; that is, each vector is contained in a row.


posted on 2008-04-05 16:18 lovedday 閱讀(3843) 評論(4)  編輯 收藏 引用

評論

# re: 高級著色語言HLSL入門(2)[未登錄] 2009-01-08 16:51 sam

寫得不錯,但有個問題,如果傳大數據到像素作色器好像不行。

如一個float[12][256].的數據。好像ps_2_0只能設置最大30個成員的數組。有什么方法定義大常量數據嗎?  回復  更多評論   

# re: 高級著色語言HLSL入門(2)[未登錄] 2009-01-08 16:53 sam

QQ:36046869  回復  更多評論   

# re: 高級著色語言HLSL入門(2) 2009-02-02 11:37 笑笑

QQ:490861526  回復  更多評論   

# re: 高級著色語言HLSL入門(2) 2010-11-18 15:36 oppo

受教了~ 多謝天兄~  回復  更多評論   


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   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| 一区在线免费| 国产精品都在这里| 美女精品在线| 午夜在线播放视频欧美| 最近中文字幕日韩精品| 久久精品国产2020观看福利| 亚洲激情中文1区| 国产伦理精品不卡| 欧美日韩 国产精品| 久久精品一区二区三区不卡| 亚洲裸体俱乐部裸体舞表演av| 久久亚洲色图| 午夜精品免费在线| 99re热精品| 亚洲欧美在线另类| 亚洲国产一区二区三区青草影视| 欧美在线播放一区| 99国产精品久久久久久久久久 | 欧美国产高清| 久久精品99| 亚洲欧美日本伦理| 日韩午夜在线视频| 亚洲盗摄视频| 国产一区高清视频| 国产精品一区三区| 欧美图区在线视频| 欧美精品电影| 另类av一区二区| 久久久久久久久久久久久久一区| 亚洲一区影院| 一区二区欧美日韩视频| 亚洲精品激情| 91久久一区二区| 亚洲国产美女精品久久久久∴| 六月婷婷一区| 久久一区二区三区四区五区| 欧美中文字幕久久| 香蕉免费一区二区三区在线观看| 一区二区三区视频在线播放| 亚洲精品乱码久久久久久黑人 | 欧美影院在线播放| 午夜精品久久久久| 亚洲欧美综合v| 香蕉av福利精品导航| 亚洲欧美影音先锋| 午夜免费久久久久| 午夜老司机精品| 久久成人资源| 久久综合成人精品亚洲另类欧美 | 国产一区二区三区的电影 | 亚洲精品自在在线观看| 亚洲国产欧美不卡在线观看| 在线观看亚洲| 亚洲国产精品视频| 亚洲国产精品专区久久| 亚洲国产成人久久综合一区| 亚洲国产婷婷香蕉久久久久久| 亚洲国内高清视频| 99re6热只有精品免费观看| 一区二区精品在线| 亚洲影院污污.| 欧美专区第一页| 久久综合久久综合久久| 欧美激情一区二区在线 | 91久久久久久久久久久久久| 亚洲精品国产精品国产自| 99re热精品| 欧美二区在线看| 欧美日韩国产精品专区| 国产精品成人免费精品自在线观看| 国产精品久99| 精品二区视频| 99国产精品久久久久久久久久 | 亚洲欧美视频一区| 久久精品一区二区三区不卡牛牛| 蜜桃精品久久久久久久免费影院| 欧美精品一卡| 国产欧美日韩免费| 亚洲福利免费| 亚洲综合欧美| 久久视频在线视频| 日韩视频二区| 午夜影院日韩| 欧美精品精品一区| 国产免费成人| 亚洲精品综合精品自拍| 欧美一区1区三区3区公司| 免费在线观看日韩欧美| 99国产精品久久久久久久成人热| 亚洲欧美日韩精品久久亚洲区| 免播放器亚洲| 国产精品香蕉在线观看| 亚洲激情网站| 欧美一区二区三区视频免费播放| 欧美~级网站不卡| 亚洲一区高清| 欧美激情一区二区| 黄色成人免费观看| 亚洲午夜精品17c| 免费欧美高清视频| 亚洲综合成人在线| 欧美噜噜久久久xxx| 狠狠色2019综合网| 亚洲女性裸体视频| 91久久精品国产91久久| 久久精品国产一区二区三| 国产精品久久久久9999吃药| 亚洲二区三区四区| 久久久福利视频| 在线一区二区三区做爰视频网站| 鲁大师成人一区二区三区| 国产亚洲亚洲| 性欧美大战久久久久久久免费观看 | 一本色道久久综合一区| 欧美mv日韩mv国产网站| 国语自产精品视频在线看8查询8| 亚洲欧美日韩一区二区| 亚洲精品综合久久中文字幕| 久久视频一区| 黄色精品一二区| 欧美专区第一页| 亚洲一区二区视频在线观看| 欧美理论大片| 亚洲精品欧美| 欧美激情偷拍| 欧美不卡福利| 91久久国产综合久久| 蜜桃久久av一区| 久久精品在线视频| 国产丝袜一区二区| 欧美有码在线观看视频| 亚洲免费网址| 国产精品专区一| 欧美在线播放| 性视频1819p久久| 国产一区二区三区黄视频| 欧美在线观看一区二区| 午夜久久一区| 狠狠色狠狠色综合日日91app| 国产精品久久久久9999| 亚洲综合色网站| 亚洲一区二区在线观看视频| 国产精品乱子乱xxxx| 亚洲欧美日韩精品一区二区| 亚洲制服欧美中文字幕中文字幕| 欧美午夜宅男影院在线观看| 亚洲主播在线观看| 亚洲欧美春色| 国产一区二区日韩精品| 麻豆精品在线视频| 狂野欧美性猛交xxxx巴西| 亚洲欧洲精品天堂一级| 亚洲日本中文字幕免费在线不卡| 欧美日韩一本到| 亚洲欧美日韩视频二区| 欧美亚洲在线| 在线观看日韩| 亚洲精选在线观看| 国产精品一区二区久久久| 久久久国际精品| 欧美 亚欧 日韩视频在线| 一本色道久久加勒比精品| 亚洲网站视频| 精品福利电影| 亚洲人妖在线| 国产欧美一区二区三区久久人妖| 麻豆av福利av久久av| 欧美激情自拍| 欧美亚洲一区二区在线观看| 久久久久久久久久久久久女国产乱| 亚洲精品欧美专区| 亚洲一区影音先锋| 亚洲国产欧美一区| 亚洲视频999| 亚洲国产精品一区二区www| 99精品国产在热久久婷婷|