a GLUT question
I have a project in a class that requires us to use GLUT in windows. The problem I am having is that to render a scene in GLUT, you must send it a void funtion. Unfortantly, it won''t accept the void function from my object class. Can I make GLUT take my class function? Is there anything I can do, besides making the object global and then writing a global function to render my scene?
Also, it requires us to use a menu to add vertexs, etc. How can I set GLUT up to handle all of this. I''ve read though the manuals, what I really need is just some examples of how to make it work.
Why not just create a generic void Draw(void) function and then use that function to call the member functions of your object to get the information you need to render? Thats what I normally do...
Nate Miller
http://nate.scuzzy.net
Nate Miller
http://nate.scuzzy.net
That is what i did, but it requires a global object (at least from the way i am thinking of it), and i''m trying to stay away from global variables.
in a nutshell this is what i have.
class Obj {
public: ...
SetUpVerticies();
...}
void Obj:SetUpVerticies() {
for each vertex .
glVertex2d(x, y)}
void Draw() {
glBegin(GL_SOME_STATE);
VarName.glVertex();
glEnd();}
Obj VarName;
main(){..
glutRenderScene(Draw);
...}
is there a better way to do this, using classes and glut, or is this what i am stuck doing?
in a nutshell this is what i have.
class Obj {
public: ...
SetUpVerticies();
...}
void Obj:SetUpVerticies() {
for each vertex .
glVertex2d(x, y)}
void Draw() {
glBegin(GL_SOME_STATE);
VarName.glVertex();
glEnd();}
Obj VarName;
main(){..
glutRenderScene(Draw);
...}
is there a better way to do this, using classes and glut, or is this what i am stuck doing?
i use a single global class
theres heaps of examples on how to set up popup menus in examples folder included with glut
Game game;voif Game::draw(){ .....}Draw(){ game.draw();}main(){..glutRenderScene(Draw);...}
theres heaps of examples on how to set up popup menus in examples folder included with glut
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement