shade
學(xué)習(xí)筆記(
3
)-
cg openGL runtime
library
-
當(dāng)
uniform
參數(shù)設(shè)置到
openGL
以后是保存在
CG
openGL runtime
里邊或者
cg core runtime
里邊,而
d
3d
是直接保存到
GPU
的
constant memory
里邊。
-
openGL
在使用
CG
的時(shí)候必須首先使用wglCreateContext()
or glXCreateContext()來創(chuàng)建
openGL Context
。
-
設(shè)置
Uniform參數(shù):
-
cgGLSetParameter,兩種類型
float
(f),double(d).
-
cgGLSetMatrixParameterfr
,
cgGLSetMatrixParameter
dc,
四種,
c
表示列向量為主,
r
表示
row
向量為主。
-
cgGLSetStateMatrixParameter()可以用來設(shè)置狀態(tài)矩陣,包括
ModelView
矩陣,
Projection
矩陣,紋理矩陣。
-
cgGLSetParameterArray()用來設(shè)置
Uniform
的數(shù)組參數(shù);cgGLSetMatrixParameterArrayfr用來設(shè)置矩陣數(shù)組
??? 設(shè)置變量參數(shù):
- 因?yàn)?/span>FP的變量參數(shù)是按照光柵化插值后的結(jié)果來設(shè)置的,所以只有VS程序有變量參數(shù)。
- 設(shè)置變量參數(shù)兩步:
- cgGLSetParameterPointer():設(shè)置變量數(shù)組,我理解就是頂點(diǎn)數(shù)組
- void
cgGLEnableClientState(CGparameter parameter);和void
cgGLDisableClientState(CGparameter parameter);使得該參數(shù)有效。
- 注意:cgGLSetParameter也可以用來設(shè)置變量參數(shù),這時(shí)采用的是openGL立即模式,也就相當(dāng)于glVertex,glNormal,glColor這樣的做法吧,但是我想這顯然是一種效率不高的做法。且cgGLGetParameter不能用來取變量參數(shù)。
??? 設(shè)置Sampler參數(shù):Sampler和紋理是一一對應(yīng)的,所以實(shí)際就是對一段頂點(diǎn)繪制指定一個紋理。- cgGLSetTextureParameter(CGparameter
parameter,GLuint textureName);來指定一個紋理給CGParameter。
- void
cgGLEnableTextureParameter(CGparameter parameter);來使紋理生效。void
cgGLDisableTextureParameter(CGparameter parameter);使其失效,相當(dāng)于glBindTexture命令。
void
cgGLSetOptimalOptions(CGprofile profile);來使用最優(yōu)的Profile。而CGbool
cgGLIsProfileSupported(CGprofile profile);可以用來判斷硬件是否支持該Profile。
經(jīng)過這幾天的學(xué)習(xí),終于大概明白了shader是怎么work的了,但是對于用programmable pipeline替換掉fixed function還是一頭霧水。
?