Troubles with GLUT sighandler

This topic is 4161 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

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();

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 on other sites
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 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..

1. 1
2. 2
frob
15
3. 3
4. 4
5. 5

• 13
• 13
• 14
• 68
• 15
• Forum Statistics

• Total Topics
632137
• Total Posts
3004314

×