I am working on a software with lots of different shaders, which require different states in OpenGL. My problem is the following: The different models with different shaders are not rendered in the same order, so there is a switch form shader1 to shader23 to shader2 and so on. In the next frame this order can change (depending on the scenario). When I am adding a new kind of object (with new shader and so on) and I think it is working, I need to check every order of object-rendering to see, if bugs appear. With bugs I mean OpenGL states which are set to a specific value and later not changed back. How do you handle this?
I have the idea, to create a OpenGL state class where you can define each parameter. When running an render method, the current state will be compared with the OpenGL state and each setting which is different should be set to the state will is required for this rendering.
This seems to me more than a few lines of code... The most hardest part is to figure out which states are saved in which OpenGL table (with table I mean VAO, FBO, Texture, ...). Where can I find a table very good described where each OpenGL state will be saved?
I mean: when binding Shader1 and setting uniform "test" to value "123" and then binding Shader2, the uniform there also named "test" will not have the value "123"... so the uniform values are somehow stored on shader level?? Same with attributepointer and VAO...
On the other hand: PointSize is not stored on shader level... so each time I am rendering Points, I need to check which size they have and change it to the required size.
Can someone give me some URL to a table of OpenGL states?
Does someone has a better idea to handle this problem? BTW: I am not the only one who is working on this software... so saying "every time when changing a state, change it back at the end of the method" will not work.