Textures: glEnableClientState vs glEnable

English is not my primary language, so please exuse me for poor sentences.

I need to disable textures to select the objects using colors pick technique.
Actual code organization is (pseudo code*):

on init:

for each object to draw:

glTexCoordPointer(2, GL_FLOAT, 0, uvcoords);

when read color:

glReadPixels(x, viewport[3] - y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, color_picked );


Anyway, with the sequence above I’ve notice of some strange artifact under Ubuntu.
The artifacts are fixed using, in read color, glEnableClientState/glDisableClientState
instead glEnable/glDisable:

when read color:

glReadPixels(x, viewport[3] - y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, color_picked );


It’s a correct usage?

Because the experiment above, I have thought that glEnable(GL_TEXTURE_2D) and
glEnableClientState(GL_TEXTURE_COORD_ARRAY) was redundant, so I’ve tried to use only
the second, but it don’t work. I need at least a glEnable(GL_TEXTURE_2D) in init function.
So I just want know more about this aspect.

It’s needed to call the glEnableClientState/glDisableClientState for each
object to draw? I’ve tried to enable all just one time, in init function, and
disable all only when exit from the sw. It seem to work, but I don’t know if it’s
formally correct. Can you help me?



[*]Full code: http://makehuman.svn.sourceforge.net/viewvc/makehuman/trunk/mh_phoenix/src/glmodule.c?view=markup

  1. Use both glDisableClientState(GL_TEXTURE_COORD_ARRAY) and glDisable(GL_TEXTURE_2D) when you are in read color mode.

glEnable(GL_TEXTURE_2D) and glEnableClientState(GL_TEXTURE_COORD_ARRAY)
enable 2 different things. When you do not use shaders, the first enable the use of texturing when rendering. The second tell OpenGL that you will use a texture array and the data for that texture array is specified by glTexCoordPointer.

  1. No you do not need to call for each object glEnableClientState/glDisableClientState if they all use the same type of arrays.
  1. I’m 99,999% sure, that neither glDisableClientState(GL_TEXTURE_COORD_ARRAY) nor glDisable(GL_TEXTURE_2D) have anything to do with glReadPixels().

Furthermore, I’d suggest not to redundently enable or disable these for performance reasons. When rendering 1,000s of low triangle count objects with simple fixed function pipeline, I received up to a 40% boost in frame rate by removing the redundant glEnableClientState calls.


Thanks. But unfortunately using both glDisableClientState(GL_TEXTURE_COORD_ARRAY) and glDisable(GL_TEXTURE_2D) don’t fix the problem, while using only glDisableClientState(GL_TEXTURE_COORD_ARRAY) fix it.

The artifacts are very strange and apparently random. I’ve captures some shots for you:


Note the click don’t alter the geometry, just disable/enable textures, so I can’t understand why the “explosions” of polygons…

Any suggestions?

@pjcozzi : thanks

@skynet: I know glReadPixels() is not related to the client state. I have added it just to show the reason I need to enable and disable textures (to read only the verts colors).

Again, thanks to all.