Re: [PyOpenGL-Users] VBO question
Brought to you by:
mcfletch
From: Jason H. <Jas...@vo...> - 2011-06-21 01:29:34
|
Thanks for the reply Henry. After a lot of trial and error, I finally figured out what the real problem is. I'm on OpenGL 3.3 and glVertexPointer and the others have been deprecated since 3.0, but PyOpenGL tries to maintain backwards compatability I guess. So I figured out the correct method and switched to glVertexAttribPointer and wrote a GLSL shader, now everything works great. -Jason ________________________________________ From: Henry Gomersall [he...@ca...] Sent: Monday, June 20, 2011 3:02 PM To: pyo...@li... Subject: Re: [PyOpenGL-Users] VBO question On Mon, 2011-06-20 at 12:20 -0700, Jason Hayes wrote: > # send vertices over to the GPU self.vbo_name = glGenBuffersARB( 1 ) > glBindBufferARB( GL_ARRAY_BUFFER_ARB, self.vbo_name ) > glBufferDataARB( GL_ARRAY_BUFFER_ARB, vertices, GL_STATIC_DRAW_ARB ) I'm not an expert, but don't you still need to copy the data to the buffer. I'm not quite sure how you've managed with 3 arguments there though. The docs all suggest you need 4. After that I think you need to do something like (modified from my pbo code, which is all in terms of numpy arrays, which are well laid out in memory): # Map the buffer object to a pointer vbo_pointer = ctypes.cast(\ GL.glMapBuffer(GL.GL_ARRAY_BUFFER, GL.GL_WRITE_ONLY), ctypes.POINTER(ctypes.c_ubyte)) # Turn that pointer into a numpy array that spans # the whole block.(buffer size is the size of your buffer) vbo_array = numpy.ctypeslib.as_array(vbo_pointer, (buffer_size,)) vbo_array[0:data_size_to_copy] = \ data.view(dtype='uint8').ravel() # Unmap the buffer. GL.glUnmapBuffer(GL.GL_ARRAY_BUFFER) Hope that helps. cheers, Henry ------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev _______________________________________________ PyOpenGL Homepage http://pyopengl.sourceforge.net _______________________________________________ PyOpenGL-Users mailing list PyO...@li... https://lists.sourceforge.net/lists/listinfo/pyopengl-users This message, including any attachments, may contain privileged and/or confidential information. Any distribution or use of this email by anyone other than the intended recipient(s) is strictly prohibited. If you are not the intended recipient, please notify the sender immediately and delete all copies. Thank you. |