My engine is still based on OpenGL 2.1 and I would like to migrate it to a higher OGL version in the (far) future. To prepare the engine and optimize it by the way, I would like to get rid of the (deprecated) immediate mode GUI. Nevertheless, I would like to keep most of my GUI framework and features, which are
- all gui elements (including text letters) are quads,
- all gui elements could have a shader,
- all gui elements could have a texture (already on a handful of atlases),
- gui is redrawn each frame,
- gui is drawn in strict order (lot of alpha blending).
Thought, I'm not able to use OGL >2.1 yet, I would like to use an architecture which comes close to Ogl4, that is, I plan to make it completely buffered based (vertex buffers for now). The rest should try to mimic new features (shader buffers, bindless etc.) to make a later migration easier.
My basic idea is
1. map a vertex buffer object (double buffered)
2. while drawing the widgets, fill up the vertex buffer object
3. fill an additional buffer with meta information about shader,texture
4. unmap the buffer
5. bind the buffer
6. draw quad from the buffer in order,switch texture/shader if necessary, try to batch as much quads as possible by grouping them by texture/shader
Well, this could result in lot of texture/shader switches and draw calls. I'm now looking for hints/ideas to optimize it.
These ideas are coming to mind:
I. Assign a layer to each quad, quads on the same layer can be rendered out of order.
II. Use a texture array (same texture size required, utilize atlases) and use an index (3rd tex-coord) into the texture layer, avoiding texture switches.
III. Group multiple shaders into a less uber-shaders.
IV. Sort quads by layer and shader.
I would like to hear some comment and critics on my idea ? Is this the wrong way to approach the next generation of APIs (Mantel/OpenGL Next) ?
Are there other known, (good) working alternatives ?