Checking OpenGL Errors

  • Follow


I'm working on my first non-trivial OpenGL application,
and I'm not sure if I'm taking the correct approach
when it comes to the use of glGetError().

At the moment every time I need an OpenGL command
I make it into a macro by prepending the letter "i".
e.g. If I needed glTexImage2D then I'd make
iglTexImage2D, or glEnd might become iglEnd.

When the c preprocessor macro NO_GL_DEBUG
is defined then that macros are just direct mappings, e.g.:
#define iglTexImage2D glTexImage2D
#define iglEnd glEnd

However, when NO_GL_DEBUG is not defined
then the macros map to some custom functions e.g.:
#define iglTexImage2D glTexImage2D_and_check_errors
#define iglEnd glEnd_and_check_errors

And these functions then call the given command,
check for errors via glGetError, and the throw a C++
exception if an error is discovered.

This approach is a bit tedious since I have to define
a new macro plus _and_check_errors function for every
single OpenGL command.

Is there any easier way to go about this sort of thing?
I'd love to discover some sort of setting
that makes OpenGL errors intrinsically fatal
without me having to check for errors and manually
throw an exception.

0
Reply rutski89 5/14/2008 6:31:29 AM

On May 14, 8:31 am, rutski89 <rutsk...@gmail.com> wrote:
>
> Is there any easier way to go about this sort of thing?
>

It seems a bit excessive.

I just check once in my main loop. If errors appear it's usually
in the code I'm working on at the time so it's trivial to find out
where.

--
<\___/>
/ O O \
\_____/  FTB.     Remove my socks for email address.
0
Reply fungus 5/14/2008 1:40:00 PM


On May 14, 1:31=A0am, rutski89 <rutsk...@gmail.com> wrote:

> I'm working on my first non-trivial OpenGL application,
> and I'm not sure if I'm taking the correct approach
> when it comes to the use of glGetError().

I use an OpenGL debugger (BuGLe) which can check for errors at every
OpenGL call.

- Chris
0
Reply crjjrc 5/14/2008 2:24:22 PM

2 Replies
94 Views

(page loaded in 0.039 seconds)

Similiar Articles:













7/17/2012 3:19:56 PM


Reply: