When do I need to call glEnableClientState () and glDisableClientState () in android

I simply call glEnableClientState() once in the onSurfaceCreated() method of the GLSurfaceView.Renderer interface. For instance:

 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 do not call them again. I never call the glDisableClientState() method. But I see that many programmers call both methods, which often wrap them in all drawing calls.

Is there something wrong with my approach? Or is it a good practice, or perhaps a more efficient approach to wrapping them in all drawing calls?

+6
source share
1 answer

I don’t think that something is wrong with your approach, provided that all your calls to the call require the same state. If you are drawing something without normals / colors, you do not want the normal / color array included, etc.

If all of your objects will necessarily use the same arrays, your method is likely to be the best, since you can eliminate unnecessary opengl calls. Disabling everything after each object is potentially worse for performance, but generally safer so you don't accidentally leave something you don't need.

+3
source

Source: https://habr.com/ru/post/912410/


All Articles