Archived

This topic is now archived and is closed to further replies.

Wierd Problem

This topic is 5305 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have this in a header file: class light { public: color amb; color dif; color spec; CVector pos; light() { amb.grey(); dif.grey(); spec.white(); pos.x = 0; pos.y = 0; pos.z = 1 ; } void setup() /// for initianzation { glLightfv(GL_LIGHT0, GL_AMBIENT,amb.givearray()); glLightfv(GL_LIGHT0, GL_DIFFUSE,dif.givearray()); glLightfv(GL_LIGHT0, GL_SPECULAR ,spec.givearray()); glLightfv(GL_LIGHT0, GL_POSITION ,pos.v); glEnable(GL_LIGHT0); } void set() /// for setting { glLightfv(GL_LIGHT0, GL_POSITION ,pos.v); } }; light ambient; void initlight() { // lights glEnable(GL_COLOR_MATERIAL); glEnable(GL_LIGHTING); ambient.setup(); glMaterialfv(GL_FRONT, GL_SPECULAR, ambient.spec.givearray()); } and it gives me a weird error ::\game002\light.h(63) : error C2146: syntax error : missing '';'' before identifier ''amb'' c:\game002\light.h(63) : error C2501: ''color'' : missing storage-class or type specifiers c:\game002\light.h(63) : error C2501: ''amb'' : missing storage-class or type specifiers c:\game002\light.h(64) : error C2146: syntax error : missing '';'' before identifier ''dif'' c:\game002\light.h(64) : error C2501: ''color'' : missing storage-class or type specifiers c:\game002\light.h(64) : error C2501: ''dif'' : missing storage-class or type specifiers c:\game002\light.h(65) : error C2146: syntax error : missing '';'' before identifier ''spec'' c:\game002\light.h(65) : error C2501: ''color'' : missing storage-class or type specifiers c:\game002\light.h(65) : error C2501: ''spec'' : missing storage-class or type specifiers c:\game002\light.h(101) : error C2039: ''spec'' : is not a member of ''light'' c:\game002\light.h(61) : see declaration of ''light'' c:\game002\light.h(101) : error C2228: left of ''.givearray'' must have class/struct/union type c:\game002\glinit.h(23) : error C2039: ''amb'' : is not a member of ''light'' c:\game002\light.h(61) : see declaration of ''light'' c:\game002\glinit.h(23) : error C2228: left of ''.givearray'' must have class/struct/union type c:\game002\glinit.h(24) : error C2039: ''dif'' : is not a member of ''light'' c:\game002\light.h(61) : see declaration of ''light'' c:\game002\glinit.h(24) : error C2228: left of ''.givearray'' must have class/struct/union type c:\game002\glinit.h(25) : error C2039: ''spec'' : is not a member of ''light'' c:\game002\light.h(61) : see declaration of ''light'' c:\game002\glinit.h(25) : error C2228: left of ''.givearray'' must have class/struct/union type Error executing cl.exe. GAME002.exe - 17 error(s), 0 warning(s) Does anyone know what this could me? I dont see anything wrong with the header file i made.

Share this post


Link to post
Share on other sites
oh sorry, heres color:
class color
{
public:
float r,g,b,a;

color(float pr = 0,float pg= 0,float pb = 0,float a = 1)
{
r = pr;
g = pg;
b = pb;
}
void white()
{
r = 0.5;
g = 0.5;
b = 0.5;
}

void red()
{
r = 1;
g = 0;
b = 0;
}
void green()
{
r = 0;
g = 1;
b = 0;
}
void blue()
{
r = 0;
g = 0;
b = 1;
}
void grey()
{
r = 0.1f;
g = 0.1f;
b = 0.1f;
}

float* givearray()
{
float *myarray;
myarray = new float;
myarray[0] = r;
myarray[1] = g;
myarray[2] = b;
myarray[3] = a;
return myarray;
}

};

Share this post


Link to post
Share on other sites
Nope it's in there, i moved it around some and still no.
hmmm im using Visual Studio 6.0 Intruductory Version
it was working a while ago, but now it just stoped and started giving me these errors

[edited by - MetaKnight on June 2, 2003 12:52:25 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The compiler is telling you that "color" is not a known type at the point where it''s trying to declare "light".

Probably, light will include color, which will include something else, which will ... include light, which will cause the error because color isn''t actually defined yet.

Share this post


Link to post
Share on other sites