View Full Version : Asynchronous control

11-07-2005, 10:07 AM
I am working on a project in which a user navigates through a maze(based off of the Maze example here (http://www.sgi.com/products/software/opengl/examples/more_samples/) .

i have several functions that allow the user to move through the maze, one that moves one step forward, one that turns 90 degrees clockwise, and one that turns 90 degrees counter-clockwise.

the problem is that when you call 2 of the methods described above without a sufficient waiting time, it runs both methods at the same time(ie going diagonal by turning and going forward synchronously.)

i would like for the methods to complete before moving onto the next one.

a temporary work-around i've been using is the glutTimerFunc, but it's hard to calibrate to how long it will take for a given method to complete movement(this is further complicated if you were to switch machines, which might make movements take longer)

looking back i'm realizing this probably isn't an opengl issue, but any help would be appreciated.

11-08-2005, 05:17 AM
I don't think using the timer will help.

It sounds to me like you might be doing your transformations in the wrong order, thus giving you the wrong coordinates.

Try swapping over the order of your glTransalte and glRotate commands, and see if that makes a difference. :)


11-08-2005, 06:13 AM
Just have a flag "isMoving" that is true while moving and false otherweise (set to true when you start moving, and set to false when you stop moving). Then, before doing a rotation, check if(isMoving).

Then you can make a "isRotating" flag that prevents from moving...