blob: e902964c9222c9b7ed6831c33b53430624446c9a [file] [log] [blame]
Camilla Berglund2955cd32010-11-17 15:42:55 +01001/*************************************************************************
Camilla Berglund6e553c72011-03-06 01:46:39 +01002 * GLFW - An OpenGL library
Camilla Berglund38b0ccb2010-09-07 17:41:26 +02003 * API version: 3.0
Camilla Berglund3249f812010-09-07 17:34:51 +02004 * WWW: http://www.glfw.org/
5 *------------------------------------------------------------------------
6 * Copyright (c) 2002-2006 Marcus Geelnard
Camilla Berglundf8105ed2010-11-09 02:57:46 +01007 * Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
Camilla Berglund3249f812010-09-07 17:34:51 +02008 *
9 * This software is provided 'as-is', without any express or implied
10 * warranty. In no event will the authors be held liable for any damages
11 * arising from the use of this software.
12 *
13 * Permission is granted to anyone to use this software for any purpose,
14 * including commercial applications, and to alter it and redistribute it
15 * freely, subject to the following restrictions:
16 *
17 * 1. The origin of this software must not be misrepresented; you must not
18 * claim that you wrote the original software. If you use this software
19 * in a product, an acknowledgment in the product documentation would
20 * be appreciated but is not required.
21 *
22 * 2. Altered source versions must be plainly marked as such, and must not
23 * be misrepresented as being the original software.
24 *
25 * 3. This notice may not be removed or altered from any source
26 * distribution.
27 *
28 *************************************************************************/
29
Camilla Berglund36e54092010-11-09 02:58:35 +010030#ifndef __glfw3_h__
31#define __glfw3_h__
Camilla Berglund3249f812010-09-07 17:34:51 +020032
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37
38/*************************************************************************
39 * Global definitions
40 *************************************************************************/
41
42/* We need a NULL pointer from time to time */
43#ifndef NULL
44 #ifdef __cplusplus
45 #define NULL 0
46 #else
Camilla Berglund9a716692010-09-08 16:40:43 +020047 #define NULL ((void*) 0)
Camilla Berglund3249f812010-09-07 17:34:51 +020048 #endif
49#endif /* NULL */
50
51
52/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
53
54/* Please report any probles that you find with your compiler, which may
55 * be solved in this section! There are several compilers that I have not
56 * been able to test this file with yet.
57 *
58 * First: If we are we on Windows, we want a single define for it (_WIN32)
59 * (Note: For Cygwin the compiler flag -mwin32 should be used, but to
60 * make sure that things run smoothly for Cygwin users, we add __CYGWIN__
61 * to the list of "valid Win32 identifiers", which removes the need for
62 * -mwin32)
63 */
64#if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__))
65 #define _WIN32
66#endif /* _WIN32 */
67
68/* In order for extension support to be portable, we need to define an
69 * OpenGL function call method. We use the keyword APIENTRY, which is
70 * defined for Win32. (Note: Windows also needs this for <GL/gl.h>)
71 */
72#ifndef APIENTRY
73 #ifdef _WIN32
74 #define APIENTRY __stdcall
75 #else
76 #define APIENTRY
77 #endif
78 #define GL_APIENTRY_DEFINED
79#endif /* APIENTRY */
80
81
82/* The following three defines are here solely to make some Windows-based
83 * <GL/gl.h> files happy. Theoretically we could include <windows.h>, but
84 * it has the major drawback of severely polluting our namespace.
85 */
86
87/* Under Windows, we need WINGDIAPI defined */
88#if !defined(WINGDIAPI) && defined(_WIN32)
89 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__POCC__)
90 /* Microsoft Visual C++, Borland C++ Builder and Pelles C */
91 #define WINGDIAPI __declspec(dllimport)
92 #elif defined(__LCC__)
93 /* LCC-Win32 */
94 #define WINGDIAPI __stdcall
95 #else
96 /* Others (e.g. MinGW, Cygwin) */
97 #define WINGDIAPI extern
98 #endif
99 #define GL_WINGDIAPI_DEFINED
100#endif /* WINGDIAPI */
101
102/* Some <GL/glu.h> files also need CALLBACK defined */
103#if !defined(CALLBACK) && defined(_WIN32)
104 #if defined(_MSC_VER)
105 /* Microsoft Visual C++ */
106 #if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
107 #define CALLBACK __stdcall
108 #else
109 #define CALLBACK
110 #endif
111 #else
112 /* Other Windows compilers */
113 #define CALLBACK __stdcall
114 #endif
115 #define GLU_CALLBACK_DEFINED
116#endif /* CALLBACK */
117
118/* Microsoft Visual C++, Borland C++ and Pelles C <GL*glu.h> needs wchar_t */
119#if defined(_WIN32) && (defined(_MSC_VER) || defined(__BORLANDC__) || defined(__POCC__)) && !defined(_WCHAR_T_DEFINED)
120 typedef unsigned short wchar_t;
121 #define _WCHAR_T_DEFINED
122#endif /* _WCHAR_T_DEFINED */
123
124
125/* ---------------- GLFW related system specific defines ----------------- */
126
127#if defined(_WIN32) && defined(GLFW_BUILD_DLL)
128
129 /* We are building a Win32 DLL */
Camilla Berglund2955cd32010-11-17 15:42:55 +0100130 #define GLFWAPI __declspec(dllexport)
Camilla Berglund3249f812010-09-07 17:34:51 +0200131
132#elif defined(_WIN32) && defined(GLFW_DLL)
133
134 /* We are calling a Win32 DLL */
135 #if defined(__LCC__)
Camilla Berglund2955cd32010-11-17 15:42:55 +0100136 #define GLFWAPI extern
Camilla Berglund3249f812010-09-07 17:34:51 +0200137 #else
Camilla Berglund2955cd32010-11-17 15:42:55 +0100138 #define GLFWAPI __declspec(dllimport)
Camilla Berglund3249f812010-09-07 17:34:51 +0200139 #endif
140
141#else
142
143 /* We are either building/calling a static lib or we are non-win32 */
144 #define GLFWAPI
145
146#endif
147
148/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
149
150/* Include standard OpenGL headers: GLFW uses GL_FALSE/GL_TRUE, and it is
151 * convenient for the user to only have to include <GL/glfw.h>. This also
152 * solves the problem with Windows <GL/gl.h> and <GL/glu.h> needing some
153 * special defines which normally requires the user to include <windows.h>
154 * (which is not a nice solution for portable programs).
155 */
156#if defined(__APPLE_CC__)
Camilla Berglund3e6d00a2010-10-27 14:13:24 +0200157 #define GL_GLEXT_LEGACY
Camilla Berglund3249f812010-09-07 17:34:51 +0200158 #include <OpenGL/gl.h>
159 #ifndef GLFW_NO_GLU
160 #include <OpenGL/glu.h>
161 #endif
162#else
163 #include <GL/gl.h>
164 #ifndef GLFW_NO_GLU
165 #include <GL/glu.h>
166 #endif
167#endif
168
169
170/*************************************************************************
171 * GLFW version
172 *************************************************************************/
173
Camilla Berglund38b0ccb2010-09-07 17:41:26 +0200174#define GLFW_VERSION_MAJOR 3
175#define GLFW_VERSION_MINOR 0
Camilla Berglund3249f812010-09-07 17:34:51 +0200176#define GLFW_VERSION_REVISION 0
177
178
179/*************************************************************************
180 * Input handling definitions
181 *************************************************************************/
182
183/* Key and button state/action definitions */
184#define GLFW_RELEASE 0
185#define GLFW_PRESS 1
186
Marcusc0cb4c22011-01-02 11:18:14 +0100187/* Keyboard raw key codes.
188 * These key codes are inspired by the USB HID Usage Tables v1.12 (p. 53-60),
189 * but re-arranged to map to 7-bit ASCII for printable keys (function keys are
190 * put in the 256+ range).
191 * The naming of the key codes follow these rules:
192 * - The US keyboard layout is used.
193 * - Names of printable alpha-numeric characters are used (e.g. "A", "R",
194 * "3", etc).
195 * - For non-alphanumeric characters, Unicode:ish names are used (e.g.
196 * "COMMA", "LEFT_SQUARE_BRACKET", etc). Note that some names do not
197 * correspond to the Unicode standard (usually for brevity).
198 * - Keys that lack a clear US mapping are named "WORLD_x".
199 * - For non-printable keys, custom names are used (e.g. "F4",
200 * "BACKSPACE", etc).
Camilla Berglund3249f812010-09-07 17:34:51 +0200201 */
Marcusc0cb4c22011-01-02 11:18:14 +0100202
203/* Printable keys */
204#define GLFW_KEY_SPACE 32
205#define GLFW_KEY_APOSTROPHE 39 /* ' */
206#define GLFW_KEY_COMMA 44 /* , */
207#define GLFW_KEY_MINUS 45 /* - */
208#define GLFW_KEY_PERIOD 46 /* . */
209#define GLFW_KEY_SLASH 47 /* / */
210#define GLFW_KEY_0 48
211#define GLFW_KEY_1 49
212#define GLFW_KEY_2 50
213#define GLFW_KEY_3 51
214#define GLFW_KEY_4 52
215#define GLFW_KEY_5 53
216#define GLFW_KEY_6 54
217#define GLFW_KEY_7 55
218#define GLFW_KEY_8 56
219#define GLFW_KEY_9 57
220#define GLFW_KEY_SEMICOLON 59 /* ; */
221#define GLFW_KEY_EQUAL 61 /* = */
222#define GLFW_KEY_A 65
223#define GLFW_KEY_B 66
224#define GLFW_KEY_C 67
225#define GLFW_KEY_D 68
226#define GLFW_KEY_E 69
227#define GLFW_KEY_F 70
228#define GLFW_KEY_G 71
229#define GLFW_KEY_H 72
230#define GLFW_KEY_I 73
231#define GLFW_KEY_J 74
232#define GLFW_KEY_K 75
233#define GLFW_KEY_L 76
234#define GLFW_KEY_M 77
235#define GLFW_KEY_N 78
236#define GLFW_KEY_O 79
237#define GLFW_KEY_P 80
238#define GLFW_KEY_Q 81
239#define GLFW_KEY_R 82
240#define GLFW_KEY_S 83
241#define GLFW_KEY_T 84
242#define GLFW_KEY_U 85
243#define GLFW_KEY_V 86
244#define GLFW_KEY_W 87
245#define GLFW_KEY_X 88
246#define GLFW_KEY_Y 89
247#define GLFW_KEY_Z 90
Marcus3b008472011-01-03 22:07:01 +0100248#define GLFW_KEY_LEFT_BRACKET 91 /* [ */
Marcusc0cb4c22011-01-02 11:18:14 +0100249#define GLFW_KEY_BACKSLASH 92 /* \ */
Marcus3b008472011-01-03 22:07:01 +0100250#define GLFW_KEY_RIGHT_BRACKET 93 /* ] */
Marcusc0cb4c22011-01-02 11:18:14 +0100251#define GLFW_KEY_GRAVE_ACCENT 96 /* ` */
252#define GLFW_KEY_WORLD_1 161 /* non-US #1 */
253#define GLFW_KEY_WORLD_2 162 /* non-US #2 */
254
255/* Function keys */
256#define GLFW_KEY_ESCAPE 256
257#define GLFW_KEY_ENTER 257
258#define GLFW_KEY_TAB 258
259#define GLFW_KEY_BACKSPACE 259
260#define GLFW_KEY_INSERT 260
261#define GLFW_KEY_DELETE 261
262#define GLFW_KEY_RIGHT 262
263#define GLFW_KEY_LEFT 263
264#define GLFW_KEY_DOWN 264
265#define GLFW_KEY_UP 265
266#define GLFW_KEY_PAGE_UP 266
267#define GLFW_KEY_PAGE_DOWN 267
268#define GLFW_KEY_HOME 268
269#define GLFW_KEY_END 269
270#define GLFW_KEY_CAPS_LOCK 280
271#define GLFW_KEY_SCROLL_LOCK 281
272#define GLFW_KEY_NUM_LOCK 282
273#define GLFW_KEY_PRINT_SCREEN 283
274#define GLFW_KEY_PAUSE 284
275#define GLFW_KEY_F1 290
276#define GLFW_KEY_F2 291
277#define GLFW_KEY_F3 292
278#define GLFW_KEY_F4 293
279#define GLFW_KEY_F5 294
280#define GLFW_KEY_F6 295
281#define GLFW_KEY_F7 296
282#define GLFW_KEY_F8 297
283#define GLFW_KEY_F9 298
284#define GLFW_KEY_F10 299
285#define GLFW_KEY_F11 300
286#define GLFW_KEY_F12 301
287#define GLFW_KEY_F13 302
288#define GLFW_KEY_F14 303
289#define GLFW_KEY_F15 304
290#define GLFW_KEY_F16 305
291#define GLFW_KEY_F17 306
292#define GLFW_KEY_F18 307
293#define GLFW_KEY_F19 308
294#define GLFW_KEY_F20 309
295#define GLFW_KEY_F21 310
296#define GLFW_KEY_F22 311
297#define GLFW_KEY_F23 312
298#define GLFW_KEY_F24 313
299#define GLFW_KEY_F25 314
300#define GLFW_KEY_KP_0 320
301#define GLFW_KEY_KP_1 321
302#define GLFW_KEY_KP_2 322
303#define GLFW_KEY_KP_3 323
304#define GLFW_KEY_KP_4 324
305#define GLFW_KEY_KP_5 325
306#define GLFW_KEY_KP_6 326
307#define GLFW_KEY_KP_7 327
308#define GLFW_KEY_KP_8 328
309#define GLFW_KEY_KP_9 329
310#define GLFW_KEY_KP_DECIMAL 330
311#define GLFW_KEY_KP_DIVIDE 331
312#define GLFW_KEY_KP_MULTIPLY 332
313#define GLFW_KEY_KP_SUBTRACT 333
314#define GLFW_KEY_KP_ADD 334
315#define GLFW_KEY_KP_ENTER 335
316#define GLFW_KEY_KP_EQUAL 336
317#define GLFW_KEY_LEFT_SHIFT 340
318#define GLFW_KEY_LEFT_CONTROL 341
319#define GLFW_KEY_LEFT_ALT 342
320#define GLFW_KEY_LEFT_SUPER 343
321#define GLFW_KEY_RIGHT_SHIFT 344
322#define GLFW_KEY_RIGHT_CONTROL 345
323#define GLFW_KEY_RIGHT_ALT 346
324#define GLFW_KEY_RIGHT_SUPER 347
325#define GLFW_KEY_MENU 348
326#define GLFW_KEY_LAST GLFW_KEY_MENU
327
328/* GLFW 2.x key name aliases (deprecated) */
329#define GLFW_KEY_ESC GLFW_KEY_ESCAPE
330#define GLFW_KEY_DEL GLFW_KEY_DELETE
331#define GLFW_KEY_PAGEUP GLFW_KEY_PAGE_UP
332#define GLFW_KEY_PAGEDOWN GLFW_KEY_PAGE_DOWN
333#define GLFW_KEY_KP_NUM_LOCK GLFW_KEY_NUM_LOCK
334#define GLFW_KEY_LCTRL GLFW_KEY_LEFT_CONTROL
335#define GLFW_KEY_LSHIFT GLFW_KEY_LEFT_SHIFT
336#define GLFW_KEY_LALT GLFW_KEY_LEFT_ALT
337#define GLFW_KEY_LSUPER GLFW_KEY_LEFT_SUPER
338#define GLFW_KEY_RCTRL GLFW_KEY_RIGHT_CONTROL
339#define GLFW_KEY_RSHIFT GLFW_KEY_RIGHT_SHIFT
340#define GLFW_KEY_RALT GLFW_KEY_RIGHT_ALT
341#define GLFW_KEY_RSUPER GLFW_KEY_RIGHT_SUPER
Camilla Berglund3249f812010-09-07 17:34:51 +0200342
343/* Mouse button definitions */
344#define GLFW_MOUSE_BUTTON_1 0
345#define GLFW_MOUSE_BUTTON_2 1
346#define GLFW_MOUSE_BUTTON_3 2
347#define GLFW_MOUSE_BUTTON_4 3
348#define GLFW_MOUSE_BUTTON_5 4
349#define GLFW_MOUSE_BUTTON_6 5
350#define GLFW_MOUSE_BUTTON_7 6
351#define GLFW_MOUSE_BUTTON_8 7
352#define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8
353
354/* Mouse button aliases */
355#define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1
356#define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2
357#define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3
358
359/* Joystick identifiers */
360#define GLFW_JOYSTICK_1 0
361#define GLFW_JOYSTICK_2 1
362#define GLFW_JOYSTICK_3 2
363#define GLFW_JOYSTICK_4 3
364#define GLFW_JOYSTICK_5 4
365#define GLFW_JOYSTICK_6 5
366#define GLFW_JOYSTICK_7 6
367#define GLFW_JOYSTICK_8 7
368#define GLFW_JOYSTICK_9 8
369#define GLFW_JOYSTICK_10 9
370#define GLFW_JOYSTICK_11 10
371#define GLFW_JOYSTICK_12 11
372#define GLFW_JOYSTICK_13 12
373#define GLFW_JOYSTICK_14 13
374#define GLFW_JOYSTICK_15 14
375#define GLFW_JOYSTICK_16 15
376#define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16
377
378
379/*************************************************************************
380 * Other definitions
381 *************************************************************************/
382
383/* glfwOpenWindow modes */
Camilla Berglund484a2712010-09-10 13:24:19 +0200384#define GLFW_WINDOWED 0x00010001
Camilla Berglund3249f812010-09-07 17:34:51 +0200385#define GLFW_FULLSCREEN 0x00010002
386
387/* glfwGetWindowParam tokens */
Camilla Berglund39dfa7d2010-11-15 21:39:46 +0100388#define GLFW_ACTIVE 0x00020001
389#define GLFW_ICONIFIED 0x00020002
390#define GLFW_ACCELERATED 0x00020003
Camilla Berglund950a3be2010-09-09 19:58:51 +0200391
392/* The following constants are used for both glfwGetWindowParam
393 * and glfwOpenWindowHint
394 */
Camilla Berglund39dfa7d2010-11-15 21:39:46 +0100395#define GLFW_RED_BITS 0x00020004
396#define GLFW_GREEN_BITS 0x00020005
397#define GLFW_BLUE_BITS 0x00020006
398#define GLFW_ALPHA_BITS 0x00020007
399#define GLFW_DEPTH_BITS 0x00020008
400#define GLFW_STENCIL_BITS 0x00020009
401#define GLFW_REFRESH_RATE 0x0002000A
402#define GLFW_ACCUM_RED_BITS 0x0002000B
403#define GLFW_ACCUM_GREEN_BITS 0x0002000C
404#define GLFW_ACCUM_BLUE_BITS 0x0002000D
405#define GLFW_ACCUM_ALPHA_BITS 0x0002000E
406#define GLFW_AUX_BUFFERS 0x0002000F
407#define GLFW_STEREO 0x00020010
408#define GLFW_WINDOW_NO_RESIZE 0x00020011
409#define GLFW_FSAA_SAMPLES 0x00020012
Camilla Berglund77e3b422011-01-02 00:11:47 +0100410#define GLFW_OPENGL_VERSION_MAJOR 0x00020013
411#define GLFW_OPENGL_VERSION_MINOR 0x00020014
412#define GLFW_OPENGL_FORWARD_COMPAT 0x00020015
413#define GLFW_OPENGL_DEBUG_CONTEXT 0x00020016
414#define GLFW_OPENGL_PROFILE 0x00020017
Camilla Berglundd43e0b52011-03-07 20:51:34 +0100415#define GLFW_OPENGL_ROBUSTNESS 0x00020018
416
417/* GLFW_OPENGL_ROBUSTNESS mode tokens */
418#define GLFW_OPENGL_NO_ROBUSTNESS 0x00000000
419#define GLFW_OPENGL_NO_RESET_NOTIFICATION 0x00000001
420#define GLFW_OPENGL_LOSE_CONTEXT_ON_RESET 0x00000002
Camilla Berglund3249f812010-09-07 17:34:51 +0200421
Camilla Berglund20662dd2010-11-15 21:40:43 +0100422/* GLFW_OPENGL_PROFILE bit tokens */
423#define GLFW_OPENGL_CORE_PROFILE 0x00000001
424#define GLFW_OPENGL_COMPAT_PROFILE 0x00000002
425#define GLFW_OPENGL_ES2_PROFILE 0x00000004
Camilla Berglund3249f812010-09-07 17:34:51 +0200426
427/* glfwEnable/glfwDisable tokens */
428#define GLFW_MOUSE_CURSOR 0x00030001
429#define GLFW_STICKY_KEYS 0x00030002
430#define GLFW_STICKY_MOUSE_BUTTONS 0x00030003
431#define GLFW_SYSTEM_KEYS 0x00030004
432#define GLFW_KEY_REPEAT 0x00030005
Camilla Berglund3249f812010-09-07 17:34:51 +0200433
434/* glfwGetJoystickParam tokens */
435#define GLFW_PRESENT 0x00050001
436#define GLFW_AXES 0x00050002
437#define GLFW_BUTTONS 0x00050003
438
Camilla Berglunde28543c2010-09-09 21:08:50 +0200439/* glfwGetError/glfwErrorString tokens */
440#define GLFW_NO_ERROR 0
441#define GLFW_NOT_INITIALIZED 0x00070001
Camilla Berglund52546172010-10-05 00:08:19 +0200442#define GLFW_NO_CURRENT_WINDOW 0x00070002
443#define GLFW_INVALID_ENUM 0x00070003
444#define GLFW_INVALID_VALUE 0x00070004
445#define GLFW_OUT_OF_MEMORY 0x00070005
446#define GLFW_OPENGL_UNAVAILABLE 0x00070006
447#define GLFW_VERSION_UNAVAILABLE 0x00070007
448#define GLFW_PLATFORM_ERROR 0x00070008
Camilla Berglund3249f812010-09-07 17:34:51 +0200449
Camilla Berglund2630d492010-10-13 04:04:43 +0200450/* Gamma ramps */
451#define GLFW_GAMMA_RAMP_SIZE 256
Camilla Berglund2c091572010-09-09 21:09:11 +0200452
Camilla Berglund3249f812010-09-07 17:34:51 +0200453/*************************************************************************
454 * Typedefs
455 *************************************************************************/
456
Camilla Berglund8d8eb0c2010-09-16 06:05:50 +0200457/* Window handle type */
Camilla Berglunda66a4cd2011-02-09 12:37:42 +0100458typedef void* GLFWwindow;
Camilla Berglund135194a2010-09-09 18:15:32 +0200459
Camilla Berglund897558f2011-03-07 13:34:58 +0100460/* Function pointer types */
461typedef void (* GLFWerrorfun)(int,const char*);
462typedef void (* GLFWwindowsizefun)(GLFWwindow,int,int);
463typedef int (* GLFWwindowclosefun)(GLFWwindow);
464typedef void (* GLFWwindowrefreshfun)(GLFWwindow);
465typedef void (* GLFWwindowfocusfun)(GLFWwindow,int);
466typedef void (* GLFWwindowiconifyfun)(GLFWwindow,int);
467typedef void (* GLFWmousebuttonfun)(GLFWwindow,int,int);
468typedef void (* GLFWmouseposfun)(GLFWwindow,int,int);
469typedef void (* GLFWscrollfun)(GLFWwindow,int,int);
470typedef void (* GLFWkeyfun)(GLFWwindow,int,int);
471typedef void (* GLFWcharfun)(GLFWwindow,int);
Camilla Berglundccbb9562011-03-07 14:09:13 +0100472typedef void* (* GLFWmallocfun)(size_t);
473typedef void (* GLFWfreefun)(void*);
Camilla Berglund897558f2011-03-07 13:34:58 +0100474
Camilla Berglund8d8eb0c2010-09-16 06:05:50 +0200475/* The video mode structure used by glfwGetVideoModes */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +0200476typedef struct
477{
478 int width;
479 int height;
480 int redBits;
481 int blueBits;
482 int greenBits;
Camilla Berglund3249f812010-09-07 17:34:51 +0200483} GLFWvidmode;
484
Camilla Berglund2630d492010-10-13 04:04:43 +0200485/* Gamma ramp */
486typedef struct
487{
488 unsigned short red[GLFW_GAMMA_RAMP_SIZE];
489 unsigned short green[GLFW_GAMMA_RAMP_SIZE];
490 unsigned short blue[GLFW_GAMMA_RAMP_SIZE];
491} GLFWgammaramp;
492
Camilla Berglundccbb9562011-03-07 14:09:13 +0100493/* Custom memory allocator interface */
494typedef struct
495{
496 GLFWmallocfun malloc;
497 GLFWfreefun free;
498} GLFWallocator;
499
500/* Custom threading model interface */
501typedef struct
502{
503} GLFWthreadmodel;
504
Camilla Berglund3249f812010-09-07 17:34:51 +0200505
506/*************************************************************************
507 * Prototypes
508 *************************************************************************/
509
Camilla Berglund16cf53b2010-09-20 00:38:06 +0200510/* Initialization, termination and version querying */
Camilla Berglund9a716692010-09-08 16:40:43 +0200511GLFWAPI int glfwInit(void);
Camilla Berglundccbb9562011-03-07 14:09:13 +0100512GLFWAPI int glfwInitWithModels(GLFWthreadmodel* threading, GLFWallocator* allocator);
Camilla Berglund9a716692010-09-08 16:40:43 +0200513GLFWAPI void glfwTerminate(void);
514GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
Camilla Berglundd6fe4472010-09-13 18:05:59 +0200515GLFWAPI const char* glfwGetVersionString(void);
Camilla Berglund3249f812010-09-07 17:34:51 +0200516
Camilla Berglundf5d74c42010-09-09 21:06:59 +0200517/* Error handling */
518GLFWAPI int glfwGetError(void);
519GLFWAPI const char* glfwErrorString(int error);
Camilla Berglundf1e7d7c2010-11-23 17:45:23 +0100520GLFWAPI void glfwSetErrorCallback(GLFWerrorfun cbfun);
Camilla Berglundf5d74c42010-09-09 21:06:59 +0200521
Camilla Berglund3249f812010-09-07 17:34:51 +0200522/* Video mode functions */
Camilla Berglund9a716692010-09-08 16:40:43 +0200523GLFWAPI int glfwGetVideoModes(GLFWvidmode* list, int maxcount);
524GLFWAPI void glfwGetDesktopMode(GLFWvidmode* mode);
Camilla Berglund3249f812010-09-07 17:34:51 +0200525
Camilla Berglund2630d492010-10-13 04:04:43 +0200526/* Gamma ramp functions */
527GLFWAPI void glfwSetGammaFormula(float gamma, float blacklevel, float gain);
528GLFWAPI void glfwGetGammaRamp(GLFWgammaramp* ramp);
529GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp);
530
Camilla Berglund135194a2010-09-09 18:15:32 +0200531/* Window handling */
Camilla Berglund99ddce32010-10-04 18:17:53 +0200532GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, int mode, const char* title, GLFWwindow share);
Camilla Berglund135194a2010-09-09 18:15:32 +0200533GLFWAPI void glfwOpenWindowHint(int target, int hint);
534GLFWAPI void glfwMakeWindowCurrent(GLFWwindow window);
Camilla Berglund29a0ca42010-09-09 18:42:41 +0200535GLFWAPI int glfwIsWindow(GLFWwindow window);
Camilla Berglund419f9f12010-10-04 23:13:33 +0200536GLFWAPI GLFWwindow glfwGetCurrentWindow(void);
Camilla Berglund135194a2010-09-09 18:15:32 +0200537GLFWAPI void glfwCloseWindow(GLFWwindow window);
538GLFWAPI void glfwSetWindowTitle(GLFWwindow, const char* title);
539GLFWAPI void glfwGetWindowSize(GLFWwindow, int* width, int* height);
540GLFWAPI void glfwSetWindowSize(GLFWwindow, int width, int height);
Camilla Berglunde0ba9e42011-02-09 12:57:11 +0100541GLFWAPI void glfwGetWindowPos(GLFWwindow, int* xpos, int* ypos);
542GLFWAPI void glfwSetWindowPos(GLFWwindow, int xpos, int ypos);
Camilla Berglund135194a2010-09-09 18:15:32 +0200543GLFWAPI void glfwIconifyWindow(GLFWwindow window);
544GLFWAPI void glfwRestoreWindow(GLFWwindow window);
545GLFWAPI int glfwGetWindowParam(GLFWwindow window, int param);
Camilla Berglund48f5a7e2010-09-09 22:44:38 +0200546GLFWAPI void glfwSetWindowUserPointer(GLFWwindow window, void* pointer);
547GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow window);
Camilla Berglund4044c2d2010-10-24 18:28:55 +0200548GLFWAPI void glfwSetWindowSizeCallback(GLFWwindowsizefun cbfun);
549GLFWAPI void glfwSetWindowCloseCallback(GLFWwindowclosefun cbfun);
550GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindowrefreshfun cbfun);
551GLFWAPI void glfwSetWindowFocusCallback(GLFWwindowfocusfun cbfun);
552GLFWAPI void glfwSetWindowIconifyCallback(GLFWwindowiconifyfun cbfun);
Camilla Berglund135194a2010-09-09 18:15:32 +0200553
554/* Event handling */
Camilla Berglund9a716692010-09-08 16:40:43 +0200555GLFWAPI void glfwPollEvents(void);
556GLFWAPI void glfwWaitEvents(void);
Camilla Berglund135194a2010-09-09 18:15:32 +0200557
558/* Input handling */
559GLFWAPI int glfwGetKey(GLFWwindow window, int key);
560GLFWAPI int glfwGetMouseButton(GLFWwindow window, int button);
561GLFWAPI void glfwGetMousePos(GLFWwindow window, int* xpos, int* ypos);
562GLFWAPI void glfwSetMousePos(GLFWwindow window, int xpos, int ypos);
Camilla Berglunde0ba9e42011-02-09 12:57:11 +0100563GLFWAPI void glfwGetScrollOffset(GLFWwindow window, int* xoffset, int* yoffset);
Camilla Berglund4044c2d2010-10-24 18:28:55 +0200564GLFWAPI void glfwSetKeyCallback(GLFWkeyfun cbfun);
565GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun);
566GLFWAPI void glfwSetMouseButtonCallback(GLFWmousebuttonfun cbfun);
567GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun);
568GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun);
Camilla Berglund3249f812010-09-07 17:34:51 +0200569
570/* Joystick input */
Camilla Berglund9a716692010-09-08 16:40:43 +0200571GLFWAPI int glfwGetJoystickParam(int joy, int param);
572GLFWAPI int glfwGetJoystickPos(int joy, float* pos, int numaxes);
573GLFWAPI int glfwGetJoystickButtons(int joy, unsigned char* buttons, int numbuttons);
Camilla Berglund3249f812010-09-07 17:34:51 +0200574
575/* Time */
Camilla Berglund9a716692010-09-08 16:40:43 +0200576GLFWAPI double glfwGetTime(void);
577GLFWAPI void glfwSetTime(double time);
Camilla Berglund3249f812010-09-07 17:34:51 +0200578
Camilla Berglund135194a2010-09-09 18:15:32 +0200579/* OpenGL support */
580GLFWAPI void glfwSwapBuffers(void);
581GLFWAPI void glfwSwapInterval(int interval);
Camilla Berglund9a716692010-09-08 16:40:43 +0200582GLFWAPI int glfwExtensionSupported(const char* extension);
583GLFWAPI void* glfwGetProcAddress(const char* procname);
584GLFWAPI void glfwGetGLVersion(int* major, int* minor, int* rev);
Camilla Berglund3249f812010-09-07 17:34:51 +0200585
586/* Enable/disable functions */
Camilla Berglund135194a2010-09-09 18:15:32 +0200587GLFWAPI void glfwEnable(GLFWwindow window, int token);
588GLFWAPI void glfwDisable(GLFWwindow window, int token);
Camilla Berglund3249f812010-09-07 17:34:51 +0200589
590
591#ifdef __cplusplus
592}
593#endif
594
Camilla Berglund36e54092010-11-09 02:58:35 +0100595#endif /* __glfw3_h__ */
Camilla Berglund3249f812010-09-07 17:34:51 +0200596