[PATCH] glGetActiveAttribARB, glGetShaderSourceARB and glGetActiveUniformARB

"Marco Bubke" <[email protected]>
Newsgroups gmane.comp.python.opengl.devel
Message-ID <[email protected]>
Hi

I have patched glGetActiveAttribARB, glGetShaderSourceARB and
glGetActiveUniformARB more python friendly interface.
glLinkProgramARB.errcheck is also running without problems for me.

regards

Marco

Index: OpenGL/GL/ARB/shader_objects.py
===================================================================
RCS file: /cvsroot/pyopengl/OpenGL-ctypes/OpenGL/GL/ARB/shader_objects.py,v
retrieving revision 1.12
diff -r1.12 shader_objects.py
479c479
< ##glLinkProgramARB.errcheck = _afterCheck( GL_OBJECT_LINK_STATUS_ARB )
---
> glLinkProgramARB.errcheck = _afterCheck( GL_OBJECT_LINK_STATUS_ARB )
494a495,522
> base_glGetShaderSourceARB = glGetShaderSourceARB
> def glGetShaderSourceARB( obj ):
>   """Retrieve the program/shader's source code as a Python string
>
>   returns string which is '' if no source code
>   """
>   length = glGetObjectParameterivARB(obj, GL_OBJECT_SHADER_SOURCE_LENGTH_ARB)
>   if length > 0:
>     source = ctypes.create_string_buffer(length)
>     base_glGetShaderSourceARB(obj, length, None, source)
>     return source.value.strip('\000') # null-termination
>   return ''
>
> base_glGetActiveUniformARB = glGetActiveUniformARB
> def glGetActiveUniformARB(program, index):
>       """Retrieve the name, size and type of the uniform of the index in the program"""
>       max_index = glGetObjectParameterivARB( program, GL_OBJECT_ACTIVE_UNIFORMS_ARB )
>       length = glGetObjectParameterivARB( program, GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB)
>       if index < max_index and index >= 0 and length > 0:
>               name = ctypes.create_string_buffer(length)
>               size = arrays.GLintArray.zeros( (1,))
>               gl_type = arrays.GLuintArray.zeros( (1,))
>               base_glGetActiveUniformARB(program, index, length, None, size, gl_type, name)
>               return name.value, size[0], gl_type[0]
>       raise IndexError, 'index out of range from zero to %i' % (max_index - 1, )
>
>
>
503a532,533
>
>
Index: OpenGL/GL/ARB/vertex_shader.py
===================================================================
RCS file: /cvsroot/pyopengl/OpenGL-ctypes/OpenGL/GL/ARB/vertex_shader.py,v
retrieving revision 1.6
diff -r1.6 vertex_shader.py
64c64,79
< ### END AUTOGENERATED SECTION
\ No newline at end of file
---
> ### END AUTOGENERATED SECTION
>
> from shader_objects import glGetObjectParameterivARB
>
> base_glGetActiveAttribARB = glGetActiveAttribARB
> def glGetActiveAttribARB(program, index):
>       """Retrieve the name, size and type of the uniform of the index in the program"""
>       max_index = glGetObjectParameterivARB( program, GL_OBJECT_ACTIVE_ATTRIBUTES_ARB )
>       length = glGetObjectParameterivARB( program, GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB)
>       if index < max_index and index >= 0 and length > 0:
>               name = ctypes.create_string_buffer(length)
>               size = arrays.GLintArray.zeros( (1,))
>               gl_type = arrays.GLuintArray.zeros( (1,))
>               base_glGetActiveAttribARB(program, index, length, None, size, gl_type, name)
>               return name.value, size[0], gl_type[0]
>       raise IndexError, 'index out of range from zero to %i' % (max_index - 1, )

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
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.