The Virtual and No-Virtual
You are writing some system where different implementations have to be used for different platforms. To keep things real, let’s say it’s a rendering system which we’ll call “GfxDevice” (based on a true story!). For example, on Windows there could be a Direct3D 9, Direct3D 11 or OpenGL implementations; on iOS/Android there could be OpenGL ES 1.1 & 2.0 ones and so on.
For sake of simplicity, let’s say our GfxDevice interface needs to do this (in real world it would need to do much more):
void SetShader (ShaderType type, ShaderID shader); void SetTexture (int unit, TextureID texture); void SetGeometry (VertexBufferID vb, IndexBufferID ib); void Draw (PrimitiveType prim, int primCount);
How this can be done?
