istereo

view src/glutmain.c @ 1:4d25539806d2

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