Dear Friends
I am using orthographic projection to render my 3d model. As I rotate the geometry the model gets distorted near the edeges at the top. Can u tell me anyone why is it happening. please check my code snippet.
Is my projection correct ??Code:void CRevolutionProjView::orthogonalStart() { glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(left_side*AR, right_side*AR, top_side, bottom_side, near_side, far_side); glScalef(zoomFactor,zoomFactor,1); glTranslatef(trans[0], trans[1], trans[2]); glRotatef(rot[0], 1.0f, 0.0f, 0.0f); glRotatef(rot[1], 0.0f, 1.0f, 0.0f); glRotatef(rot[2], 0.0f, 0.0f, 1.0f); glMatrixMode(GL_MODELVIEW); } void CRevolutionProjView::orthogonalEnd() { glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); } void CRevolutionProjView::DrawScene(CDC *pDC) { wglMakeCurrent(pDC->m_hDC, m_hrc); //--------------------------------- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); orthogonalStart(); glCallList(axes); glCallList(object); glPrintX("X"); glPrintY("Y"); glPrintZ("Z"); glFlush(); orthogonalEnd(); SwapBuffers(pDC->m_hDC); wglMakeCurrent(NULL, NULL); } void CRevolutionProjView::Reshape(CDC *pDC, int w, int h) { AR = (double)w/(double)h; wd = w; ht = h; wglMakeCurrent(pDC->m_hDC, m_hrc); //--------------------------------- glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluPerspective (45, (GLfloat)w / (GLfloat)h, 0.1, 1000.0); glMatrixMode (GL_MODELVIEW); Invalidate(); wglMakeCurrent(NULL, NULL); }




Reply With Quote