I just call glEnableClientState()
once in onSurfaceCreated()
method of GLSurfaceView.Renderer
interface. Eg:
public class GLRenderer implements GLSurfaceView.Renderer {
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
...
}
After that I don't invoke them again. I never invoke the glDisableClientState()
method. But I see many programmers call both methods often wrapping them around all drawing calls.
Is anything wrong with my approach? Or is it a good practice or maybe more efficient to use the approach of wrapping them around all drawing calls?
I don't think there's anything wrong with your approach provided that all of your draw calls require the same state. If you're drawing something without normals/colors, you don't want to have the normal/color array enabled, etc.
If all your objects are sure to use the same arrays, then your method is likely the best, as you can eliminate unnecessary opengl calls. Disabling everything after each object is potentially worse for performance, but it is safer in general that you won't accidentally leave something enabled that you don't want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With