OpenGL/C confusion

spsweet
Unregistered
 
Post: #1
I'm pretty new to OpenGL and would like clearing up from you guys who have been doing this sort of thing for a while. I do have a few years of experience with other languages, but this small problem is making me feel stupid.

The situation is that I'm trying to just make a real time animation using OpenGL and C. I've got a nice model in 3D space and want to enter the infinite loop to make it keep rotating. I can make it rotate with the modelview matrix, but only on keyboard input. I want it to keep going. I know this sounds like a stupid question but I couldn't find anything in the many other places I've looked. As good as the Red Book is, it didn't have a straightforward answer for me. If anyone's willing to help, I'll start posting code upon your command.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
This isn't an OpenGL question as such... What windowing API are you using? SDL? GLUT? Carbon? Cocoa?
Quote this message in a reply
spsweet
Unregistered
 
Post: #3
GLUT. I am also unfortunately not using MAC. I'm using a Linux machine. I believe there is a concept I don't understand and that is what I hope someone can explain to me.
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #4
You're likely missing glutPostRedisplay() in your idle() function.
Quote this message in a reply
spsweet
Unregistered
 
Post: #5
Perhaps a bit more clarity is in order. I am in fact using GLUT. What I want is something basic. I want a figure, lets say a cylinder, to rotate on an axis, how about the y axis, without me having to push anything to make the display function be invoked again. I tried things like glutIdleFunc(display); hoping that if input was idle, display would be called. And when that didn't work I went back to the drawing board. I see a lot of things about rotating over time but don't see how to do it. My ultimate goal is to just have my model rotate and be able to rotate it faster and faster using the modeview matrix and a call to glRotate(yRot,x,y,z);

I hope that makes someone want to explain it to me better. Cool

edit:I just tried a new function for being idle called, is_idle. And made that my parameter to glutIdleFunc(). Within is_idle was a single line to call glutPostRedisplay(). It didn't work as I expected. I did however get what I wanted when I put a glutPostRedisplay() at the end of my display function. This seems like a crude method but it definitely worked. Any other suggestions guys?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
the usual way is as you describe:

Code:
void idle(void)
{
    glutPostRedisplay();
}

...

glutIdleFunc(idle);

Putting it at the end of display should work fine too, though.
Quote this message in a reply
spsweet
Unregistered
 
Post: #7
thanks guys. the problem was that I didn't tell my display function that is_idle is my idle function. For some reason I had to tell display as well as main and not just main like I had been doing. thanks for the help guys.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #8
You only have to make that call once, in main. Doing it more often than that might cause peculiar things to happen, I guess.

Basic GLUT skeleton code here: http://onesadcookie.com/Tutorials (and yes, I have tried it on Linux; only the #include needs to change)
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Confusion about -isFlipped in Cocoa ThemsAllTook 7 5,864 Mar 31, 2006 07:55 AM
Last Post: ThemsAllTook
  OpenGL Confusion BinarySpike 10 4,675 Jan 15, 2005 10:59 PM
Last Post: SethWillits
  Confusion about native pixel format tigakub 3 5,826 May 14, 2002 02:45 PM
Last Post: OneSadCookie