open GL keyboard func

How can I listen for the keys for UP, DOWN, LEFT and RIGHT?
When I ran a test on this using the function below, I fount it hard to display the keys and I don’t know their ascii values.

Anybody help?

void KeyDown(unsigned char key, int x, int y)
{	cout <<key<<endl;
}  

1: This is about GLUT, not OpenGL. They are not the same thing.

2: If you want to display the ASCII value of a key, you need to convert it into an integer with a cast operation.

use glut
im not sure if u know but
there are more than one function for each device sometimes
depending on what they do

init();

glutDisplayFunc(display); 
glutIdleFunc(display);
glutReshapeFunc(reshape);


/* MOUSE */
glutWarpPointer(mid_x, mid_y);
glutSetCursor(GLUT_CURSOR_NONE);

glutMouseFunc(mousePress); 

glutMotionFunc(mouseMove);
glutPassiveMotionFunc(mouseMove); //check for mouse movement


/* KEYS */
glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF);

glutKeyboardFunc(keyboard);
glutKeyboardUpFunc(keyboardup);

glutSpecialFunc(specialkeyboard);
glutSpecialUpFunc(specialkeyboardup);



glutMainLoop();

void keyboardup(unsigned char key, int x, int y) {

//glutIgnoreKeyRepeat(1);


/* avoid thrashing this procedure */
usleep(100);


int tex = 1;


switch (key) {

	case ESCAPE: // kill everything.
	
		exit(1);                   	
		break; // redundant.


	case 'a': case 'A': // switch the blending

		ambOn = ambOn ? 0 : 1;
	
		printf("amb is now: %d

", ambOn);
break;

	case 'd': case 'D': // switch the blending

		difOn = difOn ? 0 : 1;

		
		printf("dif is now: %d

", difOn);
break;

/*
case ‘b’: case ‘B’: // switch the blending

		blend = blend ? 0 : 1;
		
		if (blend) {
			glEnable(GL_BLEND);
			glDisable(GL_DEPTH_TEST);
		} else {
			glDisable(GL_BLEND);
			glEnable(GL_DEPTH_TEST);
		}
		
		printf("Blending is now: %d

", blend);
break;
*/

	case 't': case 'T': // switch the blending

		tex = tex ? 0 : 1;
		
		if (!tex) {
			glEnable(GL_TEXTURE_2D);
		} else {
			glDisable(GL_TEXTURE_2D);
		}
		
		printf("Textures is now: %d

", tex);
break;

	case 'l': case 'L': // switch the lighting
	
		light = light ? 0 : 1;
		
		if (light) glEnable(GL_LIGHTING);
		else glDisable(GL_LIGHTING);
		
		printf("Lighting is now: %d

", light);
break;

	case '-': case '_': // switch the lighting

		if (light_intensity &lt;= 0) return;
		
		light_intensity -= 0.1;  	
		break;


	case '=': case '+': // switch the lighting

		if (light_intensity &gt;= 1) return;
		
		light_intensity += 0.1;  
		break;
		
		
		
	case '{': case '[': // switch the lighting

		if (light_id &lt;= 0) return;
		
		light_id -= 1;  	
		break;


	case '}': case ']': // switch the lighting

		//if (light_id &gt;= 1) return;
		
		light_id += 1;  
		break;

/*
case ‘.’: // switch the lighting

		//if (light_id &gt;= 1) return;
		
		f0 += 5;  
		break;
		
		
	case ',': // switch the lighting

		//if (light_id &gt;= 1) return;
		
		f0 -= 5;  
		break;
		
		
		
	case 'm': // switch the lighting

		//if (light_id &gt;= 1) return;
		
		f1 += 5;  
		break;

		
	case 'n': // switch the lighting

		//if (light_id &gt;= 1) return;
		
		f1 -= 5;  
		break;	
		
		
	case 'b': // switch the lighting

		//if (light_id &gt;= 1) return;
		
		f2 += 5;  
		break;

		
	case 'v': // switch the lighting

		//if (light_id &gt;= 1) return;
		
		f2 -= 5;  
		break;	

*/

	case 'v': case 'V': // switch the lighting

		camera.perspective = camera.perspective ? 0 : 1;

		printf("camera.perspective is now: %d

", camera.perspective);
break;

	case 'c': case 'C': // drop crate
	
		dropCrate();
		break;
		


	default:
	
		printf ("Key %d pressed. No action there yet.

", key);
break;

}	

keyboard_state = 0;

}

In other words:[ul][li]There is no OpenGL keyboard function.[]OpenGL does not handle keyboard input.[]OpenGL does not know the difference between a keyboard and an elephant.[]OpenGL does not know the difference between a keyboard and the planet Mars.[]OpenGL provides functions for interfacing with your graphics hardware, nothing else. Page 1, line 1 of any OpenGL manual.[]GLUT provides some simple keyboard functions.[]GLUT is a library built on top of OpenGL for the purposes of simplifying code in demos and tutorials.[*]GLUT is not OpenGL.[/ul][/li]This really should be a FAQ entry…

http://www.opengl.org/wiki/FAQ#What_is_OpenGL.3F

omfg rub it in jfc
or u can get a dirt bike a street bike a skate board surf board and a snowboard one mountain bike a drumset and a bass guitar and get the f outside and enjoy the sun
jk
loling is ok
free country!
usa!