   Error on glortho2d
  I have a wierd bug where when I call glOrtho2d glGetError is throwing me back an error (there can only be one error it throws).  The error is that I am calling glOrtho2d between a glBegin and glEnd call, but i'm not.Can anyone spot a problem?void GameEngine::orthoMode(){ glPushMatrix();glLoadIdentity();glViewport(0,0,width,height);glMatrixMode(GL_PROJECTION);glPushMatrix();glLoadIdentity();gluOrtho2D(0,width,height,0);int blah = glGetError();    //  Here is the problemglMatrixMode(GL_MODELVIEW);}void GameEngine::exitOrthoMode(){ glPopMatrix();glMatrixMode(GL_PROJECTION);glPopMatrix();glMatrixMode(GL_MODELVIEW);}glLoadIdentity();gluLookAt(0, 0, 0, 0, 0, 1, 0, 1, 0);glTranslated(0, 0, 8);glRotatef(a, 1, 0, 0);a++;glBindTexture(GL_TEXTURE_2D, backGround);glBegin(GL_QUADS);// Front FaceglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);// Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);// Bottom Right Of The Texture and Quad// blah blah balhglEnd();//*/glBindTexture(GL_TEXTURE_2D, backGround);glDisable(GL_DEPTH_TEST);GameEngine::orthoMode();int blah = glGetError();glBegin(GL_QUADS);glVertex2i(0, 0); glTexCoord2f(0.0f, 1.0f);glVertex2i(0, GameEngine::getHeight()); glTexCoord2f(0.0f, 0.0f); glVertex2i(GameEngine::getWidth(), GameEngine::getHeight()); glTexCoord2f(1.0f, 0.0f); glVertex2i(GameEngine::getWidth(), 0); glTexCoord2f(1.0f, 1.0f);glEnd();GameEngine::exitOrthoMode();
  I've narrowed down the problem a bit...  I can comment out ALL of the glBegins and glEnds and it still causes the same error.Suggestions?   ;  You mean, the return value is GL_INVALID_OPERATION?Be aware that the glGetError() call itself might not be what's responsible.Be aware that the gl error, once set, is never cleared until checked by glGetError(), so if you forgot to check somewhere *else*, it could conceivably hang around (through a complex code path) until you finally get there.   ;  No, i checked, it is definitely on glOrtho2d().I switched the code to:int blah = glGetError();gluOrtho2D(0,width,height,0);blah = glGetError();and glGetError() returns 0 before and 0x00000501 (1281 in decimal) after.Any other suggestions?J   ;  Maybe try calling just glOrtho?   ;  Nope, then i get the error 0x00000501 .  Other ideas?   ;  At long last, solved!I foolishly overlooked that I had correctly updated my width and height variables.  They were still unitialised, and the function was getting 0.  The error was actually an invalid paramater error, not invalid operation. Thanks for the suggestions guys!J   