Re: [PyOpenGL-Users] Question on glBufferData / glBufferSubData
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@vr...> - 2014-03-24 14:43:55
|
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 |