mcfletch / pyopengl

Repository for the PyOpenGL Project
Other
320 stars 102 forks source link

Is there a simple way to stringify GL enums in this ? #63

Open rebb opened 3 years ago

rebb commented 3 years ago

Are the Enums here using the Python Enum Class feature, which allows things like someEnum.name ? I'm currently trying to print some info about uniforms using glGetActiveUniform, but have to resort to making a dict that maps enum values to their own name as a string ..

Is that really the way to go ?

mcfletch commented 3 years ago

Code for the constants is in OpenGL.constant, short answer, no it's not the Python 3 enums, but they do have an attribute name:

>>> import OpenGL.GL
>>> print(OpenGL.GL.GL_FALSE.name)
GL_FALSE

Note, however, that many apis are going to return raw integers, not enumerant types.

HTH, Mike

rebb commented 3 years ago

That is currently my problem :) glGetActiveUniform returns integers for types. I assume there is no way to cast to a constant, to then get access to the corresponding .name ? Sorry if these are silly questions btw, my Python-Fu is not very strong.

mcfletch commented 3 years ago

In theory, the OpenGL XML api might have some declaration where they specify what enum-type is coming out of each entry point, but I don't know of one. PyOpenGL is pseudo-automatically generated from the XML spec/definition, rather than hand-coded. There are a few bits where we've added another data-source to flesh out the api, but that increases the maintenance work each time we do it.