View Full Version : tyring to verify our renderer output with that of OpenGL(only perspective projection0

06-05-2002, 06:56 AM

OS: Windows NT.
I am trying to verify our (3d)raycaster output by comparing the bounding box of our rendered output with OpenGl output image's bounding box. I need this checking only for verifying if our "perspective projection" is fine.

For simplicity consider I have a cube of (256x256x256) having same intensity, rotated by -20 degrees about z axis and being displayed in a window(in our program) I need program in OpenGL which does the same and which can give me bounding box of the 2d output image. I was successful in creating cube in OpenGL and displaying with ortho projection.
* but setting the size of the cube to 256x256x256 in OpenGL is not known to me. How do I do that? Curently I use glBegin(GL_QUADS) ...;....; for all 6 sides of the cube. Looks like glVertex3f only takes in normalised values w.r.t windows. I need to set the size of the cube exactly!
*Also rotating about z axis by -20 degrees. I tried using glRotatef(-20, 0, 0,1); Is this right?
*I have my nearVal, farVal and fieldOfView for setting the perspective projection.. I currently use ortho projection in OpenGL. How do I set perspective projection.

Thanks for any hints or help.

06-05-2002, 11:53 AM
for setting up your projective projection use:

gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)

fovy: field of view in degree in y direction
aspect: aspect ratio (width/height of your viewport)
zNear, zFar: NearPlane, FarPlane

i don't really understand your glVertex problems

for the front side ouf you cube your code should look like this:


glVertex takes world-coordinates as input
so if you want a 256x256x256 cube the above code gives you the front side the other sides you should be able to figure out yourself http://www.opengl.org/discussion_boards/ubb/smile.gif

btw remember that all vertices have to be specified in the correct order (default is counter-clockwise)

your rotation should work the way you do it

if you have any more problems don't be shy just ask

hope this helps

p.s.:if you want your cube in wireframe mode use glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) - (as you said this cube shall be a bounding box)