All pastes #122691 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-08-08 21:04 UTC
rendered paste body
#include <iostream>
#include <GL/glut.h>
#include <string>
using namespace std;
double WIDTH = 400, HEIGHT = 400;
double HMIN = -WIDTH/2, HMAX = WIDTH/2, KMIN = -HEIGHT/2, KMAX = HEIGHT/2;
void display() {
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_QUADS);
glColor3f(1, 1, 1);
glVertex3f(0, 10, 0);
glVertex3f(10, 10, 0);
glVertex3f(10, 0, 0);
glVertex3f(0, 1, 0);
glEnd();
glutPostRedisplay();
glutSwapBuffers();
}

void keyboard(unsigned char key, int x, int y) {
}

void special(int key, int x, int y) {
  if(key==GLUT_KEY_RIGHT) {
    glTranslatef(10,0,0);
  } 
 if(key==GLUT_KEY_LEFT) {
    glTranslatef(-10,0,0);
  } 
 if(key==GLUT_KEY_UP) {
    glTranslatef(0,10,0);
  } 
 if(key==GLUT_KEY_DOWN) {
    glTranslatef(0,-10,0);
  }
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(WIDTH, HEIGHT);
glutInitWindowPosition(100, 100);
glutCreateWindow("Keyboard Input");
glClearColor(0, 0, 0, 0);
glColor3f(1, 1, 1);
glMatrixMode(GL_MODELVIEW);
glOrtho(HMIN, HMAX, KMIN, KMAX, -1, 1);
glClear(GL_COLOR_BUFFER_BIT);
glutKeyboardFunc(keyboard);
glutSpecialFunc(special);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}