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??
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?
Here’s some of my code…
void CMyView::OnSize(UINT nType, int cx, int cy)
CView::OnSize(nType, cx, cy);
GLsizei width, height; GLdouble aspect width = cx; height = cy; if (cy==0) aspect = (GLdouble)width; else aspect = (GLdouble)width/(GLdouble)height; glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); 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.
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.
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…