PDA

View Full Version : gl*ClientState problem.



Phoenix
04-09-2002, 01:14 AM
Hi!

I am having some troubles with the glEnableClientState & glDisableClientState. I just want to know if I can Enable and Disable the client-states as I want, if I have to reset the array-pointers and above all if I can call the gl*ClientState(...) wherever and whenever I like. I know that it seems a beginner/silly question but I used that function without any problem and know I have found a condition where these instruction seems to cause some troubles.
I'll explain better:

--FIRST WAY--------
Pass_1:
set_array_pointers();
glEnableClientState(COLOR,TEXTURE,VERTEX,NORMAL)
draw_opaque_surfaces();

Pass 2:
glDisableClientState(GL_NORMAL_ARRAY) //I just dont need normals here!!!
drawTransparentSurfaces();
--------
this way simply doesnt work!!
and if I delete the line glDisableClientState(GL_NORMAL_ARRAY) in "Pass-2" it works fine and I dont know why...any suggestions???
Thanx in advacne!

knackered
04-09-2002, 01:28 AM
That should work fine.
Sorry I can't help.

Phoenix
04-09-2002, 01:45 AM
Thanx anyway! ;-)
Your answered incredibly FAST!
At the moment I am still working on that bug...I noticed an incredibly strange thing (at least for me) It seems that If I render with COLOR_ARRAY and NORMAL_ARRAY enabled everything works fine, but If I disable the NORMAL_ARRAY, the ALPHA value on the color-array are considered to be 0.0 and so the object is completely transparent and is not rendered :-??? very very strange...I really dont know how to do...Do you think it should be a driver problem?
thanx!

knackered
04-09-2002, 01:59 AM
Sure you've got the 4 in the right place?




glColorPointer(4,GL_FLOAT,0,dataptr);


Also, be aware that the *secondary* colour array can only be rgb, and cannot have alpha.

Phoenix
04-09-2002, 06:02 AM
I am very SURE about the glColorPointer(4,FL_FLOAT,0,array); but, sorry for my ignorance: what is the "Secondary" array???
Thanx!

Phoenix
04-09-2002, 06:15 AM
Ah I forgot an important thing: to be sincere I don't know what is the secondary color-array (and would be happy to know something about that) but I noticed that the problem is that if I disable the NORMAL_ARRAY then the gfx-card set the alpha values to ZERO! and if the color-array would be RGB only, then the alpha-value should be automatically set to *1.0* and not to 0.0, am I right?
Thanx for your help, I hope to hear more info http://www.opengl.org/discussion_boards/ubb/wink.gif

knackered
04-09-2002, 06:49 AM
The secondary colour array is used to specify a second colour - this second colour was originally designed to add specular highlights *after* the texture stage, so as to give you a brighter specular highlight. e.g. if *all* your lighting calculations (including specular) happen before the texture is taken into account, and your texture combine mode is GL_MODULATE, then the brightest pixel in the polygon will only be as bright as the brightest texel in the texture:-
PrimaryColour=1,1,1 (ie. full brightness)
TexelColour=0.5,0.5,0.2 (ie. dull brownish colour)
FinalColour=0.5*1,0*1,1*1 (ie. dull brownish colour)

The secondary colour is used to add the specular highlight after the texel has been multiplied by the colour produced by diffuse/ambient/emission:-

PrimaryColour=1,1,1 (ie. full brightness)
SecondaryColour=0.5,0.5,0.5 (ie. half brightness)
TexelColour=0.5,0.5,0.2 (ie. dull brownish colour)
FinalColour=(0.5*1)+0.5,(0*1)+0.5,(1*1)+0.5 (ie. quite bright where there's highlights, ie. where the specular (secondary) colour is brightest)

The secondary colour is also useful in other ways now, with certain extensions becoming popular (register combiners, vertex programs. etc.)

I'm not entirely sure what you're saying about the alpha value being automatically set to 1. Could you clarify what you think is happening at this point? with some example code, maybe.

Sorry for the rushed explaination of the secondary colour.

[edit]
BTW, the secondarycolorpointer() function is an opengl extension in win32.

[This message has been edited by knackered (edited 04-09-2002).]

Relic
04-10-2002, 01:03 AM
While you have disabled the normal-array, do you also have lighting disabled?
If not the current normal is taken for lighting and if that's not pointing in the right direction you're hosed.
Additionally, when lighting is enabled colors are only taken into account when color material is enabled, otherwise the color is taken from the material properties.
The final alpha value is taken from the diffuse term. Hope that helps.

[This message has been edited by Relic (edited 04-10-2002).]

Phoenix
04-12-2002, 12:54 AM
Yes. Lighting is disabled. I tested my application on other three computers with different configurations and gfx cards and it worked properly...I'm starting to think that the problem is in my 3dfx-Voodoo3 and its bugged drivers. :-?