View Full Version : Ortho mode - what's wrong?
Orzech
04-02-2003, 10:15 AM
Hello.
I've have a question about switching beetwen projection modes. The problem is that when I want to jump to the ortho mode and then draw something nothing happens. I have no idea why is that so because I've copied these lines just straight from a tutorial - look :
glMatrixMode(GL_PROJECTION_MATRIX);
glPushMatrix();
glLoadIdentity();
glOrtho(0, Width, 0, Height, 1, -1); // Switch to ortograhpic projection
glMatrixMode(GL_MODELVIEW);
/* blah blah blah goes here */
glMatrixMode(GL_PROJECTION_MATRIX);
glPopMatrix();
glMatrixMode(GL_MODELVIEW); // Back to the perspective
Is there anything wrong? I don't think I've screwd up drawing of primitives...
It's GL_PROJECTION, not GL_PROJECTION_MATRIX.
Orzech
04-03-2003, 08:18 AM
http://www.opengl.org/discussion_boards/ubb/smile.gif OK
Thanks
nexusone
04-03-2003, 09:18 AM
Let's look at your code it seems a bit strange:
// Start
glMatrixMode(GL_PROJECTION); // not GL_PROJECTION_MATRIX
glPushMatrix(); // Save projection matrix
glLoadIdentity(); // Clear project matrix
glOrtho(0, Width, 0, Height, 1, -1); // Switch to ortograhpic projection
glMatrixMode(GL_MODELVIEW); // Draw matrix state unknown
// We have not use glLoadIdentity for Modelview so matrix in state of last call to draw world
/* blah blah blah goes here */
glMatrixMode(GL_PROJECTION); // Back to Projection matrix
glPopMatrix(); // Restore projection matrix from last Push command
glMatrixMode(GL_MODELVIEW); // Back to the perspective
// Modelview state unknown???
Is there anything wrong? I don't think I've screwd up drawing of primitives...
I don't think it is primitive problem, more a initializing the diffrent matrix modes.
Also not enought code to see if there are any other problems. post more of the display routine code.
[This message has been edited by nexusone (edited 04-03-2003).]
[This message has been edited by nexusone (edited 04-03-2003).]
roffe
04-03-2003, 09:33 AM
Originally posted by Orzech:
glOrtho(0, Width, 0, Height, 1, -1); //
You reversed the values for the near and far plane. Try :
glOrtho(0, Width, 0, Height, -1, 1);
oliii
04-03-2003, 04:29 PM
try with a glLoadIdentity() instead of a push/pop matrix, and create the matrix from the blank template.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, Width, 0, Height, 1, -1);
glMatrixMode(GL_MODELVIEW);
glIdentity();
// BLA BLA BLA ECT....
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glPerspective(....);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// BLA BLA BLA again....
maybe you don't need the glLoadIdentity() after the glMatrixMode(GL_MODELVIEW), but usually, the 'camera' is different from perspective views and orthographic views. That could screw up things too.
[This message has been edited by oliii (edited 04-03-2003).]
Orzech
04-05-2003, 02:58 AM
http://www.opengl.org/discussion_boards/ubb/smile.gif Haha! Ok guys, thanks for your help but reply of Bob (first post) already solved my problem. It was just a tiny bug. I used GL_PROJECTION_MATRIX insted of GL_PROJECTION. That's all. Everthing works just fine.
Thanks
Orzech
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.