View Full Version : Having problems with projections
09-15-2003, 10:04 AM
I am in a great problem ...as I am not able to obtain the 2D projection[ Square] of a 3D Cube on the window...Is there a feasible way to do that...Can you guys give me a hint or can I get a sample code from any of you guys..Please reply me...I am in need of great help.....Many Thanks...Cheers
09-15-2003, 10:37 AM
Hi. Honestly I don't really understand your problem. I'd like to help you but I don't how... http://www.opengl.org/discussion_boards/ubb/wink.gif
There is something interesting for me in your post... How can a projection on a window be not 2D? Meaby my monitor is weird but I didn't noticed any objects flying around me... http://www.opengl.org/discussion_boards/ubb/wink.gif
09-15-2003, 10:47 AM
glOrtho(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f);
Substitute your own cube diomensions to suit.
09-15-2003, 10:50 AM
P.S. that assumes you have identity on the projection matrix to start with. And of course you'd only call it once. It would be safer to make the following call between the first matrixmode call and the ortho call.
Do you mean, that your cube does not look like a cube, because its faces are not squares but rectangles?
In this case, you didnīt tell OpenGL, the aspect ratio of your window correctly:
float fRatio = ScreenResolutionX / ScreenResolutionY;
gluPerspective (m_fFOVAngle, fRatio, m_fNearPlane, m_fFarPlane);
For example if you have a 1024*768 window, fRatio will be 1.33, which simply means, that your screen is 1.33 times wider than it is high. If you do this, than your cube will look like a cube.
But maybe you meant something different ;-)
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.