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

天行健 君子當自強而不息

高級著色語言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 閱讀(3837) 評論(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

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

公告

導航

統計

常用鏈接

隨筆分類(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>
            亚洲美女在线观看| 在线电影一区| 浪潮色综合久久天堂| 亚洲欧美日韩人成在线播放| 一区二区精品| 亚洲欧美第一页| 久久久国产精品一区| 男人插女人欧美| 欧美日韩和欧美的一区二区| 欧美日韩在线直播| 国产日韩视频| 亚洲国产免费看| 亚洲无毛电影| 久久躁狠狠躁夜夜爽| 欧美激情精品久久久久久黑人| 最新亚洲激情| 国产精品99久久久久久宅男| 午夜在线电影亚洲一区| 久久久久久久久久久久久9999| 欧美国产第一页| 国产日韩专区在线| 亚洲精品免费在线播放| 亚洲欧美激情诱惑| 欧美激情一区| 欧美一级片在线播放| 欧美91视频| 国产日韩综合| 亚洲午夜在线视频| 欧美成人精品在线播放| 亚洲无限乱码一二三四麻| 免费h精品视频在线播放| 国产精品美女www爽爽爽视频| 亚洲成人直播| 久久久999精品视频| 99精品欧美一区二区三区| 久久久久成人网| 国产日韩欧美一区| 亚洲欧美日韩国产综合在线 | 香蕉久久夜色精品| 亚洲国产另类 国产精品国产免费| 亚洲一区国产精品| 欧美日本国产| 亚洲精品中文字幕有码专区| 久久综合影音| 亚洲一区在线看| 欧美日韩免费观看一区=区三区| 国产精品国产精品国产专区不蜜| 亚洲第一福利在线观看| 久久蜜桃精品| 欧美一区二区三区啪啪 | 国产一区二区精品久久91| 一区二区不卡在线视频 午夜欧美不卡在 | 欧美v亚洲v综合ⅴ国产v| 国产精品美女久久福利网站| 99国产精品99久久久久久粉嫩| 欧美99久久| 蜜乳av另类精品一区二区| 激情欧美亚洲| 欧美成年人网| 欧美国产日本在线| 亚洲网址在线| 欧美亚洲专区| 在线欧美一区| 亚洲福利av| 欧美精品手机在线| 一区二区三区免费网站| 99国产一区二区三精品乱码| 欧美视频在线看| 午夜一区二区三区不卡视频| 亚洲午夜激情网站| 国产午夜精品理论片a级探花| 久久aⅴ国产紧身牛仔裤| 久久成年人视频| 亚洲国产午夜| 日韩一级二级三级| 国产欧美精品在线| 欧美sm视频| 欧美日韩国产欧| 久久国产视频网| 美女黄色成人网| 宅男噜噜噜66一区二区66| 亚洲天堂av综合网| 国自产拍偷拍福利精品免费一| 欧美夫妇交换俱乐部在线观看| 欧美激情偷拍| 久久久国产精彩视频美女艺术照福利| 久久久久久国产精品mv| 99精品欧美一区二区三区| 亚洲欧美韩国| 亚洲国产精品久久精品怡红院| 亚洲久久一区| 韩国成人理伦片免费播放| 亚洲激情网站| 国产丝袜美腿一区二区三区| 欧美黄色aa电影| 国产日韩欧美中文| 亚洲激情小视频| 国产一区二区三区久久悠悠色av| 亚洲国产黄色| 国产欧美一区二区色老头| 久久国产99| 亚洲乱亚洲高清| 欧美国产日韩在线观看| 亚洲靠逼com| 国产三级欧美三级日产三级99| 亚洲第一天堂av| 国产日本欧美一区二区| 亚洲高清色综合| 国产综合久久久久久鬼色| 亚洲精品国产精品久久清纯直播 | 欧美片第1页综合| 久久久久国产一区二区| 欧美区视频在线观看| 久久看片网站| 国产精品入口尤物| 日韩一区二区电影网| 亚洲电影在线观看| 欧美一区二区女人| 亚洲欧美另类久久久精品2019| 欧美成人午夜免费视在线看片| 久久精品成人一区二区三区 | 亚洲人成人一区二区在线观看 | 99国产精品久久久久久久久久| 伊人久久综合97精品| 午夜精品久久久久| 欧美亚洲一区二区在线| 欧美日韩国产小视频| 欧美激情第六页| 亚洲高清免费在线| 久久永久免费| 久久综合伊人77777麻豆| 国产私拍一区| 亚洲欧美另类国产| 久久av老司机精品网站导航 | 日韩午夜av电影| 久久综合99re88久久爱| 久久婷婷国产麻豆91天堂| 国产欧美一区二区精品秋霞影院| 一本久道久久综合狠狠爱| 一区二区三区 在线观看视| 欧美日韩国产成人在线91| 99国产精品久久久| 亚洲女同同性videoxma| 国产精品人人爽人人做我的可爱| 亚洲无吗在线| 久久免费高清| 亚洲国产精品毛片| 欧美噜噜久久久xxx| 99视频精品免费观看| 午夜精品久久久久| 国产一区二区三区视频在线观看| 久久久综合网站| 亚洲国产日韩欧美在线图片| 亚洲伦理在线免费看| 欧美午夜寂寞影院| 香蕉成人伊视频在线观看 | 欧美日精品一区视频| 日韩视频第一页| av成人激情| 欧美一级黄色网| 亚洲一区综合| 国产欧美亚洲日本| 美女爽到呻吟久久久久| 最新国产精品拍自在线播放| 亚洲夜晚福利在线观看| 国产视频不卡| 欧美激情2020午夜免费观看| 亚洲午夜视频在线观看| 久久亚洲综合色一区二区三区| 亚洲精品久久在线| 国产精品视频免费观看www| 久久精品亚洲热| 中文欧美字幕免费| 欧美大片在线观看一区| 亚洲欧美日韩国产精品| 亚洲第一久久影院| 欧美亚洲成人网| 久久综合久久88| 亚洲天堂久久| 亚洲高清激情| 久久久天天操| 亚洲欧美国产日韩中文字幕| 精品成人国产| 国产精品免费久久久久久| 毛片一区二区三区| 欧美在线三区| 亚洲综合色视频| 亚洲精品视频在线观看网站| 久久躁日日躁aaaaxxxx| 亚洲男人第一网站| 日韩午夜在线| 亚洲国产一区二区三区在线播| 国产欧美一区二区精品忘忧草| 欧美色123| 欧美日韩在线播放一区二区| 女主播福利一区| 久久久一本精品99久久精品66| 先锋资源久久| 欧美亚洲综合另类| 午夜激情一区|