Advertisement

Scene offset to the lower right

Started by May 15, 2004 05:22 PM
2 comments, last by karx11erx 20 years, 6 months ago
Hi, another question. As before, I have a number of faces to render. My program contains a software renderer too and all code to do the required rotations and projections. To make things easier, I have decided to keep that projection code, let my program do all scaling and panning and render my scene using that coordinates. My example scene consists of one six sided cube. When started, the program calculates the vertex coordinates so that the cube is rendered by the software renderer exactly in the middle of the viewport. When I use OpenGL rendering, the cube is invisible and somewhere far off the lower right of the viewport. If I call glTranslated (0,0,-500) before rendering, it is visible somewhere near the lower right of the viewport. Obviously I am having some misconception of what OpenGL is doing with my vertices. How can I fix this behaviour?
_________karx11erxVisit my Descent site or see my case mod.
Solved. I simply have to do the following:

CRect rc;
GetClientRect (rc);
zMin = GetMinZ () // get the smallest z value
glTranslated (-rc.Width () / 2, rc.Height () / 2, zMin);

[edited by - karx11erx on May 15, 2004 8:02:17 PM]
_________karx11erxVisit my Descent site or see my case mod.
Advertisement
k. glad we could be of service
"Game Programming" in an of itself does not exist. We learn to program and then use that knowledge to make games.
Sometimes you simply need someone to listen ...

It doesn't work perfectly however. I don't know yet how to compute the z value for glTranslated so that my entire scene is rendered, and not a part of it. If I simply use the smallest z value from my vertices, the outer parts of the scene get clipped.

[edited by - karx11erx on May 15, 2004 8:01:59 PM]
_________karx11erxVisit my Descent site or see my case mod.

This topic is closed to new replies.

Advertisement