Re: Question on glBufferData / glBufferSubData
"Mike C. Fletcher" <[email protected]> Mon, 24 Mar 2014 10:43:46 -0400
| Newsgroups | gmane.comp.python.opengl.user |
|---|---|
| Message-ID | <[email protected]> |
On 03/24/2014 05:23 AM, Walter White wrote: ... > Hello, > > I have a question about PyOpenGL and hope that you can help me. > > While working through the arcsynthesis opengl tutorial I came > across a problem using glBufferSubData. > > My code is here: > > http://bpaste.net/show/FAhw0W1Hx4WDW9toa75H/ > > This works fine: > > glBufferData(GL_ARRAY_BUFFER, ADT.arrayByteCount(npData), > ADT.voidDataPointer(npData), GL_STATIC_DRAW) > > But using > > glBufferSubData(GL_ARRAY_BUFFER, 0, ADT.arrayByteCount(npData), npData) > > or (I guess identical) > > glBufferSubData(GL_ARRAY_BUFFER, 0, ADT.arrayByteCount(npData), > ADT.voidDataPointer(npData)) > > results in an OpenGL Error 1281 Invalid Type after a few > seconds. During the first 1 - 5 seconds the program works as expected. Your code in the bpaste there works fine on my Kubuntu 13.10 machine, so I'm assuming you mean you replace the existing glBufferData call with a glBufferSubData call. I'm surprised it works for the first few seconds with that substitution. If I replace the initial call to glBufferData with a glBufferSubData call you should (and my tests show that I do) get an INVALID_VALUE error, because the buffer to which we are attempting to write currently has 0 size (the docs for glBufferSubData describe this condition as well, where offset + size goes beyond the end of the reserved space for the buffer). The first call to glBufferData creates the buffer *and sets its size*, only once that is done can you start writing with glBufferSubData. Hope that helps, Mike -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech _______________________________________________ PyOpenGL Homepage http://pyopengl.sourceforge.net