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

  • SEARCH
  • Home
  • 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 8861937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:36:25+00:00 2026-06-14T15:36:25+00:00

I have been working on a GL program for some time now and suddenly

  • 0

I have been working on a GL program for some time now and suddenly it began to give errors.
After trying to resolve these for a while I wrote a short test program that generates the same behavior:

#include <GL/glut.h>
#include <iostream>

#define CHECK_GL_ERR() printError(__LINE__)

void printError(int line)
{
        GLenum err = glGetError();
        if(err != GL_NO_ERROR)
        {
                std::cerr << "GL error on line " << line << ": " << gluErrorString(err) << std::endl;
        }
}

void displayFunc()
{
        CHECK_GL_ERR();
        glBegin(GL_POINTS);
        CHECK_GL_ERR();
        glVertex3f(0, 0, 0);
        CHECK_GL_ERR();
        glEnd();
        CHECK_GL_ERR(); //line 23
        exit(0);
}

int main(int argc, char **argv)
{
        glutInit(&argc, argv);
        glutInitWindowSize(300, 300);
        glutCreateWindow("Test");

        glutDisplayFunc(displayFunc);

        glutMainLoop();
}

When I run this program it gives the output:

GL error on line 23: invalid operation

So it seems that glEnd(); causes the error.
The docs say:

GL_INVALID_OPERATION is generated if glEnd is executed without being
preceded by a glBegin.

Which is not the case in my code. So does anyone see, why this code gives an error message?

PS: Of course I know that glBegin/End has been deprecated/removed for a long time but it is very convenient to hack together some small amounts of code. Also the program worked without errors until GL decided to be grumpy.

EDIT

I just did a trace with glslDevil which gave:

W! Program Start
|  glXQueryExtension(0x1ab03f0, (nil), (nil))
|  glXChooseFBConfig(0x1ab03f0, 0, 0x7fffb8fcf8b0, 0x7fffb8fcf8a4)
|  glXGetVisualFromFBConfig(0x1ab03f0, 0x111)
|  glXGetProcAddressARB(0x7f93c37526e5)
|  glXCreateNewContext(0x1ab03f0, 0x111, 32788, (nil), 1)
|  glXIsDirect(0x1ab03f0, 0x1ac8de8)
|  glXMakeContextCurrent(0x1ab03f0, 123731970, 123731970, 0x1ac8de8)
|  glXMakeContextCurrent(0x1ab03f0, 123731970, 123731970, 0x1ac8de8)
|  glDrawBuffer(GL_FRONT)
|  glReadBuffer(GL_FRONT)
|  glXMakeContextCurrent(0x1ab03f0, 123731970, 123731970, 0x1ac8de8)
|  glViewport(0, 0, 300, 300)
|  glXMakeContextCurrent(0x1ab03f0, 123731970, 123731970, 0x1ac8de8)
|  glXMakeContextCurrent(0x1ab03f0, 123731970, 123731970, 0x1ac8de8)
|  glGetError()
|  glBegin(GL_POINTS)
|  glGetError()
|  glVertex3f(0,000000, 0,000000, 0,000000)
|  glGetError()
|  glEnd()
W! OpenGL error GL_INVALID_OPERATION detected
|  glGetError()
|  glXMakeContextCurrent(0x1ab03f0, 123731970, 123731970, 0x1ac8de8)
|  glXDestroyContext(0x1ab03f0, 0x1ac8de8)
E! Child process exited
W! Program termination forced!
  • 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-06-14T15:36:26+00:00Added an answer on June 14, 2026 at 3:36 pm

    After some testing, I found your program have two simple issues:

    1. You must not use glGetError inside a glBegin/glEnd block. The API is strict about that. But the error only happens after glEnd. If you read the API, you’ll find that the error might propagate: it only happens after the glEnd.
    2. A segmentation fault occurs when you use exit(0) inside the display function(that only happens with the Intel driver.) That happens because the GL context hasn’t been freed yet, and a driver bug comes along. So you should avoid exit inside the display function.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Eclipse project I've been working on for some time now, and
I have been working for some time on a library which performs numeric calculations.
I've been working on a program to draw cards. I have 54 cards and
I have been working with Zend for a few months now and am at
I have been working on a huge project for work for a while now,
I have a C++ code base that has been working for a long time.
I've been asked to build a real-time face recognition application, and after some looking
I've been working/coding in C#/Java for some years, so the basics etc. don't give
I've been working on a text editor for some time. I made a custom
for quite some time I've been working on an application. As programming is just

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.