cubemapper

view src/main.cc @ 2:e308561f9889

correct cubemap export and visualization
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 28 Jul 2017 13:24:34 +0300
parents d7a29cb7ac8d
children 2bfafdced01a
line source
1 #include <stdlib.h>
2 #ifdef __APPLE__
3 #include <GLUT/glut.h>
4 #else
5 #include <GL/glut.h>
6 #endif
7 #include "app.h"
9 static void display();
10 static void reshape(int x, int y);
11 static void keydown(unsigned char key, int x, int y);
12 static void mouse(int bn, int st, int x, int y);
13 static void motion(int x, int y);
15 static int win_width, win_height;
17 int main(int argc, char **argv)
18 {
19 glutInitWindowSize(1024, 768);
20 glutInit(&argc, argv);
21 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_MULTISAMPLE);
22 glutCreateWindow("cubemapper");
24 glutDisplayFunc(display);
25 glutReshapeFunc(reshape);
26 glutKeyboardFunc(keydown);
27 glutMouseFunc(mouse);
28 glutMotionFunc(motion);
30 if(!app_init(argc, argv)) {
31 return 1;
32 }
34 glutMainLoop();
35 return 0;
36 }
38 void app_quit()
39 {
40 app_cleanup();
41 exit(0);
42 }
44 void app_redisplay()
45 {
46 glutPostRedisplay();
47 }
49 void app_swap_buffers()
50 {
51 glutSwapBuffers();
52 }
54 void app_resize(int x, int y)
55 {
56 glutReshapeWindow(x, y);
57 }
59 void app_print_text(int x, int y, const char *str)
60 {
61 glMatrixMode(GL_PROJECTION);
62 glPushMatrix();
63 glLoadIdentity();
64 glOrtho(0, win_width, 0, win_height, -1, 1);
66 glMatrixMode(GL_MODELVIEW);
67 glPushMatrix();
68 glLoadIdentity();
70 glRasterPos2i(x, y);
72 while(*str) {
73 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, *str++);
74 }
76 glMatrixMode(GL_PROJECTION);
77 glPopMatrix();
78 glMatrixMode(GL_MODELVIEW);
79 glPopMatrix();
80 }
82 static void display()
83 {
84 app_draw();
85 }
87 static void reshape(int x, int y)
88 {
89 win_width = x;
90 win_height = y;
91 app_reshape(x, y);
92 }
94 static void keydown(unsigned char key, int x, int y)
95 {
96 app_keyboard(key, true);
97 }
99 static void mouse(int bn, int st, int x, int y)
100 {
101 app_mouse_button(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN, x, y);
102 }
104 static void motion(int x, int y)
105 {
106 app_mouse_motion(x, y);
107 }