OpenGL and OOD
I am a friend of OpenGL as well as object oriented programming.
Because of OpenGL's bind/use philosophy I find it complicated to find an OO-Approach.
Take for instance a shader class, a texture class and a model class.
The shader class has a method render. The texture and the model objects are passed in as parameters of render.
What do you do in the render method to bind the OpenGL texture (inside the texture object) and the VAO (inside the model object) ?
Do you just bind them every time render is called even if they are already bound.
Do you query what texture and VAO is currently bound and bind them only if needed.
If you practice one of the two approaches how much performance do you loose with unnecessary binds and query's ?
Do you store the status of all bound OpenGL object on application side so you can query them without bothering the driver?
I am sure that a lot of you have thought about that problem as well and I just want to here what approaches you have found / chosen.
Thanks in advance