I have a SceneNode
class which contains a Mesh
instance. The Mesh
class stores client side information such as vertex and index arrays (before they're uploaded to the GPU). I also have an abstracted Renderer
class, for GL and D3D, which render the SceneNode
s. However, I'm not sure where I should store the API specific variables, e.g. GLuint
via glGenBuffers
for GL, and an ID3D11Buffer
for D3D.
The few options I've considered are:
- Create a derived
Mesh
class for each API, e.g.GLMesh
/D3DMesh
- Create a derived
MeshData
class for each API, which is stored in the mainMesh
class - Store a map of
Mesh
to API variables in each renderer, e.g. perform a lookup ofMesh
toGLuint
/ID3D11Buffer
for each object that is rendered (variables would have to be generated after the scene had been updated, but before rendering). - Separate the logic of rendering from scenes, by visiting the
SceneGraph
after update, and generating aRenderGraph
of all renderable nodes in the scene.
What's the recommended way of doing this?
#ifdef
of member variables. \$\endgroup\$