Greetings,
While working with NeHe #33 tutorial, I tried setting glMatrixMode(GL_PROJECTION) with some standard resolutions, (0, 800, 0, 600), etc.
However, when I invoke this call in the init portion of the code, the rotating sprites disappear. I have no idea how what the coordinates correspond to, when rendering the GL_QUADS.
Would anyone be able to show me how to set this up whilst having the glMatrixMode set to GL_PROJECTION?
NeHe 33 coupled with gluOrtho2D
I do something like this:
The glOrtho takes arguments (left-side, right-side, bottom, top, near, far) it looks like you had it backwards, but that's ok, the OpenGL guys got it backwards IMHO
Oh and to minimize linkage I use glOrtho and glFrustum instead of any glu stuff so that I'm not linking more than is really necessary, but it's really no biggie.
void SetPerspective(float fov, float aspect, float znear, float zfar)
{
float top, bottom, left, right;
top = znear * tan(fov / 2 * DEG2RAD);
bottom = -top;
right = aspect * top;
left = -right;
glFrustum(left, right, bottom, top, znear, zfar);
}
void Draw_Perspective()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
SetPerspective(camera_fov, (float)(app_rect.right - app_rect.left)/(app_rect.bottom - app_rect.top), 1, 99999);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(camera_angles.x, 1, 0, 0);
glRotatef(camera_angles.y, 0, 1, 0);
glRotatef(camera_angles.z, 0, 0, 1);
glTranslatef(-camera_origin.x, -camera_origin.y, -camera_origin.z);
}
void Draw_Ortho()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, VID_WIDTH, VID_HEIGHT, 0, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
The glOrtho takes arguments (left-side, right-side, bottom, top, near, far) it looks like you had it backwards, but that's ok, the OpenGL guys got it backwards IMHO
Oh and to minimize linkage I use glOrtho and glFrustum instead of any glu stuff so that I'm not linking more than is really necessary, but it's really no biggie.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement