#include <GL/glut.h>
float x_position = 0;
float speed = 0.1f;
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glTranslatef(x_position, 0, 0);
glColor3f(1, 0, 0);
glBegin(GL_QUADS);
glVertex2f(-2, 2);
glVertex2f(2, 2);
glVertex2f(2, -2);
glVertex2f(-2, -2);
glEnd();
glutSwapBuffers();
}
void teclado(unsigned char key, int x, int y) {
glutPostRedisplay();
if (key == 27) {
exit(0);
}
if (key == 97) {
x_position = -speed;
}
if (key == 100) {
x_position = speed;
}
}
int main(int argc, char** argv)
{
glutInit(&argc;, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowSize(640, 640);
glutCreateWindow("OpenGL");
glutDisplayFunc(display);
glutKeyboardFunc(teclado);
gluOrtho2D(-10, 10, -10, 10);
glClearColor(0.5, 0.7, 0.5, 0);
glutMainLoop();
return 0;
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}