Jump to content
  • Advertisement
Sign in to follow this  
CyberSlag5k

OpenGL GL error source

This topic is 4063 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a log class which I use to log normal application errors and OpenGL errors. In the past I had been just writing out any GL errors when my program exited, and then hunted them down when I noticed the log was written to. This was a bit of a pain, so I've started wrapping my methods like so:
void Log::WriteGLError(const string& header)
{
	string errorString = GetGLErrorString(glGetError());
	if(errorString != "GL_NO_ERROR")
		Write(header, errorString);
}

Shader& Shader::operator = (const Shader& shader)
{
	Log::WriteGLError("Entering Shader::operator =");

	if(this != &shader)
		Copy(shader);

	Log::WriteGLError("Exiting Shader::operator = ");

	return *this;
}

This is a bit of a pain, and it clutters up my code a ton. Is there a better way to do this? I would love it if there were a way to find out where precisely a GL error occurred? Or even better, is there a GL exception type or something.

Share this post


Link to post
Share on other sites
Advertisement
Personally if I was clever I would wrap the glGetError function in a macro called something like GL_ASSERT which I would call after every gl function call and if glGetError returns an error code I would make my code assert(0) so I could break into the code and look in the call-stack to see where the error ocurred.

If I was lazy I would use GLIntercept (http://glintercept.nutty.org/) because it basically does this for you without any code changes. Neat :-)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!