Hi!
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:
glEnable(GL_TEXTURE_2D);
for each object to draw:
…
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, uvcoords);
glDrawArrays(GL_TRIANGLES,0,ntriangles);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
…
when read color:
glDisable(GL_TEXTURE_2D);
…
glReadPixels(x, viewport[3] - y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, color_picked );
…
glEnable(GL_TEXTURE_2D);
QUESTION 1
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:
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
…
glReadPixels(x, viewport[3] - y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, color_picked );
…
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
It’s a correct usage?
QUESTION 2
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.
QUESTION 3
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?
Thanks,
Manuel
[*]Full code: http://makehuman.svn.sourceforge.net/viewvc/makehuman/trunk/mh_phoenix/src/glmodule.c?view=markup