glMatrixMode(GL_PROJECTION) problem

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() {

OutputGlError(“MatrixMode”) ;
GLdouble gldAspect = (GLdouble) (GLdouble);
// nFov value gotten from combobox
GLdouble gldFov = (GLdouble) nFoV; gluPerspective(gldFov, gldAspect, 1.0, 100);
glViewport(0, 0,,;

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

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

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…


[QUOTE]Originally posted by chennes:

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


It’s working fine now.