Re: [PyOpenGL-Users] glGetUniformIndices
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@vr...> - 2012-01-16 17:41:48
|
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 |