View Full Version : gluOrtho2D v. gluPerspective
02-13-2001, 10:39 AM
I use gluOrtho2D cuz i want to define the coordinates for my clipping planes. However, my scene rotation doesnt work. If i use gluPerspective...my rotation works. My question is if and how i can use both? I want my rotation but would also like to define my plane. What to do?? http://www.opengl.org/discussion_boards/ubb/confused.gif
02-13-2001, 11:26 AM
Perspective means that the object gets smaller as it goes into the screen. Ortho doesn't do that.
So I am confused on what you mean by it works with Orth, but not perspective. Perspective has near/far clipping planes also.
Maybe a code snippet would help me understand your problem?
02-13-2001, 11:38 AM
Here's some of my code...
void CMyView::OnSize(UINT nType, int cx, int cy)
CView::OnSize(nType, cx, cy);
GLsizei width, height;
width = cx;
height = cy;
aspect = (GLdouble)width;
aspect = (GLdouble)width/(GLdouble)height;
glViewport(0, 0, width, height);
gluOrtho2D(1515.0, 1565.0, -3.0, 15.0);
// gluPerspective(45, aspect, 1, 15.0);
void COPMView::OnMouseMove(UINT nFlags, CPoint point)
m_yRot -= (float)(m_leftDownPos.x - point.x)/3.0f;
m_xRot -= (float)(m_leftDownPos.y - point.y)/3.0f;
m_leftDownPos = point;
In the OnSize above, if i uncomment the glPerspective line and comment the Ortho line, my OnMouseMove function works properly-rotation. But then i cant set the coords of my clipping plane!! However, if i leave as is, then all i get is flickering...but i do get the coords i want.
Its the same with other methods...not just OnMouseMove. My scaling and animation as well.
How else can i set the clipping planes w/o glOrtho?? maybe an MFC solution?
Dude, change your 1 in the perspective call to .1 or .01, and move 15 to 1000.
02-14-2001, 05:23 AM
Those parameters are the near and far clipping planes though. Id like to define the top, bottom, left, and right as Ortho2D does.
I attempted your solution but nothing appears in my window. Id like to know how to be able to rotate a scene as well as set the clipping region. Why doesnt the rotation, etc... work with glOrtho?
Then use glFrustum call. That will control what you want.
02-14-2001, 08:44 AM
Thanx!! I think that is what i wanted. However, I get weird behaviour still. OnMouseMove method makes the rendering disappear; as though it goes out of view. Could this have to do with the aspect ratio. Because im not callin gluPerspective, this ratio is not being set.
If so, then i need the means to call gluPerspective as well as glFrustum. If i try this now...nothing shows up...
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.