Preconcepts
Ok, so what I've gathered so far is this:
- don't use fixed pipeline (deprecated or going to be deprecated)
- vbos store "object models" (n vertex data, mostly)
- vaos describe how data is laid down so that draw calls know what part of each vbo is for what kind of vertex information (one vao can refer to multiple vbos, the opposite is kinda difficult)
- each draw call also sends vertex data to shaders
How I see 3D (optional)
Given these informations, I can see how drawing 3D complicated objects is very nice with modern OpenGL. You basically load a bunch of object models (probably from Blender or other similar software) into VBOs with local coordinates, and then you simply provide for each instance of an object a different shader parameter (offset) to draw to world space.
Problem/question
In 2D problems and priorities are completely different, though. You don't draw much complex objects, you don't need complicated projection matrixes and whatnot and shaders are much simpler.
What would be the best way to draw frequently (really frequently, basically every frame) changing geometry with modern OpenGL?
In the following paragraph you can see some ideas of problems (the circle and rectangle problem), that better identify the kind of changes I'm interested in.
My attempts (optional)
So, I began to think how I would deal with drawing basic 2D geometry on the screen:
- a square: load a
[(1, 0), (1, 1), (0, 1), (0, 0)]
VBO for the geometry of a square in local space, then provide the shader with the actual width of the square and world coordinates and color informations
cools, looks easy. Let's move to a circle:
- a circle: triangle fan with... eh. how much precision (number of vertexes)? for small circles precision must be small and for bug circles precision must be high. Clearly loading 1 VBO cannot possibly fit all cases. What if I need to add precision because a circle is resized to be bigger?
Less cool. Let's move to something slightly easier, a rectangle:
- a rectangle: eh. there's no "general rectangle geometry". You just have a width/height proportion and that's it, but each rectangle is probably different if the size changes.
As you can see, things go downhill from there. Especially with complex polygons and whatnot.
No code policy :P
I just need an overview of the idea, no code is necessary, especially C or C++ code. Just say stuff like: "make a VBO with this vertex data, and then bind it, ...".