🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Rotations in GL

Started by
13 comments, last by Ched45 24 years ago
Ched,

The reason your are having compilation problems is just as everyone has stated before : GLUT callabck functions are void functions, taking void as arguments and returning void. There is no reason that your function has to return TRUE, you can implement it in another way by maintaning a global state variable set to 1 or 0 that signifies if you wish to rotate during the current display() call. I''m not sure if this code you posted is everything in your program, but I assume that is isn''t because your program wouldn''t compile without the
#include header or a keyboard function actually defined somewhere. Also, not sure if this is like this in your actual code or not, but in the function calls that take multiple pre-defined constants, like glClear() and glutInitDisplayMode(), the constants should be seperated by the "/" symbol, not the "/" symbol. The "/" symbol stands for bitwise OR in C and C++, the "/" is division in C and C++.

Your real question about "how do rotate" really has to do with the fact that display would only be called once with the code that you have presented. Not I don''t know what your keyboard function might do, so based on user input it might make display be called more, but what you really need is an idle function. When glutMainLoop() doesn''t find anything to process and doesn''t need to call any of your callback functions, it will idle. If you defined a callback idle function, this function will be called anytime that glutMainLoop() basically has nothing else to do. A good thing to do inside this idle function is to have the window updated and re-displayed. You would register your callback function in main() like this:

glutIdleFunc(idle);

Then you might define the idle function as so:

void idle(void){

glutPostRedisplay();

}

glutPostRedisplay() simply tells glut to update the window by calling the registered glutDisplayFunc() function, in this case your display() function. This will continuously update the window, and since your display() is now being called over and over, so is your glRotate call and your triangle will spin ''round and round. Sorry if this was a little lengthy, but if your follow those steps your program should work just fine. Keep with the OpenGL stuff, its a lot of fun, and it really gets a lot easier after you get a decent understanding of OpenGL and GLUT or whatever windowing system you are using. Just tell me if you need any more help, good luck!

Chris
Advertisement
Ched,

About the "/" symbol thing versus the "\" symbol, it looks like for some reason the "pipe" symbol, or vertical line, comes out as a slash, really strange, I''m sure your code is correct on your machine, but when you put it on the message board it seems to screw it up like it did in my message. Anyway, good luck.

Chris

About the "\" /" Thing. It is a half pipe. Its not the entire code. I didn''t think anyone would be too please with me posting all the code when most is the same for every app U create. I have got them rotating now, just not around their centers.
Thanx for the advice. I''ll take alook at the MAC source. Thanx for the suggestion.


--Ched--
chris@ched45.com
--Ched--chris@ched45.com
Slight problem with the MAC file. Can''t get Win RAR or WinZip to open it. How do I open .sit extenstions. I know this isn''t related to openGL, just thought I''d ask as U''d suggested it and done it before.
Thanx

--Ched--
chris@ched45.com
--Ched--chris@ched45.com
Oh, yeah, sorry I forgot to mention that. What you need is StuffIt Expander for Windows (www.aladdinsys.com).

Morgan

This topic is closed to new replies.

Advertisement