PDA

View Full Version : glMatrixMode(GL_PROJECTION) problem



RJH
07-04-2001, 08:16 AM
Help! I want the perspective field of view angle to be configurable by the user. I thought I could just copy & paste the CView:OnSize() GL_PROJECTION matrix code to the FoV combobox selection change code:

void CView::OnSelchangeFoV() {

glMatrixMode(GL_PROJECTION);
OutputGlError("MatrixMode") ;
glLoadIdentity();
GLdouble gldAspect = (GLdouble) m_clientArea.cx/ (GLdouble) m_clientArea.cy;
// nFov value gotten from combobox
GLdouble gldFov = (GLdouble) nFoV; gluPerspective(gldFov, gldAspect, 1.0, 100);
glViewport(0, 0, m_clientArea.cx, m_clientArea.cy);
Invalidate(FALSE);

Howver, I get the following error:
MatrixMode had error: #(1282) invalid operation

Removing the glMatrixMode(GL_PROJECTION) line does not change the screen rendering.

chennes
07-04-2001, 11:03 AM
Are you certain that's where you are actually getting the error? You get nothing if you check for it on the line before the call?

If so, that all I can think of is that you're doing it between a glBegin() and glEnd(), which is illegal. Make sure all of your begins have matching ends...

Chris

RJH
07-04-2001, 12:35 PM
[QUOTE]Originally posted by chennes:
QUOTE]

Thanks for your reply chennes. I figured out the problem. I had left out these 2 lines of code:

CClientDC dc(this) ;
// Make the rendering context m_hrc current
BOOL bResult = wglMakeCurrent(dc.m_hDC, m_hRC);

before the call to

glMatrixMode(GL_PROJECTION);

It's working fine now.