Skip to main content
gamedev.net
🔒 Locked

glutTimerFunc

Started by 3dnewbie Feb 20, 2007 at 11:02 AM 2 replies 5.9k views
Original Post
3dnewbie
3dnewbie
Not sure if this topic is valid here, but here goes. I'm finally discoverd how to implement a 'followmode' in my program by using the timerfunc of GLUT. Now i use this code, but unfortunately, it keeps incrementing the field by the translations. I could do a loadidentity or something akin, but i tried that, does not work. I tried everything, can't see where the problem is. It also doesn't seem to translate properly, but that's another problem. I tried setting to modelview matrix, push and popping the view, nothing. If anyone can provide me with any insight on this, it would be most welcome. What the timerfunc basically does is it translates to an already drawn object on screen, that's all. In this case it always translates to the last node, hence the word followmode.
GLvoid follow_mode(GLvoid)
{

	if(o_tail) {
	
	glTranslatef(atof(o_tail->x),atof(o_tail->z),atof(o_tail->y));
	glutPostRedisplay();

	}
	glutTimerFunc(1000,follow_mode,0);
	
	//glutPostRedisplay();
	}
zedz
zedz
well your translateions keep getting added to each other

thus glTranslatef( 1, ..) then glTranslatef( 2, ..) then glTranslatef( 3, ..) will draw something at 6 units away from the first place
u want to use

glPushMatrix();
glTranslatef(..)
draw
glPopMatrix();

also i wouldnt use glutTimerFunc func
3dnewbie
3dnewbie
I did that, did not work. Also, why would you not use gluttimeFunc ?
mopey
mopey
glutTimerFunc isn't always called after the amount of time specified has elapsed, it's sometimes called way after. If you have your own timer that can query how long it was since the last frame you can use this value as a multiplier to specify movements per second.
James Whitworth@NCCA Bournemouth

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.