View Full Version : error C2664: 'glMaterialfv'

11-25-2002, 02:26 PM
The following is code i am trying to apply to an object in opengl:
GLfloat material_Ka[] ={0.11,0.06,0.11,1};
GLfloat material_Kd[] ={0.43,0.47,0.54,1};
GLfloat material_Ks[] ={0.33,0.33,0.52,1};
GLfloat material_Ke[] ={0,0,0,0};
GLfloat material_Se =5.0;

glMaterialfv(GL_FRONT, GL_AMBIENT, material_Ka);
glMaterialfv(GL_FRONT, GL_DIFFUSE, material_Kd);
glMaterialfv(GL_FRONT, GL_SPECULAR, material_Ks);
glMaterialfv(GL_FRONT, GL_EMISSION, material_Ke);
-> glMaterialfv(GL_FRONT, GL_SHININESS, material_Se);

And I get the following error message in relation to the last line:
cannot convert parameter 3 from 'float' to 'const float *'

And Solutions?

11-25-2002, 03:13 PM
Originally posted by gerire:
And Solutions?

How about learning C and pointers prior to OpenGL?

This is a very basic C pointer mistake and has nothing to do with OpenGL (not even with OpenGL beginners).

Learn to walk before you try to run.

11-25-2002, 06:44 PM
Declare the material property as below:
GLfloat material_Se[] = {5.0};

This should work. Hope that helps!!


11-26-2002, 01:00 AM
Thanks for tryin to help but it didnt work either


11-26-2002, 02:06 AM

glMaterialfv(GL_FRONT, GL_SHININESS, material_Se);


glMaterialfv(GL_FRONT, GL_SHININESS, &material_Se);

Notice the '&' characterc before the last parameter? That means the address_to_material_Se...
cannot convert float to float* means that it requires an address rather than a value.

What vijaykiran said SHOULD work too BTW, why it doesn't beats me...

11-26-2002, 03:27 AM
since shininess is only 1 floating point value, you could leave off the v:

glMaterialf(GL_FRONT, GL_SHININESS, material_SE);