PDA

View Full Version : No Z-axis?



hollowcoder
08-30-2002, 02:59 AM
what did I do wrong? theese are just 2 quads which should rotate around the y-axis. but always the second (the red one) is in the foreground. here's the code...

void Scene1::Render()
{
glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glRotatef(Angle, 0, 1, 0);
Angle += 1.0f;
if (Angle == 360.0f) Angle =0.0f;

glBegin(GL_QUADS);
glNormal3f(0.0f, 0.0f, -0.5f);
glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f(-0.5f, +0.5f, -0.5f);
glVertex3f(+0.5f, +0.5f, -0.5f);
glVertex3f(+0.5f, -0.5f, -0.5f);
glVertex3f(-0.5f, -0.5f, -0.5f);
glEnd();
glBegin(GL_QUADS);
glNormal3f(0.0f, 0.0f, +0.5f);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(-0.5f, +0.5f, +0.5f);
glVertex3f(+0.5f, +0.5f, +0.5f);
glVertex3f(+0.5f, -0.5f, +0.5f);
glVertex3f(-0.5f, -0.5f, +0.5f);
glEnd();
return;
}

and I can't move the camera with glTranslatef in any z-direction..
can you help me?

g.h.

[This message has been edited by hollowcoder (edited 08-30-2002).]

Gavin
08-30-2002, 03:30 AM
what have you set your projection/ortho with?

hollowcoder
08-30-2002, 03:33 AM
that's my init-routine:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(1.0f, (GLfloat) WidthOfWindow / (GLfloat) HeightOfWindow, 0.5f, 100.0f); glMatrixMode(GL_MODELVIEW);

Deiussum
08-30-2002, 04:38 AM
When is your Init routine run? If it gets run before your GL context is setup, all of your gl functions there will fail.

Gavin
08-30-2002, 05:08 AM
You are asking for a depth buffer when you start gl?

hollowcoder
08-30-2002, 05:34 AM
ah, thank you! I first have set up my screen details and then init opengl. now it works http://www.opengl.org/discussion_boards/ubb/smile.gif

thx very much http://www.opengl.org/discussion_boards/ubb/smile.gif)