- added glutIgnoreKeyRepeat in miniglut
[vrlugburz] / src / miniglut.h
1 /*
2 MiniGLUT - minimal GLUT subset without dependencies
3 Copyright (C) 2020  John Tsiombikas <nuclear@member.fsf.org>
4
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.
9
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.
14
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <https://www.gnu.org/licenses/>.
17  */
18 #ifndef MINIGLUT_H_
19 #define MINIGLUT_H_
20
21 #ifdef _WIN32
22 #define WIN32_LEAN_AND_MEAN 1
23 #include <windows.h>
24
25 #ifdef _MSC_VER
26 #pragma comment (lib, "opengl32")
27 #ifndef MINIGLUT_NO_WINMM
28 #pragma comment (lib, "winmm")
29 #endif
30 #endif  /* MSVC */
31
32 #endif
33 #include <GL/gl.h>
34
35 /* mode flags for glutInitDisplayMode */
36 #define GLUT_RGB                        0
37 #define GLUT_RGBA                       0
38 #define GLUT_INDEX                      0x001
39 #define GLUT_SINGLE                     0
40 #define GLUT_DOUBLE                     0x002
41 #define GLUT_ACCUM                      0x004
42 #define GLUT_ALPHA                      0x008
43 #define GLUT_DEPTH                      0x010
44 #define GLUT_STENCIL            0x020
45 #define GLUT_STEREO                     0x040
46 #define GLUT_MULTISAMPLE        0x100
47 #define GLUT_SRGB                       0x200
48
49 enum { GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, GLUT_RIGHT_BUTTON };
50 enum { GLUT_UP, GLUT_DOWN };
51 enum { GLUT_NOT_VISIBLE, GLUT_VISIBLE };
52 enum { GLUT_LEFT, GLUT_ENTERED };
53
54 /* cursors */
55 enum {
56         GLUT_CURSOR_INHERIT,
57         GLUT_CURSOR_LEFT_ARROW,
58         GLUT_CURSOR_NONE
59 };
60
61 /* glutGet */
62 enum {
63         GLUT_WINDOW_X,
64         GLUT_WINDOW_Y,
65         GLUT_WINDOW_WIDTH,
66         GLUT_WINDOW_HEIGHT,
67         GLUT_WINDOW_BUFFER_SIZE,
68         GLUT_WINDOW_STENCIL_SIZE,
69         GLUT_WINDOW_DEPTH_SIZE,
70         GLUT_WINDOW_RED_SIZE,
71         GLUT_WINDOW_GREEN_SIZE,
72         GLUT_WINDOW_BLUE_SIZE,
73         GLUT_WINDOW_ALPHA_SIZE,
74         GLUT_WINDOW_DOUBLEBUFFER,
75         GLUT_WINDOW_RGBA,
76         GLUT_WINDOW_NUM_SAMPLES,
77         GLUT_WINDOW_STEREO,
78         GLUT_WINDOW_SRGB,
79         GLUT_WINDOW_CURSOR,
80         GLUT_SCREEN_WIDTH,
81         GLUT_SCREEN_HEIGHT,
82         GLUT_INIT_DISPLAY_MODE,
83         GLUT_INIT_WINDOW_X,
84         GLUT_INIT_WINDOW_Y,
85         GLUT_INIT_WINDOW_WIDTH,
86         GLUT_INIT_WINDOW_HEIGHT,
87         GLUT_ELAPSED_TIME
88 };
89
90 enum {
91         GLUT_KEY_HOME = 0xff50,
92         GLUT_KEY_LEFT = 0xff51,
93         GLUT_KEY_UP,
94         GLUT_KEY_RIGHT,
95         GLUT_KEY_DOWN,
96         GLUT_KEY_PAGE_UP,
97         GLUT_KEY_PAGE_DOWN,
98         GLUT_KEY_END = 0xff57,
99         GLUT_KEY_INSERT = 0xff63,
100         GLUT_KEY_F1 = 0xffbe,
101         GLUT_KEY_F2,
102         GLUT_KEY_F3,
103         GLUT_KEY_F4,
104         GLUT_KEY_F5,
105         GLUT_KEY_F6,
106         GLUT_KEY_F7,
107         GLUT_KEY_F8,
108         GLUT_KEY_F9,
109         GLUT_KEY_F10,
110         GLUT_KEY_F11,
111         GLUT_KEY_F12
112 };
113
114 /* returned by glutGetModifiers */
115 #define GLUT_ACTIVE_SHIFT       1
116 #define GLUT_ACTIVE_CTRL        4
117 #define GLUT_ACTIVE_ALT         8
118
119 enum {
120         GLUT_KEY_REPEAT_OFF,
121         GLUT_KEY_REPEAT_ON
122 };
123 #define GLUT_KEY_REPEAT_DEFAULT GLUT_KEY_REPEAT_ON
124
125 typedef void (*glut_cb)(void);
126 typedef void (*glut_cb_reshape)(int x, int y);
127 typedef void (*glut_cb_state)(int state);
128 typedef void (*glut_cb_keyb)(unsigned char key, int x, int y);
129 typedef void (*glut_cb_special)(int key, int x, int y);
130 typedef void (*glut_cb_mouse)(int bn, int state, int x, int y);
131 typedef void (*glut_cb_motion)(int x, int y);
132 typedef void (*glut_cb_sbmotion)(int x, int y, int z);
133 typedef void (*glut_cb_sbbutton)(int bn, int state);
134
135 #ifdef __cplusplus
136 extern "C" {
137 #endif
138
139 void glutInit(int *argc, char **argv);
140 void glutInitWindowPosition(int x, int y);
141 void glutInitWindowSize(int xsz, int ysz);
142 void glutInitDisplayMode(unsigned int mode);
143 void glutCreateWindow(const char *title);
144
145 void glutExit(void);
146 void glutMainLoop(void);
147 void glutMainLoopEvent(void);
148
149 void glutPostRedisplay(void);
150 void glutSwapBuffers(void);
151 void glutPositionWindow(int x, int y);
152 void glutReshapeWindow(int xsz, int ysz);
153 void glutFullScreen(void);
154 void glutSetWindowTitle(const char *title);
155 void glutSetIconTitle(const char *title);
156 void glutSetCursor(int cursor);
157
158 void glutIgnoreKeyRepeat(int ignore);
159 void glutSetKeyRepeat(int repmode);
160
161 void glutIdleFunc(glut_cb func);
162 void glutDisplayFunc(glut_cb func);
163 void glutReshapeFunc(glut_cb_reshape func);
164 void glutVisibilityFunc(glut_cb_state func);
165 void glutEntryFunc(glut_cb_state func);
166 void glutKeyboardFunc(glut_cb_keyb func);
167 void glutKeyboardUpFunc(glut_cb_keyb func);
168 void glutSpecialFunc(glut_cb_special func);
169 void glutSpecialUpFunc(glut_cb_special func);
170 void glutMouseFunc(glut_cb_mouse func);
171 void glutMotionFunc(glut_cb_motion func);
172 void glutPassiveMotionFunc(glut_cb_motion func);
173 void glutSpaceballMotionFunc(glut_cb_sbmotion func);
174 void glutSpaceballRotateFunc(glut_cb_sbmotion func);
175 void glutSpaceballButtonFunc(glut_cb_sbbutton func);
176
177 int glutGet(unsigned int s);
178 int glutGetModifiers(void);
179 int glutExtensionSupported(char *ext);
180
181 void glutSolidSphere(float rad, int slices, int stacks);
182 void glutWireSphere(float rad, int slices, int stacks);
183 void glutSolidCube(float sz);
184 void glutWireCube(float sz);
185 void glutSolidCone(float base, float height, int slices, int stacks);
186 void glutWireCone(float base, float height, int slices, int stacks);
187 void glutSolidCylinder(float rad, float height, int slices, int stacks);
188 void glutSolidTorus(float inner_rad, float outer_rad, int sides, int rings);
189 void glutWireTorus(float inner_rad, float outer_rad, int sides, int rings);
190 void glutSolidTeapot(float size);
191 void glutWireTeapot(float size);
192
193 #ifdef __cplusplus
194 }       /* extern "C" */
195 #endif
196
197 #endif  /* MINIGLUT_H_ */