PDA

View Full Version : Vincent Perspective View



zeus
02-08-2005, 08:05 PM
Hi,

I am trying to get a perspective view to work with Vincent.

I have set it up as follows :

-------------------------------
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

glViewport(0, 0, width, height);
ugluPerspectivef(45.0f, (float)(width / height), 0.1f, 20.0f);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
--------------------------------

My display code is as follows. I have enabled depth testing and have cleared the depth buffer and set the depth function to GL_LEQUAL.

-----------------------

glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
ugSolidCubef(0.5f);

glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
glTranslatef(-0.25f, 0.0f, -1.0f);
ugSolidCubef(0.5f);

glFlush ();
ugSwapBuffers(uwin);

--------------------------------------

This renders a red square and a green square in front of the red square.

First of all, shouldn't the translation of -1.0f in the z axis move the green square behind the red one, not the other way around.

Second of all, the squares are the same size. Shouldn't they be different sizes considering that they are not in the same place in the z axis.

Any ideas of what could be wrong.

Thanks,
Zeus

zeus
02-09-2005, 07:32 AM
Hi,

Nevermind. I found that I was actually using the wrong depth parameters.

Thanks