Open io7m opened 8 years ago
It won't be possible to prevent deliberate sabotage, obviously. It is possible through testing to show that the state tracking doesn't go out of sync on its own.
It is possible to provide a single "reset state cache" method that causes the state tracker to re-fetch all state from the GPU, but in what situation would this be useful? For the user to call this method, they would have to know that the state cache had gone out of sync, and if they knew that, then presumably that's an indication of a bug or deliberate sabotage!
Actually, this may be useful in the case that the user is using the plain OpenGL API and is using a library that is using jcanephora internally. The user may make changes to the state machine and jcanephora will then need to be told that its own view of the state is now out of date.
This is vital towards allowing jcanephora to be composed with other OpenGL libraries (of which there aren't many, because OpenGL isn't composable).
The rewrite of the
jcanephora
package has moved towards doing full state shadowing. Previous versions added partial state shadowing to allow for the removal of redundant GL calls. For example, it would maintain a boolean flag that indicated whether or not depth clamping is enabled:The "problem" here is that somebody could call
this.gl.glEnable(GL3.GL_DEPTH_CLAMP);
outside of thejcanephora
package and essentially cause the shadowed state to go out of sync with the actual GPU state.