ruby-glfw 0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. data/README +1 -0
  2. data/README.API +73 -0
  3. data/Rakefile +120 -0
  4. data/examples/boing.rb +519 -0
  5. data/examples/gears.rb +327 -0
  6. data/examples/keytest.rb +117 -0
  7. data/examples/listmodes.rb +20 -0
  8. data/examples/mipmaps.rb +104 -0
  9. data/examples/mipmaps.tga +0 -0
  10. data/examples/particles.rb +837 -0
  11. data/examples/pong3d.rb +741 -0
  12. data/examples/pong3d_field.tga +0 -0
  13. data/examples/pong3d_instr.tga +0 -0
  14. data/examples/pong3d_menu.tga +0 -0
  15. data/examples/pong3d_title.tga +0 -0
  16. data/examples/pong3d_winner1.tga +0 -0
  17. data/examples/pong3d_winner2.tga +0 -0
  18. data/examples/splitview.rb +432 -0
  19. data/examples/triangle.rb +89 -0
  20. data/examples/wave.rb +294 -0
  21. data/ext/glfw/glfw.c +1094 -0
  22. data/ext/glfw/mkrf_conf.rb +70 -0
  23. data/glfw-src/Makefile +220 -0
  24. data/glfw-src/compile.ami +61 -0
  25. data/glfw-src/compile.bat +217 -0
  26. data/glfw-src/compile.sh +607 -0
  27. data/glfw-src/docs/Makefile +57 -0
  28. data/glfw-src/docs/Reference.pdf +0 -0
  29. data/glfw-src/docs/UsersGuide.pdf +0 -0
  30. data/glfw-src/docs/cleanup.bat +22 -0
  31. data/glfw-src/docs/glfwdoc.sty +80 -0
  32. data/glfw-src/docs/glfwrm.tex +3034 -0
  33. data/glfw-src/docs/glfwug.tex +2024 -0
  34. data/glfw-src/docs/readme.txt +80 -0
  35. data/glfw-src/examples/Makefile.amigaos.gcc +70 -0
  36. data/glfw-src/examples/Makefile.amigaos.vbcc +70 -0
  37. data/glfw-src/examples/Makefile.dos.djgpp +71 -0
  38. data/glfw-src/examples/Makefile.macosx.gcc +96 -0
  39. data/glfw-src/examples/Makefile.win32.bcc +75 -0
  40. data/glfw-src/examples/Makefile.win32.cross-mgw +79 -0
  41. data/glfw-src/examples/Makefile.win32.cygwin +79 -0
  42. data/glfw-src/examples/Makefile.win32.lcc +74 -0
  43. data/glfw-src/examples/Makefile.win32.mgw +75 -0
  44. data/glfw-src/examples/Makefile.win32.msvc +74 -0
  45. data/glfw-src/examples/Makefile.win32.ow +74 -0
  46. data/glfw-src/examples/Makefile.win32.pellesc +74 -0
  47. data/glfw-src/examples/Makefile.x11.in +54 -0
  48. data/glfw-src/examples/boing.c +606 -0
  49. data/glfw-src/examples/bundle.sh +46 -0
  50. data/glfw-src/examples/gears.c +382 -0
  51. data/glfw-src/examples/keytest.c +264 -0
  52. data/glfw-src/examples/listmodes.c +48 -0
  53. data/glfw-src/examples/mipmaps.c +126 -0
  54. data/glfw-src/examples/mipmaps.tga +0 -0
  55. data/glfw-src/examples/mtbench.c +301 -0
  56. data/glfw-src/examples/mthello.c +48 -0
  57. data/glfw-src/examples/particles.c +1148 -0
  58. data/glfw-src/examples/pong3d.c +839 -0
  59. data/glfw-src/examples/pong3d_field.tga +0 -0
  60. data/glfw-src/examples/pong3d_instr.tga +0 -0
  61. data/glfw-src/examples/pong3d_menu.tga +0 -0
  62. data/glfw-src/examples/pong3d_title.tga +0 -0
  63. data/glfw-src/examples/pong3d_winner1.tga +0 -0
  64. data/glfw-src/examples/pong3d_winner2.tga +0 -0
  65. data/glfw-src/examples/splitview.c +506 -0
  66. data/glfw-src/examples/triangle.c +108 -0
  67. data/glfw-src/examples/wave.c +397 -0
  68. data/glfw-src/images/opengl.gif +0 -0
  69. data/glfw-src/images/osicert.gif +0 -0
  70. data/glfw-src/include/GL/glfw.h +486 -0
  71. data/glfw-src/lib/amigaos/Makefile.amigaos.gcc +128 -0
  72. data/glfw-src/lib/amigaos/Makefile.amigaos.vbcc +128 -0
  73. data/glfw-src/lib/amigaos/SDI_compiler.h +94 -0
  74. data/glfw-src/lib/amigaos/amigaos_enable.c +51 -0
  75. data/glfw-src/lib/amigaos/amigaos_fullscreen.c +319 -0
  76. data/glfw-src/lib/amigaos/amigaos_glext.c +61 -0
  77. data/glfw-src/lib/amigaos/amigaos_init.c +284 -0
  78. data/glfw-src/lib/amigaos/amigaos_joystick.c +359 -0
  79. data/glfw-src/lib/amigaos/amigaos_thread.c +494 -0
  80. data/glfw-src/lib/amigaos/amigaos_time.c +206 -0
  81. data/glfw-src/lib/amigaos/amigaos_window.c +830 -0
  82. data/glfw-src/lib/amigaos/platform.h +337 -0
  83. data/glfw-src/lib/dos/Makefile.dos.djgpp +146 -0
  84. data/glfw-src/lib/dos/dos_enable.c +51 -0
  85. data/glfw-src/lib/dos/dos_events.c +173 -0
  86. data/glfw-src/lib/dos/dos_fullscreen.c +101 -0
  87. data/glfw-src/lib/dos/dos_glext.c +59 -0
  88. data/glfw-src/lib/dos/dos_init.c +105 -0
  89. data/glfw-src/lib/dos/dos_irq.s +246 -0
  90. data/glfw-src/lib/dos/dos_joystick.c +94 -0
  91. data/glfw-src/lib/dos/dos_keyboard.c +694 -0
  92. data/glfw-src/lib/dos/dos_mouse.c +337 -0
  93. data/glfw-src/lib/dos/dos_thread.c +267 -0
  94. data/glfw-src/lib/dos/dos_time.c +309 -0
  95. data/glfw-src/lib/dos/dos_window.c +563 -0
  96. data/glfw-src/lib/dos/platform.h +341 -0
  97. data/glfw-src/lib/enable.c +295 -0
  98. data/glfw-src/lib/fullscreen.c +95 -0
  99. data/glfw-src/lib/glext.c +201 -0
  100. data/glfw-src/lib/image.c +629 -0
  101. data/glfw-src/lib/init.c +108 -0
  102. data/glfw-src/lib/input.c +280 -0
  103. data/glfw-src/lib/internal.h +210 -0
  104. data/glfw-src/lib/joystick.c +101 -0
  105. data/glfw-src/lib/macosx/Makefile.macosx.gcc +172 -0
  106. data/glfw-src/lib/macosx/Makefile.macosx.gcc.universal +166 -0
  107. data/glfw-src/lib/macosx/libglfw.pc.in +11 -0
  108. data/glfw-src/lib/macosx/macosx_enable.c +42 -0
  109. data/glfw-src/lib/macosx/macosx_fullscreen.c +126 -0
  110. data/glfw-src/lib/macosx/macosx_glext.c +52 -0
  111. data/glfw-src/lib/macosx/macosx_init.c +194 -0
  112. data/glfw-src/lib/macosx/macosx_joystick.c +50 -0
  113. data/glfw-src/lib/macosx/macosx_thread.c +414 -0
  114. data/glfw-src/lib/macosx/macosx_time.c +112 -0
  115. data/glfw-src/lib/macosx/macosx_window.c +1279 -0
  116. data/glfw-src/lib/macosx/platform.h +349 -0
  117. data/glfw-src/lib/stream.c +194 -0
  118. data/glfw-src/lib/tga.c +405 -0
  119. data/glfw-src/lib/thread.c +340 -0
  120. data/glfw-src/lib/time.c +83 -0
  121. data/glfw-src/lib/win32/Makefile.win32.bcc +265 -0
  122. data/glfw-src/lib/win32/Makefile.win32.cross-mgw +274 -0
  123. data/glfw-src/lib/win32/Makefile.win32.cygwin +279 -0
  124. data/glfw-src/lib/win32/Makefile.win32.lcc +246 -0
  125. data/glfw-src/lib/win32/Makefile.win32.mgw +243 -0
  126. data/glfw-src/lib/win32/Makefile.win32.msvc +242 -0
  127. data/glfw-src/lib/win32/Makefile.win32.ow +242 -0
  128. data/glfw-src/lib/win32/Makefile.win32.pellesc +242 -0
  129. data/glfw-src/lib/win32/glfwdll.def +67 -0
  130. data/glfw-src/lib/win32/glfwdll_mgw1.def +67 -0
  131. data/glfw-src/lib/win32/glfwdll_mgw2.def +67 -0
  132. data/glfw-src/lib/win32/glfwdll_pellesc.def +65 -0
  133. data/glfw-src/lib/win32/libglfw.pc.in +11 -0
  134. data/glfw-src/lib/win32/platform.h +474 -0
  135. data/glfw-src/lib/win32/win32_dllmain.c +60 -0
  136. data/glfw-src/lib/win32/win32_enable.c +155 -0
  137. data/glfw-src/lib/win32/win32_fullscreen.c +317 -0
  138. data/glfw-src/lib/win32/win32_glext.c +85 -0
  139. data/glfw-src/lib/win32/win32_init.c +356 -0
  140. data/glfw-src/lib/win32/win32_joystick.c +234 -0
  141. data/glfw-src/lib/win32/win32_thread.c +511 -0
  142. data/glfw-src/lib/win32/win32_time.c +146 -0
  143. data/glfw-src/lib/win32/win32_window.c +1714 -0
  144. data/glfw-src/lib/window.c +727 -0
  145. data/glfw-src/lib/x11/Makefile.x11.in +243 -0
  146. data/glfw-src/lib/x11/platform.h +415 -0
  147. data/glfw-src/lib/x11/x11_enable.c +51 -0
  148. data/glfw-src/lib/x11/x11_fullscreen.c +524 -0
  149. data/glfw-src/lib/x11/x11_glext.c +69 -0
  150. data/glfw-src/lib/x11/x11_init.c +275 -0
  151. data/glfw-src/lib/x11/x11_joystick.c +371 -0
  152. data/glfw-src/lib/x11/x11_keysym2unicode.c +902 -0
  153. data/glfw-src/lib/x11/x11_thread.c +507 -0
  154. data/glfw-src/lib/x11/x11_time.c +154 -0
  155. data/glfw-src/lib/x11/x11_window.c +1746 -0
  156. data/glfw-src/license.txt +21 -0
  157. data/glfw-src/readme.html +927 -0
  158. data/glfw-src/support/d/examples/Makefile +59 -0
  159. data/glfw-src/support/d/examples/boing.d +610 -0
  160. data/glfw-src/support/d/examples/gears.d +379 -0
  161. data/glfw-src/support/d/examples/keytest.d +272 -0
  162. data/glfw-src/support/d/examples/listmodes.d +48 -0
  163. data/glfw-src/support/d/examples/mipmaps.d +126 -0
  164. data/glfw-src/support/d/examples/mtbench.d +304 -0
  165. data/glfw-src/support/d/examples/mthello.d +54 -0
  166. data/glfw-src/support/d/examples/particles.d +1150 -0
  167. data/glfw-src/support/d/examples/pong3d.d +840 -0
  168. data/glfw-src/support/d/examples/splitview.d +486 -0
  169. data/glfw-src/support/d/examples/triangle.d +108 -0
  170. data/glfw-src/support/d/examples/wave.d +400 -0
  171. data/glfw-src/support/d/imports/gl.d +4539 -0
  172. data/glfw-src/support/d/imports/glfw.d +349 -0
  173. data/glfw-src/support/d/imports/glu.d +328 -0
  174. data/glfw-src/support/d/lib/glfwdll.def +64 -0
  175. data/glfw-src/support/d/lib/glu32.def +56 -0
  176. data/glfw-src/support/d/lib/makefile +12 -0
  177. data/glfw-src/support/d/lib/opengl32.def +372 -0
  178. data/glfw-src/support/d/readme.html +83 -0
  179. data/glfw-src/support/delphi/examples/Triangle.dpr +105 -0
  180. data/glfw-src/support/delphi/lib/glfw.pas +437 -0
  181. data/glfw-src/support/delphi/readme.html +97 -0
  182. data/glfw-src/support/lua/examples/gears.lua +383 -0
  183. data/glfw-src/support/lua/examples/test1.lua +68 -0
  184. data/glfw-src/support/lua/readme.html +128 -0
  185. data/glfw-src/support/lua/src/luaglfw.c +1179 -0
  186. data/glfw-src/support/lua/src/luaglfw.h +48 -0
  187. data/glfw-src/support/lua/src/runlua.c +82 -0
  188. data/glfw-src/support/masm/examples/fpc.mac +47 -0
  189. data/glfw-src/support/masm/examples/makeit.bat +66 -0
  190. data/glfw-src/support/masm/examples/triangle.asm +232 -0
  191. data/glfw-src/support/masm/include/glfw.inc +326 -0
  192. data/glfw-src/support/masm/include/glu32.inc +55 -0
  193. data/glfw-src/support/masm/include/opengl32.inc +372 -0
  194. data/glfw-src/support/masm/lib/glfwdll.lib +0 -0
  195. data/glfw-src/support/masm/readme.html +170 -0
  196. data/glfw-src/support/msvc80/GLFW.sln +26 -0
  197. data/glfw-src/support/msvc80/GLFW.vcproj +257 -0
  198. data/glfw-src/support/msvc80/GLFWDLL.vcproj +287 -0
  199. data/glfw-src/support/visualbasic/bindings/glfw.bas +320 -0
  200. data/glfw-src/support/visualbasic/bindings/glu32.bas +284 -0
  201. data/glfw-src/support/visualbasic/bindings/opengl32.bas +999 -0
  202. data/glfw-src/support/visualbasic/examples/Triangle.bas +101 -0
  203. data/glfw-src/support/visualbasic/readme.html +164 -0
  204. data/website/index.html +84 -0
  205. data/website/style.css +110 -0
  206. metadata +301 -0
@@ -0,0 +1,727 @@
1
+ //========================================================================
2
+ // GLFW - An OpenGL framework
3
+ // File: window.c
4
+ // Platform: Any
5
+ // API version: 2.6
6
+ // WWW: http://glfw.sourceforge.net
7
+ //------------------------------------------------------------------------
8
+ // Copyright (c) 2002-2006 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
+
31
+ #include "internal.h"
32
+
33
+
34
+
35
+ //************************************************************************
36
+ //**** GLFW internal functions ****
37
+ //************************************************************************
38
+
39
+ //========================================================================
40
+ // Clear all open window hints
41
+ //========================================================================
42
+
43
+ void _glfwClearWindowHints( void )
44
+ {
45
+ _glfwWinHints.RefreshRate = 0;
46
+ _glfwWinHints.AccumRedBits = 0;
47
+ _glfwWinHints.AccumGreenBits = 0;
48
+ _glfwWinHints.AccumBlueBits = 0;
49
+ _glfwWinHints.AccumAlphaBits = 0;
50
+ _glfwWinHints.AuxBuffers = 0;
51
+ _glfwWinHints.Stereo = 0;
52
+ _glfwWinHints.WindowNoResize = 0;
53
+ _glfwWinHints.Samples = 0;
54
+ }
55
+
56
+
57
+ //========================================================================
58
+ // Handle the input tracking part of window deactivation
59
+ //========================================================================
60
+
61
+ void _glfwInputDeactivation( void )
62
+ {
63
+ int i;
64
+
65
+ // Release all keyboard keys
66
+ for( i = 0; i <= GLFW_KEY_LAST; i ++ )
67
+ {
68
+ if( _glfwInput.Key[ i ] == GLFW_PRESS )
69
+ {
70
+ _glfwInputKey( i, GLFW_RELEASE );
71
+ }
72
+ }
73
+
74
+ // Release all mouse buttons
75
+ for( i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i ++ )
76
+ {
77
+ if( _glfwInput.MouseButton[ i ] == GLFW_PRESS )
78
+ {
79
+ _glfwInputMouseClick( i, GLFW_RELEASE );
80
+ }
81
+ }
82
+ }
83
+
84
+
85
+ //========================================================================
86
+ // _glfwClearInput() - Clear all input state
87
+ //========================================================================
88
+
89
+ void _glfwClearInput( void )
90
+ {
91
+ int i;
92
+
93
+ // Release all keyboard keys
94
+ for( i = 0; i <= GLFW_KEY_LAST; i ++ )
95
+ {
96
+ _glfwInput.Key[ i ] = GLFW_RELEASE;
97
+ }
98
+
99
+ // Clear last character
100
+ _glfwInput.LastChar = 0;
101
+
102
+ // Release all mouse buttons
103
+ for( i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i ++ )
104
+ {
105
+ _glfwInput.MouseButton[ i ] = GLFW_RELEASE;
106
+ }
107
+
108
+ // Set mouse position to (0,0)
109
+ _glfwInput.MousePosX = 0;
110
+ _glfwInput.MousePosY = 0;
111
+
112
+ // Set mouse wheel position to 0
113
+ _glfwInput.WheelPos = 0;
114
+
115
+ // The default is to use non sticky keys and mouse buttons
116
+ _glfwInput.StickyKeys = GL_FALSE;
117
+ _glfwInput.StickyMouseButtons = GL_FALSE;
118
+
119
+ // The default is to disable key repeat
120
+ _glfwInput.KeyRepeat = GL_FALSE;
121
+ }
122
+
123
+
124
+ //========================================================================
125
+ // _glfwInputKey() - Register keyboard activity
126
+ //========================================================================
127
+
128
+ void _glfwInputKey( int key, int action )
129
+ {
130
+ int keyrepeat = 0;
131
+
132
+ if( key < 0 || key > GLFW_KEY_LAST )
133
+ {
134
+ return;
135
+ }
136
+
137
+ // Are we trying to release an already released key?
138
+ if( action == GLFW_RELEASE && _glfwInput.Key[ key ] != GLFW_PRESS )
139
+ {
140
+ return;
141
+ }
142
+
143
+ // Register key action
144
+ if( action == GLFW_RELEASE && _glfwInput.StickyKeys )
145
+ {
146
+ _glfwInput.Key[ key ] = GLFW_STICK;
147
+ }
148
+ else
149
+ {
150
+ keyrepeat = (_glfwInput.Key[ key ] == GLFW_PRESS) &&
151
+ (action == GLFW_PRESS);
152
+ _glfwInput.Key[ key ] = (char) action;
153
+ }
154
+
155
+ // Call user callback function
156
+ if( _glfwWin.KeyCallback && (_glfwInput.KeyRepeat || !keyrepeat) )
157
+ {
158
+ _glfwWin.KeyCallback( key, action );
159
+ }
160
+ }
161
+
162
+
163
+ //========================================================================
164
+ // _glfwInputChar() - Register (keyboard) character activity
165
+ //========================================================================
166
+
167
+ void _glfwInputChar( int character, int action )
168
+ {
169
+ int keyrepeat = 0;
170
+
171
+ // Valid Unicode (ISO 10646) character?
172
+ if( !( (character >= 32 && character <= 126) || character >= 160 ) )
173
+ {
174
+ return;
175
+ }
176
+
177
+ // Is this a key repeat?
178
+ if( action == GLFW_PRESS && _glfwInput.LastChar == character )
179
+ {
180
+ keyrepeat = 1;
181
+ }
182
+
183
+ // Store this character as last character (or clear it, if released)
184
+ if( action == GLFW_PRESS )
185
+ {
186
+ _glfwInput.LastChar = character;
187
+ }
188
+ else
189
+ {
190
+ _glfwInput.LastChar = 0;
191
+ }
192
+
193
+ // Call user callback function
194
+ if( _glfwWin.CharCallback && (_glfwInput.KeyRepeat || !keyrepeat) )
195
+ {
196
+ _glfwWin.CharCallback( character, action );
197
+ }
198
+ }
199
+
200
+
201
+ //========================================================================
202
+ // _glfwInputMouseClick() - Register mouse button clicks
203
+ //========================================================================
204
+
205
+ void _glfwInputMouseClick( int button, int action )
206
+ {
207
+ if( button >= 0 && button <= GLFW_MOUSE_BUTTON_LAST )
208
+ {
209
+ // Register mouse button action
210
+ if( action == GLFW_RELEASE && _glfwInput.StickyMouseButtons )
211
+ {
212
+ _glfwInput.MouseButton[ button ] = GLFW_STICK;
213
+ }
214
+ else
215
+ {
216
+ _glfwInput.MouseButton[ button ] = (char) action;
217
+ }
218
+
219
+ // Call user callback function
220
+ if( _glfwWin.MouseButtonCallback )
221
+ {
222
+ _glfwWin.MouseButtonCallback( button, action );
223
+ }
224
+ }
225
+ }
226
+
227
+
228
+
229
+ //************************************************************************
230
+ //**** GLFW user functions ****
231
+ //************************************************************************
232
+
233
+ //========================================================================
234
+ // glfwOpenWindow() - Here is where the window is created, and the OpenGL
235
+ // rendering context is created
236
+ //========================================================================
237
+
238
+ GLFWAPI int GLFWAPIENTRY glfwOpenWindow( int width, int height,
239
+ int redbits, int greenbits, int bluebits, int alphabits,
240
+ int depthbits, int stencilbits, int mode )
241
+ {
242
+ int x;
243
+ _GLFWhints hints;
244
+
245
+ // Is GLFW initialized?
246
+ if( !_glfwInitialized || _glfwWin.Opened )
247
+ {
248
+ return GL_FALSE;
249
+ }
250
+
251
+ // Copy and clear window hints
252
+ hints = _glfwWinHints;
253
+ _glfwClearWindowHints();
254
+
255
+ // Check input arguments
256
+ if( mode != GLFW_WINDOW && mode != GLFW_FULLSCREEN )
257
+ {
258
+ return GL_FALSE;
259
+ }
260
+
261
+ // Clear GLFW window state
262
+ _glfwWin.Active = GL_TRUE;
263
+ _glfwWin.Iconified = GL_FALSE;
264
+ _glfwWin.MouseLock = GL_FALSE;
265
+ _glfwWin.AutoPollEvents = GL_TRUE;
266
+ _glfwClearInput();
267
+
268
+ // Unregister all callback functions
269
+ _glfwWin.WindowSizeCallback = NULL;
270
+ _glfwWin.WindowCloseCallback = NULL;
271
+ _glfwWin.WindowRefreshCallback = NULL;
272
+ _glfwWin.KeyCallback = NULL;
273
+ _glfwWin.CharCallback = NULL;
274
+ _glfwWin.MousePosCallback = NULL;
275
+ _glfwWin.MouseButtonCallback = NULL;
276
+ _glfwWin.MouseWheelCallback = NULL;
277
+
278
+ // Check width & height
279
+ if( width > 0 && height <= 0 )
280
+ {
281
+ // Set the window aspect ratio to 4:3
282
+ height = (width * 3) / 4;
283
+ }
284
+ else if( width <= 0 && height > 0 )
285
+ {
286
+ // Set the window aspect ratio to 4:3
287
+ width = (height * 4) / 3;
288
+ }
289
+ else if( width <= 0 && height <= 0 )
290
+ {
291
+ // Default window size
292
+ width = 640;
293
+ height = 480;
294
+ }
295
+
296
+ // Remember window settings
297
+ _glfwWin.Width = width;
298
+ _glfwWin.Height = height;
299
+ _glfwWin.Fullscreen = (mode == GLFW_FULLSCREEN ? 1 : 0);
300
+
301
+ // Platform specific window opening routine
302
+ if( !_glfwPlatformOpenWindow( width, height, redbits, greenbits,
303
+ bluebits, alphabits, depthbits, stencilbits, mode, &hints ) )
304
+ {
305
+ return GL_FALSE;
306
+ }
307
+
308
+ // Flag that window is now opened
309
+ _glfwWin.Opened = GL_TRUE;
310
+
311
+ // Get window parameters (such as color buffer bits etc)
312
+ _glfwPlatformRefreshWindowParams();
313
+
314
+ // Get OpenGL version
315
+ glfwGetGLVersion( &_glfwWin.GLVerMajor, &_glfwWin.GLVerMinor, &x );
316
+
317
+ // Do we have non-power-of-two textures?
318
+ _glfwWin.Has_GL_ARB_texture_non_power_of_two =
319
+ glfwExtensionSupported( "GL_ARB_texture_non_power_of_two" );
320
+
321
+ // Do we have automatic mipmap generation?
322
+ _glfwWin.Has_GL_SGIS_generate_mipmap =
323
+ (_glfwWin.GLVerMajor >= 2) || (_glfwWin.GLVerMinor >= 4) ||
324
+ glfwExtensionSupported( "GL_SGIS_generate_mipmap" );
325
+
326
+ // If full-screen mode was requested, disable mouse cursor
327
+ if( mode == GLFW_FULLSCREEN )
328
+ {
329
+ glfwDisable( GLFW_MOUSE_CURSOR );
330
+ }
331
+
332
+ return GL_TRUE;
333
+ }
334
+
335
+
336
+ //========================================================================
337
+ // glfwOpenWindowHint() - Set hints for opening the window
338
+ //========================================================================
339
+
340
+ GLFWAPI void GLFWAPIENTRY glfwOpenWindowHint( int target, int hint )
341
+ {
342
+ // Is GLFW initialized?
343
+ if( !_glfwInitialized )
344
+ {
345
+ return;
346
+ }
347
+
348
+ switch( target )
349
+ {
350
+ case GLFW_REFRESH_RATE:
351
+ _glfwWinHints.RefreshRate = hint;
352
+ break;
353
+ case GLFW_ACCUM_RED_BITS:
354
+ _glfwWinHints.AccumRedBits = hint;
355
+ break;
356
+ case GLFW_ACCUM_GREEN_BITS:
357
+ _glfwWinHints.AccumGreenBits = hint;
358
+ break;
359
+ case GLFW_ACCUM_BLUE_BITS:
360
+ _glfwWinHints.AccumBlueBits = hint;
361
+ break;
362
+ case GLFW_ACCUM_ALPHA_BITS:
363
+ _glfwWinHints.AccumAlphaBits = hint;
364
+ break;
365
+ case GLFW_AUX_BUFFERS:
366
+ _glfwWinHints.AuxBuffers = hint;
367
+ break;
368
+ case GLFW_STEREO:
369
+ _glfwWinHints.Stereo = hint;
370
+ break;
371
+ case GLFW_WINDOW_NO_RESIZE:
372
+ _glfwWinHints.WindowNoResize = hint;
373
+ break;
374
+ case GLFW_FSAA_SAMPLES:
375
+ _glfwWinHints.Samples = hint;
376
+ break;
377
+ default:
378
+ break;
379
+ }
380
+ }
381
+
382
+
383
+ //========================================================================
384
+ // glfwCloseWindow() - Properly kill the window / video display
385
+ //========================================================================
386
+
387
+ GLFWAPI void GLFWAPIENTRY glfwCloseWindow( void )
388
+ {
389
+ // Is GLFW initialized?
390
+ if( !_glfwInitialized )
391
+ {
392
+ return;
393
+ }
394
+
395
+ // Show mouse pointer again (if hidden)
396
+ glfwEnable( GLFW_MOUSE_CURSOR );
397
+
398
+ // Close window
399
+ _glfwPlatformCloseWindow();
400
+
401
+ // Window is no longer opened
402
+ _glfwWin.Opened = GL_FALSE;
403
+ }
404
+
405
+
406
+ //========================================================================
407
+ // glfwSetWindowTitle() - Set the window title
408
+ //========================================================================
409
+
410
+ GLFWAPI void GLFWAPIENTRY glfwSetWindowTitle( const char *title )
411
+ {
412
+ // Is GLFW initialized?
413
+ if( !_glfwInitialized || !_glfwWin.Opened )
414
+ {
415
+ return;
416
+ }
417
+
418
+ // Set window title
419
+ _glfwPlatformSetWindowTitle( title );
420
+ }
421
+
422
+
423
+ //========================================================================
424
+ // glfwGetWindowSize() - Get the window size
425
+ //========================================================================
426
+
427
+ GLFWAPI void GLFWAPIENTRY glfwGetWindowSize( int *width, int *height )
428
+ {
429
+ if( width != NULL )
430
+ {
431
+ *width = _glfwWin.Width;
432
+ }
433
+ if( height != NULL )
434
+ {
435
+ *height = _glfwWin.Height;
436
+ }
437
+ }
438
+
439
+
440
+ //========================================================================
441
+ // glfwSetWindowSize() - Set the window size
442
+ //========================================================================
443
+
444
+ GLFWAPI void GLFWAPIENTRY glfwSetWindowSize( int width, int height )
445
+ {
446
+ // Is GLFW initialized?
447
+ if( !_glfwInitialized || !_glfwWin.Opened || _glfwWin.Iconified )
448
+ {
449
+ return;
450
+ }
451
+
452
+ // Don't do anything if the window size did not change
453
+ if( width == _glfwWin.Width && height == _glfwWin.Height )
454
+ {
455
+ return;
456
+ }
457
+
458
+ // Change window size
459
+ _glfwPlatformSetWindowSize( width, height );
460
+
461
+ // Refresh window parameters (may have changed due to changed video
462
+ // modes)
463
+ _glfwPlatformRefreshWindowParams();
464
+ }
465
+
466
+
467
+ //========================================================================
468
+ // glfwSetWindowPos() - Set the window position
469
+ //========================================================================
470
+
471
+ GLFWAPI void GLFWAPIENTRY glfwSetWindowPos( int x, int y )
472
+ {
473
+ // Is GLFW initialized?
474
+ if( !_glfwInitialized || !_glfwWin.Opened || _glfwWin.Fullscreen ||
475
+ _glfwWin.Iconified )
476
+ {
477
+ return;
478
+ }
479
+
480
+ // Set window position
481
+ _glfwPlatformSetWindowPos( x, y );
482
+ }
483
+
484
+
485
+ //========================================================================
486
+ // glfwIconfyWindow() - Window iconification
487
+ //========================================================================
488
+
489
+ GLFWAPI void GLFWAPIENTRY glfwIconifyWindow( void )
490
+ {
491
+ // Is GLFW initialized?
492
+ if( !_glfwInitialized || !_glfwWin.Opened || _glfwWin.Iconified )
493
+ {
494
+ return;
495
+ }
496
+
497
+ // Iconify window
498
+ _glfwPlatformIconifyWindow();
499
+ }
500
+
501
+
502
+ //========================================================================
503
+ // glfwRestoreWindow() - Window un-iconification
504
+ //========================================================================
505
+
506
+ GLFWAPI void GLFWAPIENTRY glfwRestoreWindow( void )
507
+ {
508
+ // Is GLFW initialized?
509
+ if( !_glfwInitialized || !_glfwWin.Opened || !_glfwWin.Iconified )
510
+ {
511
+ return;
512
+ }
513
+
514
+ // Restore iconified window
515
+ _glfwPlatformRestoreWindow();
516
+
517
+ // Refresh window parameters
518
+ _glfwPlatformRefreshWindowParams();
519
+ }
520
+
521
+
522
+ //========================================================================
523
+ // glfwSwapBuffers() - Swap buffers (double-buffering) and poll any new
524
+ // events
525
+ //========================================================================
526
+
527
+ GLFWAPI void GLFWAPIENTRY glfwSwapBuffers( void )
528
+ {
529
+ // Is GLFW initialized?
530
+ if( !_glfwInitialized || !_glfwWin.Opened )
531
+ {
532
+ return;
533
+ }
534
+
535
+ // Check for window messages
536
+ if( _glfwWin.AutoPollEvents )
537
+ {
538
+ glfwPollEvents();
539
+ }
540
+
541
+ // Update display-buffer
542
+ if( _glfwWin.Opened )
543
+ {
544
+ _glfwPlatformSwapBuffers();
545
+ }
546
+ }
547
+
548
+
549
+ //========================================================================
550
+ // glfwSwapInterval() - Set double buffering swap interval (0 = vsync off)
551
+ //========================================================================
552
+
553
+ GLFWAPI void GLFWAPIENTRY glfwSwapInterval( int interval )
554
+ {
555
+ // Is GLFW initialized?
556
+ if( !_glfwInitialized || !_glfwWin.Opened )
557
+ {
558
+ return;
559
+ }
560
+
561
+ // Set double buffering swap interval
562
+ _glfwPlatformSwapInterval( interval );
563
+ }
564
+
565
+
566
+ //========================================================================
567
+ // glfwGetWindowParam() - Get window parameter
568
+ //========================================================================
569
+
570
+ GLFWAPI int GLFWAPIENTRY glfwGetWindowParam( int param )
571
+ {
572
+ // Is GLFW initialized?
573
+ if( !_glfwInitialized )
574
+ {
575
+ return 0;
576
+ }
577
+
578
+ // Is the window opened?
579
+ if( !_glfwWin.Opened )
580
+ {
581
+ if( param == GLFW_OPENED )
582
+ {
583
+ return GL_FALSE;
584
+ }
585
+ return 0;
586
+ }
587
+
588
+ // Window parameters
589
+ switch( param )
590
+ {
591
+ case GLFW_OPENED:
592
+ return GL_TRUE;
593
+ case GLFW_ACTIVE:
594
+ return _glfwWin.Active;
595
+ case GLFW_ICONIFIED:
596
+ return _glfwWin.Iconified;
597
+ case GLFW_ACCELERATED:
598
+ return _glfwWin.Accelerated;
599
+ case GLFW_RED_BITS:
600
+ return _glfwWin.RedBits;
601
+ case GLFW_GREEN_BITS:
602
+ return _glfwWin.GreenBits;
603
+ case GLFW_BLUE_BITS:
604
+ return _glfwWin.BlueBits;
605
+ case GLFW_ALPHA_BITS:
606
+ return _glfwWin.AlphaBits;
607
+ case GLFW_DEPTH_BITS:
608
+ return _glfwWin.DepthBits;
609
+ case GLFW_STENCIL_BITS:
610
+ return _glfwWin.StencilBits;
611
+ case GLFW_ACCUM_RED_BITS:
612
+ return _glfwWin.AccumRedBits;
613
+ case GLFW_ACCUM_GREEN_BITS:
614
+ return _glfwWin.AccumGreenBits;
615
+ case GLFW_ACCUM_BLUE_BITS:
616
+ return _glfwWin.AccumBlueBits;
617
+ case GLFW_ACCUM_ALPHA_BITS:
618
+ return _glfwWin.AccumAlphaBits;
619
+ case GLFW_AUX_BUFFERS:
620
+ return _glfwWin.AuxBuffers;
621
+ case GLFW_STEREO:
622
+ return _glfwWin.Stereo;
623
+ case GLFW_REFRESH_RATE:
624
+ return _glfwWin.RefreshRate;
625
+ case GLFW_WINDOW_NO_RESIZE:
626
+ return _glfwWin.WindowNoResize;
627
+ case GLFW_FSAA_SAMPLES:
628
+ return _glfwWin.Samples;
629
+ default:
630
+ return 0;
631
+ }
632
+ }
633
+
634
+
635
+ //========================================================================
636
+ // glfwSetWindowSizeCallback() - Set callback function for window size
637
+ // changes
638
+ //========================================================================
639
+
640
+ GLFWAPI void GLFWAPIENTRY glfwSetWindowSizeCallback( GLFWwindowsizefun cbfun )
641
+ {
642
+ // Is GLFW initialized?
643
+ if( !_glfwInitialized || !_glfwWin.Opened )
644
+ {
645
+ return;
646
+ }
647
+
648
+ // Set callback function
649
+ _glfwWin.WindowSizeCallback = cbfun;
650
+
651
+ // Call the callback function to let the application know the current
652
+ // window size
653
+ if( cbfun )
654
+ {
655
+ cbfun( _glfwWin.Width, _glfwWin.Height );
656
+ }
657
+ }
658
+
659
+ //========================================================================
660
+ // glfwSetWindowCloseCallback() - Set callback function for window close
661
+ // events
662
+ //========================================================================
663
+
664
+ GLFWAPI void GLFWAPIENTRY glfwSetWindowCloseCallback( GLFWwindowclosefun cbfun )
665
+ {
666
+ // Is GLFW initialized?
667
+ if( !_glfwInitialized || !_glfwWin.Opened )
668
+ {
669
+ return;
670
+ }
671
+
672
+ // Set callback function
673
+ _glfwWin.WindowCloseCallback = cbfun;
674
+ }
675
+
676
+
677
+ //========================================================================
678
+ // glfwSetWindowRefreshCallback() - Set callback function for window
679
+ // refresh events
680
+ //========================================================================
681
+
682
+ GLFWAPI void GLFWAPIENTRY glfwSetWindowRefreshCallback( GLFWwindowrefreshfun cbfun )
683
+ {
684
+ // Is GLFW initialized?
685
+ if( !_glfwInitialized || !_glfwWin.Opened )
686
+ {
687
+ return;
688
+ }
689
+
690
+ // Set callback function
691
+ _glfwWin.WindowRefreshCallback = cbfun;
692
+ }
693
+
694
+
695
+ //========================================================================
696
+ // glfwPollEvents() - Poll for new window and input events
697
+ //========================================================================
698
+
699
+ GLFWAPI void GLFWAPIENTRY glfwPollEvents( void )
700
+ {
701
+ // Is GLFW initialized?
702
+ if( !_glfwInitialized || !_glfwWin.Opened )
703
+ {
704
+ return;
705
+ }
706
+
707
+ // Poll for new events
708
+ _glfwPlatformPollEvents();
709
+ }
710
+
711
+
712
+ //========================================================================
713
+ // glfwWaitEvents() - Wait for new window and input events
714
+ //========================================================================
715
+
716
+ GLFWAPI void GLFWAPIENTRY glfwWaitEvents( void )
717
+ {
718
+ // Is GLFW initialized?
719
+ if( !_glfwInitialized || !_glfwWin.Opened )
720
+ {
721
+ return;
722
+ }
723
+
724
+ // Poll for new events
725
+ _glfwPlatformWaitEvents();
726
+ }
727
+