istereo
annotate src/glutmain.c @ 1:4d25539806d2
bollocks
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Tue, 06 Sep 2011 12:48:39 +0300 |
parents | |
children | bb68fac22579 |
rev | line source |
---|---|
nuclear@1 | 1 #include <stdio.h> |
nuclear@1 | 2 #include <stdlib.h> |
nuclear@1 | 3 #include <GL/glew.h> |
nuclear@1 | 4 #include <GL/glut.h> |
nuclear@1 | 5 #include "sanegl.h" |
nuclear@1 | 6 |
nuclear@1 | 7 void disp(void); |
nuclear@1 | 8 void reshape(int x, int y); |
nuclear@1 | 9 void keyb(unsigned char key, int x, int y); |
nuclear@1 | 10 |
nuclear@1 | 11 int main(int argc, char **argv) |
nuclear@1 | 12 { |
nuclear@1 | 13 glutInit(&argc, argv); |
nuclear@1 | 14 glutInitWindowSize(960, 640); |
nuclear@1 | 15 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); |
nuclear@1 | 16 glutCreateWindow("test"); |
nuclear@1 | 17 |
nuclear@1 | 18 glutDisplayFunc(disp); |
nuclear@1 | 19 glutIdleFunc(glutPostRedisplay); |
nuclear@1 | 20 glutReshapeFunc(reshape); |
nuclear@1 | 21 glutKeyboardFunc(keyb); |
nuclear@1 | 22 |
nuclear@1 | 23 glutMainLoop(); |
nuclear@1 | 24 return 0; |
nuclear@1 | 25 } |
nuclear@1 | 26 |
nuclear@1 | 27 void disp(void) |
nuclear@1 | 28 { |
nuclear@1 | 29 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
nuclear@1 | 30 |
nuclear@1 | 31 glMatrixMode(GL_MODELVIEW); |
nuclear@1 | 32 glLoadIdentity(); |
nuclear@1 | 33 glTranslatef(0, 0, -8); |
nuclear@1 | 34 |
nuclear@1 | 35 glBegin(GL_QUADS); |
nuclear@1 | 36 glColor3f(1, 0, 0); |
nuclear@1 | 37 glVertex3f(-1, -1, 0); |
nuclear@1 | 38 glColor3f(0, 1, 0); |
nuclear@1 | 39 glVertex3f(1, -1, 0); |
nuclear@1 | 40 glColor3f(0, 0, 1); |
nuclear@1 | 41 glVertex3f(1, 1, 0); |
nuclear@1 | 42 glColor3f(1, 1, 0); |
nuclear@1 | 43 glVertex3f(-1, 1, 0); |
nuclear@1 | 44 glEnd(); |
nuclear@1 | 45 |
nuclear@1 | 46 glutSwapBuffers(); |
nuclear@1 | 47 } |
nuclear@1 | 48 |
nuclear@1 | 49 void reshape(int x, int y) |
nuclear@1 | 50 { |
nuclear@1 | 51 glViewport(0, 0, x, y); |
nuclear@1 | 52 |
nuclear@1 | 53 glMatrixMode(GL_PROJECTION); |
nuclear@1 | 54 glLoadIdentity(); |
nuclear@1 | 55 gluPerspective(45.0, (float)x / (float)y, 1.0, 1000.0); |
nuclear@1 | 56 } |
nuclear@1 | 57 |
nuclear@1 | 58 void keyb(unsigned char key, int x, int y) |
nuclear@1 | 59 { |
nuclear@1 | 60 switch(key) { |
nuclear@1 | 61 case 27: |
nuclear@1 | 62 exit(0); |
nuclear@1 | 63 |
nuclear@1 | 64 default: |
nuclear@1 | 65 break; |
nuclear@1 | 66 } |
nuclear@1 | 67 } |