Re: [PyOpenGL-Users] using glGetSynciv
Brought to you by:
mcfletch
|
From: Henry G. <he...@ca...> - 2011-05-24 09:33:27
|
On Mon, 2011-05-23 at 22:55 -0400, Mike C. Fletcher wrote:
> Okay, I constructed my own test case so I could see what the problem
> is. There was a bug in the declaration of GLsync, which was declared
> to
> be a c_void_p, it should have been declared as a ctypes.POINTER(
> structure ). I had thought c_void_p would create an opaque pointer
> type
> as a return-type, but apparently ctypes short-circuits it to return an
> integer.
>
> I've checked a fix into bzr, and that should appear in the next
> release
> of PyOpenGL. In the meantime, you can patch your copy of PyOpenGL
> with
> this:
Yeah, that fixes it - thank you. I've got the fence test code working as
follows now:
from OpenGL.GL.ARB import sync as GL_sync
...
my_sync = \
GL_sync.glFenceSync(GL_sync.GL_SYNC_GPU_COMMANDS_COMPLETE, 0)
fence_status = GL.GLint(0)
GL_sync.glGetSynciv(my_sync,
GL_sync.GL_SYNC_STATUS, GL.GLint(1), GL.GLint(0), fence_status)
print GL_sync.GL_UNSIGNALED == fence_status.value
A couple of things come to light with this code. Firstly, as it is
fence_status can only return a single argument. I couldn't work out how
to instantiate GLintArray (it allows raises the following exception:
TypeError: Cannot create instance: has no _type_ ). This isn't a problem
as it stands because all the parameters will only return a single value.
Secondly, its pretty unpythonic as it stands. I understand that the
PyOpenGL is a pretty thin shim around OpenGL, but this seems like a good
opportunity for a little more logic on the python side, returning a
datatype that is more conducive to being tested, or even better, a whole
wrapper around the sync object.
Is there any movement by anyone to make the whole OpenGL experience more
pythonic? It strikes me that its starting to make a lot of sense with
the buffers and shaders paradigm. I guess there is something towards
this end with Qt and PySide/PyQt. Do any of the various game engines
offer similar?
Cheers,
HEnry
|