Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 530011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:09:05+00:00 2026-05-13T09:09:05+00:00

glLoadIdentity says GL_INVALID_OPERATION is generated if glLoadIdentity is executed between the execution of glBegin

  • 0

glLoadIdentity says

GL_INVALID_OPERATION is generated if
glLoadIdentity is executed between the
execution of glBegin and the
corresponding execution of glEnd.

But GL_INVALID_OPERATION is a flag returns by glGetError.

My question is, when should we call glGetError ( in order to know whether we are calling opengl in correct sequence)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:09:06+00:00Added an answer on May 13, 2026 at 9:09 am

    I’m not sure if your question is about when you can call glGetError if inside glBegin/End or whether it’s a more general question about glGetError usage in general. So I’ll answer both.

    What you can do between glBegin and glEnd is very limited. This is on purpose, as you put the GL in a very specific mode – in the middle of a Draw. As such, anything that does not relate directly to per-vertex attributes is simply invalid. Even a glGetError is invalid in that context.Try and think of glBegin+all the GL calls in between+glEnd as a single Draw call to the GL, that helps get closer to what the GL really does anyways.

    Now, you should never really have a GL error triggered while inside the Begin/End pair if you stick to the simple rule to only call attribute methods (glNormal, glTexCoord, glColor, glSecondaryColor, glIndex, glMultiTexCoord, glVertexAttrib, glVertex and a couple others). Anything else will trigger an error. (err… well, glMaterial is a bit of an exception. It works, but its usage has been discouraged)

    If your question is when you can call glGetError when the error was triggered inside a Begin/End pair, ChrisF answered in a comment: after the glEnd call.

    Now, in a broader sense, use glGetError only as a debugging tool. My personal bias is twofold:

    • check glGetError once per frame to be sure there is no error
    • wrap most GL calls with a macro that can check the GL error code, and only turn it on when the per-frame check fails.

    Of course, since the attribute methods can be called outside a Begin/End pair, it’s a bit tricky to get them right. But in practice, those methods never fail anyways, so I don’t bother to macro-check them.

    A tidbit of trivia: the GL API was originally designed so that the client implementation could actually not know whether there was an error at the call site. E.g. if the GL was actually implemented in a remote machine (like in the SGI days), a call to, say, glTexEnv with a target not of GL_TEXTURE_ENV could simply be added to the command buffer, and no error would be recorded at that point.

    If you then called glGetError, the client side would then have to flush the command buffer to the GL server, wait for the commands that are buffered to be processed, get the error code back, and return the appropriate error code to the application.

    If this sounds heavy, that’s because it was. This was the main reason why not each call was returning an error code, by the way, and why calling glGetError was only considered ok for debugging purposes. These days, most GL implementations are handling all the state management in the same process, so as I said, it’s really trivia for most users.

    Last, whenever I’m talking about Begin/End, I feel I need to say that you should probably look at not using it at all. It’s about the worst performing way to Draw with GL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assuming the code is: glLoadIdentity(); glTranslatef(-1.5f,0.0f,-6.0f); glBegin(GL_TRIANGLES); glVertex3f( 0.0f, 1.0f, 0.0f); glVertex3f(-1.0f,-1.0f, 0.0f); glVertex3f(
When applying transformations to objects we use glPushMatrix/glPopMatrix. But why don't we use glLoadIdentity
When I draw a cube with this code glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); gluLookAt( x,
I draw my background every frames : void Window::paintGL() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity();
An image says a thousand words, so what about two? I have this map
I have the following OpenGL code in the display function: glLoadIdentity(); gluLookAt(eyex, eyey, eyez,
I'm studying for an exam, and a previous exam had this question: 1. void
I init OpenGL in my lwgjl application in this way: glEnable(GL_TEXTURE_2D) glMatrixMode(GL_PROJECTION) glLoadIdentity() glOrtho(0,
Here I created one simple OpenGLES iPad sample. //---------------------------------------- glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustumf(-1, 1, -1,
My instructor says they can be used interchangeably to affect the projection matrix. He

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.