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,349 @@
1
+ //========================================================================
2
+ // GLFW - An OpenGL framework
3
+ // File: platform.h
4
+ // Platform: Mac OS X
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 _platform_h_
32
+ #define _platform_h_
33
+
34
+
35
+ // This is the Mac OS X version of GLFW
36
+ #define _GLFW_MAC_OS_X
37
+
38
+
39
+ // Include files
40
+ #include <Carbon/Carbon.h>
41
+ #include <OpenGL/OpenGL.h>
42
+ #include <AGL/agl.h>
43
+ #include <sched.h>
44
+ #include <pthread.h>
45
+ #include <sys/sysctl.h>
46
+ #include "../../include/GL/glfw.h"
47
+
48
+
49
+ //========================================================================
50
+ // Defines
51
+ //========================================================================
52
+
53
+ #define _GLFW_MAX_PATH_LENGTH (8192)
54
+
55
+ #define MAC_KEY_ENTER 0x24
56
+ #define MAC_KEY_RETURN 0x34
57
+ #define MAC_KEY_ESC 0x35
58
+ #define MAC_KEY_F1 0x7A
59
+ #define MAC_KEY_F2 0x78
60
+ #define MAC_KEY_F3 0x63
61
+ #define MAC_KEY_F4 0x76
62
+ #define MAC_KEY_F5 0x60
63
+ #define MAC_KEY_F6 0x61
64
+ #define MAC_KEY_F7 0x62
65
+ #define MAC_KEY_F8 0x64
66
+ #define MAC_KEY_F9 0x65
67
+ #define MAC_KEY_F10 0x6D
68
+ #define MAC_KEY_F11 0x67
69
+ #define MAC_KEY_F12 0x6F
70
+ #define MAC_KEY_F13 0x69
71
+ #define MAC_KEY_F14 0x6B
72
+ #define MAC_KEY_F15 0x71
73
+ #define MAC_KEY_UP 0x7E
74
+ #define MAC_KEY_DOWN 0x7D
75
+ #define MAC_KEY_LEFT 0x7B
76
+ #define MAC_KEY_RIGHT 0x7C
77
+ #define MAC_KEY_TAB 0x30
78
+ #define MAC_KEY_BACKSPACE 0x33
79
+ #define MAC_KEY_HELP 0x72
80
+ #define MAC_KEY_DEL 0x75
81
+ #define MAC_KEY_PAGEUP 0x74
82
+ #define MAC_KEY_PAGEDOWN 0x79
83
+ #define MAC_KEY_HOME 0x73
84
+ #define MAC_KEY_END 0x77
85
+ #define MAC_KEY_KP_0 0x52
86
+ #define MAC_KEY_KP_1 0x53
87
+ #define MAC_KEY_KP_2 0x54
88
+ #define MAC_KEY_KP_3 0x55
89
+ #define MAC_KEY_KP_4 0x56
90
+ #define MAC_KEY_KP_5 0x57
91
+ #define MAC_KEY_KP_6 0x58
92
+ #define MAC_KEY_KP_7 0x59
93
+ #define MAC_KEY_KP_8 0x5B
94
+ #define MAC_KEY_KP_9 0x5C
95
+ #define MAC_KEY_KP_DIVIDE 0x4B
96
+ #define MAC_KEY_KP_MULTIPLY 0x43
97
+ #define MAC_KEY_KP_SUBTRACT 0x4E
98
+ #define MAC_KEY_KP_ADD 0x45
99
+ #define MAC_KEY_KP_DECIMAL 0x41
100
+ #define MAC_KEY_KP_EQUAL 0x51
101
+ #define MAC_KEY_KP_ENTER 0x4C
102
+
103
+ //========================================================================
104
+ // full-screen/desktop-window "virtual" function table
105
+ //========================================================================
106
+
107
+ typedef int ( * GLFWmacopenwindowfun )( int, int, int, int, int, int, int, int, int, int, int, int, int, int, int );
108
+ typedef void ( * GLFWmacclosewindowfun )( void );
109
+ typedef void ( * GLFWmacsetwindowtitlefun )( const char * );
110
+ typedef void ( * GLFWmacsetwindowsizefun )( int, int );
111
+ typedef void ( * GLFWmacsetwindowposfun )( int, int );
112
+ typedef void ( * GLFWmaciconifywindowfun )( void );
113
+ typedef void ( * GLFWmacrestorewindowfun )( void );
114
+ typedef void ( * GLFWmacrefreshwindowparamsfun )( void );
115
+ typedef void ( * GLFWmacsetmousecursorposfun )( int, int );
116
+
117
+ typedef struct
118
+ {
119
+ GLFWmacopenwindowfun OpenWindow;
120
+ GLFWmacclosewindowfun CloseWindow;
121
+ GLFWmacsetwindowtitlefun SetWindowTitle;
122
+ GLFWmacsetwindowsizefun SetWindowSize;
123
+ GLFWmacsetwindowposfun SetWindowPos;
124
+ GLFWmaciconifywindowfun IconifyWindow;
125
+ GLFWmacrestorewindowfun RestoreWindow;
126
+ GLFWmacrefreshwindowparamsfun RefreshWindowParams;
127
+ GLFWmacsetmousecursorposfun SetMouseCursorPos;
128
+ }
129
+ _GLFWmacwindowfunctions;
130
+
131
+
132
+ //========================================================================
133
+ // Global variables (GLFW internals)
134
+ //========================================================================
135
+
136
+ GLFWGLOBAL CFDictionaryRef _glfwDesktopVideoMode;
137
+
138
+ //------------------------------------------------------------------------
139
+ // Window structure
140
+ //------------------------------------------------------------------------
141
+ typedef struct _GLFWwin_struct _GLFWwin;
142
+
143
+ struct _GLFWwin_struct {
144
+
145
+ // ========= PLATFORM INDEPENDENT MANDATORY PART =========================
146
+
147
+ // Window states
148
+ int Opened; // Flag telling if window is opened or not
149
+ int Active; // Application active flag
150
+ int Iconified; // Window iconified flag
151
+
152
+ // User callback functions
153
+ GLFWwindowsizefun WindowSizeCallback;
154
+ GLFWwindowclosefun WindowCloseCallback;
155
+ GLFWwindowrefreshfun WindowRefreshCallback;
156
+ GLFWmousebuttonfun MouseButtonCallback;
157
+ GLFWmouseposfun MousePosCallback;
158
+ GLFWmousewheelfun MouseWheelCallback;
159
+ GLFWkeyfun KeyCallback;
160
+ GLFWcharfun CharCallback;
161
+
162
+ // User selected window settings
163
+ int Fullscreen; // Fullscreen flag
164
+ int MouseLock; // Mouse-lock flag
165
+ int AutoPollEvents; // Auto polling flag
166
+ int SysKeysDisabled; // System keys disabled flag
167
+ int RefreshRate; // Refresh rate (for fullscreen mode)
168
+ int WindowNoResize; // Resize- and maximize gadgets disabled flag
169
+ int Samples;
170
+
171
+ // Window status
172
+ int Width, Height; // Window width and heigth
173
+
174
+ // Extensions & OpenGL version
175
+ int Has_GL_SGIS_generate_mipmap;
176
+ int Has_GL_ARB_texture_non_power_of_two;
177
+ int GLVerMajor,GLVerMinor;
178
+
179
+
180
+ // ========= PLATFORM SPECIFIC PART ======================================
181
+
182
+ WindowRef MacWindow;
183
+ AGLContext AGLContext;
184
+ CGLContextObj CGLContext;
185
+
186
+ EventHandlerUPP MouseUPP;
187
+ EventHandlerUPP CommandUPP;
188
+ EventHandlerUPP KeyboardUPP;
189
+ EventHandlerUPP WindowUPP;
190
+
191
+ _GLFWmacwindowfunctions* WindowFunctions;
192
+
193
+ // for easy access by _glfwPlatformGetWindowParam
194
+ int Accelerated;
195
+ int RedBits, GreenBits, BlueBits, AlphaBits;
196
+ int DepthBits;
197
+ int StencilBits;
198
+ int AccumRedBits, AccumGreenBits, AccumBlueBits, AccumAlphaBits;
199
+ int AuxBuffers;
200
+ int Stereo;
201
+ };
202
+
203
+ GLFWGLOBAL _GLFWwin _glfwWin;
204
+
205
+
206
+ //------------------------------------------------------------------------
207
+ // User input status (some of this should go in _GLFWwin)
208
+ //------------------------------------------------------------------------
209
+ GLFWGLOBAL struct {
210
+
211
+ // ========= PLATFORM INDEPENDENT MANDATORY PART =========================
212
+
213
+ // Mouse status
214
+ int MousePosX, MousePosY;
215
+ int WheelPos;
216
+ char MouseButton[ GLFW_MOUSE_BUTTON_LAST+1 ];
217
+
218
+ // Keyboard status
219
+ char Key[ GLFW_KEY_LAST+1 ];
220
+ int LastChar;
221
+
222
+ // User selected settings
223
+ int StickyKeys;
224
+ int StickyMouseButtons;
225
+ int KeyRepeat;
226
+
227
+
228
+ // ========= PLATFORM SPECIFIC PART ======================================
229
+
230
+ UInt32 Modifiers;
231
+
232
+ } _glfwInput;
233
+
234
+
235
+
236
+
237
+ //------------------------------------------------------------------------
238
+ // Thread information
239
+ //------------------------------------------------------------------------
240
+ typedef struct _GLFWthread_struct _GLFWthread;
241
+
242
+ // Thread record (one for each thread)
243
+ struct _GLFWthread_struct {
244
+ // Pointer to previous and next threads in linked list
245
+ _GLFWthread *Previous, *Next;
246
+
247
+ // GLFW user side thread information
248
+ GLFWthread ID;
249
+ GLFWthreadfun Function;
250
+
251
+ // System side thread information
252
+ pthread_t PosixID;
253
+ };
254
+
255
+ // General thread information
256
+ GLFWGLOBAL struct {
257
+ // Critical section lock
258
+ pthread_mutex_t CriticalSection;
259
+
260
+ // Next thread ID to use (increments for every created thread)
261
+ GLFWthread NextID;
262
+
263
+ // First thread in linked list (always the main thread)
264
+ _GLFWthread First;
265
+ } _glfwThrd;
266
+
267
+
268
+ //------------------------------------------------------------------------
269
+ // Library global data
270
+ //------------------------------------------------------------------------
271
+ GLFWGLOBAL struct {
272
+
273
+ // Timer data
274
+ struct {
275
+ double t0;
276
+ } Timer;
277
+
278
+ struct {
279
+ // Bundle for dynamically-loading extension function pointers
280
+ CFBundleRef OpenGLFramework;
281
+ } Libs;
282
+
283
+ int Unbundled;
284
+
285
+ } _glfwLibrary;
286
+
287
+
288
+
289
+ //========================================================================
290
+ // Macros for encapsulating critical code sections (i.e. making parts
291
+ // of GLFW thread safe)
292
+ //========================================================================
293
+
294
+ // Define so we can use the same thread code as X11
295
+ #define _glfw_numprocessors(n) { \
296
+ int mib[2], ncpu; \
297
+ size_t len = 1; \
298
+ mib[0] = CTL_HW; \
299
+ mib[1] = HW_NCPU; \
300
+ n = 1; \
301
+ if( sysctl( mib, 2, &ncpu, &len, NULL, 0 ) != -1 ) \
302
+ { \
303
+ if( len > 0 ) \
304
+ { \
305
+ n = ncpu; \
306
+ } \
307
+ } \
308
+ }
309
+
310
+ // Thread list management
311
+ #define ENTER_THREAD_CRITICAL_SECTION \
312
+ pthread_mutex_lock( &_glfwThrd.CriticalSection );
313
+ #define LEAVE_THREAD_CRITICAL_SECTION \
314
+ pthread_mutex_unlock( &_glfwThrd.CriticalSection );
315
+
316
+
317
+ //========================================================================
318
+ // Prototypes for platform specific internal functions
319
+ //========================================================================
320
+
321
+ void _glfwChangeToResourcesDirectory( void );
322
+
323
+ int _glfwInstallEventHandlers( void );
324
+
325
+ //========================================================================
326
+ // Prototypes for full-screen/desktop-window "virtual" functions
327
+ //========================================================================
328
+
329
+ int _glfwMacFSOpenWindow( int width, int height, int redbits, int greenbits, int bluebits, int alphabits, int depthbits, int stencilbits, int accumredbits, int accumgreenbits, int accumbluebits, int accumalphabits, int auxbuffers, int stereo, int refreshrate );
330
+ void _glfwMacFSCloseWindow( void );
331
+ void _glfwMacFSSetWindowTitle( const char *title );
332
+ void _glfwMacFSSetWindowSize( int width, int height );
333
+ void _glfwMacFSSetWindowPos( int x, int y );
334
+ void _glfwMacFSIconifyWindow( void );
335
+ void _glfwMacFSRestoreWindow( void );
336
+ void _glfwMacFSRefreshWindowParams( void );
337
+ void _glfwMacFSSetMouseCursorPos( int x, int y );
338
+
339
+ int _glfwMacDWOpenWindow( int width, int height, int redbits, int greenbits, int bluebits, int alphabits, int depthbits, int stencilbits, int accumredbits, int accumgreenbits, int accumbluebits, int accumalphabits, int auxbuffers, int stereo, int refreshrate );
340
+ void _glfwMacDWCloseWindow( void );
341
+ void _glfwMacDWSetWindowTitle( const char *title );
342
+ void _glfwMacDWSetWindowSize( int width, int height );
343
+ void _glfwMacDWSetWindowPos( int x, int y );
344
+ void _glfwMacDWIconifyWindow( void );
345
+ void _glfwMacDWRestoreWindow( void );
346
+ void _glfwMacDWRefreshWindowParams( void );
347
+ void _glfwMacDWSetMouseCursorPos( int x, int y );
348
+
349
+ #endif // _platform_h_
@@ -0,0 +1,194 @@
1
+ //========================================================================
2
+ // GLFW - An OpenGL framework
3
+ // File: stream.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
+
32
+ #include "internal.h"
33
+
34
+
35
+ //========================================================================
36
+ // Opens a GLFW stream with a file
37
+ //========================================================================
38
+
39
+ int _glfwOpenFileStream( _GLFWstream *stream, const char* name, const char* mode )
40
+ {
41
+ memset( stream, 0, sizeof(_GLFWstream) );
42
+
43
+ stream->File = fopen( name, mode );
44
+ if( stream->File == NULL )
45
+ {
46
+ return GL_FALSE;
47
+ }
48
+
49
+ return GL_TRUE;
50
+ }
51
+
52
+
53
+ //========================================================================
54
+ // Opens a GLFW stream with a memory block
55
+ //========================================================================
56
+
57
+ int _glfwOpenBufferStream( _GLFWstream *stream, void *data, long size )
58
+ {
59
+ memset( stream, 0, sizeof(_GLFWstream) );
60
+
61
+ stream->Data = data;
62
+ stream->Size = size;
63
+ return GL_TRUE;
64
+ }
65
+
66
+
67
+ //========================================================================
68
+ // Reads data from a GLFW stream
69
+ //========================================================================
70
+
71
+ long _glfwReadStream( _GLFWstream *stream, void *data, long size )
72
+ {
73
+ if( stream->File != NULL )
74
+ {
75
+ return fread( data, 1, size, stream->File );
76
+ }
77
+
78
+ if( stream->Data != NULL )
79
+ {
80
+ // Check for EOF
81
+ if( stream->Position == stream->Size )
82
+ {
83
+ return 0;
84
+ }
85
+
86
+ // Clamp read size to available data
87
+ if( stream->Position + size > stream->Size )
88
+ {
89
+ size = stream->Size - stream->Position;
90
+ }
91
+
92
+ // Perform data read
93
+ memcpy( data, (unsigned char*) stream->Data + stream->Position, size );
94
+ stream->Position += size;
95
+ return size;
96
+ }
97
+
98
+ return 0;
99
+ }
100
+
101
+
102
+ //========================================================================
103
+ // Returns the current position of a GLFW stream
104
+ //========================================================================
105
+
106
+ long _glfwTellStream( _GLFWstream *stream )
107
+ {
108
+ if( stream->File != NULL )
109
+ {
110
+ return ftell( stream->File );
111
+ }
112
+
113
+ if( stream->Data != NULL )
114
+ {
115
+ return stream->Position;
116
+ }
117
+
118
+ return 0;
119
+ }
120
+
121
+
122
+ //========================================================================
123
+ // Sets the current position of a GLFW stream
124
+ //========================================================================
125
+
126
+ int _glfwSeekStream( _GLFWstream *stream, long offset, int whence )
127
+ {
128
+ long position;
129
+
130
+ if( stream->File != NULL )
131
+ {
132
+ if( fseek( stream->File, offset, whence ) != 0 )
133
+ {
134
+ return GL_FALSE;
135
+ }
136
+
137
+ return GL_TRUE;
138
+ }
139
+
140
+ if( stream->Data != NULL )
141
+ {
142
+ position = offset;
143
+
144
+ // Handle whence parameter
145
+ if( whence == SEEK_CUR )
146
+ {
147
+ position += stream->Position;
148
+ }
149
+ else if( whence == SEEK_END )
150
+ {
151
+ position += stream->Size;
152
+ }
153
+ else if( whence != SEEK_SET )
154
+ {
155
+ return GL_FALSE;
156
+ }
157
+
158
+ // Clamp offset to buffer bounds and apply it
159
+ if( position > stream->Size )
160
+ {
161
+ stream->Position = stream->Size;
162
+ }
163
+ else if( position < 0 )
164
+ {
165
+ stream->Position = 0;
166
+ }
167
+ else
168
+ {
169
+ stream->Position = position;
170
+ }
171
+
172
+ return GL_TRUE;
173
+ }
174
+
175
+ return GL_FALSE;
176
+ }
177
+
178
+
179
+ //========================================================================
180
+ // Closes a GLFW stream
181
+ //========================================================================
182
+
183
+ void _glfwCloseStream( _GLFWstream *stream )
184
+ {
185
+ if( stream->File != NULL )
186
+ {
187
+ fclose( stream->File );
188
+ }
189
+
190
+ // Nothing to be done about (user allocated) memory blocks
191
+
192
+ memset( stream, 0, sizeof(_GLFWstream) );
193
+ }
194
+