紋理對映座標glTexCoordPointer用法

2021-06-03 19:40:10 字數 755 閱讀 4498

gltexcoordpointer(int size, int type, int stride, buffer pointer);  設定頂點陣列為紋理座標快取

其中: size:紋理頂點座標的分量個數;  //size: number of coordinates per vertex; 

type:紋理座標的資料型別;short, int, float, double都可以;

stride:點陣圖的寬度,可以理解為相鄰的兩個紋理之間跨多少個位元組,一般為0,因為一般不會在紋理中再新增其他的信  息。//stride: offset between 2 consecutive vertices;

pointer:存放紋理座標的陣列,指明將繪製的第i個點(i

0,1,1,1,1,0,0,0, 

});gl.gltexcoordpointer(2, gl10.gl_fixed, 0, texcoords);

注意:pointer是以頂點陣列為參照的,而不是以繪製索引為參照!如

gl.glvertexpointer(3, gl10.gl_fixed, 0, vertices);

gl.gltexcoordpointer(2, gl10.gl_fixed, 0, texcoords);

gl.gldrawelements(gl10.gl_********_strip, 4,  gl10.gl_unsigned_byte, indices);

pointer以vertices中頂點的順序為參照,而不是indices所指定的順序。

NeNe opengl 紋理對映

include stdafx.h include windows的標頭檔案 include include 包含最新的gl.h,glu.h庫 include 包含opengl實用庫 include glaux庫的標頭檔案 include pragma comment lib,opengl32.lib...

NeNe opengl 紋理對映

include stdafx.h include windows的標頭檔案 include include 包含最新的gl.h,glu.h庫 include 包含opengl實用庫 include glaux庫的標頭檔案 include pragma comment lib,opengl32.lib...

平面紋理與球面紋理對映關係

球面紋理對映就是將乙個平面紋理對映到球面上,見下圖 實現球面紋理對映有兩種方法,一種是使用頂點的法向量來生成紋理座標,另乙個是使用頂點的位置向量來生成紋理座標。問題的本質是根據球面上每個點的法向量座標生成對應的紋理座標,請看下圖,下圖中外部的方框表示二維紋理座標,其範圍是 u,v min 0,0 u...