I’ve been managing without any textures and such, but now i’d like to add them. My main problem is how to batch them up correctly without too many problems.
I’ve got a Shader object associated with every drawable chuck. For now this only contains a texture to use, I’m going to assume that it’ll need at least:
2 textures to use, maybe some texture combine mode.
Alpha test on/off, test mode, test value.
Transparency on/off and maybe a blending mode.
Now for rendering at the moment I fill a single big vertex buffer with all objects in view, and an asssociated index buffer. I then use this to render the entire visible scene once per light (via vertex arrays).
However if i have multiple surface settings, this needs to be broken down somewhat. Obviously I need a draw call for each shader, which means i need a unique index buffer for each. And i need to group my shaders together (probably get away with only sorting by textures and transparency). Whats the best way of doing this? Can I perhaps abuse a hash map or tree map for doing this for me?
Any suggestions appreciated