glMaterialfv and gl_FrontMaterial ?

Hello,

I have found some very unexpected behaviour and I am wondering if there something I am missing or it is in fact so ? I am using the following code to install a shader and then render two QUADS, each with a different ambient color.

    glUseProgramObjectARB(mProgram);

float mat_ambient1[] = {0.0f, 0.0f, 0.7f, 1.0f};
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT,mat_ambient1);
glBegin(GL_QUADS);
glVertex3f(0, 0, 0);
glVertex3f(100, 0, 0);
glVertex3f(100, 100, 0);
glVertex3f(0, 100, 0);
glEnd();

float mat_ambient2[] = {0.7f, 0.0f, 0.0f, 1.0f};
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient2);
glBegin(GL_QUADS);
glVertex3f(-100, -100, 0);
glVertex3f(0, -100, 0);
glVertex3f(0, 0, 0);
glVertex3f(-100, 0, 0);
glEnd();

All that the shaders do is

gl_Position = ftransform(); 

and

    gl_FragColor = gl_FrontMaterial.ambient;

It turns out that both QUADS are blue (i.e. mat_ambient1) allthough I changed the color to red for the second one. Does the shader somehow cash the gl_FrontMaterial. If I insert another

    glUseProgramObjectARB(mProgram);

just before the declaration of mat_ambient2 then the second quad becomes red. Am I missing something fundamentel here? Do I have to call glUseProgramObjectARB every time I change the material?

Cheers
Jochen

Sounds like a driver bug. What hardware and drivers are you using, and on what Operating System?

Here is what I get from Catalyst control Center. My card is a 1950 Pro and I am running windows XP.

Driver Packaging Version 8.421-070928a-053250C-ATI
Catalyst® Version 07.10
Provider ATI Technologies Inc.
2D Driver Version 6.14.10.6727
Direct3D Version 6.14.10.0532
OpenGL Version 6.14.10.6956
Catalyst® Control Center Version 2007.0320.2241.38712
AV Stream (T200) Driver Version 6.14.10.1074

Thx for the tip! I just installed Catalyst 7.12 and the problem is gone.

J

OMG, ATi fixed something in their newer drivers!!!

:wink:

Try the Catalyst 8.1 drivers. Maybe it’s back :smiley:

Funny that you say that. After I installed 7.12, glRenderMode(GL_SELECT) didn’t work anymore. zMin and zMax always had the same value for all hits. I had the same problem with 8.1, and now I am back to 7.10. Selecting works again but I still have the same problem that started this thread in the first place.

Hopefully I am not the only one experiencing this and it will be fixed soon.

J

Hopefully I am not the only one experiencing this and it will be fixed soon.

Well, it is selection mode, which is not exactly widely used. So while they will probably get around to fixing it, getting a marginally functional (which is the best ATi can ever be expected to deliver) GL 3 driver would almost certainly be a higher priority.

That’s a bummer. I find the selection mode really useful for 3D editing widgets. By far beats implementing complicated raycasts to determine which regions are clicked on, dragged etc…

Anyways, i am assuming that ATI reads this board and they are looking at the problem as we speak, right ? Or, do they have a QA board of their own somewhere ?

i am assuming that ATI reads this board and they are looking at the problem as we speak, right ?

LOL! You’re kidding, right?

I wasn’t joking when I basically said, “Don’t hold your breath.” Selection mode just isn’t a high priority item even in the best of times.

I can confirm that catalyst drivers 9.2 have exactly the same problem with the glmaterialfv command.

ati is definatly the cause of the problem, since ive tried my program on a geforce computer and the problem dissapears completly.

To me it seems like there is a delay to which the command updates a material color.

It can be caused by the timing used to color things i.e. in our code the timing of commands may be in the correct order but since colouring operations are done separatly to that primitives, a bug will exist in thier code if not performed in the correct order.

ive been trying to find a workaround for this for weeks, unfortunatly using the other “colormaterial” method seems to only work for my geometric primitives rather than bitmap fonts which is the problem i face. Its more of just this particular method of coloring.

Try to use the glcolormaterial method to color your quads instead. i think that may solve your problem.

Can you make a change to your second section, add another glbegin command but this time a diffferent quad. If im correct is the third quad the correct color ???

float mat_ambient2[] = {0.7f, 0.0f, 0.0f, 1.0f};
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient2);
glBegin(GL_QUADS);
glVertex3f(-100, -100, 0);
glVertex3f(0, -100, 0);
glVertex3f(0, 0, 0);
glVertex3f(-100, 0, 0);
glEnd()

glBegin(GL_QUADS); 3rd quad
(any four vertexes)
glEnd()