Poll for openGL errors.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user