user2136963
user2136963

Reputation: 2606

glGetError returns 1282 infinitely

Here is my function for logging errors:

void check_error(const char* st)
{
    GLenum err(glGetError());

    while (err != GL_NO_ERROR)
    {
        cerr << "OpenGL error: " << err << " "<<st<<endl;
        err = glGetError();
    }
    cerr << "?\n";
}

It's called this way:

int _tmain(int argc, char* argv[])
{
    check_error("start");
    ...
}

It's not called anywhere else.

It produces: OpenGL error 1282 start in infinite loop.

Here are my includes:

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <gl/glew.h>
#include <gl/glut.h>
#include <GL/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>

Visual studio 2013

Upvotes: 3

Views: 2912

Answers (1)

Brett Hale
Brett Hale

Reputation: 22358

This isn't a direct answer; but in lieu of your comment, I have a function in my GL library:

GLenum
G0::glFlushError () // noexcept
{
    GLenum ret = glGetError();

    if (ret != GL_NO_ERROR)
    {
        GLuint finite = 255; // (watchdog count)
        GLenum gl_err = ret;

        while (gl_err != GL_NO_ERROR && finite--)
            gl_err = glGetError();

        if (gl_err != GL_NO_ERROR)
            G0::terminate("glGetError: reset failed\n");
    }

    return ret;
}

Where G0 is my library's namespace. When you want to test the most recent GL error - and clear it - glGetError needs to be called in a loop. It's an 'expensive' call, as it stalls the pipeline, and therefore should only be used in 'setup' code, or during debugging.

Upvotes: 4

Related Questions