I have been reading and trying to piece together code from the example you gave me dorbie… however as I’ve mentioned I do not have the ability to use that code in its present form due to its use of EXT… (Which I have not yet figured out how to load on my MAC G5 yet). However when I do try that code I just get a white screen… (I have removed the EXT stuff in the hopes it will just ‘work’)
void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
glEnable(GL_DEPTH_TEST);
ThreeDTexture * text = readRawSlice("morerawct/ct.raw", iWidth, iHeight, iDepth);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(1, &texName);
glBindTexture(GL_TEXTURE_3D, texName);
glTexImage3D(GL_TEXTURE_3D, 0, GL_INTENSITY16, iWidth, iHeight, iDepth, 0, GL_LUMINANCE, GL_UNSIGNED_SHORT, (GLvoid *) text->image);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glEnable(GL_TEXTURE_3D);
}
void display(void)
{
static float r=0.0;
bool clipping = true;
static double eqnxy1[] = { 0.0, 0.0, 1.0, 0};
static double eqnxy2[] = { 0.0, 0.0, -1.0, 1};
static double eqnxz1[] = { 0.0, 1.0, 0.0, 0};
static double eqnxz2[] = { 0.0, -1.0, 0.0, 1};
static double eqnzy1[] = { 1.0, 0.0, 0.0, 0};
static double eqnzy2[] = {-1.0, 0.0, 0.0, 1};
static float planeS[] = {1,0,0,1};
static float planeT[] = {0,1,0,1};
static float planeR[] = {0,0,1,1};
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//Rotations
glTranslatef(.5, .5, .5);
glRotatef(r, 1,0,0);
glRotatef(r, 0,1,0);
glTranslatef(-.5, -.5, -.5);
//Store the MODELVIEW matrix into memory
static float modelMatrix[16];
glGetFloatv(GL_MODELVIEW_MATRIX, modelMatrix);
glMatrixMode(GL_TEXTURE);
glLoadMatrixf(modelMatrix);
glTranslatef(-1.0f, -1.0f, -1.0f);
//Set clipping planes
glClipPlane(GL_CLIP_PLANE0, &eqnxy1[0]);
glClipPlane(GL_CLIP_PLANE1, &eqnxy2[0]);
glClipPlane(GL_CLIP_PLANE2, &eqnxz1[0]);
glClipPlane(GL_CLIP_PLANE3, &eqnxz2[0]);
glClipPlane(GL_CLIP_PLANE4, &eqnzy1[0]);
glClipPlane(GL_CLIP_PLANE5, &eqnzy2[0]);
//Enable to the clipping planes
if (clipping)
{
glEnable(GL_CLIP_PLANE0);
glEnable(GL_CLIP_PLANE1);
glEnable(GL_CLIP_PLANE2);
glEnable(GL_CLIP_PLANE3);
glEnable(GL_CLIP_PLANE4);
glEnable(GL_CLIP_PLANE5);
}
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
//Generate the texture coordinates
glTexGenfv(GL_S, GL_EYE_PLANE, planeS);
glTexGenfv(GL_T, GL_EYE_PLANE, planeT);
glTexGenfv(GL_R, GL_EYE_PLANE, planeR);
//Start drawing the QUADs
glBegin(GL_QUADS);
for (float a = -2.0; a < 2.0; a += 1.0/(iDepth-1))
{
glVertex3f(-2, -2, a);
glVertex3f(-2, 2, a);
glVertex3f( 2, 2, a);
glVertex3f( 2, -2, a);
}
glEnd();
glPopMatrix();
r = r + 0.5f;
}
void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 30.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -2.5);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(250, 250);
glutInitWindowPosition(100, 100);
glutCreateWindow(argv[0]);
init();
glutReshapeFunc(reshape);
glutDisplayFunc(display);
//glutIdleFunc(idle);
//glutKeyboardFunc (keyboard);
glutMainLoop();
return 0;
}