cubemapper

view src/main.cc @ 4:2bfafdced01a

added README, COPYING, and copyright headers
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 30 Jul 2017 16:11:19 +0300
parents e308561f9889
children
line source
1 /*
2 Cubemapper - a program for converting panoramic images into cubemaps
3 Copyright (C) 2017 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include <stdlib.h>
19 #ifdef __APPLE__
20 #include <GLUT/glut.h>
21 #else
22 #include <GL/glut.h>
23 #endif
24 #include "app.h"
26 static void display();
27 static void reshape(int x, int y);
28 static void keydown(unsigned char key, int x, int y);
29 static void mouse(int bn, int st, int x, int y);
30 static void motion(int x, int y);
32 static int win_width, win_height;
34 int main(int argc, char **argv)
35 {
36 glutInitWindowSize(1024, 768);
37 glutInit(&argc, argv);
38 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_MULTISAMPLE);
39 glutCreateWindow("cubemapper");
41 glutDisplayFunc(display);
42 glutReshapeFunc(reshape);
43 glutKeyboardFunc(keydown);
44 glutMouseFunc(mouse);
45 glutMotionFunc(motion);
47 if(!app_init(argc, argv)) {
48 return 1;
49 }
51 glutMainLoop();
52 return 0;
53 }
55 void app_quit()
56 {
57 app_cleanup();
58 exit(0);
59 }
61 void app_redisplay()
62 {
63 glutPostRedisplay();
64 }
66 void app_swap_buffers()
67 {
68 glutSwapBuffers();
69 }
71 void app_resize(int x, int y)
72 {
73 glutReshapeWindow(x, y);
74 }
76 void app_print_text(int x, int y, const char *str)
77 {
78 glMatrixMode(GL_PROJECTION);
79 glPushMatrix();
80 glLoadIdentity();
81 glOrtho(0, win_width, 0, win_height, -1, 1);
83 glMatrixMode(GL_MODELVIEW);
84 glPushMatrix();
85 glLoadIdentity();
87 glRasterPos2i(x, y);
89 while(*str) {
90 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, *str++);
91 }
93 glMatrixMode(GL_PROJECTION);
94 glPopMatrix();
95 glMatrixMode(GL_MODELVIEW);
96 glPopMatrix();
97 }
99 static void display()
100 {
101 app_draw();
102 }
104 static void reshape(int x, int y)
105 {
106 win_width = x;
107 win_height = y;
108 app_reshape(x, y);
109 }
111 static void keydown(unsigned char key, int x, int y)
112 {
113 app_keyboard(key, true);
114 }
116 static void mouse(int bn, int st, int x, int y)
117 {
118 app_mouse_button(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN, x, y);
119 }
121 static void motion(int x, int y)
122 {
123 app_mouse_motion(x, y);
124 }