[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Debugging GL apps
Will Weisser wrote:
> I seem to be having a serious problem...my OpenGL application does completely
> different things under different drivers, and I have no way of debugging or
> knowing why this is.
That can happen - even if both drivers are working correctly, the way that
they respond to errors in your code can differ. Sometimes you can 'get
away with it' under one driver and it'll segfault on another.
So, it would be bad to start out by blaming the drivers....that comes
> So the problem is thus: I don't think I'm doing anything too spectacularly
> fancy with OpenGL (most of my code is based on Steve Baker's ac_to_gl utility),
Oh great - so it's *MY* fault now?! :-)
> but I get entirely different responses from different drivers, and I have no
> way of debugging any of them.
Sure you do - start out by writing a routine to check the glGetError() return(s)
and to print out the appropriate messages.
Sprinkle calls to that routine throughout your initialisation and main-loop code,
bearing in mind that:
1) It's illegal to call glGetError between a glBegin and glEnd pair.
2) OpenGL buffers up multiple errors in some cases - so you have to
call glGetError in a loop, printing out the messages until it tells
you that the error is cleared. RTFM.
There's no absolute guarantee that this is OpenGL's fault at all, your
program could be doing something like screwing up the stack or the free
memory arena - either of which could screw up in OpenGL later on (or
not if you get lucky).
Hence, normal debugging practices apply.
If you are using Mesa, there is (IIRC) a way to compile it with
some degree of verbosity enabled so that errors get checked and printed
more often. This slows it down quite a bit - but for debugging, who
> Even if I fix this, what happens when my code
> gets released to the 100 other GL implementations out there
> which I don't even have access to.
The same thing as happens when you ship it onto different CPU's,
different C compilers, different OS's, etc. There is nothing
special about OpenGL in this regard.
One of the cool things about the OpenSource movement is that
when you put out beta code, you get back LOTS of error reports
in short order - mostly from people with different CPU's, compilers,
OS's and OpenGL's.
Steve Baker http://web2.airmail.net/sjbaker1
firstname.lastname@example.org (home) http://www.woodsoup.org/~sbaker