Poll for openGL errors.
This commit is contained in:
@@ -111,3 +111,17 @@ void fmri::renderText(std::string_view text)
|
|||||||
glutBitmapCharacter(font, c);
|
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.
|
* @param text The text to draw.
|
||||||
*/
|
*/
|
||||||
void renderText(std::string_view text);
|
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[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
google::InitGoogleLogging(argv[0]);
|
google::InitGoogleLogging(argv[0]);
|
||||||
@@ -126,7 +131,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Register callbacks
|
// Register callbacks
|
||||||
glutDisplayFunc(render);
|
glutDisplayFunc(render);
|
||||||
glutIdleFunc(glutPostRedisplay);
|
glutIdleFunc(idleFunc);
|
||||||
glutReshapeFunc(changeWindowSize);
|
glutReshapeFunc(changeWindowSize);
|
||||||
|
|
||||||
Camera::instance().registerControls();
|
Camera::instance().registerControls();
|
||||||
|
|||||||
Reference in New Issue
Block a user