|
|
OPENGL中关于3D 纹理贴图时,设置纹理坐标函数glTexCoord3f(S,R,T) 中参数 T 的含义及用法,有知道的大侠请给个详细指使,谢谢。。。。
一下是代码片断:
#define iWidth 16
#define iHeight 16
#define iDepth 16
static GLubyte image[iDepth][iHeight][iWidth][3];
static GLuint texName;
void makeImage(void)
{
int s, t, r;
for (s = 0; s < 16; s++)
for (t = 0; t < 16; t++)
for (r = 0; r < 16; r++)
{
image[r][t][0] = (GLubyte) (s * 17);
image[r][t][1] = (GLubyte) (t * 17);
image[r][t][2] = (GLubyte) (r * 17);
}
}
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, iWidth, iHeight,iDepth, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_QUADS);
glTexCoord3f(0.0, 0.0, 0.0); glVertex3f(-2.25, -1.0, 0.0);
glTexCoord3f(0.0, 1.0, 0.0); glVertex3f(-2.25, 1.0, 0.0);
glTexCoord3f(1.0, 1.0, 0.0); glVertex3f(-0.25, 1.0, 0.0);
glTexCoord3f(1.0, 0.0, 0.0); glVertex3f(-0.25, -1.0, 0.0);
glEnd();
glFlush();
}
[em7] |
|