Correct level of abstraction for a 3d rendering component?
- by JohnB
I've seen lots of questions around this area but not this exact question so apologies if this is a duplicate.
I'm making a small 3d game. Well to be honest, it's just a little hobby project and likely won't turn out to be an actual game, I'll be happy to make a nice graphics demo and learn about 3d rendering and c++ design.
My intent is to use direct3d9 for rendering as I have some little experience of it, and it seems to meet my requirements. However if I've learned one thing as a programmer it's to ask "is there any conceivable reason that this component might be replaced by a different implmentation" and if the answer is yes then I need to design a proper abstraction and interface to that component. So even though I intend to implment d3d9 I need to design a 3d interface that could be implemented for d3d11, opengl...
My question then is what level is it best to do this at?
I'm thinking that an interface capable of creating and later drawing
Vertex buffers and index buffers
Textures
Vertex and Pixel "shaders"
Some representation of drawing state (blending modes etc...)
In other words a fairly low level interface where my code to draw for example an animated model would use the interface to obtain abstract vertex buffers etc. I worry though that it's too low level to abstract out all the functionallity I need efficiently.
The alternative is to do this at a higher level where the interface can draw objects, animations, landscapes etc, and implement them for each system. This seems like more work, but it more flexible I guess.
So that's my question really, when abstracting out the drawing system, what level of interface works best?