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,61 @@
1
+ //========================================================================
2
+ // GLFW - An OpenGL framework
3
+ // File: amigaos_glext.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
+ //**** Platform implementation functions ****
36
+ //************************************************************************
37
+
38
+ //========================================================================
39
+ // _glfwPlatformExtensionSupported() - Check if an OpenGL extension is
40
+ // available at runtime
41
+ //========================================================================
42
+
43
+ int _glfwPlatformExtensionSupported( const char *extension )
44
+ {
45
+ // There are no AmigaOS specific ways to check for extensions
46
+ return GL_FALSE;
47
+ }
48
+
49
+
50
+ //========================================================================
51
+ // _glfwPlatformGetProcAddress() - Get the function pointer to an OpenGL
52
+ // function
53
+ //========================================================================
54
+
55
+ void * _glfwPlatformGetProcAddress( const char *procname )
56
+ {
57
+ #ifdef _GLFW_STORMMESA
58
+ // StormMesa does not support this
59
+ return NULL;
60
+ #endif
61
+ }
@@ -0,0 +1,284 @@
1
+ //========================================================================
2
+ // GLFW - An OpenGL framework
3
+ // File: amigaos_init.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
+ // _glfwInitLibraries() - Load shared libraries
41
+ //========================================================================
42
+
43
+ static int _glfwInitLibraries( void )
44
+ {
45
+ // Note: exec.library & dos.library are always opened (by C startup)
46
+
47
+ // Start by clearing all handles
48
+ GfxBase = NULL;
49
+ IntuitionBase = NULL;
50
+ KeymapBase = NULL;
51
+ UtilityBase = NULL;
52
+
53
+ // graphics.library
54
+ GfxBase = (struct GfxBase *) OpenLibrary( "graphics.library", 40 );
55
+ if( !GfxBase )
56
+ {
57
+ return 0;
58
+ }
59
+
60
+ // intuition.library
61
+ IntuitionBase = (struct IntuitionBase *) OpenLibrary( "intuition.library", 40 );
62
+ if( !IntuitionBase )
63
+ {
64
+ return 0;
65
+ }
66
+
67
+ // keymap.library
68
+ KeymapBase = OpenLibrary( "keymap.library", 40 );
69
+ if( !KeymapBase )
70
+ {
71
+ return 0;
72
+ }
73
+
74
+ // Utility.library
75
+ UtilityBase = (struct UtilityBase *) OpenLibrary( "utility.library", 40 );
76
+ if( !UtilityBase )
77
+ {
78
+ return 0;
79
+ }
80
+
81
+ return 1;
82
+ }
83
+
84
+
85
+ //========================================================================
86
+ // _glfwTerminateLibraries() - Unload shared libraries
87
+ //========================================================================
88
+
89
+ static void _glfwTerminateLibraries( void )
90
+ {
91
+ // Close graphics.library
92
+ if( GfxBase )
93
+ {
94
+ CloseLibrary( (struct Library *) GfxBase );
95
+ GfxBase = NULL;
96
+ }
97
+
98
+ // Close intuition.library
99
+ if( IntuitionBase )
100
+ {
101
+ CloseLibrary( (struct Library *) IntuitionBase );
102
+ IntuitionBase = NULL;
103
+ }
104
+
105
+ // Close keymap.library
106
+ if( KeymapBase )
107
+ {
108
+ CloseLibrary( KeymapBase );
109
+ KeymapBase = NULL;
110
+ }
111
+
112
+ // Close utility.library
113
+ if( UtilityBase )
114
+ {
115
+ CloseLibrary( (struct Library *) UtilityBase );
116
+ UtilityBase = NULL;
117
+ }
118
+ }
119
+
120
+
121
+ //========================================================================
122
+ // _glfwInitThreads() - Initialize GLFW thread package
123
+ //========================================================================
124
+
125
+ static int _glfwInitThreads( void )
126
+ {
127
+ int waitSig;
128
+
129
+ // Allocate a signal to use for waiting (glfwWaitThread and
130
+ // glfwWaitCond)
131
+ waitSig = AllocSignal( -1 );
132
+ if( waitSig == -1 )
133
+ {
134
+ return 0;
135
+ }
136
+
137
+ // Initialize critical section handle
138
+ memset( &_glfwThrd.CriticalSection,0,sizeof(struct SignalSemaphore) );
139
+ InitSemaphore( &_glfwThrd.CriticalSection );
140
+
141
+ // The first thread (the main thread) has ID 0
142
+ _glfwThrd.NextID = 0;
143
+
144
+ // The first condition variable has ID 0xFFFFFFFF
145
+ _glfwThrd.NextCondID = 0xFFFFFFFF;
146
+
147
+ // Fill out information about the main thread (this thread)
148
+ _glfwThrd.First.Previous = NULL;
149
+ _glfwThrd.First.Next = NULL;
150
+ _glfwThrd.First.ID = _glfwThrd.NextID ++;
151
+ _glfwThrd.First.Function = NULL;
152
+ _glfwThrd.First.Arg = NULL;
153
+ _glfwThrd.First.AmiTask = FindTask( NULL );
154
+ _glfwThrd.First.AmiProc = (struct Process *) _glfwThrd.First.AmiTask;
155
+ _glfwThrd.First.WaitFor = NULL;
156
+ _glfwThrd.First.WaitSig = waitSig;
157
+
158
+ // Store GLFW thread struct pointer in task user data
159
+ _glfwThrd.First.AmiTask->tc_UserData = (APTR) &_glfwThrd.First;
160
+
161
+ return 1;
162
+ }
163
+
164
+
165
+ //========================================================================
166
+ // _glfwTerminateThreads() - Terminate GLFW thread package
167
+ //========================================================================
168
+
169
+ static void _glfwTerminateThreads( void )
170
+ {
171
+ _GLFWthread *t, *t_next;
172
+
173
+ // Enter critical section
174
+ ENTER_THREAD_CRITICAL_SECTION
175
+
176
+ // Kill all threads (NOTE: THE USER SHOULD WAIT FOR ALL THREADS TO
177
+ // DIE, _BEFORE_ CALLING glfwTerminate()!!!)
178
+ t = _glfwThrd.First.Next;
179
+ while( t != NULL )
180
+ {
181
+ // Get pointer to next thread
182
+ t_next = t->Next;
183
+
184
+ // Simply murder the process, no mercy!
185
+ // ?? How about Process resources ??
186
+ RemTask( t->AmiTask );
187
+
188
+ // Free memory allocated for this thread
189
+ free( (void *) t );
190
+
191
+ // Select next thread in list
192
+ t = t_next;
193
+ }
194
+
195
+ // Free waiting signal for main thread
196
+ FreeSignal( _glfwThrd.First.WaitSig );
197
+
198
+ // Leave critical section
199
+ LEAVE_THREAD_CRITICAL_SECTION
200
+ }
201
+
202
+
203
+ //========================================================================
204
+ // _glfwTerminate_atexit() - Terminate GLFW when exiting application
205
+ //========================================================================
206
+
207
+ void _glfwTerminate_atexit( void )
208
+ {
209
+ glfwTerminate();
210
+ }
211
+
212
+
213
+
214
+ //************************************************************************
215
+ //**** Platform implementation functions ****
216
+ //************************************************************************
217
+
218
+ //========================================================================
219
+ // _glfwPlatformInit() - Initialize various GLFW state
220
+ //========================================================================
221
+
222
+ int _glfwPlatformInit( void )
223
+ {
224
+ // Load shared libraries
225
+ if( !_glfwInitLibraries() )
226
+ {
227
+ _glfwTerminateLibraries();
228
+ return GL_FALSE;
229
+ }
230
+
231
+ // Initialize thread package
232
+ if( !_glfwInitThreads() )
233
+ {
234
+ _glfwTerminateLibraries();
235
+ return GL_FALSE;
236
+ }
237
+
238
+ // Start the timer
239
+ if( !_glfwInitTimer() )
240
+ {
241
+ _glfwTerminateThreads();
242
+ _glfwTerminateLibraries();
243
+ return GL_FALSE;
244
+ }
245
+
246
+ // Initialize joysticks
247
+ _glfwInitJoysticks();
248
+
249
+ // Install atexit() routine
250
+ atexit( _glfwTerminate_atexit );
251
+
252
+ return GL_TRUE;
253
+ }
254
+
255
+
256
+ //========================================================================
257
+ // _glfwPlatformTerminate() - Close window and kill all threads
258
+ //========================================================================
259
+
260
+ int _glfwPlatformTerminate( void )
261
+ {
262
+ // Only the main thread is allowed to do this...
263
+ if( FindTask( NULL ) != _glfwThrd.First.AmiTask )
264
+ {
265
+ return GL_FALSE;
266
+ }
267
+
268
+ // Close OpenGL window
269
+ glfwCloseWindow();
270
+
271
+ // Terminate joysticks
272
+ _glfwTerminateJoysticks();
273
+
274
+ // Kill timer
275
+ _glfwTerminateTimer();
276
+
277
+ // Kill thread package
278
+ _glfwTerminateThreads();
279
+
280
+ // Unload shared libraries
281
+ _glfwTerminateLibraries();
282
+
283
+ return GL_TRUE;
284
+ }
@@ -0,0 +1,359 @@
1
+ //========================================================================
2
+ // GLFW - An OpenGL framework
3
+ // File: amigaos_joystick.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
+ // _glfwSendJoyReadRequest() - Send joystick read request
40
+ //========================================================================
41
+
42
+ static void _glfwSendJoyReadRequest( void )
43
+ {
44
+ // Send read request
45
+ _glfwJoy.GameIO->io_Command = GPD_READEVENT;
46
+ _glfwJoy.GameIO->io_Flags = 0;
47
+ _glfwJoy.GameIO->io_Data = (APTR) &_glfwJoy.GameEvent;
48
+ _glfwJoy.GameIO->io_Length = sizeof(struct InputEvent);
49
+ SendIO( (struct IORequest *) _glfwJoy.GameIO );
50
+ }
51
+
52
+
53
+ //========================================================================
54
+ // _glfwInitJoysticks() - Initialize joystick interface
55
+ //========================================================================
56
+
57
+ void _glfwInitJoysticks( void )
58
+ {
59
+ unsigned char controller_type = 0;
60
+ struct GamePortTrigger game_trigger;
61
+
62
+ // Start by clearing all handles
63
+ _glfwJoy.GameMP = NULL;
64
+ _glfwJoy.GameIO = NULL;
65
+ _glfwJoy.Present = 0;
66
+ _glfwJoy.GameDeviceOpen = 0;
67
+
68
+ // Create gameport.device message port
69
+ if( !(_glfwJoy.GameMP = CreatePort( NULL, 0 )) )
70
+ {
71
+ return;
72
+ }
73
+
74
+ // Create gameport.device I/O request
75
+ if( !( _glfwJoy.GameIO = (struct IOStdReq *)
76
+ CreateExtIO(_glfwJoy.GameMP, sizeof(struct IOStdReq)) ) )
77
+ {
78
+ _glfwTerminateJoysticks();
79
+ return;
80
+ }
81
+
82
+ // Open gameport.device (unit 1 = port 2)
83
+ _glfwJoy.GameIO->io_Message.mn_Node.ln_Type = NT_UNKNOWN;
84
+ if( OpenDevice( "gameport.device", 1,
85
+ (struct IORequest *)_glfwJoy.GameIO, 0 ) )
86
+ {
87
+ _glfwTerminateJoysticks();
88
+ return;
89
+ }
90
+ _glfwJoy.GameDeviceOpen = 1;
91
+
92
+ // Start critical section
93
+ Forbid();
94
+
95
+ // Find out if anyone else is using the stick
96
+ _glfwJoy.GameIO->io_Command = GPD_ASKCTYPE;
97
+ _glfwJoy.GameIO->io_Flags = IOF_QUICK;
98
+ _glfwJoy.GameIO->io_Data = (APTR) &controller_type;
99
+ _glfwJoy.GameIO->io_Length = 1;
100
+ DoIO( (struct IORequest *) _glfwJoy.GameIO );
101
+
102
+ // Was it already allocated?
103
+ if( controller_type != GPCT_NOCONTROLLER )
104
+ {
105
+ Permit();
106
+ _glfwTerminateJoysticks();
107
+ return;
108
+ }
109
+
110
+ // Allocate joystick
111
+ controller_type = GPCT_ABSJOYSTICK;
112
+ _glfwJoy.GameIO->io_Command = GPD_SETCTYPE;
113
+ _glfwJoy.GameIO->io_Flags = IOF_QUICK;
114
+ _glfwJoy.GameIO->io_Data = (APTR) &controller_type;
115
+ _glfwJoy.GameIO->io_Length = 1;
116
+ DoIO( (struct IORequest *) _glfwJoy.GameIO );
117
+ _glfwJoy.Present = 1;
118
+
119
+ // End critical section
120
+ Permit();
121
+
122
+ // Set trigger conditions
123
+ game_trigger.gpt_Keys = GPTF_UPKEYS | GPTF_DOWNKEYS;
124
+ game_trigger.gpt_XDelta = 1;
125
+ game_trigger.gpt_YDelta = 1;
126
+ game_trigger.gpt_Timeout = (UWORD) 0xFFFF; // ~20 minutes
127
+ _glfwJoy.GameIO->io_Command = GPD_SETTRIGGER;
128
+ _glfwJoy.GameIO->io_Flags = IOF_QUICK;
129
+ _glfwJoy.GameIO->io_Data = (APTR) &game_trigger;
130
+ _glfwJoy.GameIO->io_Length = (LONG) sizeof(struct GamePortTrigger);
131
+ DoIO( (struct IORequest *) _glfwJoy.GameIO );
132
+
133
+ // Flush buffer
134
+ _glfwJoy.GameIO->io_Command = CMD_CLEAR;
135
+ _glfwJoy.GameIO->io_Flags = IOF_QUICK;
136
+ _glfwJoy.GameIO->io_Data = NULL;
137
+ _glfwJoy.GameIO->io_Length = 0;
138
+ DoIO( (struct IORequest *) _glfwJoy.GameIO );
139
+
140
+ // Send joystick read request (asynchronous)
141
+ _glfwSendJoyReadRequest();
142
+ }
143
+
144
+
145
+ //========================================================================
146
+ // _glfwTerminateJoysticks() - Close all opened joystick handles
147
+ //========================================================================
148
+
149
+ void _glfwTerminateJoysticks( void )
150
+ {
151
+ unsigned char controller_type;
152
+
153
+ // Remove any remaining asynchronous messages
154
+ if( _glfwJoy.GameIO )
155
+ {
156
+ if( !CheckIO( (struct IORequest *)_glfwJoy.GameIO ) )
157
+ {
158
+ AbortIO( (struct IORequest *)_glfwJoy.GameIO );
159
+ WaitIO( (struct IORequest *)_glfwJoy.GameIO );
160
+ }
161
+ }
162
+
163
+ // Deallocate joystick
164
+ if( _glfwJoy.Present )
165
+ {
166
+ controller_type = GPCT_NOCONTROLLER;
167
+ _glfwJoy.GameIO->io_Command = GPD_SETCTYPE;
168
+ _glfwJoy.GameIO->io_Flags = IOF_QUICK;
169
+ _glfwJoy.GameIO->io_Data = (APTR) &controller_type;
170
+ _glfwJoy.GameIO->io_Length = 1;
171
+ DoIO( (struct IORequest *) _glfwJoy.GameIO );
172
+ _glfwJoy.Present = 0;
173
+ }
174
+
175
+ // Close gameport.device
176
+ if( _glfwJoy.GameDeviceOpen )
177
+ {
178
+ CloseDevice( (struct IORequest *) _glfwJoy.GameIO );
179
+ _glfwJoy.GameDeviceOpen = 0;
180
+ }
181
+
182
+ // Delete I/O request
183
+ if( _glfwJoy.GameIO )
184
+ {
185
+ DeleteExtIO( (struct IORequest *) _glfwJoy.GameIO );
186
+ _glfwJoy.GameIO = NULL;
187
+ }
188
+
189
+ // Delete message port
190
+ if( _glfwJoy.GameMP )
191
+ {
192
+ DeletePort( _glfwJoy.GameMP );
193
+ _glfwJoy.GameMP = NULL;
194
+ }
195
+ }
196
+
197
+
198
+ //========================================================================
199
+ // _glfwPollJoystickEvents() - Empty joystick event queue
200
+ //========================================================================
201
+
202
+ static void _glfwPollJoystickEvents( void )
203
+ {
204
+ int got_event = 0;
205
+
206
+ // Do we have a stick?
207
+ if( !_glfwJoy.Present )
208
+ {
209
+ return;
210
+ }
211
+
212
+ // Empty the message queue
213
+ while( GetMsg( _glfwJoy.GameMP ) != NULL )
214
+ {
215
+ // Flag: we got an event
216
+ got_event = 1;
217
+
218
+ switch( _glfwJoy.GameEvent.ie_Code )
219
+ {
220
+ // Left button pressed
221
+ case IECODE_LBUTTON:
222
+ _glfwJoy.Button[ 0 ] = 1;
223
+ break;
224
+
225
+ // Left button released
226
+ case (IECODE_LBUTTON | IECODE_UP_PREFIX):
227
+ _glfwJoy.Button[ 0 ] = 0;
228
+ break;
229
+
230
+ // Right button pressed
231
+ case IECODE_RBUTTON:
232
+ _glfwJoy.Button[ 1 ] = 1;
233
+ break;
234
+
235
+ // Right button released
236
+ case (IECODE_RBUTTON | IECODE_UP_PREFIX):
237
+ _glfwJoy.Button[ 1 ] = 0;
238
+ break;
239
+
240
+ // Axis event
241
+ case IECODE_NOBUTTON:
242
+ _glfwJoy.Axis[ 0 ] = (float) _glfwJoy.GameEvent.ie_X;
243
+ _glfwJoy.Axis[ 1 ] = (float) -_glfwJoy.GameEvent.ie_Y;
244
+ break;
245
+
246
+ default:
247
+ break;
248
+ }
249
+ }
250
+
251
+ // Did we get any events?
252
+ if( got_event )
253
+ {
254
+ // Send joystick read request (asynchronous)
255
+ _glfwSendJoyReadRequest();
256
+ }
257
+ }
258
+
259
+
260
+
261
+ //************************************************************************
262
+ //**** Platform implementation functions ****
263
+ //************************************************************************
264
+
265
+ //========================================================================
266
+ // _glfwPlatformGetJoystickParam() - Determine joystick capabilities
267
+ //========================================================================
268
+
269
+ int _glfwPlatformGetJoystickParam( int joy, int param )
270
+ {
271
+ // Is joystick present?
272
+ if( joy != GLFW_JOYSTICK_1 || !_glfwJoy.Present )
273
+ {
274
+ return 0;
275
+ }
276
+
277
+ // We assume that the joystick is connected, and has two axes and two
278
+ // buttons (since there is no way of retrieving this information from
279
+ // AmigaOS)
280
+ switch( param )
281
+ {
282
+ case GLFW_PRESENT:
283
+ return GL_TRUE;
284
+
285
+ case GLFW_AXES:
286
+ return 2;
287
+
288
+ case GLFW_BUTTONS:
289
+ return 2;
290
+
291
+ default:
292
+ break;
293
+ }
294
+
295
+ return 0;
296
+ }
297
+
298
+
299
+ //========================================================================
300
+ // _glfwPlatformGetJoystickPos() - Get joystick axis positions
301
+ //========================================================================
302
+
303
+ int _glfwPlatformGetJoystickPos( int joy, float *pos, int numaxes )
304
+ {
305
+ int k;
306
+
307
+ // Is joystick present?
308
+ if( joy != GLFW_JOYSTICK_1 || !_glfwJoy.Present )
309
+ {
310
+ return 0;
311
+ }
312
+
313
+ // Update joystick state
314
+ _glfwPollJoystickEvents();
315
+
316
+ // Copy axis position information to output vector
317
+ if( numaxes > 2 )
318
+ {
319
+ numaxes = 2;
320
+ }
321
+ for( k = 0; k < numaxes; ++ k )
322
+ {
323
+ pos[ k ] = _glfwJoy.Axis[ k ];
324
+ }
325
+
326
+ return numaxes;
327
+ }
328
+
329
+
330
+ //========================================================================
331
+ // _glfwPlatformGetJoystickButtons() - Get joystick button states
332
+ //========================================================================
333
+
334
+ int _glfwPlatformGetJoystickButtons( int joy, unsigned char *buttons,
335
+ int numbuttons )
336
+ {
337
+ int k;
338
+
339
+ // Is joystick present?
340
+ if( joy != GLFW_JOYSTICK_1 || !_glfwJoy.Present )
341
+ {
342
+ return 0;
343
+ }
344
+
345
+ // Update joystick state
346
+ _glfwPollJoystickEvents();
347
+
348
+ // Copy button information to output vector
349
+ if( numbuttons > 2 )
350
+ {
351
+ numbuttons = 2;
352
+ }
353
+ for( k = 0; k < numbuttons; ++ k )
354
+ {
355
+ buttons[ k ] = _glfwJoy.Button[ k ];
356
+ }
357
+
358
+ return numbuttons;
359
+ }