Sign in to follow this  
pressgreen

getting opengl keywords to work in class

Recommended Posts

pressgreen    678
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[/color]

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();

}

Share this post


Link to post
Share on other sites
pressgreen    678
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?

Share this post


Link to post
Share on other sites
rip-off    10976
[quote]
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.

Share this post


Link to post
Share on other sites
pressgreen    678
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this