Original Post
Hello, Finally, I have started creating a game. I need some advice about the game design: There are Hardware Components (Buffer, Texture, Shader), Resources (Mesh, Skeleton), RenderObjects (Skeleton Instance, Mesh Instance), Managers (TextureManager, ShaderManager, BufferManager) and Renderer. Texture and Shader are also Resources (so they are loaded only once but used many times). The Managers loads or creates the components or resources and store SOME of the components in a list ( e.g TextureManager::TextureList, ShaderManager::ShaderList ) to not load the same resources more than once but use the existing ones. Hardware Components activate themselves during rendering. The Renderer renders the RenderObjects: Here is how i think to use Renderer: * NOTE: Most of the game components have not been finished. Thanks, Kasya
void MeshInstance::Bind() {
updateBones();
texture->Bind();
shader->Bind();
shader->setMatrix(boneMatrix);
vertexbuffer->Bind();
indexbuffer->Bind();
}
void MeshInstance::Unbind() {
indexbuffer->Unbind();
vertexbuffer->Unbind();
shader->Unbind();
texture->Unbind();
}
void Renderer::Render(RenderObject * obj) {
obj->Bind();
hardware->Draw(Hardware::TRIANGLES, obj->getIndexCount());
obj->Unbind();
}