方法一:使用opengl的多重紋理以及cg的semantics
// in c++ file:
// identify the textures to use for the pixel shader...
cgglsettextureparameter( g_cgparam_testtexture, g_testtextureid );
cgglsettextureparameter( g_cgparam_checkertexture, g_checkertextureid );
// stage 0
glactivetexturearb( gl_texture0_arb );
glbindtexture( gl_texture_2d, g_testtextureid );
// stage 1
glactivetexturearb( gl_texture1_arb );
glbindtexture( gl_texture_2d, g_checkertextureid );
cgglbindprogram( g_cgprogram_pixel );
cgglenableprofile( g_cgprofile_pixel );
// draw primitives
cggldisableprofile( g_cgprofile_pixel );
// in cg file:
uniform sampler2d testtexture : texunit0,
uniform sampler2d checkertexture : texunit1
方法二:使用cg的紋理函式cgglsettextureparameter, cgglenabletextureparameter, cggldisabletextureparameter
g_cgparam_testtexture = cggetnamedparameter(g_cgprogram_pixel, "testtexture");
g_cgparam_checkertexture = cggetnamedparameter(g_cgprogram_pixel, "checkertexture");
// identify the textures to use for the pixel shader...
cgglsettextureparameter( g_cgparam_testtexture, g_testtextureid );
cgglsettextureparameter( g_cgparam_checkertexture, g_checkertextureid );
cgglbindprogram( g_cgprogram_pixel );
cgglenableprofile( g_cgprofile_pixel );
cgglenabletextureparameter( g_cgparam_testtexture );
cgglenabletextureparameter( g_cgparam_checkertexture );
// draw primitives
cggldisabletextureparameter( g_cgparam_checkertexture );
cggldisabletextureparameter( g_cgparam_testtexture );
cggldisableprofile( g_cgprofile_pixel );
// in cg file:
uniform sampler2d testtexture,
uniform sampler2d checkertexture
最近在繪製程式中用到了這兩種紋理制定方法,由於一直沒理清頭緒,遇到很多麻煩
在我程式中,兩種方法不可以混用,否則會出現紋理混淆的狀況,即你指定了紋理1,實際上在cg中得到的是紋理2
方法一似乎更穩定些,但具體這兩種方法各有什麼優勢和限制還不得而知,這方面的資料也實在很少,看來需要更多的積累
原文:
LCA兩種方法
lca least common ancestors 即最近公共祖先,是指在有根樹中,找出某兩個結點u和v最近的公共祖先。模板題 anc i j 表示第i個點的2 j的祖先的標號 整個過程就是兩個點往上跳到同一深度,再一起往上跳找到lca include include using namespac...
post get 兩種方法
a.定義乙個get函式 get url,headers none defget url,headers none return urlrequests url,headers headers 內部可以呼叫urlrequests 如果不寫headers headers會被預設為none b.定義乙個p...
popup的兩種方法
1,popup var pop function window.onload function aaa function closediv 2,div var divtop,divleft,divwidth,divheight,docheight,docwidth,objtimer,i 0 var ...