I tend to wrap OpenGL objects in my classes. OpenGL has a concept of binding, where you link your object, do something with it, and then untie it. For example, texture:
glBindTexture(GL_TEXTURE_2D, TextureColorbufferName); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1000); glBindTexture(GL_TEXTURE_2D, 0);
The wrapper will be something like:
texture->bind(); texture->setParameter(...); texture->setParameter(...); texture->unBind();
The problem here is that I want to avoid the bind () and unBind () functions and instead just be able to call set methods, and GLObject will be bound automatically.
I could just do this in every implementation of the method:
public void Texture::setParameter(...) { this.bind();
Although then I have to do it for each method added! Is there a better way, so it runs automatically before and after adding each method?
source share