Mike C. Fletcher | 3 Aug 00:53 2009

PyOpenGL 3.0.1a2, for the forward-thinking...

Second alpha of the 3.0.1 series includes a number of bug-fixes from
PyOpenGL 3.0.1a1, as well as updated extensions (including OpenGL 3.1
core).  The new extensions are currently just auto-generated, so if you
see something that needs special wrapping, feel free to ping me.  The
OpenGL.org extension header now breaks out the deprecated/non-deprecated
functionality, so you will see modules with _DEPRECATED showing up in
the tree, the raw versions are imported into the non _DEPRECATED
versions, so wrapping will continue to be in the root module(s).

I would expect to see only very minor regressions from this release, as
the 3.0.1a1 release seemed to work relatively well in testing and the
only major change is the extensions.  We're not ready for prime-time, so
don't install into live systems, but if you have code that uses
PyOpenGL, you'll want to test with this release and send any bug reports
so that we can fix the bugs before 3.0.1 final.

https://sourceforge.net/projects/pyopengl/files/PyOpenGL/3.0.1a2/

Win32 exe and cross-platform source available.

Enjoy yourselves,
Mike

--

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

(Continue reading)

Joshua Davis | 13 Aug 16:05 2009

glVertexAttribPointer(); loading platform-specific functions

I have some questions that probably boil down to my inexperience with  
Python. My setup is PyOpenGL-3.0.0c1 on Python 2.5.x on Mac OS X. I'm  
trying to modernize my OpenGL to use VBOs and vertex attributes,  
working through the tutorials at http://bazaar.launchpad.net/ 
~mcfletch/openglcontext/trunk/annotate/head:/tests/shader_4.py. When  
I execute code like this:

vertexBufferObject = vbo.VBO(...)
gl.glVertexAttribPointer(positionLocation, 3, GL_FLOAT, False, 24,  
vertexBufferObject)

The second line generates this error:

ctypes.ArgumentError: argument 6: <type 'exceptions.TypeError'>:  
Don't know how to convert parameter 6

The following code is what I've been doing to get platform-specific  
(?) PyOpenGL functions. They often seem to require some massaging of  
argument types; is the same thing needed for glVertexAttribPointer()  
above?

# This is adapted from http://www.pygame.org/wiki/GLSLExample.
try:
     from OpenGL import platform
     gl = platform.OpenGL
except ImportError:
     try:
         gl = cdll.LoadLibrary('libGL.so')
     except OSError:
         from ctypes.util import find_library
(Continue reading)

Paulo Silva | 13 Aug 16:38 2009
Picon

Re: glVertexAttribPointer(); loading platform-specific functions

Joshua Davis from http://www.joshuadavis.com/ :O ? awesome, be welcome! \o/

anyway, i don't know if it is your very first approach on OpenGL using
PyOpenGL - i think i'm even struggling with it way much more than you
- my very first approaches were trying to analyse some pyweek games
like http://pyweek.org/e/GNAG/ , but it uses Pyglet instead (which
also uses OpenGL as well) - in the case you can't fix what you try to
do with PyOpenGL, maybe would be a good idea trying Pyglet also...

cheers!

On 8/13/09, Joshua Davis <joshuardavis <at> q.com> wrote:
> I have some questions that probably boil down to my inexperience with
> Python. My setup is PyOpenGL-3.0.0c1 on Python 2.5.x on Mac OS X. I'm
> trying to modernize my OpenGL to use VBOs and vertex attributes,
> working through the tutorials at http://bazaar.launchpad.net/
> ~mcfletch/openglcontext/trunk/annotate/head:/tests/shader_4.py. When
> I execute code like this:
>
> vertexBufferObject = vbo.VBO(...)
> gl.glVertexAttribPointer(positionLocation, 3, GL_FLOAT, False, 24,
> vertexBufferObject)
>
> The second line generates this error:
>
> ctypes.ArgumentError: argument 6: <type 'exceptions.TypeError'>:
> Don't know how to convert parameter 6
>
> The following code is what I've been doing to get platform-specific
> (?) PyOpenGL functions. They often seem to require some massaging of
(Continue reading)

Mike C. Fletcher | 13 Aug 18:10 2009

Re: glVertexAttribPointer(); loading platform-specific functions

Joshua Davis wrote:
> I have some questions that probably boil down to my inexperience with  
> Python. My setup is PyOpenGL-3.0.0c1 on Python 2.5.x on Mac OS X. I'm  
> trying to modernize my OpenGL to use VBOs and vertex attributes,  
> working through the tutorials at http://bazaar.launchpad.net/ 
> ~mcfletch/openglcontext/trunk/annotate/head:/tests/shader_4.py. When  
> I execute code like this:
>
> vertexBufferObject = vbo.VBO(...)
> gl.glVertexAttribPointer(positionLocation, 3, GL_FLOAT, False, 24,  
> vertexBufferObject)
>   
The "gl." should not be necessary, PyOpenGL 3.x includes full access to
the OpenGL 2.x functionality.  The wiki sample you are looking at is
*very* old, unfortunately, the wiki editor seems broken, so I can't
update it without completely hashing the page :( .  The vbo.VBO object
uses PyOpenGL's wrapping functionality to appear as though it is a
data-array pointer, but that behaviour is not available in raw ctypes
wrappers (such as the wiki recipe is creating).

    from OpenGL.GL import *

should get you a copy of glVertexAttribPointer without needing to do
anything else (particularly, without using any ctypes code explicitly). 
If you need the ARB versions, they are available via:

    from OpenGL.GL.ARB.vertex_buffer_object import *

I'd also *strongly* suggest going for PyOpenGL 3.0.0 final or even a
PyOpenGL 3.0.1 alpha, as there were quite a number of bug-fixes and
(Continue reading)

Ian Mallett | 13 Aug 20:34 2009
Picon

Re: glVertexAttribPointer(); loading platform-specific functions

On Thu, Aug 13, 2009 at 7:38 AM, Paulo Silva <nitrofurano <at> gmail.com> wrote:

> vertexBufferObject = vbo.VBO(...)
> gl.glVertexAttribPointer(positionLocation, 3, GL_FLOAT, False, 24,
> vertexBufferObject)
>
> The second line generates this error:
>
> ctypes.ArgumentError: argument 6: <type 'exceptions.TypeError'>:
> Don't know how to convert parameter 6

You might try this code, adapted from my code, which makes use of vertex attributes for normal mapping:

vertex_attrib_vbo.bind()
glVertexAttribPointer(location,4,GL_FLOAT,GL_FALSE,0,None)

The last argument could probably also be 0. 

Ian
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
_______________________________________________
PyOpenGL-Users mailing list
PyOpenGL-Users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyopengl-users
Mike C. Fletcher | 13 Aug 20:54 2009

Re: glVertexAttribPointer(); loading platform-specific functions

Ian Mallett wrote:
> On Thu, Aug 13, 2009 at 7:38 AM, Paulo Silva <nitrofurano <at> gmail.com
> <mailto:nitrofurano <at> gmail.com>> wrote:
>
>     > vertexBufferObject = vbo.VBO(...)
>     > gl.glVertexAttribPointer(positionLocation, 3, GL_FLOAT, False, 24,
>     > vertexBufferObject)
>     >
>     > The second line generates this error:
>     >
>     > ctypes.ArgumentError: argument 6: <type 'exceptions.TypeError'>:
>     > Don't know how to convert parameter 6
>
> You might try this code, adapted from my code, which makes use of
> vertex attributes for normal mapping:
>
> vertex_attrib_vbo.bind()
> glVertexAttribPointer(location,4,GL_FLOAT,GL_FALSE,0,None)
Yup, that should work, even with the raw ctypes APIs.

> The last argument could probably also be 0. 
0 would be interpreted as a 1-element array of integers.  You can (with
a bug-fix introduced for 3.0.1) do ctypes.c_void_p( 0 ) if you want to,
though.

HTH,
Mike

--

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

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
Joshua Davis | 13 Aug 22:42 2009

Re: glVertexAttribPointer(); loading platform-specific functions

On 2009 Aug 13  , at 11:10 AM, Mike C. Fletcher wrote:

> I'd also *strongly* suggest going for PyOpenGL 3.0.0 final or even a
> PyOpenGL 3.0.1 alpha, as there were quite a number of bug-fixes and
> enhancements.  The latest 3.0.1 alpha has an OpenGL.GL.shaders module
> which provides "alternate" wrapped versions of the shader functions
> which allow for using either core or ARB-provided versions of the
> functions depending on what's available on the final machine.  That
> isn't necessary, but it should make it easier to work with shaders in
> PyOpenGL.

Thanks. I've had some trouble updating PyOpenGL -- probably my  
incompetence -- but now I'm up to 3.0.1a2 and using the  
OpenGL.GL.shaders convenience functions. When I try to construct a  
simple shader program...

vertexCode = """
attribute vec3 position;
attribute vec3 color;
void main()
{
     gl_Position = gl_ModelViewProjectionMatrix * vec4(position, 1.0);
     gl_FrontColor = vec4(color, 1.0);
}"""
fragmentCode = """
void main()
{
     gl_FragColor = gl_Color;
}"""
vertexShader = compileShader(vertexCode, GL_VERTEX_SHADER)
fragmentShader = compileShader(fragmentCode, GL_FRAGMENT_SHADER)
shaderProgram = compileProgram(vertexShader, fragmentShader)

...I get this error:

Traceback (most recent call last):
   File "vbo.py", line 88, in <module>
     shaderProgram = compileProgram(vertexShader, fragmentShader)
   File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
python2.5/site-packages/OpenGL/GL/shaders.py", line 105, in  
compileProgram
     validation = glGetProgramiv( program, GL_VALIDATE_STATUS )
   File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
python2.5/site-packages/OpenGL/extensions.py", line 95, in __call__
     return self( *args, **named )
   File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
python2.5/site-packages/OpenGL/wrapper.py", line 1294, in __call__
     return self.finalise()( *args, **named )
   File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
python2.5/site-packages/OpenGL/wrapper.py", line 572, in wrapperCall
     raise err
OpenGL.error.GLError: GLError(
         err = 1280,
         description = 'invalid enumerant',
         baseOperation = glGetProgramivARB,
         pyArgs = (3L, GL_VALIDATE_STATUS),
         cArgs = (3L, GL_VALIDATE_STATUS, array([0])),
         cArguments = (3L, GL_VALIDATE_STATUS, array([0]))
)

This never happened with my home-spun shader-building functions. Your  
continuing help is appreciated.

Josh

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
Mike C. Fletcher | 13 Aug 23:42 2009

Re: glVertexAttribPointer(); loading platform-specific functions

Joshua Davis wrote:
> On 2009 Aug 13  , at 11:10 AM, Mike C. Fletcher wrote:
>   
...
> Thanks. I've had some trouble updating PyOpenGL -- probably my  
> incompetence -- but now I'm up to 3.0.1a2 and using the  
> OpenGL.GL.shaders convenience functions. When I try to construct a  
> simple shader program...
>   
...
> OpenGL.error.GLError: GLError(
>          err = 1280,
>          description = 'invalid enumerant',
>          baseOperation = glGetProgramivARB,
>          pyArgs = (3L, GL_VALIDATE_STATUS),
>          cArgs = (3L, GL_VALIDATE_STATUS, array([0])),
>          cArguments = (3L, GL_VALIDATE_STATUS, array([0]))
> )
>
> This never happened with my home-spun shader-building functions. Your  
> continuing help is appreciated.
>   
This is a bug in the shaders module.  Turns out that glGetProgramivARB
and glGetProgramiv have different roles?!  Basically it looks like it's
glGetObjectParameteriv that's supposed to be used for the glGetProgramiv
validity check call (at least, if I use that and disable core GL I get
the correct operation).  Going to have to look into the function
definitions more to be sure that the alternate declaration works.

Good luck,
Mike

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

Attachment (glGetProgramiv-fix.diff): text/x-diff, 1414 bytes
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
_______________________________________________
PyOpenGL-Users mailing list
PyOpenGL-Users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyopengl-users
Mike C. Fletcher | 14 Aug 00:58 2009

Re: glVertexAttribPointer(); loading platform-specific functions

Mike C. Fletcher wrote:
...
> This is a bug in the shaders module.  Turns out that glGetProgramivARB
> and glGetProgramiv have different roles?!  Basically it looks like it's
> glGetObjectParameteriv that's supposed to be used for the glGetProgramiv
> validity check call (at least, if I use that and disable core GL I get
> the correct operation).  Going to have to look into the function
> definitions more to be sure that the alternate declaration works.
>   
I've just uploaded a source release with this fix in it.  SourceForge
seems to be having problems, but it should show up within 15 minutes or so.

HTH,
Mike

--

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

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
Joshua Davis | 14 Aug 21:54 2009

Re: glVertexAttribPointer(); loading platform-specific functions

>> This is a bug in the shaders module.  Turns out that  
>> glGetProgramivARB
> and glGetProgramiv have different roles?!  Basically it looks like  
> it's
> glGetObjectParameteriv that's supposed to be used for the  
> glGetProgramiv
> validity check call (at least, if I use that and disable core GL I get
> the correct operation).  Going to have to look into the function
> definitions more to be sure that the alternate declaration works.

Your changes to shaders.py have gotten me past that problem. Thanks  
very much.

I now have two versions of my program. The first uses the legacy  
glVertexPointer() stuff and works perfectly. The second is altered,  
as little as possible, so that it uses the modern  
glVertexAttribPointer() stuff instead. It raises no errors but  
generates no fragments. Here is the glVertexPointer() version of the  
two crucial functions...

def initializeShaders():
     global shaderProgram
     vertexCode = """
     void main()
     {
         gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
         gl_FrontColor = gl_Color;
     }"""
     fragmentCode = """
     void main()
     {
         gl_FragColor = gl_Color;
     }"""
     vertexShader = compileShader(vertexCode, GL_VERTEX_SHADER)
     fragmentShader = compileShader(fragmentCode, GL_FRAGMENT_SHADER)
     shaderProgram = compileProgram(vertexShader, fragmentShader)

def handleDisplayEvent():
     global vertexBufferObject, shaderProgram
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
     glUseProgram(shaderProgram)
     vertexBufferObject.bind()
     glEnableClientState(GL_VERTEX_ARRAY)
     glEnableClientState(GL_COLOR_ARRAY)
     glVertexPointer(3, GL_FLOAT, 24, vertexBufferObject)
     glColorPointer(3, GL_FLOAT, 24, vertexBufferObject + 12)
     glDrawArrays(GL_TRIANGLES, 0, 9)
     vertexBufferObject.unbind()
     glDisableClientState(GL_VERTEX_ARRAY)
     glDisableClientState(GL_COLOR_ARRAY)
     glUseProgram(0)
     glFlush()
     glutSwapBuffers()

...and here are those same functions, rewritten to use  
glVertexAttribPointer().

def initializeShaders():
     global shaderProgram, positionLocation, colorLocation
     vertexCode = """
     attribute vec3 position;
     attribute vec3 color;
     void main()
     {
         gl_Position = gl_ModelViewProjectionMatrix * vec4(position,  
1.0);
         gl_FrontColor = vec4(color, 1.0);
     }"""
     fragmentCode = """
     void main()
     {
         //gl_FragColor = gl_Color;
         gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0);
     }"""
     vertexShader = compileShader(vertexCode, GL_VERTEX_SHADER)
     fragmentShader = compileShader(fragmentCode, GL_FRAGMENT_SHADER)
     shaderProgram = compileProgram(vertexShader, fragmentShader)
     positionLocation = glGetAttribLocation(shaderProgram, 'position')
     colorLocation = glGetAttribLocation(shaderProgram, 'color')

def handleDisplayEvent():
     global vertexBufferObject, shaderProgram, positionLocation,  
colorLocation
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
     glUseProgram(shaderProgram)
     vertexBufferObject.bind()
     glEnableVertexAttribArray(positionLocation)
     glEnableVertexAttribArray(colorLocation)
     glVertexAttribPointer(positionLocation, 3, GL_FLOAT, False, 24,  
vertexBufferObject)
     glVertexAttribPointer(colorLocation, 3, GL_FLOAT, False, 24,  
vertexBufferObject + 12)
     glDrawArrays(GL_TRIANGLES, 0, 9)
     vertexBufferObject.unbind()
     glDisableVertexAttribArray(positionLocation)
     glDisableVertexAttribArray(colorLocation)
     glUseProgram(0)
     glFlush()
     glutSwapBuffers()

Am I missing something obvious? Any suggestions on how to debug further?

Josh

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net

Gmane