PDA

View Full Version : Material Problem



Kieran
04-21-2012, 01:44 PM
My problem is that i cannot set up my material using my structure because the "data member initializer is not allowed". This is deffo a simple mistake but its kinda annyoying. Here is the code.

struct material {
float ambient[4];
float diffuse[4];
float specular[4];
float shininess;
};

material redShinyMaterial = {
{0.80,0.05,0.05, 1.0},
{0.80,0.05,0.05, 1.0},
{1.0,1.0,1.0, 1.0},
100.0
};
greatful for any help thanks before hand.

Rosario Leonardi
04-22-2012, 07:43 AM
This is a C question, not openGL. :P
However, I compiled your code with
Visual studio 2010
GCC -> gcc test.cpp -std=gnu++98 -Wall -pedantic
and it work fine even if I would complain about the double to float cast.
Are you sure that you don't have some define the change the meaning of material.
Why don't you use a constructor?