1 module deimos.glfw.glfw2;
2 /************************************************************************
3  * GLFW - An OpenGL framework
4  * API version: 2.7
5  * WWW:         http://www.glfw.org/
6  *------------------------------------------------------------------------
7  * Copyright (c) 2002-2006 Marcus Geelnard
8  * Copyright (c) 2006-2010 Camilla Berglund
9  *
10  * This software is provided 'as-is', without any express or implied
11  * warranty. In no event will the authors be held liable for any damages
12  * arising from the use of this software.
13  *
14  * Permission is granted to anyone to use this software for any purpose,
15  * including commercial applications, and to alter it and redistribute it
16  * freely, subject to the following restrictions:
17  *
18  * 1. The origin of this software must not be misrepresented; you must not
19  *    claim that you wrote the original software. If you use this software
20  *    in a product, an acknowledgment in the product documentation would
21  *    be appreciated but is not required.
22  *
23  * 2. Altered source versions must be plainly marked as such, and must not
24  *    be misrepresented as being the original software.
25  *
26  * 3. This notice may not be removed or altered from any source
27  *    distribution.
28  *
29  *************************************************************************/
30 extern (C) {
31 
32   enum { 
33     /*************************************************************************
34      * GLFW version
35      *************************************************************************/
36     GLFW_VERSION_MAJOR = 2,
37     GLFW_VERSION_MINOR = 7,
38     GLFW_VERSION_REVISION = 2,
39 
40   /*************************************************************************
41    * Input handling definitions
42    *************************************************************************/
43 
44   /* Key and button state/action definitions */
45   GLFW_RELEASE =            0,
46   GLFW_PRESS =              1,
47 
48   /* Keyboard key definitions: 8-bit ISO-8859-1 (Latin 1) encoding is used
49    * for printable keys (such as A-Z, 0-9 etc), and values above 256
50    * represent special (non-printable) keys (e.g. F1, Page Up etc).
51    */
52   GLFW_KEY_UNKNOWN =      -1,
53   GLFW_KEY_SPACE =        32,
54   GLFW_KEY_SPECIAL =      256,
55   GLFW_KEY_ESC =          (GLFW_KEY_SPECIAL+1),
56   GLFW_KEY_F1 =           (GLFW_KEY_SPECIAL+2),
57   GLFW_KEY_F2 =           (GLFW_KEY_SPECIAL+3),
58   GLFW_KEY_F3 =           (GLFW_KEY_SPECIAL+4),
59   GLFW_KEY_F4 =           (GLFW_KEY_SPECIAL+5),
60   GLFW_KEY_F5 =           (GLFW_KEY_SPECIAL+6),
61   GLFW_KEY_F6 =           (GLFW_KEY_SPECIAL+7),
62   GLFW_KEY_F7 =           (GLFW_KEY_SPECIAL+8),
63   GLFW_KEY_F8 =           (GLFW_KEY_SPECIAL+9),
64   GLFW_KEY_F9 =           (GLFW_KEY_SPECIAL+10),
65   GLFW_KEY_F10 =          (GLFW_KEY_SPECIAL+11),
66   GLFW_KEY_F11 =          (GLFW_KEY_SPECIAL+12),
67   GLFW_KEY_F12 =          (GLFW_KEY_SPECIAL+13),
68   GLFW_KEY_F13 =          (GLFW_KEY_SPECIAL+14),
69   GLFW_KEY_F14 =          (GLFW_KEY_SPECIAL+15),
70   GLFW_KEY_F15 =          (GLFW_KEY_SPECIAL+16),
71   GLFW_KEY_F16 =          (GLFW_KEY_SPECIAL+17),
72   GLFW_KEY_F17 =          (GLFW_KEY_SPECIAL+18),
73   GLFW_KEY_F18 =          (GLFW_KEY_SPECIAL+19),
74   GLFW_KEY_F19 =          (GLFW_KEY_SPECIAL+20),
75   GLFW_KEY_F20 =          (GLFW_KEY_SPECIAL+21),
76   GLFW_KEY_F21 =          (GLFW_KEY_SPECIAL+22),
77   GLFW_KEY_F22 =          (GLFW_KEY_SPECIAL+23),
78   GLFW_KEY_F23 =          (GLFW_KEY_SPECIAL+24),
79   GLFW_KEY_F24 =          (GLFW_KEY_SPECIAL+25),
80   GLFW_KEY_F25 =          (GLFW_KEY_SPECIAL+26),
81   GLFW_KEY_UP =           (GLFW_KEY_SPECIAL+27),
82   GLFW_KEY_DOWN =         (GLFW_KEY_SPECIAL+28),
83   GLFW_KEY_LEFT =         (GLFW_KEY_SPECIAL+29),
84   GLFW_KEY_RIGHT =        (GLFW_KEY_SPECIAL+30),
85   GLFW_KEY_LSHIFT =       (GLFW_KEY_SPECIAL+31),
86   GLFW_KEY_RSHIFT =       (GLFW_KEY_SPECIAL+32),
87   GLFW_KEY_LCTRL =        (GLFW_KEY_SPECIAL+33),
88   GLFW_KEY_RCTRL =        (GLFW_KEY_SPECIAL+34),
89   GLFW_KEY_LALT =         (GLFW_KEY_SPECIAL+35),
90   GLFW_KEY_RALT =         (GLFW_KEY_SPECIAL+36),
91   GLFW_KEY_TAB =          (GLFW_KEY_SPECIAL+37),
92   GLFW_KEY_ENTER =        (GLFW_KEY_SPECIAL+38),
93   GLFW_KEY_BACKSPACE =    (GLFW_KEY_SPECIAL+39),
94   GLFW_KEY_INSERT =       (GLFW_KEY_SPECIAL+40),
95   GLFW_KEY_DEL =          (GLFW_KEY_SPECIAL+41),
96   GLFW_KEY_PAGEUP =       (GLFW_KEY_SPECIAL+42),
97   GLFW_KEY_PAGEDOWN =     (GLFW_KEY_SPECIAL+43),
98   GLFW_KEY_HOME =         (GLFW_KEY_SPECIAL+44),
99   GLFW_KEY_END =          (GLFW_KEY_SPECIAL+45),
100   GLFW_KEY_KP_0 =         (GLFW_KEY_SPECIAL+46),
101   GLFW_KEY_KP_1 =         (GLFW_KEY_SPECIAL+47),
102   GLFW_KEY_KP_2 =         (GLFW_KEY_SPECIAL+48),
103   GLFW_KEY_KP_3 =         (GLFW_KEY_SPECIAL+49),
104   GLFW_KEY_KP_4 =         (GLFW_KEY_SPECIAL+50),
105   GLFW_KEY_KP_5 =         (GLFW_KEY_SPECIAL+51),
106   GLFW_KEY_KP_6 =         (GLFW_KEY_SPECIAL+52),
107   GLFW_KEY_KP_7 =         (GLFW_KEY_SPECIAL+53),
108   GLFW_KEY_KP_8 =         (GLFW_KEY_SPECIAL+54),
109   GLFW_KEY_KP_9 =         (GLFW_KEY_SPECIAL+55),
110   GLFW_KEY_KP_DIVIDE =    (GLFW_KEY_SPECIAL+56),
111   GLFW_KEY_KP_MULTIPLY =  (GLFW_KEY_SPECIAL+57),
112   GLFW_KEY_KP_SUBTRACT =  (GLFW_KEY_SPECIAL+58),
113   GLFW_KEY_KP_ADD =       (GLFW_KEY_SPECIAL+59),
114   GLFW_KEY_KP_DECIMAL =   (GLFW_KEY_SPECIAL+60),
115   GLFW_KEY_KP_EQUAL =     (GLFW_KEY_SPECIAL+61),
116   GLFW_KEY_KP_ENTER =     (GLFW_KEY_SPECIAL+62),
117   GLFW_KEY_KP_NUM_LOCK =  (GLFW_KEY_SPECIAL+63),
118   GLFW_KEY_CAPS_LOCK =    (GLFW_KEY_SPECIAL+64),
119   GLFW_KEY_SCROLL_LOCK =  (GLFW_KEY_SPECIAL+65),
120   GLFW_KEY_PAUSE =        (GLFW_KEY_SPECIAL+66),
121   GLFW_KEY_LSUPER =       (GLFW_KEY_SPECIAL+67),
122   GLFW_KEY_RSUPER =       (GLFW_KEY_SPECIAL+68),
123   GLFW_KEY_MENU =         (GLFW_KEY_SPECIAL+69),
124   GLFW_KEY_LAST =         GLFW_KEY_MENU,
125   /* Mouse button definitions */
126   GLFW_MOUSE_BUTTON_1 =      0,
127   GLFW_MOUSE_BUTTON_2 =      1,
128   GLFW_MOUSE_BUTTON_3 =      2,
129   GLFW_MOUSE_BUTTON_4 =      3,
130   GLFW_MOUSE_BUTTON_5 =      4,
131   GLFW_MOUSE_BUTTON_6 =      5,
132   GLFW_MOUSE_BUTTON_7 =      6,
133   GLFW_MOUSE_BUTTON_8 =      7,
134   GLFW_MOUSE_BUTTON_LAST =   GLFW_MOUSE_BUTTON_8,
135   /* Mouse button aliases */
136   GLFW_MOUSE_BUTTON_LEFT =   GLFW_MOUSE_BUTTON_1,
137   GLFW_MOUSE_BUTTON_RIGHT =  GLFW_MOUSE_BUTTON_2,
138   GLFW_MOUSE_BUTTON_MIDDLE = GLFW_MOUSE_BUTTON_3,
139   /* Joystick identifiers */
140   GLFW_JOYSTICK_1 =          0,
141   GLFW_JOYSTICK_2 =          1,
142   GLFW_JOYSTICK_3 =          2,
143   GLFW_JOYSTICK_4 =          3,
144   GLFW_JOYSTICK_5 =          4,
145   GLFW_JOYSTICK_6 =          5,
146   GLFW_JOYSTICK_7 =          6,
147   GLFW_JOYSTICK_8 =          7,
148   GLFW_JOYSTICK_9 =          8,
149   GLFW_JOYSTICK_10 =         9,
150   GLFW_JOYSTICK_11 =         10,
151   GLFW_JOYSTICK_12 =         11,
152   GLFW_JOYSTICK_13 =         12,
153   GLFW_JOYSTICK_14 =         13,
154   GLFW_JOYSTICK_15 =         14,
155   GLFW_JOYSTICK_16 =         15,
156   GLFW_JOYSTICK_LAST =       GLFW_JOYSTICK_16,
157   /*************************************************************************
158    * Other definitions;
159    *************************************************************************/
160   /* glfwOpenWindow modes */
161   GLFW_WINDOW =               0x00010001,
162   GLFW_FULLSCREEN =           0x00010002,
163   /* glfwGetWindowParam tokens */
164   GLFW_OPENED =               0x00020001,
165   GLFW_ACTIVE =               0x00020002,
166   GLFW_ICONIFIED =            0x00020003,
167   GLFW_ACCELERATED =          0x00020004,
168   GLFW_RED_BITS =             0x00020005,
169   GLFW_GREEN_BITS =           0x00020006,
170   GLFW_BLUE_BITS =            0x00020007,
171   GLFW_ALPHA_BITS =           0x00020008,
172   GLFW_DEPTH_BITS =           0x00020009,
173   GLFW_STENCIL_BITS =         0x0002000A,
174   /* The following constants are used for both glfwGetWindowParam
175    * and glfwOpenWindowHint;
176    */
177   GLFW_REFRESH_RATE =         0x0002000B,
178   GLFW_ACCUM_RED_BITS =       0x0002000C,
179   GLFW_ACCUM_GREEN_BITS =     0x0002000D,
180   GLFW_ACCUM_BLUE_BITS =      0x0002000E,
181   GLFW_ACCUM_ALPHA_BITS =     0x0002000F,
182   GLFW_AUX_BUFFERS =          0x00020010,
183   GLFW_STEREO =               0x00020011,
184   GLFW_WINDOW_NO_RESIZE =     0x00020012,
185   GLFW_FSAA_SAMPLES =         0x00020013,
186   GLFW_OPENGL_VERSION_MAJOR = 0x00020014,
187   GLFW_OPENGL_VERSION_MINOR = 0x00020015,
188   GLFW_OPENGL_FORWARD_COMPAT = 0x00020016,
189   GLFW_OPENGL_DEBUG_CONTEXT = 0x00020017,
190   GLFW_OPENGL_PROFILE =       0x00020018,
191 
192   /* GLFW_OPENGL_PROFILE tokens */
193   GLFW_OPENGL_CORE_PROFILE =  0x00050001,
194   GLFW_OPENGL_COMPAT_PROFILE = 0x00050002,
195 
196   /* glfwEnable/glfwDisable tokens */
197   GLFW_MOUSE_CURSOR =         0x00030001,
198   GLFW_STICKY_KEYS =          0x00030002,
199   GLFW_STICKY_MOUSE_BUTTONS = 0x00030003,
200   GLFW_SYSTEM_KEYS =          0x00030004,
201   GLFW_KEY_REPEAT =           0x00030005,
202   GLFW_AUTO_POLL_EVENTS =     0x00030006,
203 
204   /* glfwWaitThread wait modes */
205   GLFW_WAIT =                 0x00040001,
206   GLFW_NOWAIT =               0x00040002,
207 
208   /* glfwGetJoystickParam tokens */
209   GLFW_PRESENT =              0x00050001,
210   GLFW_AXES =                 0x00050002,
211   GLFW_BUTTONS =              0x00050003,
212 
213   /* glfwReadImage/glfwLoadTexture2D flags */
214   GLFW_NO_RESCALE_BIT =       0x00000001,/* Only for glfwReadImage */ 
215   GLFW_ORIGIN_UL_BIT =        0x00000002,
216   GLFW_BUILD_MIPMAPS_BIT =    0x00000004,/* Only for glfwLoadTexture2D */
217   GLFW_ALPHA_MAP_BIT =        0x00000008,
218 
219   /* Time spans longer than this (seconds) are considered to be infinity */
220   GLFW_INFINITY = 100000.0
221 }
222 
223   /*************************************************************************
224    * Typedefs
225    *************************************************************************/
226 
227   /* The video mode structure used by glfwGetVideoModes() */
228   struct GLFWvidmode {
229     int Width, Height;
230     int RedBits, BlueBits, GreenBits;
231   }
232 
233   /* Image/texture information */
234   struct GLFWimage {
235     int Width, Height;
236     int Format;
237     int BytesPerPixel;
238     ubyte* Data;
239   }
240 
241   /* Thread ID */
242   alias int GLFWthread;
243 
244   /* Mutex object */
245   alias void* GLFWmutex;
246 
247   /* Condition variable object */
248   alias void* GLFWcond;
249 
250   /* Function pointer types */
251   alias void function(int,int)  GLFWwindowsizefun;
252   alias int  function()         GLFWwindowclosefun;
253   alias void function()         GLFWwindowrefreshfun;
254   alias void function(int,int)  GLFWmousebuttonfun;
255   alias void function(int,int)  GLFWmouseposfun;
256   alias void function(int)      GLFWmousewheelfun;
257   alias void function(int,int)  GLFWkeyfun;
258   alias void function(int,int)  GLFWcharfun;
259   alias void function(void*)    GLFWthreadfun;
260 
261 
262   /*************************************************************************
263    * Prototypes
264    *************************************************************************/
265 
266   /* GLFW initialization, termination and version querying */
267 
268   int  glfwInit();
269   void glfwTerminate();
270   void glfwGetVersion( int *major, int *minor, int *rev );
271 
272   /* Window handling */
273   int  glfwOpenWindow( int width, int height, int redbits, int greenbits, int bluebits, int alphabits, int depthbits, int stencilbits, int mode );
274   void glfwOpenWindowHint( int target, int hint );
275   void glfwCloseWindow();
276   void glfwSetWindowTitle( const(char)* title );
277   void glfwGetWindowSize( int *width, int *height );
278   void glfwSetWindowSize( int width, int height );
279   void glfwSetWindowPos( int x, int y );
280   void glfwIconifyWindow();
281   void glfwRestoreWindow();
282   void glfwSwapBuffers();
283   void glfwSwapInterval( int interval );
284   int  glfwGetWindowParam( int param );
285   void glfwSetWindowSizeCallback( GLFWwindowsizefun cbfun );
286   void glfwSetWindowCloseCallback( GLFWwindowclosefun cbfun );
287   void glfwSetWindowRefreshCallback( GLFWwindowrefreshfun cbfun );
288 
289   /* Video mode functions */
290   int  glfwGetVideoModes( GLFWvidmode *list, int maxcount );
291   void glfwGetDesktopMode( GLFWvidmode *mode );
292 
293   /* Input handling */
294   void glfwPollEvents();
295   void glfwWaitEvents();
296   int  glfwGetKey( int key );
297   int  glfwGetMouseButton( int button );
298   void glfwGetMousePos( int *xpos, int *ypos );
299   void glfwSetMousePos( int xpos, int ypos );
300   int  glfwGetMouseWheel();
301   void glfwSetMouseWheel( int pos );
302   void glfwSetKeyCallback( GLFWkeyfun cbfun );
303   void glfwSetCharCallback( GLFWcharfun cbfun );
304   void glfwSetMouseButtonCallback( GLFWmousebuttonfun cbfun );
305   void glfwSetMousePosCallback( GLFWmouseposfun cbfun );
306   void glfwSetMouseWheelCallback( GLFWmousewheelfun cbfun );
307 
308   /* Joystick input */
309   int glfwGetJoystickParam( int joy, int param );
310   int glfwGetJoystickPos( int joy, float *pos, int numaxes );
311   int glfwGetJoystickButtons( int joy, ubyte *buttons, int numbuttons );
312 
313   /* Time */
314   double glfwGetTime();
315   void   glfwSetTime( double time );
316   void   glfwSleep( double time );
317 
318   /* Extension support */
319   int   glfwExtensionSupported( const(char)* extension );
320   void* glfwGetProcAddress( const(char)* procname );
321   void  glfwGetGLVersion( int *major, int *minor, int *rev );
322 
323   /* Threading support */
324   GLFWthread glfwCreateThread( GLFWthreadfun fun, void *arg );
325   void glfwDestroyThread( GLFWthread ID );
326   int  glfwWaitThread( GLFWthread ID, int waitmode );
327   GLFWthread glfwGetThreadID();
328   GLFWmutex glfwCreateMutex();
329   void glfwDestroyMutex( GLFWmutex mutex );
330   void glfwLockMutex( GLFWmutex mutex );
331   void glfwUnlockMutex( GLFWmutex mutex );
332   GLFWcond glfwCreateCond();
333   void glfwDestroyCond( GLFWcond cond );
334   void glfwWaitCond( GLFWcond cond, GLFWmutex mutex, double timeout );
335   void glfwSignalCond( GLFWcond cond );
336   void glfwBroadcastCond( GLFWcond cond );
337   int  glfwGetNumberOfProcessors();
338 
339   /* Enable/disable functions */
340   void glfwEnable( int token );
341   void glfwDisable( int token );
342 
343   /* Image/texture I/O support */
344   int  glfwReadImage( const(char)* name, GLFWimage *img, int flags );
345   int  glfwReadMemoryImage( const void *data, long size, GLFWimage *img, int flags );
346   void glfwFreeImage( GLFWimage *img );
347   int  glfwLoadTexture2D( const(char)* name, int flags );
348   int  glfwLoadMemoryTexture2D( const void *data, long size, int flags );
349   int  glfwLoadTextureImage2D( GLFWimage *img, int flags );
350 
351 }
352