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

天行健 君子當(dāng)自強(qiáng)而不息

高級(jí)著色語(yǔ)言HLSL入門(mén)(2)

16.2 編譯HLSL 著色器

16.2.1 常量表

每個(gè)著色器有一個(gè)常量表,用來(lái)保存它的變量。D3DX庫(kù)通過(guò)ID3DXConstantTable接口,提供給應(yīng)用程序訪(fǎng)問(wèn)著色器的常量表。通過(guò)這個(gè)接口我們能夠在應(yīng)用程序中設(shè)置著色器源代碼中的變量。

我們現(xiàn)在描述ID3DXConstantTable接口的方法列表的實(shí)現(xiàn),全部的列表請(qǐng)查閱Direct3D文檔。

16.2.1.1 取得常量句柄

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

D3DXHANDLE ID3DXConstantTable::GetConstantByName(

     D3DXHANDLE hConstant, // scope of constant

     LPCSTR pName          // name of constant

);

Hconstant——我們要取得的父結(jié)構(gòu)中變量句柄的D3DXHANDLE標(biāo)識(shí)。例如,如果我們想獲得一個(gè)特定數(shù)據(jù)結(jié)構(gòu)中單一數(shù)據(jù)成員的句柄,我們可以傳遞結(jié)構(gòu)實(shí)例的句柄。如果我們獲得一個(gè)頂級(jí)變量的句柄,給這個(gè)參數(shù)設(shè)為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,并且這是頂級(jí)變量,我們這么寫(xiě):

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

D3DXHANDLE h0;

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

 

16.2.1.2 設(shè)置常量

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

ID3DXConstantTable::SetXXX的一般語(yǔ)法是:

HRESULT ID3DXConstantTable::SetXXX(

     LPDIRECT3DDEVICE9 pDevice,

     D3DXHANDLE hConstant,

     XXX value

);

PDevice:常量表所關(guān)聯(lián)的設(shè)備的指針。

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

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

 

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

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 閱讀(3837) 評(píng)論(4)  編輯 收藏 引用

評(píng)論

# re: 高級(jí)著色語(yǔ)言HLSL入門(mén)(2)[未登錄](méi) 2009-01-08 16:51 sam

寫(xiě)得不錯(cuò),但有個(gè)問(wèn)題,如果傳大數(shù)據(jù)到像素作色器好像不行。

如一個(gè)float[12][256].的數(shù)據(jù)。好像ps_2_0只能設(shè)置最大30個(gè)成員的數(shù)組。有什么方法定義大常量數(shù)據(jù)嗎?  回復(fù)  更多評(píng)論   

# re: 高級(jí)著色語(yǔ)言HLSL入門(mén)(2)[未登錄](méi) 2009-01-08 16:53 sam

QQ:36046869  回復(fù)  更多評(píng)論   

# re: 高級(jí)著色語(yǔ)言HLSL入門(mén)(2) 2009-02-02 11:37 笑笑

QQ:490861526  回復(fù)  更多評(píng)論   

# re: 高級(jí)著色語(yǔ)言HLSL入門(mén)(2) 2010-11-18 15:36 oppo

受教了~ 多謝天兄~  回復(fù)  更多評(píng)論   


只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


公告

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

隨筆分類(lèi)(178)

3D游戲編程相關(guān)鏈接

搜索

最新評(píng)論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲国产一区二区三区a毛片| 亚洲缚视频在线观看| 国产一本一道久久香蕉| 久久久美女艺术照精彩视频福利播放 | 艳妇臀荡乳欲伦亚洲一区| 午夜精品一区二区三区在线| 红桃视频欧美| 国产精品视频精品| 免费日韩精品中文字幕视频在线| 亚洲人成7777| 乱中年女人伦av一区二区| 一本一本a久久| 亚洲欧洲在线视频| 亚洲第一精品影视| 黄色欧美成人| 国内精品免费午夜毛片| 国产精品高清网站| 欧美日韩成人一区二区三区| 久久人人97超碰人人澡爱香蕉| 亚洲女同同性videoxma| 亚洲一区二区三区在线观看视频 | 久久久久久久综合日本| 欧美在线日韩| 欧美一二区视频| 久久久精品视频成人| 久久精品人人做人人爽| 欧美一区二区免费视频| 香蕉尹人综合在线观看| 欧美影片第一页| 久久裸体视频| 亚洲国产精品久久久久婷婷老年 | 亚洲福利视频一区| 亚洲剧情一区二区| 亚洲午夜国产一区99re久久| 性亚洲最疯狂xxxx高清| 久久嫩草精品久久久久| 欧美69视频| 国产精品一区视频网站| 亚洲电影成人| 亚洲一区精彩视频| 久久久一本精品99久久精品66| 欧美激情亚洲视频| 亚洲乱码国产乱码精品精 | 欧美视频在线免费| 在线免费一区三区| 日韩午夜精品视频| 免费观看成人鲁鲁鲁鲁鲁视频| 亚洲第一黄色网| 亚洲在线成人精品| 欧美第一黄色网| 国产主播一区二区三区| 亚洲亚洲精品三区日韩精品在线视频| 亚洲欧美日韩在线不卡| 欧美高清在线一区二区| 亚洲欧美一区二区三区极速播放 | 99精品热视频| 欧美激情a∨在线视频播放| 欧美制服丝袜第一页| 国产精品视频一区二区三区| 亚洲裸体在线观看| 亚洲国产欧美不卡在线观看 | 欧美 亚欧 日韩视频在线| 午夜宅男欧美| 国产一区二区观看| 免费人成精品欧美精品| 久久精品色图| 亚洲国产视频一区二区| 欧美黄污视频| 欧美日韩一区二区三区免费| 亚洲午夜av在线| 亚洲欧美一区二区在线观看| 国外成人在线视频网站| 欧美肥婆在线| 欧美破处大片在线视频| 亚洲在线成人精品| 亚洲自拍偷拍网址| 国产午夜精品一区二区三区欧美| 欧美亚洲一区| 美腿丝袜亚洲色图| 午夜亚洲性色视频| 久久久久久免费| 中国av一区| 久久久国产精品亚洲一区 | 欧美www视频| 亚洲欧美国产77777| 久久久亚洲国产天美传媒修理工 | 久久精品一区二区三区不卡牛牛 | 黑人巨大精品欧美黑白配亚洲| 久久男人av资源网站| 欧美日韩国产欧| 久久尤物视频| 国产午夜久久久久| 一级成人国产| 亚洲三级观看| 欧美 日韩 国产 一区| 久久久久国产一区二区三区| 免费日韩一区二区| 久久综合久久美利坚合众国| 国产精品观看| 亚洲视频一区二区免费在线观看| 亚洲国产一区二区视频| 欧美自拍偷拍午夜视频| 午夜精品国产| 国产精品欧美久久久久无广告| 亚洲国产视频直播| 91久久中文| 欧美成人dvd在线视频| 亚洲高清视频在线| 99国产精品99久久久久久| 裸体歌舞表演一区二区| 欧美电影免费观看网站| 亚洲国产小视频| 欧美国产精品劲爆| 亚洲精品日产精品乱码不卡| 一区二区三区四区五区视频| 欧美区亚洲区| 亚洲视频你懂的| 久久裸体艺术| 99精品视频一区| 国产精品美女久久久久av超清| 亚洲欧美精品一区| 欧美激情一区在线| 亚洲一级影院| 亚洲国产精品女人久久久| 欧美成年人视频| 欧美亚洲一区二区在线| 免费视频最近日韩| 亚洲午夜在线观看| 亚洲经典一区| 国产亚洲精品一区二区| 欧美激情一区二区三区高清视频 | 亚洲精品日韩精品| 国产精品影音先锋| 欧美大秀在线观看| 久久久久se| 午夜精品久久一牛影视| 亚洲精品一区二区三区樱花| 久久亚洲综合色一区二区三区| 亚洲午夜久久久| 亚洲精品国精品久久99热| 国产亚洲欧美日韩日本| 欧美午夜一区二区福利视频| 欧美激情精品久久久| 久久在线观看视频| 久久免费偷拍视频| 欧美一区二区三区喷汁尤物| 亚洲字幕一区二区| 亚洲国产精品一区二区第一页| 国产亚洲精品7777| 国产一区香蕉久久| 国产主播一区| 亚洲国产精品高清久久久| 亚洲成人影音| 亚洲日本无吗高清不卡| 亚洲精品欧美日韩专区| 日韩视频在线观看一区二区| 亚洲国产精品激情在线观看| 亚洲国产欧美日韩精品| 99精品黄色片免费大全| 亚洲综合三区| 久久久99免费视频| 欧美高清视频在线观看| 亚洲国产精品第一区二区三区| 亚洲三级影片| 欧美在线免费一级片| 欧美sm重口味系列视频在线观看| 欧美激情成人在线| 国产精品视频九色porn| 亚洲国产第一| 欧美一级大片在线免费观看| 欧美国产日韩精品| 亚洲欧美激情精品一区二区| 久久久久久久精| 国产精品久久久久久影视| 亚洲国产视频一区二区| 久久精品二区三区| 亚洲精品资源| 欧美精品粉嫩高潮一区二区| 在线高清一区| 久久精品国产精品亚洲综合| 亚洲激情网址| 欧美jizz19性欧美| 亚洲国产高清aⅴ视频| 欧美一区亚洲| 西瓜成人精品人成网站| 国产精品久久久久久久久| 亚洲精品综合精品自拍| 美女视频黄免费的久久| 欧美亚洲一级| 国产亚洲精品一区二区| 午夜在线观看免费一区| 亚洲午夜在线观看视频在线| 欧美日韩亚洲一区二| 正在播放日韩| 亚洲一区二区三区中文字幕在线 | 欧美精品一区二区三| 日韩亚洲欧美精品| 一本色道久久| 国产欧美婷婷中文| 六月天综合网|