Jump to content
  • Advertisement
Sign in to follow this  
pressgreen

getting opengl keywords to work in class

This topic is 2540 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 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();

}

Share this post


Link to post
Share on other sites
Advertisement
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

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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!