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,206 @@
1
+ //========================================================================
2
+ // GLFW - An OpenGL framework
3
+ // File: amigaos_time.c
4
+ // Platforms: AmigaOS, MorphOS
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
+ // _glfwInitTimer() - Initialize timer
41
+ //========================================================================
42
+
43
+ int _glfwInitTimer( void )
44
+ {
45
+ ULONG freq;
46
+ struct EClockVal t;
47
+
48
+ // Start by clearing all handles
49
+ TimerBase = NULL;
50
+ _glfwTimer.TimerMP = NULL;
51
+ _glfwTimer.TimerIO = NULL;
52
+
53
+ // Open timer.device (used as a library for ReadEClock)
54
+ if( (_glfwTimer.TimerMP = CreatePort( NULL, 0 )) )
55
+ {
56
+ // Create the I/O request
57
+ if( (_glfwTimer.TimerIO = (struct timerequest *)
58
+ CreateExtIO(_glfwTimer.TimerMP, sizeof(struct timerequest))) )
59
+ {
60
+ // Open the timer device
61
+ if( !( OpenDevice( "timer.device", UNIT_MICROHZ,
62
+ (struct IORequest *) _glfwTimer.TimerIO,
63
+ 0 ) ) )
64
+ {
65
+ // Set up pointer for timer functions
66
+ TimerBase =
67
+ (struct Device *)_glfwTimer.TimerIO->tr_node.io_Device;
68
+ }
69
+ else
70
+ {
71
+ return 0;
72
+ }
73
+ }
74
+ else
75
+ {
76
+ return 0;
77
+ }
78
+ }
79
+ else
80
+ {
81
+ return 0;
82
+ }
83
+
84
+ // Get current time
85
+ freq = ReadEClock( &t );
86
+
87
+ // Calculate resolution
88
+ _glfwTimer.Resolution = 1.0 / (double) freq;
89
+
90
+ // Convert to 64-bit integer
91
+ _glfwTimer.t0 = (long long) t.ev_hi * (long long) 4294967296 +
92
+ (long long) t.ev_lo;
93
+
94
+ return 1;
95
+ }
96
+
97
+
98
+ //========================================================================
99
+ // _glfwTerminateTimer() - Terminate timer
100
+ //========================================================================
101
+
102
+ void _glfwTerminateTimer( void )
103
+ {
104
+ // Empty the timer.device message port queue
105
+ if( _glfwTimer.TimerMP )
106
+ {
107
+ struct Message *msg;
108
+ while( NULL != (msg = GetMsg( _glfwTimer.TimerMP )) )
109
+ {
110
+ ReplyMsg( msg );
111
+ }
112
+ }
113
+
114
+ // Close timer.device
115
+ if( TimerBase )
116
+ {
117
+ CloseDevice( (struct IORequest *) _glfwTimer.TimerIO );
118
+ TimerBase = NULL;
119
+ }
120
+
121
+ // Delete timer.device I/O request
122
+ if( _glfwTimer.TimerIO )
123
+ {
124
+ DeleteExtIO( (struct IORequest *) _glfwTimer.TimerIO );
125
+ _glfwTimer.TimerIO = NULL;
126
+ }
127
+
128
+ // Delete timer.device message port
129
+ if( _glfwTimer.TimerMP )
130
+ {
131
+ DeletePort( _glfwTimer.TimerMP );
132
+ _glfwTimer.TimerMP = NULL;
133
+ }
134
+ }
135
+
136
+
137
+ //************************************************************************
138
+ //**** Platform implementation functions ****
139
+ //************************************************************************
140
+
141
+ //========================================================================
142
+ // _glfwPlatformGetTime() - Return timer value in seconds
143
+ //========================================================================
144
+
145
+ double _glfwPlatformGetTime( void )
146
+ {
147
+ struct EClockVal t;
148
+ long long t64;
149
+
150
+ // Get current time
151
+ (void) ReadEClock( &t );
152
+
153
+ // Convert to 64-bit integer
154
+ t64 = (long long) t.ev_hi * (long long) 4294967296 +
155
+ (long long) t.ev_lo;
156
+
157
+ return (double)(t64 - _glfwTimer.t0) * _glfwTimer.Resolution;
158
+ }
159
+
160
+
161
+ //========================================================================
162
+ // _glfwPlatformSetTime() - Set timer value in seconds
163
+ //========================================================================
164
+
165
+ void _glfwPlatformSetTime( double t )
166
+ {
167
+ struct EClockVal t0;
168
+ long long t64;
169
+
170
+ // Get current time
171
+ (void) ReadEClock( &t0 );
172
+
173
+ // Convert to 64-bit integer
174
+ t64 = (long long) t0.ev_hi * (long long) 4294967296 +
175
+ (long long) t0.ev_lo;
176
+
177
+ // Calulate new starting time
178
+ _glfwTimer.t0 = t64 - (long long)(t/_glfwTimer.Resolution);
179
+ }
180
+
181
+
182
+ //========================================================================
183
+ // _glfwPlatformSleep() - Put a thread to sleep for a specified amount of
184
+ // time
185
+ //========================================================================
186
+
187
+ void _glfwPlatformSleep( double time )
188
+ {
189
+ ULONG ticks;
190
+
191
+ // Too short time?
192
+ if( time <= 0.0 )
193
+ {
194
+ return;
195
+ }
196
+
197
+ // Calculate Delay ticks (should be 50 ticks per second)
198
+ ticks = (ULONG) ((double)TICKS_PER_SECOND * time + 0.5);
199
+ if( ticks == 0 )
200
+ {
201
+ ticks = 1;
202
+ }
203
+
204
+ // Put process to sleep
205
+ Delay( ticks );
206
+ }
@@ -0,0 +1,830 @@
1
+ //========================================================================
2
+ // GLFW - An OpenGL framework
3
+ // File: amigaos_window.c
4
+ // Platforms: AmigaOS, MorphOS
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
+ //**** GLFW internal functions ****
36
+ //************************************************************************
37
+
38
+ //========================================================================
39
+ // _glfwTranslateChar() - Translates an AmigaOS key to Unicode
40
+ //========================================================================
41
+
42
+ static int _glfwTranslateChar( struct IntuiMessage *msg )
43
+ {
44
+ struct InputEvent event;
45
+ unsigned char buffer[ 4 ];
46
+ int character;
47
+
48
+ // Create input event
49
+ event.ie_Class = IECLASS_RAWKEY;
50
+ event.ie_Code = msg->Code;
51
+ event.ie_Qualifier = msg->Qualifier;
52
+ event.ie_EventAddress = msg->IAddress;
53
+
54
+ // Map key event to text string
55
+ if( MapRawKey( &event, buffer, 4, NULL ) > 0 )
56
+ {
57
+ // Valid Unicode character?
58
+ character = (int) buffer[ 0 ];
59
+ if( (character >= 32 && character <= 126) ||
60
+ (character >= 160 && character <= 255) )
61
+ {
62
+ return character;
63
+ }
64
+ }
65
+
66
+ return -1;
67
+ }
68
+
69
+
70
+ //========================================================================
71
+ // _glfwTranslateKey() - Translates an AmigaOS key to internal coding
72
+ //========================================================================
73
+
74
+ static int _glfwTranslateKey( struct IntuiMessage *msg )
75
+ {
76
+ int key = msg->Code & 0x7F;
77
+ ULONG old_qualifier;
78
+
79
+ // Special (non printable) keys
80
+ switch( key )
81
+ {
82
+ // Modifier keys
83
+ case 0x60: return GLFW_KEY_LSHIFT;
84
+ case 0x61: return GLFW_KEY_RSHIFT;
85
+ case 0x62: return GLFW_KEY_LCTRL; // ?
86
+ case 0x63: return GLFW_KEY_RCTRL; // ?
87
+ case 0x64: return GLFW_KEY_LALT;
88
+ case 0x65: return GLFW_KEY_RALT;
89
+
90
+ // Function keys
91
+ case 0x50: return GLFW_KEY_F1;
92
+ case 0x51: return GLFW_KEY_F2;
93
+ case 0x52: return GLFW_KEY_F3;
94
+ case 0x53: return GLFW_KEY_F4;
95
+ case 0x54: return GLFW_KEY_F5;
96
+ case 0x55: return GLFW_KEY_F6;
97
+ case 0x56: return GLFW_KEY_F7;
98
+ case 0x57: return GLFW_KEY_F8;
99
+ case 0x58: return GLFW_KEY_F9;
100
+ case 0x59: return GLFW_KEY_F10;
101
+
102
+ // Other control keys
103
+ case 0x45: return GLFW_KEY_ESC;
104
+ case 0x42: return GLFW_KEY_TAB;
105
+ case 0x44: return GLFW_KEY_ENTER;
106
+ case 0x46: return GLFW_KEY_DEL;
107
+ case 0x41: return GLFW_KEY_BACKSPACE;
108
+ case 0x66: return GLFW_KEY_INSERT; // ?
109
+ case 0x4F: return GLFW_KEY_LEFT;
110
+ case 0x4E: return GLFW_KEY_RIGHT;
111
+ case 0x4C: return GLFW_KEY_UP;
112
+ case 0x4D: return GLFW_KEY_DOWN;
113
+
114
+ // Keypad keys
115
+ case 0x0F: return GLFW_KEY_KP_0;
116
+ case 0x1D: return GLFW_KEY_KP_1;
117
+ case 0x1E: return GLFW_KEY_KP_2;
118
+ case 0x1F: return GLFW_KEY_KP_3;
119
+ case 0x2D: return GLFW_KEY_KP_4;
120
+ case 0x2E: return GLFW_KEY_KP_5;
121
+ case 0x2F: return GLFW_KEY_KP_6;
122
+ case 0x3D: return GLFW_KEY_KP_7;
123
+ case 0x3E: return GLFW_KEY_KP_8;
124
+ case 0x3F: return GLFW_KEY_KP_9;
125
+ case 0x43: return GLFW_KEY_KP_ENTER;
126
+ case 0x5E: return GLFW_KEY_KP_ADD;
127
+ case 0x4A: return GLFW_KEY_KP_SUBTRACT;
128
+ case 0x5D: return GLFW_KEY_KP_MULTIPLY;
129
+ case 0x5C: return GLFW_KEY_KP_DIVIDE;
130
+ case 0x3C: return GLFW_KEY_KP_DECIMAL;
131
+
132
+ default: break;
133
+ }
134
+
135
+ // Printable keys (without modifiers!)
136
+ old_qualifier = msg->Qualifier;
137
+ msg->Qualifier = 0;
138
+ key = _glfwTranslateChar( msg );
139
+ msg->Qualifier = old_qualifier;
140
+ if( key > 0 )
141
+ {
142
+ // Make sure it is upper case
143
+ key = ToUpper( key );
144
+ }
145
+
146
+ return key;
147
+ }
148
+
149
+
150
+ //========================================================================
151
+ // _glfwProcessEvents() - Process all pending AmigaOS events
152
+ //========================================================================
153
+
154
+ static int _glfwProcessEvents( void )
155
+ {
156
+ struct IntuiMessage message, *tmp_message = NULL;
157
+ struct MsgPort *msg_port;
158
+ int win_closed = GL_FALSE, action;
159
+ int x, y;
160
+
161
+ // Examine pending messages
162
+ msg_port = _glfwWin.Window->UserPort;
163
+ while( (tmp_message = (struct IntuiMessage *) GetMsg( msg_port )) )
164
+ {
165
+ // Copy contents of message structure
166
+ message = *tmp_message;
167
+
168
+ // Now reply to the message (we don't need it anymore)
169
+ ReplyMsg( (struct Message *) tmp_message );
170
+
171
+ // Handle different messages
172
+ switch( message.Class )
173
+ {
174
+
175
+ // Was the window activated?
176
+ case IDCMP_ACTIVEWINDOW:
177
+ _glfwWin.Active = GL_TRUE;
178
+ break;
179
+
180
+ // Was the window deactivated?
181
+ case IDCMP_INACTIVEWINDOW:
182
+ _glfwWin.Active = GL_FALSE;
183
+ _glfwInputDeactivation();
184
+ break;
185
+
186
+ // Did we get a keyboard press or release?
187
+ case IDCMP_RAWKEY:
188
+ action = (message.Code & 0x80) ? GLFW_RELEASE : GLFW_PRESS;
189
+ message.Code &= 0x7F;
190
+ _glfwInputKey( _glfwTranslateKey( &message ), action );
191
+ _glfwInputChar( _glfwTranslateChar( &message ), action );
192
+ break;
193
+
194
+ // Was the mouse moved?
195
+ case IDCMP_MOUSEMOVE:
196
+ x = message.MouseX;
197
+ y = message.MouseY;
198
+ if( _glfwWin.PointerHidden )
199
+ {
200
+ // When pointer is hidden, we get delta moves
201
+ x += _glfwInput.MousePosX;
202
+ y += _glfwInput.MousePosY;
203
+ }
204
+ else if( x < 0 || x >= _glfwWin.Width ||
205
+ y < 0 || y >= _glfwWin.Height )
206
+ {
207
+ // Only report mouse moves that are INSIDE client area
208
+ break;
209
+ }
210
+ if( x != _glfwInput.MousePosX || y != _glfwInput.MousePosY )
211
+ {
212
+ _glfwInput.MousePosX = x;
213
+ _glfwInput.MousePosY = y;
214
+ if( _glfwWin.MousePosCallback )
215
+ {
216
+ _glfwWin.MousePosCallback( x, y );
217
+ }
218
+ }
219
+ break;
220
+
221
+ // Did we get a mouse button event?
222
+ case IDCMP_MOUSEBUTTONS:
223
+ switch( message.Code )
224
+ {
225
+ case SELECTUP:
226
+ _glfwInputMouseClick( GLFW_MOUSE_BUTTON_LEFT,
227
+ GLFW_RELEASE );
228
+ break;
229
+ case SELECTDOWN:
230
+ _glfwInputMouseClick( GLFW_MOUSE_BUTTON_LEFT,
231
+ GLFW_PRESS );
232
+ break;
233
+ case MENUUP:
234
+ _glfwInputMouseClick( GLFW_MOUSE_BUTTON_RIGHT,
235
+ GLFW_RELEASE );
236
+ break;
237
+ case MENUDOWN:
238
+ _glfwInputMouseClick( GLFW_MOUSE_BUTTON_RIGHT,
239
+ GLFW_PRESS );
240
+ break;
241
+ default:
242
+ break;
243
+ }
244
+ break;
245
+
246
+ // Was the window size changed?
247
+ case IDCMP_NEWSIZE:
248
+ _glfwWin.Width = message.IDCMPWindow->GZZWidth;
249
+ _glfwWin.Height = message.IDCMPWindow->GZZHeight;
250
+ if( _glfwWin.WindowSizeCallback )
251
+ {
252
+ _glfwWin.WindowSizeCallback( _glfwWin.Width,
253
+ _glfwWin.Height );
254
+ }
255
+ break;
256
+
257
+ // Was the window contents damaged?
258
+ case IDCMP_REFRESHWINDOW:
259
+ // Intuition wants us to do this...
260
+ BeginRefresh( _glfwWin.Window );
261
+ EndRefresh( _glfwWin.Window, TRUE );
262
+
263
+ // Call user callback function
264
+ if( _glfwWin.WindowRefreshCallback )
265
+ {
266
+ _glfwWin.WindowRefreshCallback();
267
+ }
268
+ break;
269
+
270
+ // Was the window closed?
271
+ case IDCMP_CLOSEWINDOW:
272
+ win_closed = GL_TRUE;
273
+ break;
274
+
275
+ default:
276
+ break;
277
+ }
278
+ }
279
+
280
+ // Return GL_TRUE if window was closed
281
+ return( win_closed );
282
+ }
283
+
284
+
285
+
286
+ //************************************************************************
287
+ //**** Platform implementation functions ****
288
+ //************************************************************************
289
+
290
+ //========================================================================
291
+ // _glfwPlatformOpenWindow() - Here is where the window is created, and
292
+ // the OpenGL rendering context is created
293
+ //========================================================================
294
+
295
+ int _glfwPlatformOpenWindow( int width, int height, int redbits,
296
+ int greenbits, int bluebits, int alphabits, int depthbits,
297
+ int stencilbits, int mode, int accumredbits, int accumgreenbits,
298
+ int accumbluebits, int accumalphabits, int auxbuffers, int stereo,
299
+ int refreshrate )
300
+ {
301
+ struct TagItem tagList[ 25 ];
302
+ int tagNR, accumbits;
303
+
304
+ // Calculate sum of accumulator bits
305
+ accumbits = accumredbits + accumgreenbits + accumbluebits +
306
+ accumalphabits;
307
+
308
+ // Clear window state
309
+ _glfwWin.Screen = NULL;
310
+ _glfwWin.Window = NULL;
311
+ _glfwWin.Context = NULL;
312
+ _glfwWin.PointerHidden = 0;
313
+ _glfwWin.PointerSprite = NULL;
314
+ _glfwWin.InputMP = NULL;
315
+ _glfwWin.InputIO = NULL;
316
+
317
+ // Create input.device message port
318
+ if( !(_glfwWin.InputMP = CreatePort( NULL, 0 )) )
319
+ {
320
+ _glfwPlatformCloseWindow();
321
+ return GL_FALSE;
322
+ }
323
+
324
+ // Create input.device I/O request
325
+ if( !(_glfwWin.InputIO = (struct IOStdReq *)
326
+ CreateExtIO( _glfwWin.InputMP, sizeof(struct IOStdReq) )) )
327
+ {
328
+ _glfwPlatformCloseWindow();
329
+ return GL_FALSE;
330
+ }
331
+
332
+ // Open input.device (for pointer position manipulation)
333
+ if( OpenDevice( "input.device", 0,
334
+ (struct IORequest *)_glfwWin.InputIO, 0 ) )
335
+ {
336
+ DeleteExtIO( (struct IORequest *) _glfwWin.InputIO );
337
+ _glfwWin.InputIO = NULL;
338
+ _glfwPlatformCloseWindow();
339
+ return GL_FALSE;
340
+ }
341
+
342
+ // Do we want fullscreen?
343
+ if( _glfwWin.Fullscreen )
344
+ {
345
+ // Open a new Amiga screen
346
+ if( !_glfwOpenScreen( &width, &height, &redbits, &greenbits,
347
+ &bluebits, refreshrate ) )
348
+ {
349
+ _glfwWin.Fullscreen = GL_FALSE;
350
+ }
351
+ }
352
+
353
+ // Select window properties
354
+ tagNR = 0;
355
+ tagList[ tagNR ].ti_Tag = WA_Left;
356
+ tagList[ tagNR++ ].ti_Data = 0;
357
+ tagList[ tagNR ].ti_Tag = WA_Top;
358
+ tagList[ tagNR++ ].ti_Data = 0;
359
+ tagList[ tagNR ].ti_Tag = WA_IDCMP;
360
+ tagList[ tagNR++ ].ti_Data = IDCMP_REFRESHWINDOW |
361
+ IDCMP_CLOSEWINDOW |
362
+ IDCMP_NEWSIZE |
363
+ IDCMP_ACTIVEWINDOW |
364
+ IDCMP_INACTIVEWINDOW |
365
+ IDCMP_RAWKEY |
366
+ IDCMP_MOUSEMOVE |
367
+ IDCMP_MOUSEBUTTONS;
368
+ tagList[ tagNR ].ti_Tag = WA_ReportMouse;
369
+ tagList[ tagNR++ ].ti_Data = TRUE;
370
+ tagList[ tagNR ].ti_Tag = WA_RMBTrap;
371
+ tagList[ tagNR++ ].ti_Data = TRUE;
372
+ tagList[ tagNR ].ti_Tag = WA_NoCareRefresh;
373
+ tagList[ tagNR++ ].ti_Data = FALSE;
374
+ tagList[ tagNR ].ti_Tag = WA_SimpleRefresh;
375
+ tagList[ tagNR++ ].ti_Data = TRUE;
376
+ tagList[ tagNR ].ti_Tag = WA_Activate;
377
+ tagList[ tagNR++ ].ti_Data = TRUE;
378
+ tagList[ tagNR ].ti_Tag = WA_CloseGadget;
379
+ tagList[ tagNR++ ].ti_Data = _glfwWin.Fullscreen ? FALSE : TRUE;
380
+ tagList[ tagNR ].ti_Tag = WA_SizeGadget;
381
+ tagList[ tagNR++ ].ti_Data = _glfwWin.Fullscreen ? FALSE : ( _glfwWinHints.WindowNoResize ? FALSE : TRUE );
382
+ tagList[ tagNR ].ti_Tag = WA_DepthGadget;
383
+ tagList[ tagNR++ ].ti_Data = _glfwWin.Fullscreen ? FALSE : TRUE;
384
+ tagList[ tagNR ].ti_Tag = WA_DragBar;
385
+ tagList[ tagNR++ ].ti_Data = _glfwWin.Fullscreen ? FALSE : TRUE;
386
+ tagList[ tagNR ].ti_Tag = WA_Borderless;
387
+ tagList[ tagNR++ ].ti_Data = _glfwWin.Fullscreen ? TRUE : FALSE;
388
+ tagList[ tagNR ].ti_Tag = WA_Backdrop;
389
+ tagList[ tagNR++ ].ti_Data = _glfwWin.Fullscreen ? TRUE : FALSE;
390
+ if( _glfwWin.Fullscreen )
391
+ {
392
+ tagList[ tagNR ].ti_Tag = WA_CustomScreen;
393
+ tagList[ tagNR++ ].ti_Data = (ULONG) _glfwWin.Screen;
394
+ tagList[ tagNR ].ti_Tag = WA_Width;
395
+ tagList[ tagNR++ ].ti_Data = width;
396
+ tagList[ tagNR ].ti_Tag = WA_Height;
397
+ tagList[ tagNR++ ].ti_Data = height;
398
+ }
399
+ else
400
+ {
401
+ tagList[ tagNR ].ti_Tag = WA_GimmeZeroZero;
402
+ tagList[ tagNR++ ].ti_Data = TRUE;
403
+ tagList[ tagNR ].ti_Tag = WA_InnerWidth;
404
+ tagList[ tagNR++ ].ti_Data = width;
405
+ tagList[ tagNR ].ti_Tag = WA_InnerHeight;
406
+ tagList[ tagNR++ ].ti_Data = height;
407
+ tagList[ tagNR ].ti_Tag = WA_MinWidth;
408
+ tagList[ tagNR++ ].ti_Data = 20;
409
+ tagList[ tagNR ].ti_Tag = WA_MinHeight;
410
+ tagList[ tagNR++ ].ti_Data = 20;
411
+ tagList[ tagNR ].ti_Tag = WA_MaxWidth;
412
+ tagList[ tagNR++ ].ti_Data = 9999;
413
+ tagList[ tagNR ].ti_Tag = WA_MaxHeight;
414
+ tagList[ tagNR++ ].ti_Data = 9999;
415
+ tagList[ tagNR ].ti_Tag = WA_Title;
416
+ tagList[ tagNR++ ].ti_Data = (ULONG) "GLFW Window";
417
+ tagList[ tagNR ].ti_Tag = WA_ScreenTitle;
418
+ tagList[ tagNR++ ].ti_Data = (ULONG) "GLFW Application";
419
+ }
420
+ tagList[ tagNR ].ti_Tag = TAG_DONE;
421
+
422
+ // Open window
423
+ _glfwWin.Window = OpenWindowTagList( NULL, tagList );
424
+ if( !_glfwWin.Window )
425
+ {
426
+ _glfwPlatformCloseWindow();
427
+ return GL_FALSE;
428
+ }
429
+
430
+ // Fullscreen/windowed post fixups
431
+ if( _glfwWin.Fullscreen )
432
+ {
433
+ // Don't show screen title
434
+ ShowTitle( _glfwWin.Screen, FALSE );
435
+
436
+ // Remember window size
437
+ _glfwWin.Width = _glfwWin.Window->Width;
438
+ _glfwWin.Height = _glfwWin.Window->Height;
439
+ }
440
+ else
441
+ {
442
+ // If we are not in fullscreen mode, get screen handle from window
443
+ _glfwWin.Screen = _glfwWin.Window->WScreen;
444
+
445
+ // Get ModeID for the current video mode
446
+ _glfwWin.ModeID = GetVPModeID( &_glfwWin.Screen->ViewPort );
447
+
448
+ // Remember window size
449
+ _glfwWin.Width = _glfwWin.Window->GZZWidth;
450
+ _glfwWin.Height = _glfwWin.Window->GZZHeight;
451
+ }
452
+
453
+ // Put window on top
454
+ WindowToFront( _glfwWin.Window );
455
+
456
+ // Create OpenGL context
457
+ #ifdef _GLFW_STORMMESA
458
+ tagNR = 0;
459
+ tagList[ tagNR ].ti_Tag = AMA_Window;
460
+ tagList[ tagNR++ ].ti_Data = (ULONG) _glfwWin.Window;
461
+ tagList[ tagNR ].ti_Tag = AMA_RastPort;
462
+ tagList[ tagNR++ ].ti_Data = (ULONG) _glfwWin.Window->RPort;
463
+ tagList[ tagNR ].ti_Tag = AMA_Screen;
464
+ tagList[ tagNR++ ].ti_Data = (ULONG) _glfwWin.Screen;
465
+ tagList[ tagNR ].ti_Tag = AMA_Left;
466
+ tagList[ tagNR++ ].ti_Data = 0;
467
+ tagList[ tagNR ].ti_Tag = AMA_Bottom;
468
+ tagList[ tagNR++ ].ti_Data = 0;
469
+ tagList[ tagNR ].ti_Tag = AMA_Width;
470
+ tagList[ tagNR++ ].ti_Data = _glfwWin.Width;
471
+ tagList[ tagNR ].ti_Tag = AMA_Height;
472
+ tagList[ tagNR++ ].ti_Data = _glfwWin.Height;
473
+ tagList[ tagNR ].ti_Tag = AMA_DoubleBuf;
474
+ tagList[ tagNR++ ].ti_Data = GL_TRUE;
475
+ tagList[ tagNR ].ti_Tag = AMA_RGBMode;
476
+ tagList[ tagNR++ ].ti_Data = GL_TRUE;
477
+ tagList[ tagNR ].ti_Tag = AMA_AlphaFlag;
478
+ tagList[ tagNR++ ].ti_Data = alphabits ? GL_TRUE : GL_FALSE;
479
+ tagList[ tagNR ].ti_Tag = AMA_NoDepth;
480
+ tagList[ tagNR++ ].ti_Data = depthbits ? GL_FALSE : GL_TRUE;
481
+ tagList[ tagNR ].ti_Tag = AMA_NoStencil;
482
+ tagList[ tagNR++ ].ti_Data = stencilbits ? GL_FALSE : GL_TRUE;
483
+ tagList[ tagNR ].ti_Tag = AMA_NoAccum;
484
+ tagList[ tagNR++ ].ti_Data = accumbits ? GL_FALSE : GL_TRUE;
485
+ tagList[ tagNR ].ti_Tag = AMA_DirectRender;
486
+ tagList[ tagNR++ ].ti_Data = GL_TRUE;
487
+ tagList[ tagNR ].ti_Tag = AMA_DrawMode;
488
+ tagList[ tagNR++ ].ti_Data = AMESA_AGA_C2P;
489
+ tagList[ tagNR ].ti_Tag = TAG_DONE;
490
+ _glfwWin.Context = AmigaMesaCreateContext( tagList );
491
+ #endif
492
+ if( !_glfwWin.Context )
493
+ {
494
+ _glfwPlatformCloseWindow();
495
+ return GL_FALSE;
496
+ }
497
+
498
+ // Make current
499
+ #ifdef _GLFW_STORMMESA
500
+ AmigaMesaMakeCurrent( _glfwWin.Context, _glfwWin.Context->buffer );
501
+ #endif
502
+
503
+ return GL_TRUE;
504
+ }
505
+
506
+
507
+ //========================================================================
508
+ // _glfwPlatformCloseWindow() - Properly kill the window/video display
509
+ //========================================================================
510
+
511
+ void _glfwPlatformCloseWindow( void )
512
+ {
513
+ // Restore mouse pointer (if hidden)
514
+ _glfwPlatformShowMouseCursor();
515
+
516
+ // Destroy OpenGL context
517
+ if( _glfwWin.Context )
518
+ {
519
+ #ifdef _GLFW_STORMMESA
520
+ AmigaMesaDestroyContext( _glfwWin.Context );
521
+ #endif
522
+ _glfwWin.Context = NULL;
523
+ }
524
+
525
+ // Close window
526
+ if( _glfwWin.Window )
527
+ {
528
+ CloseWindow( _glfwWin.Window );
529
+ _glfwWin.Window = NULL;
530
+ }
531
+
532
+ // Close screen
533
+ if( _glfwWin.Fullscreen && _glfwWin.Screen )
534
+ {
535
+ CloseScreen( _glfwWin.Screen );
536
+ }
537
+ _glfwWin.Screen = NULL;
538
+
539
+ // Close input device I/O request
540
+ if( _glfwWin.InputIO )
541
+ {
542
+ CloseDevice( (struct IORequest *) _glfwWin.InputIO );
543
+ DeleteExtIO( (struct IORequest *) _glfwWin.InputIO );
544
+ _glfwWin.InputIO = NULL;
545
+ }
546
+
547
+ // Close input device message port
548
+ if( _glfwWin.InputMP )
549
+ {
550
+ DeletePort( _glfwWin.InputMP );
551
+ _glfwWin.InputMP = NULL;
552
+ }
553
+
554
+ }
555
+
556
+
557
+ //========================================================================
558
+ // _glfwPlatformSetWindowTitle() - Set the window title.
559
+ //========================================================================
560
+
561
+ void _glfwPlatformSetWindowTitle( const char *title )
562
+ {
563
+ if( !_glfwWin.Fullscreen )
564
+ {
565
+ SetWindowTitles( _glfwWin.Window, (char*) title, (char*) title );
566
+ }
567
+ }
568
+
569
+
570
+ //========================================================================
571
+ // _glfwPlatformSetWindowSize() - Set the window size.
572
+ //========================================================================
573
+
574
+ void _glfwPlatformSetWindowSize( int width, int height )
575
+ {
576
+ if( !_glfwWin.Fullscreen )
577
+ {
578
+ SizeWindow( _glfwWin.Window, width-_glfwWin.Width,
579
+ height-_glfwWin.Height );
580
+ }
581
+ }
582
+
583
+
584
+ //========================================================================
585
+ // _glfwPlatformSetWindowPos() - Set the window position.
586
+ //========================================================================
587
+
588
+ void _glfwPlatformSetWindowPos( int x, int y )
589
+ {
590
+ if( !_glfwWin.Fullscreen )
591
+ {
592
+ ChangeWindowBox( _glfwWin.Window, x, y, _glfwWin.Window->Width,
593
+ _glfwWin.Window->Height );
594
+ }
595
+ }
596
+
597
+
598
+ //========================================================================
599
+ // _glfwPlatformIconfyWindow() - Window iconification
600
+ //========================================================================
601
+
602
+ void _glfwPlatformIconifyWindow( void )
603
+ {
604
+ if( _glfwWin.Fullscreen )
605
+ {
606
+ ScreenToBack( _glfwWin.Screen );
607
+ WBenchToFront();
608
+ _glfwWin.Iconified = GL_TRUE;
609
+ }
610
+ }
611
+
612
+
613
+ //========================================================================
614
+ // _glfwPlatformRestoreWindow() - Window un-iconification
615
+ //========================================================================
616
+
617
+ void _glfwPlatformRestoreWindow( void )
618
+ {
619
+ if( _glfwWin.Fullscreen )
620
+ {
621
+ ScreenToFront( _glfwWin.Screen );
622
+ }
623
+ WindowToFront( _glfwWin.Window );
624
+ ActivateWindow( _glfwWin.Window );
625
+ _glfwWin.Iconified = GL_FALSE;
626
+ }
627
+
628
+
629
+ //========================================================================
630
+ // _glfwPlatformSwapBuffers() - Swap buffers (double-buffering) and poll
631
+ // any new events.
632
+ //========================================================================
633
+
634
+ void _glfwPlatformSwapBuffers( void )
635
+ {
636
+ #ifdef _GLFW_STORMMESA
637
+ AmigaMesaSwapBuffers( _glfwWin.Context );
638
+ #endif
639
+ }
640
+
641
+
642
+ //========================================================================
643
+ // _glfwPlatformSwapInterval() - Set double buffering swap interval
644
+ //========================================================================
645
+
646
+ void _glfwPlatformSwapInterval( int interval )
647
+ {
648
+ // Not supported
649
+ }
650
+
651
+
652
+ //========================================================================
653
+ // _glfwPlatformRefreshWindowParams()
654
+ //========================================================================
655
+
656
+ void _glfwPlatformRefreshWindowParams( void )
657
+ {
658
+ int refresh;
659
+ GLint x;
660
+ GLboolean b;
661
+
662
+ // This function is not proerly implemented yet. We use OpenGL for
663
+ // getting framebuffer format information - we should use some
664
+ // alternate interface (such as glX under the X Window System), but
665
+ // StormMesa does not seem to provide this.
666
+
667
+ // Fill out information
668
+ _glfwWin.Accelerated = GL_TRUE;
669
+ glGetIntegerv( GL_RED_BITS, &x );
670
+ _glfwWin.RedBits = x;
671
+ glGetIntegerv( GL_GREEN_BITS, &x );
672
+ _glfwWin.GreenBits = x;
673
+ glGetIntegerv( GL_BLUE_BITS, &x );
674
+ _glfwWin.BlueBits = x;
675
+ glGetIntegerv( GL_ALPHA_BITS, &x );
676
+ _glfwWin.AlphaBits = x;
677
+ glGetIntegerv( GL_DEPTH_BITS, &x );
678
+ _glfwWin.DepthBits = x;
679
+ glGetIntegerv( GL_STENCIL_BITS, &x );
680
+ _glfwWin.StencilBits = x;
681
+ glGetIntegerv( GL_ACCUM_RED_BITS, &x );
682
+ _glfwWin.AccumRedBits = x;
683
+ glGetIntegerv( GL_ACCUM_GREEN_BITS, &x );
684
+ _glfwWin.AccumGreenBits = x;
685
+ glGetIntegerv( GL_ACCUM_BLUE_BITS, &x );
686
+ _glfwWin.AccumBlueBits = x;
687
+ glGetIntegerv( GL_ACCUM_ALPHA_BITS, &x );
688
+ _glfwWin.AccumAlphaBits = x;
689
+ glGetIntegerv( GL_AUX_BUFFERS, &x );
690
+ _glfwWin.AuxBuffers = x;
691
+ glGetBooleanv( GL_AUX_BUFFERS, &b );
692
+ _glfwWin.Stereo = b ? GL_TRUE : GL_FALSE;
693
+
694
+ // Get ModeID information (refresh rate)
695
+ _glfwGetModeIDInfo( _glfwWin.ModeID, NULL, NULL, NULL, NULL, NULL,
696
+ &refresh );
697
+ _glfwWin.RefreshRate = refresh;
698
+ }
699
+
700
+
701
+ //========================================================================
702
+ // _glfwPlatformPollEvents() - Poll for new window and input events
703
+ //========================================================================
704
+
705
+ void _glfwPlatformPollEvents( void )
706
+ {
707
+ int winclosed;
708
+
709
+ // Process all pending window events
710
+ winclosed = GL_FALSE;
711
+ if( _glfwProcessEvents() )
712
+ {
713
+ winclosed = GL_TRUE;
714
+ }
715
+
716
+ // Was there a window close request?
717
+ if( winclosed && _glfwWin.WindowCloseCallback )
718
+ {
719
+ // Check if the program wants us to close the window
720
+ winclosed = _glfwWin.WindowCloseCallback();
721
+ }
722
+ if( winclosed )
723
+ {
724
+ glfwCloseWindow();
725
+ }
726
+ }
727
+
728
+
729
+ //========================================================================
730
+ // _glfwPlatformWaitEvents() - Wait for new window and input events
731
+ //========================================================================
732
+
733
+ void _glfwPlatformWaitEvents( void )
734
+ {
735
+ // Wait for new events
736
+ Wait( 1L << _glfwWin.Window->UserPort->mp_SigBit );
737
+
738
+ // Poll new events
739
+ _glfwPlatformPollEvents();
740
+ }
741
+
742
+
743
+ //========================================================================
744
+ // _glfwPlatformHideMouseCursor() - Hide mouse cursor (lock it)
745
+ //========================================================================
746
+
747
+ void _glfwPlatformHideMouseCursor( void )
748
+ {
749
+ // We only allow this under fullscreen right now, since we can't rely
750
+ // on the pointer position in windowed mode! Perhaps it's possible to
751
+ // "steal" the mouse with input.device or something...?
752
+ if( !_glfwWin.PointerHidden && _glfwWin.Fullscreen )
753
+ {
754
+ // Allocate chip memory for the blank mouse pointer
755
+ _glfwWin.PointerSprite = AllocVec( 128, MEMF_CHIP | MEMF_CLEAR );
756
+ if( _glfwWin.PointerSprite )
757
+ {
758
+ // Switch to blank/transparent pointer
759
+ SetPointer( _glfwWin.Window, (UWORD *) _glfwWin.PointerSprite,
760
+ 1, 1, 0, 0 );
761
+ _glfwWin.PointerHidden = 1;
762
+
763
+ // Switch to mouse delta movement
764
+ Forbid();
765
+ _glfwWin.Window->IDCMPFlags |= IDCMP_DELTAMOVE;
766
+ Permit();
767
+ }
768
+ }
769
+ }
770
+
771
+
772
+ //========================================================================
773
+ // _glfwPlatformShowMouseCursor() - Show mouse cursor (unlock it)
774
+ //========================================================================
775
+
776
+ void _glfwPlatformShowMouseCursor( void )
777
+ {
778
+ if( _glfwWin.PointerHidden )
779
+ {
780
+ // Switch to absolute mouse movement
781
+ Forbid();
782
+ _glfwWin.Window->IDCMPFlags &= (0xFFFFFFFF^IDCMP_DELTAMOVE);
783
+ Permit();
784
+
785
+ // Change back to normal pointer
786
+ ClearPointer( _glfwWin.Window );
787
+ if( _glfwWin.PointerSprite )
788
+ {
789
+ FreeVec( _glfwWin.PointerSprite );
790
+ _glfwWin.PointerSprite = NULL;
791
+ }
792
+ _glfwWin.PointerHidden = 0;
793
+ }
794
+ }
795
+
796
+
797
+ //========================================================================
798
+ // _glfwPlatformSetMouseCursorPos() - Set physical mouse cursor position
799
+ //========================================================================
800
+
801
+ void _glfwPlatformSetMouseCursorPos( int x, int y )
802
+ {
803
+ struct IEPointerPixel ppxl;
804
+ struct InputEvent event;
805
+
806
+ // Adjust coordinates to window client area upper left corner
807
+ x += _glfwWin.Window->LeftEdge;
808
+ y += _glfwWin.Window->TopEdge;
809
+
810
+ /* Set up IEPointerPixel fields */
811
+ ppxl.iepp_Screen = _glfwWin.Screen;
812
+ ppxl.iepp_Position.X = x;
813
+ ppxl.iepp_Position.Y = y;
814
+
815
+ /* Set up InputEvent fields */
816
+ event.ie_EventAddress = (APTR)&ppxl; /* IEPointerPixel */
817
+ event.ie_NextEvent = NULL;
818
+ event.ie_Class = IECLASS_NEWPOINTERPOS; /* new mouse pos */
819
+ event.ie_SubClass = IESUBCLASS_PIXEL; /* on pixel */
820
+ event.ie_Code = IECODE_NOBUTTON;
821
+ event.ie_Qualifier = 0; /* absolute pos */
822
+
823
+ /* Set up I/O request */
824
+ _glfwWin.InputIO->io_Data = (APTR)&event;
825
+ _glfwWin.InputIO->io_Length = sizeof(struct InputEvent);
826
+ _glfwWin.InputIO->io_Command = IND_WRITEEVENT;
827
+
828
+ /* Perform I/O (move mouse cursor) */
829
+ DoIO( (struct IORequest *)_glfwWin.InputIO );
830
+ }