Re: PyOpenGL GLX extension problem
"Mike C. Fletcher" <[email protected]> Sun, 31 Mar 2013 23:48:13 -0400
| Newsgroups | gmane.comp.python.opengl.user |
|---|---|
| Message-ID | <[email protected]> |
On 13-03-29 07:30 AM, Jean-Baptiste Molle wrote:
> |Hi,
>
> I'm trying to create a program with PyOpenGL but I'm stuck with a GLX problem.
> |
|Attached find a script that does what your code is doing AFAICS, though
without a pixmap to actually use, it doesn't do anything useful. It is
written to be run from the PyOpenGL source-code checkout tests
directory|, but that's just so that I don't have to go about creating
contexts and the like.
Quick summary:
* you need the [0]'th element of the returned Display pointer to get
the Display reference that all other calls are expecting (you have
to dereference the pointer, basically)
* the array-of-enums pattern is shown, in this case I'm using ctypes
arrays to create the data:
o note that you need an ordered sequence (list or tuple) not a set
(the C syntax for arrays happens to look like a literal set in
Python)
o GLint * len(attributes) -> creates an array type
o (*attributes) --> then creates an instance of that array type
which is initialized to the values in the list
* you could also have used:
o GLintArray.asArray( attributes )
o but I'd suggest being explicit about this kind of thing where
possible
Note that the GLX API is not "wrapped" in the same way as the GL API,
it's an auto-generated/raw wrapper with little or no attempt to make the
API clean or friendly.
Hope that helps,
Mike
------------------------------------------------------------------------------
Own the Future-Intel® Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest.
Compete for recognition, cash, and the chance to get your game
on Steam. $5K grand prize plus 10 genre and skill prizes.
Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d
_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
_______________________________________________
PyOpenGL-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyopengl-users
test_glx.py
(text/x-python, 734 B)
from OpenGL.GL import *
from OpenGL.GLX import *
from pygamegltest import pygametest
attributes = [
GLX_BIND_TO_TEXTURE_RGBA_EXT, 1,
GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT,
GLX_DOUBLEBUFFER, 0,
GLX_Y_INVERTED_EXT, GLX_DONT_CARE,
GL_NONE
]
@pygametest()
def main():
d = glXGetCurrentDisplay()[0]
elements = GLint(0)
configs = glXChooseFBConfig(
d,
0,
(GLint * len(attributes))( * attributes ),
elements
)
print '%s configs found'%( elements.value )
for config in range( elements.value ):
glxpix = glXCreatePixmap(d, configs[config], pixmap, None)
if __name__ == "__main__":
main()