sanegl

view test.c @ 0:00b315b6db1e

sanegl initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 23 Jun 2011 05:19:40 +0300
parents
children
line source
1 #include <stdlib.h>
2 #include <GL/glut.h>
3 #include "sanegl.h"
5 void disp(void);
6 void reshape(int x, int y);
7 void keyb(unsigned char key, int x, int y);
10 int main(int argc, char **argv)
11 {
12 glutInit(&argc, argv);
13 glutInitWindowSize(800, 600);
14 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
15 glutCreateWindow("foo");
17 glutDisplayFunc(disp);
18 glutReshapeFunc(reshape);
19 glutKeyboardFunc(keyb);
21 glutMainLoop();
22 return 0;
23 }
25 void disp(void)
26 {
27 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
29 glBegin(GL_QUADS);
30 glColor3f(1, 0, 0);
31 glVertex2f(-0.5, -0.5);
32 glColor3f(0, 1, 0);
33 glVertex2f(0.5, -0.5);
34 glColor3f(0, 0, 1);
35 glVertex2f(0.5, 0.5);
36 glColor3f(1, 1, 0);
37 glVertex2f(-0.5, 0.5);
38 glEnd();
40 glutSwapBuffers();
41 }
43 void reshape(int x, int y)
44 {
45 glViewport(0, 0, x, y);
46 }
48 void keyb(unsigned char key, int x, int y)
49 {
50 if(key == 27) {
51 exit(0);
52 }
53 }