2 MiniGLUT - minimal GLUT subset without dependencies
3 Copyright (C) 2020-2022 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 <https://www.gnu.org/licenses/>.
22 #define WIN32_LEAN_AND_MEAN 1
26 #pragma comment (lib, "opengl32")
27 #ifndef MINIGLUT_NO_WINMM
28 #pragma comment (lib, "winmm")
35 /* mode flags for glutInitDisplayMode */
38 #define GLUT_INDEX 0x001
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
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 };
57 GLUT_CURSOR_LEFT_ARROW,
67 GLUT_WINDOW_BUFFER_SIZE,
68 GLUT_WINDOW_STENCIL_SIZE,
69 GLUT_WINDOW_DEPTH_SIZE,
71 GLUT_WINDOW_GREEN_SIZE,
72 GLUT_WINDOW_BLUE_SIZE,
73 GLUT_WINDOW_ALPHA_SIZE,
74 GLUT_WINDOW_DOUBLEBUFFER,
76 GLUT_WINDOW_NUM_SAMPLES,
82 GLUT_INIT_DISPLAY_MODE,
85 GLUT_INIT_WINDOW_WIDTH,
86 GLUT_INIT_WINDOW_HEIGHT,
88 GLUT_WINDOW_COLORMAP_SIZE
98 GLUT_KEY_HOME = 0xff50,
99 GLUT_KEY_LEFT = 0xff51,
105 GLUT_KEY_END = 0xff57,
106 GLUT_KEY_INSERT = 0xff63,
107 GLUT_KEY_F1 = 0xffbe,
121 /* returned by glutGetModifiers */
122 #define GLUT_ACTIVE_SHIFT 1
123 #define GLUT_ACTIVE_CTRL 4
124 #define GLUT_ACTIVE_ALT 8
130 #define GLUT_KEY_REPEAT_DEFAULT GLUT_KEY_REPEAT_ON
132 typedef void (*glut_cb)(void);
133 typedef void (*glut_cb_reshape)(int x, int y);
134 typedef void (*glut_cb_state)(int state);
135 typedef void (*glut_cb_keyb)(unsigned char key, int x, int y);
136 typedef void (*glut_cb_special)(int key, int x, int y);
137 typedef void (*glut_cb_mouse)(int bn, int state, int x, int y);
138 typedef void (*glut_cb_motion)(int x, int y);
139 typedef void (*glut_cb_sbmotion)(int x, int y, int z);
140 typedef void (*glut_cb_sbbutton)(int bn, int state);
146 void glutInit(int *argc, char **argv);
147 void glutInitWindowPosition(int x, int y);
148 void glutInitWindowSize(int xsz, int ysz);
149 void glutInitDisplayMode(unsigned int mode);
150 void glutCreateWindow(const char *title);
153 void glutMainLoop(void);
154 void glutMainLoopEvent(void);
156 void glutPostRedisplay(void);
157 void glutSwapBuffers(void);
158 void glutPositionWindow(int x, int y);
159 void glutReshapeWindow(int xsz, int ysz);
160 void glutFullScreen(void);
161 void glutSetWindowTitle(const char *title);
162 void glutSetIconTitle(const char *title);
163 void glutSetCursor(int cursor);
164 void glutSetColor(int idx, float r, float g, float b);
165 float glutGetColor(int idx, int comp);
167 void glutIgnoreKeyRepeat(int ignore);
168 void glutSetKeyRepeat(int repmode);
170 void glutIdleFunc(glut_cb func);
171 void glutDisplayFunc(glut_cb func);
172 void glutReshapeFunc(glut_cb_reshape func);
173 void glutVisibilityFunc(glut_cb_state func);
174 void glutEntryFunc(glut_cb_state func);
175 void glutKeyboardFunc(glut_cb_keyb func);
176 void glutKeyboardUpFunc(glut_cb_keyb func);
177 void glutSpecialFunc(glut_cb_special func);
178 void glutSpecialUpFunc(glut_cb_special func);
179 void glutMouseFunc(glut_cb_mouse func);
180 void glutMotionFunc(glut_cb_motion func);
181 void glutPassiveMotionFunc(glut_cb_motion func);
182 void glutSpaceballMotionFunc(glut_cb_sbmotion func);
183 void glutSpaceballRotateFunc(glut_cb_sbmotion func);
184 void glutSpaceballButtonFunc(glut_cb_sbbutton func);
186 int glutGet(unsigned int s);
187 int glutGetModifiers(void);
188 int glutExtensionSupported(char *ext);
190 void glutSolidSphere(float rad, int slices, int stacks);
191 void glutWireSphere(float rad, int slices, int stacks);
192 void glutSolidCube(float sz);
193 void glutWireCube(float sz);
194 void glutSolidCone(float base, float height, int slices, int stacks);
195 void glutWireCone(float base, float height, int slices, int stacks);
196 void glutSolidCylinder(float rad, float height, int slices, int stacks);
197 void glutSolidTorus(float inner_rad, float outer_rad, int sides, int rings);
198 void glutWireTorus(float inner_rad, float outer_rad, int sides, int rings);
199 void glutSolidTeapot(float size);
200 void glutWireTeapot(float size);
206 #endif /* MINIGLUT_H_ */