Hello,
I've been using the shader utilities and GLArrayDataServer to draw 2D objects for a bit now. I've been handling animation by storing all frames in my vbo and making multiple draw calls with different values passed to glMultiDrawArrays() to get the correct animation for a given entity. I hear it's a better practice to instead make a single draw call and update your vbo each frame with what's on the screen. I want to test this out with my tile maps since it will be easy to manage where a tile is in my vbo.
Here's a basic example of how I build a GLArrayDataServer interleaved vbo.
I draw the VBO with something like:
So with my tilemap example, say I want to change a color of a single tile to green. I figure I need to call getBuffer() and update the correct position. That should be fairly easy because I know would know which tiles are stored in the buffer and in which position (i.e., first tile would be first 48 bytes). Do I need to do anything else on the GLArrayDataServer side or do I just call seal(true) again? Thanks for your time. |
Administrator
|
Hi
glMultiDrawArrays() is broken on some platforms, it's not worth it. You use GL_STATIC_DRAW, it's not a good idea if you'd like to modify the content of GLArrayDataServer.
Julien Gouesse | Personal blog | Website
|
I was going to change that to DYNAMIC_DRAW, but from what I'm reading in 2D it's probably easier to just use STREAM_DRAW and replace the entire buffer whenever anything changes on screen. Is it OK to continuously replace my GLArrayDataServer object or should I reuse the same GLArrayDataServer and only replace its buffer? Thanks for the glMultiDrawArrays() tip. I'll be switching to glDrawArrays() once I get down to a single VBO of all my onscreen objects. |
Administrator
|
You should only update the content of the buffer.
Julien Gouesse | Personal blog | Website
|
Free forum by Nabble | Edit this page |