Jump to content
  • Advertisement
Sign in to follow this  
AmanN

OpenGL GLUT Problem

This topic is 4486 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

Hey guys!! How can I use the following GLUT functions without having to include them in main(int argc, char **argv) ?? glutMouseFunc(Mouse); glutMotionFunc(MouseActiveMotion); glutPassiveMotionFunc(MousePassiveMotion); glutEntryFunc(MouseEntry); glutKeyboardFunc(NormalKeys); glutSpecialFunc(KeyInput); I'm trying to implement a camera using GLUT but the thing is I have to use this inside an OpenGL window that ive integrated in MFC. I have a separate class for my camera functions like void CCAMERA::Mouse(int button, int state, int x, int y) But the compiler wont let me do this: glutMouseFunc(Mouse); or this glutMouseFunc(CCAMERA::Mouse); or even when I instantiate my class as Camera and do this: glutMouseFunc(Camera.Mouse); , it wont let me. Please help! Thanks in advance guys Aman N

Share this post


Link to post
Share on other sites
Advertisement
What you will want to do is something along these lines - since GLUT uses a callback function system, you have to follow tht system, but inside of that function you can pass the data along. So, for example, first take a look at the glutMouseFunc. As you can see, it needs a specific function to be used, such as - void myMouseFunction(int button, int state, int x, int y);

Now what you can do is make that function, then inside, pass the data to your camera class. Make sure that you register this function with GLUT though.

void myMouseFunction(int button, int state, int x, int y)
{
myCamera.SendData(x, y, button, state);
}

...

glutMouseFunc(myMouseFunction);

And that's about it! You will have to take the same approach for everything else as well.

While I'm at it, might I reccomend GLFW over GLUT. It is a lot more flexible and gives you the option of polling as well as callbacks for your OpenGL system. You do have to build it, but I have the VS and DevCpp project ready to build on this thread. Just make sure to read that second post and you should be up and running with it in no time. For an example of GLFW code, take a look here.

Good luck! [smile]

Share this post


Link to post
Share on other sites
Quote:
I'm trying to implement a camera using GLUT but the thing is I have to use this inside an OpenGL window that ive integrated in MFC. I have a separate class for my camera functions like void CCAMERA::Mouse(int button, int state, int x, int y)

Did you create the window/OpenGL context using GLUT or MFC?

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!