The plot thickens, if I bypass pyopengl and do the glGenVertexArrays call direct through ctypes the "invalid enumerant" error moves to the subsequent glBindVertexArray call, if I use cytpes for that as well then everything starts working.

G

On Fri, Nov 4, 2011 at 11:30 PM, Gordon Wrigley <gordon@tolomea.com> wrote:
I just got a chance to get back to this and I've made a little head way, far enough that I have something on screen.
Specifying GLUT_COMPATIBILITY_PROFILE instead of GLUT_CORE_PROFILE got round the glGenVertexArrays error.
I also had to do ctypes stuff to work around the lack of wrapper for that function.
And the function glVertexAttribPointer was getting cast errors on the last argument so I had to ctypes around that as well.
I believe that's the only dirty stuff I have so far.

G


On Tue, Oct 25, 2011 at 1:56 AM, Mike C. Fletcher <mcfletch@vrplumber.com> wrote:
On 11-10-20 06:41 AM, Gordon Wrigley wrote:
And I attached the wrong log, here's the correct one.

Hrm, not much to go on there.  The call to createShader() does not appear in the stack, which is a bit weird.  Is this code I could trace through to try to find the error (i.e. not something proprietary?)

Good luck,
Mike



On Thu, Oct 20, 2011 at 9:39 PM, Gordon Wrigley <gordon@tolomea.com> wrote:
On Tue, Oct 18, 2011 at 4:56 AM, Mike C. Fletcher <mcfletch@vrplumber.com> wrote:
On 11-10-12 03:34 AM, tolomea wrote:
> Version stuff:
> Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
> [GCC 4.5.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> import OpenGL
> OpenGL.__version__
> '3.0.2a1'
> I'm using FORWARD_COMPATIBLE_ONLY, context version 3.3 and GLUT_CORE_PROFILE.
>
>
> I'm porting a working (same machine and environment etc) C program to Python,
> and the glGenVertexArrays function is giving me grief.
>
> The pythonic form:
>     vao = glGenVertexArrays(1)
> produces "TypeError: this function takes at least 2 arguments" which I presume
> means it hasn't been wrapped yet.
Yes.
> I've no idea what could be causing that and googling hasn't turned up anything
> useful.
>
> Does anyone have any suggestions as to where to look?
> Are there any known working examples of using vertex array objects and pyopengl
> that I could cross check against?
My go-to guess with almost any Python-differs-from-C problems during
init is to look at the error-checking code.  PyOpenGL's biggest
difference from C code is that it runs error checking after every call.
I'm guessing either your context isn't quite ready-to-go and you're
getting an error from the error checking, or that the line before had an
error and the error checking picked it up a line late.

import OpenGL
OpenGL.USE_ACCELERATE = False
OpenGL.ERROR_CHECKING = False

at the top of your script should let you quickly determine a) where the
problem is b) whether the problem is with error checking.


If I turn error checking off it dies much earlier on a glCreateShader call with:

WARNING:OpenGL.errors:Failure on glCreateShader: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/OpenGL/logs.py", line 74, in __call__
    return function( *args, **named )
ArgumentError: argument 3: <type 'exceptions.TypeError'>: Don't know how to convert parameter 3

Traceback (most recent call last):
  File "main.py", line 237, in <module>
    main(sys.argv)
  File "main.py", line 227, in main
    init()
  File "main.py", line 147, in init
    init_program()
  File "main.py", line 122, in init_program
    vert = gl.VertexShader("data/shaders/basic.vert")
  File "/mnt/drive1/home/gordon/code/spacecraft2/gl.py", line 50, in __init__
    _Shader.__init__(self, fname, VERTEX_SHADER)
  File "/mnt/drive1/home/gordon/code/spacecraft2/gl.py", line 37, in __init__
    self.shader = createShader(shader_type)
  File "/usr/local/lib/python2.7/dist-packages/OpenGL/platform/baseplatform.py", line 372, in __call__
    return self( *args, **named )
  File "/usr/local/lib/python2.7/dist-packages/OpenGL/logs.py", line 74, in __call__
    return function( *args, **named )
ctypes.ArgumentError: argument 3: <type 'exceptions.TypeError'>: Don't know how to convert parameter 3


That doesn't seem like progress.

With error checking on calling glGetError right before the glGenVertexArrays call returns 0.

Toggling use accelerate hasn't made any noticeable difference.

I don't know if it helps any but I turned on full logging and attached a dump of the output.

G





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