PDA

View Full Version : how to make 3d texture?



hwj_just
04-17-2005, 04:34 PM
my code is:
#define iWidth 16
#define iHeight 16
#define iDepth 16

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][s][0] = s*17;
image[r][t][s][1] = t*17;
image[r][t][s][2] = r*17;
}

glTexImage3D[GL_TEXTURE_3D,0,GL_RGB,iWidth,iHeight,iDepth,0,GL_ RGB,GL_UNSIGNED_BYTE,image];

glBegin[GL_QUADS];
glTexCoord3f[0.0,0.0,0.0];glVertex3f[-1.0,1.0,0.0];
glTexCoord3f[0.0,1.0,0.0];glVertex3f[1.0,1.0,0.0];
glTexCoord3f[1.0,1.0,0.0];glVertex3f[1.0,-1.0,0.0];
glTexCoord3f[1.0,0.0,0.0];glVertex3f[-1.0,-1.0,0.0];
glEnd[];

i donot konw how to make the texcoordinate in 3d,maybe it's not right? i just map the texture in 2d?
could you help me how to make the coordinate in 3d texture?thank you very much!!