I am a learner of OpenGL and right now focus on 3D texture. I find that I can not display the inside information of the 3D texture. I wonder how to do that?
Following is part of the example modified from the red book.
#define iWidth 16
#define iHeight 16
#define iDepth 16
static GLubyte image[iDepth][iHeight][iWidth][4];
static GLuint texName;
PFNGLTEXIMAGE3DPROC glTexImage3D;
GLfloat verts[8][3] = {{0,0,0}, {0,1,0}, {1,0,0}, {1,1,0}, {1,0,1}, {1,1,1}, {0,0,1}, {0,1,1}};
GLfloat texs[8][3] = {{0,0,0}, {0,1,0}, {1,0,0}, {1,1,0}, {1,0,1}, {1,1,1}, {0,0,1}, {0,1,1}};
void makeImage(void)
{
int s, t, r;
//first set all the voxel in moderate transparency
for (s = 0; s < 16; s++)
for (t = 0; t < 16; t++)
for (r = 0; r < 16; r++)
{
image[r][t][s][0] = (GLubyte) (s * 17);
image[r][t][s][1] = (GLubyte) (t * 17);
image[r][t][s][2] = (GLubyte) (r * 17);
image[r][t][s][3] = 180;
}
// set depth 13 at red color and no transparency
for (s = 0; s < 16; s++)
for (t = 0; t < 16; t++)
{
image[13][t][s][0] = (GLubyte) 255;
image[13][t][s][1] = (GLubyte) 0;
image[13][t][s][2] = (GLubyte) 0;
image[13][t][s][3] = 255;
}
}
The result is shown below:
(I don’t know how to insert the figure here and I could only display a link of my result picture)
From the figure, we can not see the inside red color plane. I wonder how to show such non-transparency plane?
Thanks very much.