Jump to content

  • Log In with Google      Sign In   
  • Create Account


Batching Shapes Together


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 Vincent_M   Members   -  Reputation: 617

Like
0Likes
Like

Posted 17 September 2013 - 04:57 PM

I'd like to write a batching class to hold the vertices for all my shapes. I want to support lines, squares, circles, polygons up to 8 vertices, etc. I'd prefer to draw them a single draw call as well. The way it'd work is I'd have methods in my ShapeBatch class such as AddLine(), AddBox(), AddCircle(), etc. They'd take parameters to setup the shapes, and return a pointer handle so the programmer has access to it. Internally, the shapes' definitions are all stored in an STL vector, and I'd like all of the shapes' vertices to be stored in a single STL vector which will act as a vertex array. Now, of course, how would I go about manipulating the vertices when I need to? I guess each shape can store the index to the first vertex in the array, but then removing shapes from the list would require me to iterate through the entire list from the point where the shape was remove all the way to the end to decrement the starting index offset.

 

Also, what if some of my shapes were solid and others were just outlines? This would be very helpful in writing debug geometry. I could just have two STL vectors of vertices: one for drawing with GL_LINES, and another for GL_TRIANGLES. Then, of course, the solid-drawn one would require an index buffer as well so that shapes can be drawn all at once, but not connected...

 

I also face a similar situation with my sprite library. I usually store sprites as 4-point quads, but then my 9-sliced quads will be made up of 16 vertices a piece. Should I have separate vectors for quads and 9-sliced objects? It'd be much easier to code, but then I have more vectors to manage per sprite library...

 

What are you takes on doing this?



Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS