fesoliveira014 / yanve

0 stars 0 forks source link

Global State Manager #6

Closed fesoliveira014 closed 4 years ago

fesoliveira014 commented 5 years ago

Create a global rendering state manager. This would keep track of which buffers, shaders, textures, etc are bound, enabling each rendering subsystem to act accordingly. The structure would not be visible outside the engine itself, and should only be used for internal rendering primitives (buffers, shaders. textures. etc) to keep track of which structure is in use or exists and other internal states, as to avoid unnecessary GL calls or computation.

This structure should be static and a singleton, accessible by calling something like

void Texture::bindTexture(Gluint textureUnit)
{
  auto context = gl::Context::Instance();
  if (context.textureState.boundId == _id) 
    return;
  glTextureBind(_id, textureUnit);
}
fesoliveira014 commented 4 years ago

This evolved into something more complicated than initially desired. Current design is based on Magnum's implementation of the OpenGL context and it tracks available extensions, global states and other things.