Skip to main content
gamedev.net
🔒 Locked

Wierd Problem

Started by MetaKnight Jun 2, 2003 at 11:16 PM 6 replies 550+ views
Original Post
MetaKnight
MetaKnight
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.
krez
krez
is color a defined type? if it is defined in another header, you must include it to use it.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
MetaKnight
MetaKnight
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;
}

};
JohnBolton
JohnBolton
Perhaps you forgot to include the color header at the front of of the light header.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
MetaKnight
MetaKnight
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]
MetaKnight
MetaKnight
hmmm nope color doesnt include anything.
MetaKnight
MetaKnight
Oh wait, it just started working after i copy and pasted everything into a new project. HMmmm that was werid, oh well.
Thank you for you help

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.