Poll for openGL errors.

This commit is contained in:
2017-11-23 15:35:41 +01:00
parent f289b2f52b
commit 7d43bff343
3 changed files with 25 additions and 1 deletions

View File

@@ -111,3 +111,17 @@ void fmri::renderText(std::string_view text)
glutBitmapCharacter(font, c);
}
}
void fmri::checkGLErrors()
{
while (auto error = glGetError()) {
switch (glGetError()) {
case GL_NO_ERROR:
// Should not get here, but whatever.
return;
default:
cerr << "OpenGL error: " << (const char*) glewGetErrorString(error) << endl;
}
}
}

View File

@@ -41,4 +41,9 @@ namespace fmri {
* @param text The text to draw.
*/
void renderText(std::string_view text);
/**
* Check if there are OpenGL errors and report them.
*/
void checkGLErrors();
}

View File

@@ -110,6 +110,11 @@ static void updateVisualisers(unsigned int dataset)
}
}
static void idleFunc()
{
checkGLErrors();
}
int main(int argc, char *argv[])
{
google::InitGoogleLogging(argv[0]);
@@ -126,7 +131,7 @@ int main(int argc, char *argv[])
// Register callbacks
glutDisplayFunc(render);
glutIdleFunc(glutPostRedisplay);
glutIdleFunc(idleFunc);
glutReshapeFunc(changeWindowSize);
Camera::instance().registerControls();