PDA

View Full Version : axis and viewport



giuseppe500
11-25-2011, 06:19 AM
hello .
I have this code that render an axis tern on the bottom left of my screen .
I use a vieport ,I read on a book that for solve the same problem draw the axis on a texture , then render the texture with axes on a quad at the bottom left of the screen .
Why it do this ?
i do this:



GLdouble modelMatrix[16];
GLdouble projectMatrix[16];
GLint viewport[4];

// save all information
memcpy(modelMatrix, m_modelMatrix, sizeof m_modelMatrix);
memcpy(projectMatrix, m_projectMatrix, sizeof m_projectMatrix);
memcpy(viewport, m_viewport, sizeof m_viewport);

//Imposto la Viewport per gli assi

SetViewportAxes();
glCallList(m_GLLists.Axes);


//restore the information
memcpy(m_modelMatrix, modelMatrix, sizeof modelMatrix);
memcpy(m_projectMatrix, projectMatrix, sizeof projectMatrix);
memcpy(m_viewport, viewport, sizeof viewport);

glLoadIdentity();



void CCMPView::SetViewportAxes(int x, int y)
{
//Imposta la viewport per la visualizzazione del sistema di riferimento globale
::glViewport(x, y, CMP_AXES_VIEWPORT_DIM, CMP_AXES_VIEWPORT_DIM);
#ifdef _DEBUG
if ( GL_NO_ERROR != ::glGetError() )
{
::AfxMessageBox("Error while trying to set viewport.");
}
#endif
::glMatrixMode(GL_PROJECTION);
// initialize the projection matrix to a pristine state
::glLoadIdentity();

SetupAxesViewingFrustum();

::glMatrixMode(GL_MODELVIEW);
::glLoadIdentity();


}




void CCMPView::SetupAxesViewingFrustum()
{
//Imposta la modalita di visualizzazione prospettica o ortogonale
if (m_ViewParams.Par.IsViewFlag(VIEW_PERSPECTIVE))
// select a default perspective viewing volumn
gluPerspective (30., // Field-of-view angle
1./*m_AspectRatio*/, // Aspect ratio of viewing volume
2., // Distance to near clipping plane
6.); // Distance to far clipping plane
else
glOrtho(-1., 1., -1., 1., 2., 6.);
}


I have some problem with windows 7, and that are related to the viewport (if i remove all the axis viewport code from project it work ,else all the graphics is stereched and rendered in the axis viewport.
I rebuild the above code for this you see some errors?.
thanks