ruby-glfw 0.9

Sign up to get free protection for your applications and to get access to all the features.
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,108 @@
1
+ //========================================================================
2
+ // GLFW - An OpenGL framework
3
+ // File: init.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
+ #define _init_c_
32
+ #include "internal.h"
33
+
34
+
35
+ //************************************************************************
36
+ //**** GLFW user functions ****
37
+ //************************************************************************
38
+
39
+ //========================================================================
40
+ // glfwInit() - Initialize various GLFW state
41
+ //========================================================================
42
+
43
+ GLFWAPI int GLFWAPIENTRY glfwInit( void )
44
+ {
45
+ // Is GLFW already initialized?
46
+ if( _glfwInitialized )
47
+ {
48
+ return GL_TRUE;
49
+ }
50
+
51
+ // Window is not yet opened
52
+ _glfwWin.Opened = GL_FALSE;
53
+
54
+ // Default enable/disable settings
55
+ _glfwWin.SysKeysDisabled = GL_FALSE;
56
+
57
+ // Clear window hints
58
+ _glfwClearWindowHints();
59
+
60
+ // Platform specific initialization
61
+ if( !_glfwPlatformInit() )
62
+ {
63
+ return GL_FALSE;
64
+ }
65
+
66
+ // Form now on, GLFW state is valid
67
+ _glfwInitialized = GL_TRUE;
68
+
69
+ return GL_TRUE;
70
+ }
71
+
72
+
73
+
74
+ //========================================================================
75
+ // glfwTerminate() - Close window and kill all threads.
76
+ //========================================================================
77
+
78
+ GLFWAPI void GLFWAPIENTRY glfwTerminate( void )
79
+ {
80
+ // Is GLFW initialized?
81
+ if( !_glfwInitialized )
82
+ {
83
+ return;
84
+ }
85
+
86
+ // Platform specific termination
87
+ if( !_glfwPlatformTerminate() )
88
+ {
89
+ return;
90
+ }
91
+
92
+ // GLFW is no longer initialized
93
+ _glfwInitialized = GL_FALSE;
94
+ }
95
+
96
+
97
+ //========================================================================
98
+ // glfwGetVersion() - Get GLFW version
99
+ //========================================================================
100
+
101
+ GLFWAPI void GLFWAPIENTRY glfwGetVersion( int *major, int *minor,
102
+ int *rev )
103
+ {
104
+ if( major != NULL ) *major = GLFW_VERSION_MAJOR;
105
+ if( minor != NULL ) *minor = GLFW_VERSION_MINOR;
106
+ if( rev != NULL ) *rev = GLFW_VERSION_REVISION;
107
+ }
108
+
@@ -0,0 +1,280 @@
1
+ //========================================================================
2
+ // GLFW - An OpenGL framework
3
+ // File: input.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
+ // glfwGetKey()
36
+ //========================================================================
37
+
38
+ GLFWAPI int GLFWAPIENTRY glfwGetKey( int key )
39
+ {
40
+ // Is GLFW initialized?
41
+ if( !_glfwInitialized || !_glfwWin.Opened )
42
+ {
43
+ return GLFW_RELEASE;
44
+ }
45
+
46
+ // Is it a valid key?
47
+ if( key < 0 || key > GLFW_KEY_LAST )
48
+ {
49
+ return GLFW_RELEASE;
50
+ }
51
+
52
+ if( _glfwInput.Key[ key ] == GLFW_STICK )
53
+ {
54
+ // Sticky mode: release key now
55
+ _glfwInput.Key[ key ] = GLFW_RELEASE;
56
+ return GLFW_PRESS;
57
+ }
58
+
59
+ return (int) _glfwInput.Key[ key ];
60
+ }
61
+
62
+
63
+ //========================================================================
64
+ // glfwGetMouseButton()
65
+ //========================================================================
66
+
67
+ GLFWAPI int GLFWAPIENTRY glfwGetMouseButton( int button )
68
+ {
69
+ // Is GLFW initialized?
70
+ if( !_glfwInitialized || !_glfwWin.Opened )
71
+ {
72
+ return GLFW_RELEASE;
73
+ }
74
+
75
+ // Is it a valid mouse button?
76
+ if( button < 0 || button > GLFW_MOUSE_BUTTON_LAST )
77
+ {
78
+ return GLFW_RELEASE;
79
+ }
80
+
81
+ if( _glfwInput.MouseButton[ button ] == GLFW_STICK )
82
+ {
83
+ // Sticky mode: release mouse button now
84
+ _glfwInput.MouseButton[ button ] = GLFW_RELEASE;
85
+ return GLFW_PRESS;
86
+ }
87
+
88
+ return (int) _glfwInput.MouseButton[ button ];
89
+ }
90
+
91
+
92
+ //========================================================================
93
+ // glfwGetMousePos()
94
+ //========================================================================
95
+
96
+ GLFWAPI void GLFWAPIENTRY glfwGetMousePos( int *xpos, int *ypos )
97
+ {
98
+ // Is GLFW initialized?
99
+ if( !_glfwInitialized || !_glfwWin.Opened )
100
+ {
101
+ return;
102
+ }
103
+
104
+ // Return mouse position
105
+ if( xpos != NULL )
106
+ {
107
+ *xpos = _glfwInput.MousePosX;
108
+ }
109
+ if( ypos != NULL )
110
+ {
111
+ *ypos = _glfwInput.MousePosY;
112
+ }
113
+ }
114
+
115
+
116
+ //========================================================================
117
+ // glfwSetMousePos()
118
+ //========================================================================
119
+
120
+ GLFWAPI void GLFWAPIENTRY glfwSetMousePos( int xpos, int ypos )
121
+ {
122
+ // Is GLFW initialized?
123
+ if( !_glfwInitialized || !_glfwWin.Opened )
124
+ {
125
+ return;
126
+ }
127
+
128
+ // Don't do anything if the mouse position did not change
129
+ if( xpos == _glfwInput.MousePosX && ypos == _glfwInput.MousePosY )
130
+ {
131
+ return;
132
+ }
133
+
134
+ // Set GLFW mouse position
135
+ _glfwInput.MousePosX = xpos;
136
+ _glfwInput.MousePosY = ypos;
137
+
138
+ // If we have a locked mouse, do not change cursor position
139
+ if( _glfwWin.MouseLock )
140
+ {
141
+ return;
142
+ }
143
+
144
+ // Update physical cursor position
145
+ _glfwPlatformSetMouseCursorPos( xpos, ypos );
146
+ }
147
+
148
+
149
+ //========================================================================
150
+ // glfwGetMouseWheel()
151
+ //========================================================================
152
+
153
+ GLFWAPI int GLFWAPIENTRY glfwGetMouseWheel( void )
154
+ {
155
+ // Is GLFW initialized?
156
+ if( !_glfwInitialized || !_glfwWin.Opened )
157
+ {
158
+ return 0;
159
+ }
160
+
161
+ // Return mouse wheel position
162
+ return _glfwInput.WheelPos;
163
+ }
164
+
165
+
166
+ //========================================================================
167
+ // glfwSetMouseWheel()
168
+ //========================================================================
169
+
170
+ GLFWAPI void GLFWAPIENTRY glfwSetMouseWheel( int pos )
171
+ {
172
+ // Is GLFW initialized?
173
+ if( !_glfwInitialized || !_glfwWin.Opened )
174
+ {
175
+ return;
176
+ }
177
+
178
+ // Set mouse wheel position
179
+ _glfwInput.WheelPos = pos;
180
+ }
181
+
182
+
183
+ //========================================================================
184
+ // glfwSetKeyCallback() - Set callback function for keyboard input
185
+ //========================================================================
186
+
187
+ GLFWAPI void GLFWAPIENTRY glfwSetKeyCallback( GLFWkeyfun cbfun )
188
+ {
189
+ // Is GLFW initialized?
190
+ if( !_glfwInitialized || !_glfwWin.Opened )
191
+ {
192
+ return;
193
+ }
194
+
195
+ // Set callback function
196
+ _glfwWin.KeyCallback = cbfun;
197
+ }
198
+
199
+
200
+ //========================================================================
201
+ // glfwSetCharCallback() - Set callback function for character input
202
+ //========================================================================
203
+
204
+ GLFWAPI void GLFWAPIENTRY glfwSetCharCallback( GLFWcharfun cbfun )
205
+ {
206
+ // Is GLFW initialized?
207
+ if( !_glfwInitialized || !_glfwWin.Opened )
208
+ {
209
+ return;
210
+ }
211
+
212
+ // Set callback function
213
+ _glfwWin.CharCallback = cbfun;
214
+ }
215
+
216
+
217
+ //========================================================================
218
+ // glfwSetMouseButtonCallback() - Set callback function for mouse clicks
219
+ //========================================================================
220
+
221
+ GLFWAPI void GLFWAPIENTRY glfwSetMouseButtonCallback( GLFWmousebuttonfun cbfun )
222
+ {
223
+ // Is GLFW initialized?
224
+ if( !_glfwInitialized || !_glfwWin.Opened )
225
+ {
226
+ return;
227
+ }
228
+
229
+ // Set callback function
230
+ _glfwWin.MouseButtonCallback = cbfun;
231
+ }
232
+
233
+
234
+ //========================================================================
235
+ // glfwSetMousePosCallback() - Set callback function for mouse moves
236
+ //========================================================================
237
+
238
+ GLFWAPI void GLFWAPIENTRY glfwSetMousePosCallback( GLFWmouseposfun cbfun )
239
+ {
240
+ // Is GLFW initialized?
241
+ if( !_glfwInitialized || !_glfwWin.Opened )
242
+ {
243
+ return;
244
+ }
245
+
246
+ // Set callback function
247
+ _glfwWin.MousePosCallback = cbfun;
248
+
249
+ // Call the callback function to let the application know the current
250
+ // mouse position
251
+ if( cbfun )
252
+ {
253
+ cbfun( _glfwInput.MousePosX, _glfwInput.MousePosY );
254
+ }
255
+ }
256
+
257
+
258
+ //========================================================================
259
+ // glfwSetMouseWheelCallback() - Set callback function for mouse wheel
260
+ //========================================================================
261
+
262
+ GLFWAPI void GLFWAPIENTRY glfwSetMouseWheelCallback( GLFWmousewheelfun cbfun )
263
+ {
264
+ // Is GLFW initialized?
265
+ if( !_glfwInitialized || !_glfwWin.Opened )
266
+ {
267
+ return;
268
+ }
269
+
270
+ // Set callback function
271
+ _glfwWin.MouseWheelCallback = cbfun;
272
+
273
+ // Call the callback function to let the application know the current
274
+ // mouse wheel position
275
+ if( cbfun )
276
+ {
277
+ cbfun( _glfwInput.WheelPos );
278
+ }
279
+ }
280
+
@@ -0,0 +1,210 @@
1
+ //========================================================================
2
+ // GLFW - An OpenGL framework
3
+ // File: internal.h
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
+ #ifndef _internal_h_
32
+ #define _internal_h_
33
+
34
+ //========================================================================
35
+ // GLFWGLOBAL is a macro that places all global variables in the init.c
36
+ // module (all other modules reference global variables as 'extern')
37
+ //========================================================================
38
+
39
+ #if defined( _init_c_ )
40
+ #define GLFWGLOBAL
41
+ #else
42
+ #define GLFWGLOBAL extern
43
+ #endif
44
+
45
+
46
+ //========================================================================
47
+ // Input handling definitions
48
+ //========================================================================
49
+
50
+ // Internal key and button state/action definitions
51
+ #define GLFW_STICK 2
52
+
53
+
54
+ //========================================================================
55
+ // System independent include files
56
+ //========================================================================
57
+
58
+ #include <stdlib.h>
59
+ #include <string.h>
60
+ #include <stdio.h>
61
+
62
+
63
+ //------------------------------------------------------------------------
64
+ // Platform specific definitions goes in platform.h (which also includes
65
+ // glfw.h)
66
+ //------------------------------------------------------------------------
67
+
68
+ #include "platform.h"
69
+
70
+
71
+ //========================================================================
72
+ // System independent global variables (GLFW internals)
73
+ //========================================================================
74
+
75
+ // Flag indicating if GLFW has been initialized
76
+ #if defined( _init_c_ )
77
+ int _glfwInitialized = 0;
78
+ #else
79
+ GLFWGLOBAL int _glfwInitialized;
80
+ #endif
81
+
82
+
83
+ //------------------------------------------------------------------------
84
+ // Window hints (set by glfwOpenWindowHint - will go into _GLFWthread)
85
+ //------------------------------------------------------------------------
86
+ typedef struct {
87
+ int RefreshRate;
88
+ int AccumRedBits;
89
+ int AccumGreenBits;
90
+ int AccumBlueBits;
91
+ int AccumAlphaBits;
92
+ int AuxBuffers;
93
+ int Stereo;
94
+ int WindowNoResize;
95
+ int Samples;
96
+ } _GLFWhints;
97
+
98
+ GLFWGLOBAL _GLFWhints _glfwWinHints;
99
+
100
+
101
+ //------------------------------------------------------------------------
102
+ // Abstracted data stream (for image I/O)
103
+ //------------------------------------------------------------------------
104
+ typedef struct {
105
+ FILE* File;
106
+ void* Data;
107
+ long Position;
108
+ long Size;
109
+ } _GLFWstream;
110
+
111
+
112
+ //========================================================================
113
+ // Prototypes for platform specific implementation functions
114
+ //========================================================================
115
+
116
+ // Init/terminate
117
+ int _glfwPlatformInit( void );
118
+ int _glfwPlatformTerminate( void );
119
+
120
+ // Enable/Disable
121
+ void _glfwPlatformEnableSystemKeys( void );
122
+ void _glfwPlatformDisableSystemKeys( void );
123
+
124
+ // Fullscreen
125
+ int _glfwPlatformGetVideoModes( GLFWvidmode *list, int maxcount );
126
+ void _glfwPlatformGetDesktopMode( GLFWvidmode *mode );
127
+
128
+ // OpenGL extensions
129
+ int _glfwPlatformExtensionSupported( const char *extension );
130
+ void * _glfwPlatformGetProcAddress( const char *procname );
131
+
132
+ // Joystick
133
+ int _glfwPlatformGetJoystickParam( int joy, int param );
134
+ int _glfwPlatformGetJoystickPos( int joy, float *pos, int numaxes );
135
+ int _glfwPlatformGetJoystickButtons( int joy, unsigned char *buttons, int numbuttons );
136
+
137
+ // Threads
138
+ GLFWthread _glfwPlatformCreateThread( GLFWthreadfun fun, void *arg );
139
+ void _glfwPlatformDestroyThread( GLFWthread ID );
140
+ int _glfwPlatformWaitThread( GLFWthread ID, int waitmode );
141
+ GLFWthread _glfwPlatformGetThreadID( void );
142
+ GLFWmutex _glfwPlatformCreateMutex( void );
143
+ void _glfwPlatformDestroyMutex( GLFWmutex mutex );
144
+ void _glfwPlatformLockMutex( GLFWmutex mutex );
145
+ void _glfwPlatformUnlockMutex( GLFWmutex mutex );
146
+ GLFWcond _glfwPlatformCreateCond( void );
147
+ void _glfwPlatformDestroyCond( GLFWcond cond );
148
+ void _glfwPlatformWaitCond( GLFWcond cond, GLFWmutex mutex, double timeout );
149
+ void _glfwPlatformSignalCond( GLFWcond cond );
150
+ void _glfwPlatformBroadcastCond( GLFWcond cond );
151
+ int _glfwPlatformGetNumberOfProcessors( void );
152
+
153
+ // Time
154
+ double _glfwPlatformGetTime( void );
155
+ void _glfwPlatformSetTime( double time );
156
+ void _glfwPlatformSleep( double time );
157
+
158
+ // Window management
159
+ int _glfwPlatformOpenWindow( int width, int height, int redbits, int greenbits, int bluebits, int alphabits, int depthbits, int stencilbits, int mode, _GLFWhints* hints );
160
+ void _glfwPlatformCloseWindow( void );
161
+ void _glfwPlatformSetWindowTitle( const char *title );
162
+ void _glfwPlatformSetWindowSize( int width, int height );
163
+ void _glfwPlatformSetWindowPos( int x, int y );
164
+ void _glfwPlatformIconifyWindow( void );
165
+ void _glfwPlatformRestoreWindow( void );
166
+ void _glfwPlatformSwapBuffers( void );
167
+ void _glfwPlatformSwapInterval( int interval );
168
+ void _glfwPlatformRefreshWindowParams( void );
169
+ void _glfwPlatformPollEvents( void );
170
+ void _glfwPlatformWaitEvents( void );
171
+ void _glfwPlatformHideMouseCursor( void );
172
+ void _glfwPlatformShowMouseCursor( void );
173
+ void _glfwPlatformSetMouseCursorPos( int x, int y );
174
+
175
+
176
+ //========================================================================
177
+ // Prototypes for platform independent internal functions
178
+ //========================================================================
179
+
180
+ // Window management (window.c)
181
+ void _glfwClearWindowHints( void );
182
+
183
+ // Input handling (window.c)
184
+ void _glfwClearInput( void );
185
+ void _glfwInputDeactivation( void );
186
+ void _glfwInputKey( int key, int action );
187
+ void _glfwInputChar( int character, int action );
188
+ void _glfwInputMouseClick( int button, int action );
189
+
190
+ // Threads (thread.c)
191
+ _GLFWthread * _glfwGetThreadPointer( int ID );
192
+ void _glfwAppendThread( _GLFWthread * t );
193
+ void _glfwRemoveThread( _GLFWthread * t );
194
+
195
+ // OpenGL extensions (glext.c)
196
+ int _glfwStringInExtensionString( const char *string, const GLubyte *extensions );
197
+
198
+ // Abstracted data streams (stream.c)
199
+ int _glfwOpenFileStream( _GLFWstream *stream, const char *name, const char *mode );
200
+ int _glfwOpenBufferStream( _GLFWstream *stream, void *data, long size );
201
+ long _glfwReadStream( _GLFWstream *stream, void *data, long size );
202
+ long _glfwTellStream( _GLFWstream *stream );
203
+ int _glfwSeekStream( _GLFWstream *stream, long offset, int whence );
204
+ void _glfwCloseStream( _GLFWstream *stream );
205
+
206
+ // Targa image I/O (tga.c)
207
+ int _glfwReadTGA( _GLFWstream *s, GLFWimage *img, int flags );
208
+
209
+
210
+ #endif // _internal_h_