Archived

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

jag_oes

Open GL and functions

Recommended Posts

jag_oes    122
Hello, I am writing a math-visualization program using OpenGL and I ran into a problem. I wrote a vector class and one of the methods I would like to make is "Draw_Vector." This method would use some of the OpenGL drawing functions. But, since this class is separate from my main OpenGL program the OpenGL functions are not declared according to my class. So, I tried including the various libraries for opengl in my class but no such luck. So, how does one use the opengl functions in classes they write? Thanks.

Share this post


Link to post
Share on other sites
Fruny    1658
To use OpenGL calls in your class, you''ll have to include the GL headers, or (but I advise against it), declare the prototypes yourself.

Additionally, you need to link with the GL libraries. Since they are DLLs, the .lib are just stubs anyway. That means that, if you build your classes separately from you main GL program (say, also as a DLL), you''ll have to link with them again when you build the program itself.

Or you could give more precision to your question

Share this post


Link to post
Share on other sites
jag_oes    122
I don't really see how my question could use anymore precision ... here is what I am talking about:


#ifndef _VECTOR3D_H_
#define _VECTOR3D_H_


#include <gl/gl.h>
#include <gl/glu.h>




class Vector3D
{
public:

float x, y, z;

Vector3D (const float x, const float y, const float z);
~Vector3D ();

Draw_Vector () const
{
glBegin (GL_LINES);
{
glVertex3f (0.0f, 0.0f, 0.0f);
glVertex3f (x, y, z);
}
glEnd ();
}
};

#endif

That does not work ... I included the OpenGL headers and it still does not work. Is this still ambiguous? Is this what you were talking about, or something else?

Edited by - jag_oes on January 13, 2002 1:18:11 PM

Share this post


Link to post
Share on other sites
GBGames    217
The Unambiguous maker is: Post the error you get.
Does it not compile?
Does it compile and not run correctly?
What is the specific issue that is wrong.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Why not just stick the class in a ''vector.h'' file?

Share this post


Link to post
Share on other sites
jag_oes    122
Does not compile ... errors:


c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2144: syntax error : missing '';'' before type ''void''
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2501: ''WINGDIAPI'' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : fatal error C1004: unexpected end of file found


And the class is in a header file.

I don''t understand what is wrong with it ...

Thanks for the help so far.

Share this post


Link to post
Share on other sites
Fruny    1658
Since WINGDIAPI is undefined, try adding

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

as the first two lines of your program.

Share this post


Link to post
Share on other sites