Lets say your init() call is over and you are now in the infinite display() call loop.
You now need to set up a new VBO or shader that was not needed at init() time.
The method I have used in the past is to essentially have an if statement every time you need to use your new VBO to ensure it has been set up before using it.
Would it be a good or bad idea to set up the VBO using the Threading class to remove the if statement?
Here is some pseudocode to explain myself:
constructor() {
if (Threading.isOpenGLThread()) {
setUpVBO(GLContext.getCurrent().getGL());
} else {
Threading.invokeOnOpenGLThread(new Runnable() {
public void run() {
setUpVBO(GLContext.getCurrent().getGL());
}
});
}
}
render() {
//Just use VBO
}
rather than
constructor() {
//Nothing
}
render() {
if(notSetUp) {
setUpVBO(gl);
}
//Use VBO
}
The more I think about it it seems like a bad idea since you don’t know when and where the GL stuff will be executed even if it is definately on the GL thread.