Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stringifying openGL enums

So there has been a lot of times where I needed to know what the enums returned by certain opengl operations are, to print them on the terminal to see what's going on.

It doesn't seem there's any kind of function available for stringifying the enums at the moment, so I'm thinking of going straight to gl.h (actually I'm gonna use libglew's header for now), grabbing the #defines and creating a huge switch table for convenience purposes.

Is there any better way, and how would you deal with having to port things to OpenGL ES?

like image 955
kamziro Avatar asked Jan 16 '11 21:01

kamziro


2 Answers

gluErrorString is the function you're looking for in OpenGL, as GLU library is normally always available alongside with GL.

I don't have experience in OpenGL ES, but Google turned up GLUes that may help you.

like image 137
rotoglup Avatar answered Sep 23 '22 09:09

rotoglup


OpenGL has some official .spec files that define the API, there is one enum.spec that lists all the enum names and their values. You just need to write a simple program to parse the file and produce a lookup mapping.

The file can be found at http://www.opengl.org/registry/ (specifically http://www.opengl.org/registry/api/enum.spec)

Manually processing gl.h would work but the spec files are updated for new versions and if you have a program to generate the code for you then you don't have to do anything to get the new enums in. Also gl.h file is implementation specific. So it might change between nVidia, ATI, and on different platforms.

like image 20
David C. Bishop Avatar answered Sep 23 '22 09:09

David C. Bishop