|
From: Charles M. <cm...@in...> - 2006-06-27 12:08:43
|
Marko Durkovic wrote:
> Hi,
>
> I've started using glewpy a few days ago, and so far it has been a
> pleasure working with it.
>
> I've encountered some problems with the ARB_Vertex_Buffer_Object
> extension. It seems that glBufferDataARB seems to truncate the data
> string, at the first occurence of a zero in that string.
>
> I've added a simple demo, which uploads and downloads some test data to
> and from the graphics card. I hope this helps to understand the problem.
>
> Nice work!
>
> Greetings from Munich,
> Marko
>
>
> ------------------------------------------------------------------------
>
>
> from OpenGL.GL import *
> from glew import *
> import struct
>
> vbo_data = struct.pack("12B", 1, 2, 3, 4, 4, 0, 1, 2, 3, 4, 5, 6)
>
>
> from OpenGL.GLUT import *
>
> glutInit([])
> glutInitWindowSize(512, 512)
> glutCreateWindow('GLEW Testing')
> err = glewInit()
> if err != GLEW_OK:
> print "Error:", glewGetErrorString(err)
> assert(0)
>
> assert(glewIsSupported("GL_ARB_vertex_buffer_object"))
>
> vbo = glGenBuffersARB(4)[0]
>
> #write something
> glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo)
> glBufferDataARB(GL_ARRAY_BUFFER_ARB, len(vbo_data), vbo_data, GL_STATIC_DRAW_ARB)
>
> #read it back
> data = glGetBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, len(vbo_data))
> print "error?", glGetError()
> print "len:", len(data), "original len:", len(vbo_data)
> print struct.unpack(str(len(data))+"B", data)
Indeed this was a bug. Pyrex's automatic <char*> to str conversion
chopped at the first zero, like it should. I made the cast more
explicit by using the "PyString_FromStringAndSize" method. Your demo
works now, and I committed the changes to svn. Let me know if you need
any more help or a new binary.
- Charlie
|