   Keyboard Controlling
  HelloI'm very new in OpenGL and Glut, but I want to learn, please help.I accomplished create a square in window and when you press left arrow key, the square stops only when you press the right arrow key. In some part of my code I wrote:switch(key) {case GLUT_KEY_LEFT : glutIdleFunc(spinDisplay); break;case GLUT_KEY_RIGHT : .........I understand that beacuse I used glutIdleFunc() the action will be executed until another callback enters.Now I wont the rotation ONLY runs WHILE the left arroy key is pressed and STOPS when the user releases that key.I don't know wihch method or function I shall use to accomplish this effect.Please, give me some idea or piece of code.   
  Hey JoeCool,What you do is make some variables like RightKeyPressed, LeftKeyPressed, UpKeyPressed etc.Then when you get the message there that a right key is pressed or a left key is pressed you set the right variable to TRUE (or 1) and when you get a message that a key is released, you set the right variable to FALSE (or 0).Then, in your Tick() function (whatever function is called every frame), check those variables to see if the key is pressed or not, and if so, do your logic there for actually spinning the object, moving the camera, or whatever else you are doing.This is the standard way of doing input in video games (:   ;#include<GL/glut.h>...... float x,y,z; // step 1 make a global variableGLvoid displayFunc(){   glClear(...)  //regular routine  //assuming you are using this for rotation.   // This function will rotate our square depending on the user input glRotatef(x,y,z); //the x,y,z will change every time the user presses a key.   drawSquare()   //Then you should have double buffering   glutSwapbuffers(); //you should have this   glutPostRedisplay(); //you should have add this}GLvoid keyboard(int specialKey, int x, int y){   switch(specialKey)  {    case GLUT_KEY_LEFT :  x+=1.5f; break; //This will rotate the square when left is pressed    case GLUT_KEY_RIGHT : x-=1.5f break;   }}....//Then in your int mainint main(...){   //regular routine   // you should have this in there    glutInitDisplayMode(GLUT_DEPTH | GLUT_RGBA | GLUT_DOUBLE);  ...  ...};  Well, I tried to follow the suggestion of tnutty and I modified my code and resulted this below:#include <Gl/gl.h>#include <Gl/glu.h>#include <Gl/glut.h>#include <stdlib.h>float delta=0.0;static GLfloat spin=0.0;void init(void){glClearColor(0.0,0.0,0.0,0.0);glShadeModel(GL_FLAT);}void display(void){ // draw an squareglClear(GL_COLOR_BUFFER_BIT);glPushMatrix();glRotatef(spin,0.0,0.0,1.0);glColor3f(1.0,1.0,1.0);glRectf(-5.0,-5.0,5.0,5.0);glPopMatrix();glutSwapBuffers();}void spinDisplayR(void){ //this is for mouse event, ignore itspin=spin+0.05;if (spin>360.0)spin=spin-360.0;glutPostRedisplay();}void spinDisplay(void){spin=spin+delta;if (spin>360.0)spin=spin-360.0;glutPostRedisplay();}void reshape(int w, int h){glViewport(0,0,(GLsizei)w,(GLsizei)h);glMatrixMode(GL_PROJECTION);glLoadIdentity();glOrtho(-50.0,50.0,-50.0,50.0,-1.0,1.0);glMatrixMode(GL_MODELVIEW);glLoadIdentity();}void mouse(int button, int state, int x, int y){switch(button){case GLUT_RIGHT_BUTTON:if(state==GLUT_DOWN)glutIdleFunc(spinDisplayR);break;case GLUT_LEFT_BUTTON:if(state==GLUT_DOWN)glutIdleFunc(NULL);break;default:break;}}GLvoid keyboard(int specialKey, int x, int y) {    switch(specialKey) {case GLUT_KEY_LEFT:  delta=delta+0.1f;  break;case GLUT_KEY_RIGHT:   delta=delta-0.1f;  break;default: break;}}//++++++++++++++++++++++++++++++++++++++++++++++int main (int argc, char** argv){    glutInit(&argc,argv);    glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);    glutInitWindowSize(300,300);    glutInitWindowPosition(100,100);    glutCreateWindow("Rotation Keyboard Controlled");    init();    glutDisplayFunc(display);    glutReshapeFunc(reshape);    glutMouseFunc(mouse);    glutSpecialFunc(keyboard);    glutMainLoop();    return 0;}but the square dosn't rotate >:(Where is my fault?   ;  You are changing your delta and adding it to spin value. But you never call thatfunction spinDisplay. call the spin display inside the display function. That should work.