VolumeRendering
3D Texture Slice
← Texture Coordinate Generation | ● | 3D Texture Objects →
Usage Example: Drawing a horizontal slice of a unit volume with the barycenter being the origin of world coordinates (the vertical position of the slice is determined by its height h).
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslated(0.5,0.5,0.5);
glMatrixMode(GL_MODELVIEW);
glBegin(GL_QUADS);
x_0=-0.5; y_0=h; z_0=-0.5;
glTexCoord3f(x_0,y_0,z_0);
glVertex3d(x_0,y_0,z_0);
x_1=0.5; y_1=h; z_1=-0.5;
glTexCoord3f(x_1,y_1,z_1);
glVertex3d(x_1,y_1,z_1);
x_2=0.5; y_2=h; z_2=0.5;
glTexCoord3f(x_2,y_2,z_2);
glVertex3d(x_2,y_2,z_2);
x_3=-0.5; y_3=h; z_3=0.5;
glTexCoord3f(x_3,y_3,z_3);
glVertex3d(x_3,y_3,z_3);
glEnd();
glLoadIdentity();
glTranslated(0.5,0.5,0.5);
glMatrixMode(GL_MODELVIEW);
glBegin(GL_QUADS);
x_0=-0.5; y_0=h; z_0=-0.5;
glTexCoord3f(x_0,y_0,z_0);
glVertex3d(x_0,y_0,z_0);
x_1=0.5; y_1=h; z_1=-0.5;
glTexCoord3f(x_1,y_1,z_1);
glVertex3d(x_1,y_1,z_1);
x_2=0.5; y_2=h; z_2=0.5;
glTexCoord3f(x_2,y_2,z_2);
glVertex3d(x_2,y_2,z_2);
x_3=-0.5; y_3=h; z_3=0.5;
glTexCoord3f(x_3,y_3,z_3);
glVertex3d(x_3,y_3,z_3);
glEnd();