volmetrics

annotate src/main.cc @ 0:88d390af583f

Image loader
author Eleni Maria Stea <eleni@mutantstargoat.com>
date Sat, 11 Jan 2014 17:22:36 +0200
parents
children cca2e05dbabe
rev   line source
eleni@0 1 #include <GL/glew.h>
eleni@0 2 #include <GL/glut.h>
eleni@0 3
eleni@0 4 #include <stdio.h>
eleni@0 5 #include <assert.h>
eleni@0 6
eleni@0 7 //static void init(void);
eleni@0 8 static void display(void);
eleni@0 9 static void reshape(int x, int y);
eleni@0 10 static void keyboard(unsigned char key, int x, int y);
eleni@0 11 static void mouse(int button, int state, int x, int y);
eleni@0 12 static void motion(int x, int y);
eleni@0 13
eleni@0 14 static int win_xsz, win_ysz;
eleni@0 15
eleni@0 16 int main(int argc, char **argv)
eleni@0 17 {
eleni@0 18 glutInit(&argc, argv);
eleni@0 19 glutInitWindowSize(1280, 720);
eleni@0 20 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
eleni@0 21
eleni@0 22 //TODO parse arguments
eleni@0 23
eleni@0 24 glutCreateWindow("My Colonoscopie OEO!");
eleni@0 25
eleni@0 26 glutDisplayFunc(display);
eleni@0 27 glutReshapeFunc(reshape);
eleni@0 28 glutKeyboardFunc(keyboard);
eleni@0 29 glutMouseFunc(mouse);
eleni@0 30 glutMotionFunc(motion);
eleni@0 31
eleni@0 32 glewInit();
eleni@0 33
eleni@0 34 //call init
eleni@0 35
eleni@0 36 glutMainLoop();
eleni@0 37 return 0;
eleni@0 38 }
eleni@0 39
eleni@0 40 int init(void)
eleni@0 41 {
eleni@0 42 //TODO
eleni@0 43 return 0;
eleni@0 44 }
eleni@0 45
eleni@0 46 void display(void)
eleni@0 47 {
eleni@0 48 //render
eleni@0 49
eleni@0 50 glutSwapBuffers();
eleni@0 51 assert(glGetError() == GL_NO_ERROR);
eleni@0 52 }
eleni@0 53
eleni@0 54 void reshape(int x, int y)
eleni@0 55 {
eleni@0 56 glViewport(0, 0, x, y);
eleni@0 57 if(x != win_xsz || y != win_ysz) {
eleni@0 58 //TODO raytex_needs_recalc = 1;
eleni@0 59 win_xsz = x;
eleni@0 60 win_ysz = y;
eleni@0 61 }
eleni@0 62 }
eleni@0 63
eleni@0 64 void keyboard(unsigned char key, int x, int y)
eleni@0 65 {
eleni@0 66 switch(key) {
eleni@0 67 case 27:
eleni@0 68 exit(0);
eleni@0 69 default:
eleni@0 70 break;
eleni@0 71 }
eleni@0 72 }
eleni@0 73
eleni@0 74 static int prev_x, prev_y;
eleni@0 75 void mouse(int bn, int state, int x, int y)
eleni@0 76 {
eleni@0 77 prev_x = x;
eleni@0 78 prev_y = y;
eleni@0 79 }
eleni@0 80
eleni@0 81 void motion(int x, int y)
eleni@0 82 {
eleni@0 83 int dx = x - prev_x;
eleni@0 84 int dy = y - prev_y;
eleni@0 85 prev_x = x;
eleni@0 86 prev_y = y;
eleni@0 87 }