istereo
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/glutmain.c Tue Sep 06 12:48:39 2011 +0300 1.3 @@ -0,0 +1,67 @@ 1.4 +#include <stdio.h> 1.5 +#include <stdlib.h> 1.6 +#include <GL/glew.h> 1.7 +#include <GL/glut.h> 1.8 +#include "sanegl.h" 1.9 + 1.10 +void disp(void); 1.11 +void reshape(int x, int y); 1.12 +void keyb(unsigned char key, int x, int y); 1.13 + 1.14 +int main(int argc, char **argv) 1.15 +{ 1.16 + glutInit(&argc, argv); 1.17 + glutInitWindowSize(960, 640); 1.18 + glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); 1.19 + glutCreateWindow("test"); 1.20 + 1.21 + glutDisplayFunc(disp); 1.22 + glutIdleFunc(glutPostRedisplay); 1.23 + glutReshapeFunc(reshape); 1.24 + glutKeyboardFunc(keyb); 1.25 + 1.26 + glutMainLoop(); 1.27 + return 0; 1.28 +} 1.29 + 1.30 +void disp(void) 1.31 +{ 1.32 + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 1.33 + 1.34 + glMatrixMode(GL_MODELVIEW); 1.35 + glLoadIdentity(); 1.36 + glTranslatef(0, 0, -8); 1.37 + 1.38 + glBegin(GL_QUADS); 1.39 + glColor3f(1, 0, 0); 1.40 + glVertex3f(-1, -1, 0); 1.41 + glColor3f(0, 1, 0); 1.42 + glVertex3f(1, -1, 0); 1.43 + glColor3f(0, 0, 1); 1.44 + glVertex3f(1, 1, 0); 1.45 + glColor3f(1, 1, 0); 1.46 + glVertex3f(-1, 1, 0); 1.47 + glEnd(); 1.48 + 1.49 + glutSwapBuffers(); 1.50 +} 1.51 + 1.52 +void reshape(int x, int y) 1.53 +{ 1.54 + glViewport(0, 0, x, y); 1.55 + 1.56 + glMatrixMode(GL_PROJECTION); 1.57 + glLoadIdentity(); 1.58 + gluPerspective(45.0, (float)x / (float)y, 1.0, 1000.0); 1.59 +} 1.60 + 1.61 +void keyb(unsigned char key, int x, int y) 1.62 +{ 1.63 + switch(key) { 1.64 + case 27: 1.65 + exit(0); 1.66 + 1.67 + default: 1.68 + break; 1.69 + } 1.70 +}