Jump to content
  • Advertisement
Sign in to follow this  
3dnewbie

Troubles with GLUT sighandler

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

Hi guys, I can't figure this out it seems. I'm using the idle callback/sighandler from GLUT to get some things done, unfortunately, it seems i can't draw anything from it when using it. It runs every 1/2 second. this is my code :
GLvoid focus_mode(GLvoid)
{
	if(FOLLOW&&focus_ptr) {
	fprintf(stderr,"focusptr is %f %f %f %s\n",atof(focus_ptr->x),
	atof(focus_ptr->z),atof(focus_ptr->y),focus_ptr->hostname);
	
	//glMatrixMode(GL_MODELVIEW);
	//glPopMatrix();				
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();
		
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();

	/* Show that object is in our focus by drawing a 3D quad in GL_LINES
	around it */
	glTranslatef(-atof(focus_ptr->x),atof(focus_ptr->z),-atof(focus_ptr->y));
	glColor4f(1.0,0.0,0.0,1.0);
	
	// Everything i place here GL_LINES,QUADS,POLYGONS etc, even tried
        glutSolidCube doesn't seem to draw. I tried doing a glFlush or glutPostRedisplay
        or even glutSwapBuffers but no go.
	
	/* Set our viewing point */
	//glPopMatrix();
	//glTranslatef(0,5,0); 
	} 
	
	/* So we avoid locking to node */
	if(!FOLLOW_LOCK)
	focus_ptr=NULL;
	/* Reset timer 1/2 sec */
	glutTimerFunc(500,focus_mode,0);
	
}
I hope someone with experience in glut can provide some insight. [Edited by - LessBread on March 25, 2007 4:32:11 PM]

Share this post


Link to post
Share on other sites
Advertisement
You should try to do all your rendering in glut's draw callback. If you're drawing things every 1/2 second, assuming you're at 60 frames per second, you're not drawing those things for 58/60 frames. You could also be clearing the frame buffer when the draw callback is called, and since you're probably drawing to the back buffer, everything you drew is effectively washed away.

Share this post


Link to post
Share on other sites
well i could split it up but the translate does work in the timercall. so should i then put the actual drawing in the main loop and the translate in the timer function?

for example i set a bool value in the timer func and check for it in the main drawing function then draw what i want to draw? seems a bit hacky that way..

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!