PDA

View Full Version : GLUT ... keyboard not smooth



lsdi
01-16-2002, 02:30 PM
Im changed my code from win32 api to glut, to make something portable, but I got a serious problem.

The glutSpecialFunc(special) and
glutKeyboardFunc(keyboard) functions are not smooth.

The code: (no problems when used with win 32 API)




void keyboard(unsigned char key,int x,int y)
{
switch (key) {
case 27:
exit(0);
break;
case 'f':
glutFullScreen();
break;
case 'G':
glutReshapeWindow(640,480);
break;
case 'A':
speed+=0.1;
break;
case 'Z':
speed-=0.1;
break;
default:
break;
}
}

void special(int key, int x, int y)
{
switch (key) {
case GLUT_KEY_UP:
CamQ.RotateX(-0.5);
CamQ.Update();
break;
case GLUT_KEY_DOWN:
CamQ.RotateX(0.5);
CamQ.Update();
break;
case GLUT_KEY_LEFT:
CamQ.RotateY(0.5);
CamQ.Update();
break;
case GLUT_KEY_RIGHT:
CamQ.RotateY(-0.5);
CamQ.Update();
break;
case GLUT_KEY_F1:
if(!gamemode) enterGameMode();
break;
case GLUT_KEY_F2:
if(gamemode) exitGameMode();
default:
break;
}
}

void initWindow(void)
{
setupgl();
glutSetKeyRepeat(GLUT_KEY_REPEAT_ON);
glutIdleFunc(idle);
glutReshapeFunc(reshape);
glutSpecialFunc(special);
glutKeyboardFunc(keyboard);
glutDisplayFunc(display);
}

int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutInitWindowSize(250,250);
glutCreateWindow(argv[0]);
initWindow();
glutMainLoop();
return 0;
}


Thanks http://www.opengl.org/discussion_boards/ubb/smile.gif