I am having trouble getting opengl keywords to work or be recognized in a class i am trying to build in c++ vs2010. I get several errors that start with [color="#ff0000"]Cube.cpp(32): error C3861: 'glPushMatrix': identifier not found
If I us these terms such as "glPushMatrix" on the main cpp file it works fine. I have the header for the class included on the main cpp file so im not sure what i am missing or whats the problem.
the following is placed on the Class' cpp file under the constructer and deconstructer. and like I said anything with gl in front of it is not being recognized even thought i have the header included.
void Cube::wireFrame()
{
float theta = 0.0f;
glPushMatrix();
glTranslatef(0.0f, 0.0f, -20.0);
glRotatef( theta ,1.0f, 1.0f, 0.0f );
//glRotatef(_angle, 0.0f, 1.0f, 0.0f);
glColor3f(0.0f, 0.0f, 0.0f);
glLineWidth(10.0f);
glBegin(GL_LINES);
glNormal3f(0.0f, 0.0f, 1.0f);
//glNormal3f(-1.0f, 0.0f, 1.0f);
glVertex3f(-1.5f, -1.0f, 1.5f);
//glNormal3f(1.0f, 0.0f, 1.0f);
glVertex3f(1.5f, -1.0f, 1.5f);
//glNormal3f(1.0f, 0.0f, 1.0f);
glVertex3f(1.5f, 1.0f, 1.5f);
//glNormal3f(-1.0f, 0.0f, 1.0f);
glVertex3f(-1.5f, 1.0f, 1.5f);
glEnd();
}
getting opengl keywords to work in class
I have the opengl headers included in the main cpp file. I thought that as long as they are included in the main cpp file its like including it in all the files i have included on that one. so as long as i include the class header on the main cpp file and the opengl headers included on the main cpp file they are included by default on the class header. do i have to include them twice. once on the main cpp file and once on the class header file?
You have to include the GL headers into any compilation unit (read: .CPP file) that wants to use GL.
I thought that as long as they are included in the main cpp file its like including it in all the files i have included on that one.
[/quote]
Nope. I recommend your spend some time learning the C++ compilation model, so you'll understand these kinds of errors. One important point is that #include is a simple copy/paste operation in the preprocessor step. Another important point is that each source file is processed independently in the compilation step, and they only interact with each other through the the resulting object files during the linking step.
Thank you very much for your well informed answers and suggestions. I will spend some time learning the C++ compilation model. thank you very much your suggestions also helped me resolve my issue with the class at hand.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement