Reputation: 187
Is it more efficient to use static methods for OpenGL stuff rather than initialized objects?
So, instead of an object "Model" which contains data of one model, I have just the ID of the VAO, because I used a static method to load in the model and return the VAO ID. Same thing for shaders: Is it better to have a shader program object or just the ID of the shader program (static methods create the shader and return the ID)? Are there any downsides with this way? Is it more efficient, or should I just use objects?
(LWJGL3, Java)
Upvotes: 0
Views: 186
Reputation: 140523
That really depends. If the methods are doing the same things, then there shouldn't be much of a difference. There would need to be millions of method invocation to make a real significant difference. And then the JIT should kick in anyway1
In general, relying on static methods does three things:
So, long story short: you typically lean towards non-static solutions, to avoid all the disadvantages outlined above.
Upvotes: 1