Re: glGetUniformIndices

"Mike C. Fletcher" <[email protected]>
Newsgroups gmane.comp.python.opengl.user
Message-ID <[email protected]>
On 12-01-16 12:32 PM, Hans Wurst wrote:
> Hi guys,
>
> I've written the following wrapper-code for glGetUniformIndices:
>
> @lazy( glGetUniformIndices )
> def glGetUniformIndices(baseOperation, program, uniformNames):
>     num = len(uniformNames)
>     maxLen = max([len(x) for x in uniformNames])+1
>     names = ((ctypes.c_char * maxLen) * num)()
I believe you want ctypes.c_char_p * num here, with this formulation 
you'd then need to create a new array of pointers each of which was 
pointing at the beginning of the row for that value.  Don't have a 
test-case handy to test that assumption, though.
>     for i,name in enumerate(uniformNames):
>         names[i].value = name
>     c_names = ctypes.cast(ctypes.pointer(ctypes.pointer(names)),
>                           
> ctypes.POINTER(ctypes.POINTER(OpenGL.constants.GLchar)))
>     obuff = (ctypes.c_uint32 * num)()
>     print ctypes.byref(obuff)
>     print c_names
>     print "Before", baseOperation.__name__
>     baseOperation(program, num, c_names, ctypes.byref(obuff))
>     print "After", baseOperation.__name__
>     return [o.value for o in obuff]
HTH,
Mike

-- 
________________________________________________
   Mike C. Fletcher
   Designer, VR Plumber, Coder
   http://www.vrplumber.com
   http://blog.vrplumber.com


------------------------------------------------------------------------------
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2
_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.