Reputation: 25096
I have some Haskell / OpenGLRaw code that does something like this:
verticesPtr <- newArray ...
glVertexPointer 3 gl_DOUBLE 0 verticesPtr
buffersPtr <- malloc
glGenBuffers 1 buffersPtr
buffer <- peek buffersPtr
glBindBuffer gl_ARRAY_BUFFER buffer
glBufferData gl_ARRAY_BUFFER 4 verticesPtr gl_STREAM_DRAW
glDrawArrays gl_LINE_STRIP 0 4
glDeleteBuffers 1 buffersPtr
I have two questions concerning this code:
draw
callback. Does this entirely negate the usefulness of storing my vertex data in the server?draw
, should I change the gl_STREAM_DRAW
command to something more static?Upvotes: 2
Views: 594
Reputation: 1530
Yes, you are throwing away most of the benefits of buffer objects by using them in this manner. In all likelihood, it will still be faster than glBegin
/glEnd
since the driver becomes aware of all of the data simultaneously, rather than incrementally, but there's no guarantee it will be faster, and may even be slower for small buffer sizes due to the overhead of creating and destroying the buffer object.
Yes, as described in the glBufferData API docs you should avoid STREAM_DRAW
unless the buffer is changing every or close to every frame. My personal rule of thumb is:
STATIC
DYNAMIC
STREAM
Upvotes: 2