Hi, this question is more of a structural and code based.
Lets say you have some sort of engine in lack of a better name, has as a rendersystem. The Rendersystem could be OpenGL or DX based.
The Engine have knowleage of some of the common render objects, like Shader, ShaderView, meshes and so on. It does not now what a OpenGL and DX Shader is. How does the more professional systems handle this?
I can think of two solutions, one is that the rendersystem has a list of all DX Shader and the Shaders in the engine has an ID to that list (alt 1),
Or that OpenGL Shader would be a subclass of the Engine Shader and cast to a OpenGL Shader every time its beeing used in the Render system (alt 2).
void OpenGL::ShaderInput(EngineShader* pShader)
{
OpenGL* pOpenGLShader = GetOpenGLShader(pShader->ID);
}
(alt2)
void OpenGL::ShaderInput(EngineShader* pShader)
{
OpenGL* pOpenGLShader = static_cast<OpenGLShader>(pShader);
DoSomething(pOpenGLShader)
}
Just think both solutions seems a slow and maybe a bit wasteful.
any thoughts pls?