Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (739)
Games in Android Showcase (224)
games submitted by our members
Games in WIP (820)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  SpriteBatcher Strat: Handling Buffers  (Read 2809 times)
0 Members and 1 Guest are viewing this topic.
Offline puppyShchenok

Junior Newbie





« Posted 2014-03-08 17:30:11 »

I'm making a Sprite Batcher and I was looking for some opinions

I'm using VBOs (2 for double buffer) and a IBO to handle my draw data. The VBOs are DYNAMIC_DRAW buffers and IBO is a STATIC_DRAW buffer.
When I init the VBOs I use glBufferData with a NULL param for the data, where with the IBO I pre-fill it based on my initial max buffer size.

Now, I'm not sure what to do when I hit my max buffer size. I was wondering what you guys think would be best or maybe something else

Idea 1:
In my Draw() method that fills up a float array that holds my vertex data. I check to see if I have enough space left in my vertex buffer.
If I do continue to fill up the data until we run out of room.

If we DONT have enough room, double the size of the buffer. This means I reallocate space for the float array that holds my vertex data, the actual VBO buffers, and the IBO buffer. In addition I prefill the index buffer again

Idea 2:
In my Draw() method that fills up a float array that holds my vertex data. I check to see if I have enough space left in my vertex buffer.
If I do continue to fill up the data until we run out of room.

If we DONT have enough room, flush the batch and send all the data off to the GPU. Then continue on fill the vertex data in the float array


I see down sides to these both methods.
On Idea 1, thats a lot of reallocation! It will cause a major performance hit for a couple of seconds, but it will only have if and when needed.

On Idea 2, thats a lot of potential GPU calls! If I don't have enough room in the first go then any slack will have to get picked up in the next go. And if this a is a constant slack then I will always have a performance hit.

What do you guys think? Is there a even better solution?

Also I should mention that I'm using OpenGL ES 2.0
Where my vertex data is transferred over to the gpu using glBufferSubData
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 
Ecumene (61 views)
2017-09-30 02:57:34

theagentd (82 views)
2017-09-26 18:23:31

cybrmynd (189 views)
2017-08-02 12:28:51

cybrmynd (189 views)
2017-08-02 12:19:43

cybrmynd (194 views)
2017-08-02 12:18:09

Sralse (206 views)
2017-07-25 17:13:48

Archive (770 views)
2017-04-27 17:45:51

buddyBro (904 views)
2017-04-05 03:38:00

CopyableCougar4 (1454 views)
2017-03-24 15:39:42

theagentd (1331 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!