rubygl 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +13 -5
  2. data/.travis/push-rdoc-to-gh-pages.sh +22 -0
  3. data/.travis.yml +18 -0
  4. data/Gemfile +7 -0
  5. data/Gemfile.lock +12 -0
  6. data/LICENSE +21 -21
  7. data/README.md +40 -0
  8. data/Rakefile +98 -83
  9. data/bin/ffi_code_gen.rb +166 -166
  10. data/bin/gl_code_gen.rb +458 -458
  11. data/examples/faceted_example.rb +71 -64
  12. data/examples/instanced_example.rb +135 -127
  13. data/examples/phong_example.rb +80 -71
  14. data/ext/windows/RubyGL.so +0 -0
  15. data/lib/rubygl/event.rb +64 -0
  16. data/lib/{RubyGL → rubygl}/geometry.rb +216 -211
  17. data/lib/{RubyGL → rubygl}/math.rb +300 -300
  18. data/lib/{RubyGL → rubygl}/memory.rb +125 -121
  19. data/lib/rubygl/native/all_enums.rb +641 -0
  20. data/lib/{RubyGL/Native → rubygl/native}/glcontext.rb +23 -47
  21. data/lib/{RubyGL/Native → rubygl/native}/include/GLContext.h +36 -36
  22. data/lib/{RubyGL/Native → rubygl/native}/include/Input.h +15 -15
  23. data/lib/{RubyGL/Native → rubygl/native}/include/Window.h +27 -27
  24. data/lib/rubygl/native/input.rb +247 -0
  25. data/lib/{RubyGL/Native → rubygl/native}/opengl.rb +2808 -2032
  26. data/lib/{RubyGL/Native → rubygl/native}/src/GLContext.c +72 -72
  27. data/lib/{RubyGL/Native → rubygl/native}/src/Input.c +25 -25
  28. data/lib/{RubyGL/Native → rubygl/native}/src/Window.c +57 -57
  29. data/lib/{RubyGL/Native → rubygl/native}/window.rb +24 -24
  30. data/lib/{RubyGL → rubygl}/setup.rb +50 -50
  31. data/lib/{RubyGL → rubygl}/shader.rb +203 -203
  32. data/lib/{RubyGL → rubygl}/util.rb +77 -77
  33. data/lib/rubygl.rb +49 -48
  34. data/{RubyGL.gemspec → rubygl.gemspec} +20 -23
  35. data/test/test_util.rb +19 -0
  36. metadata +36 -33
  37. data/lib/RubyGL/Native/input.rb +0 -13
  38. data/lib/RubyGL/callback.rb +0 -10
@@ -1,48 +1,24 @@
1
- require 'ffi'
2
-
3
- module RubyGL::Native
4
- enum :attr, [:red_size, 0,
5
- :green_size,
6
- :blue_size,
7
- :alpha_size,
8
- :buffer_size,
9
- :doublebuffer,
10
- :depth_size,
11
- :stencil_size,
12
- :accum_red_size,
13
- :accum_green_size,
14
- :accum_blue_size,
15
- :accum_alpha_size,
16
- :stereo,
17
- :multisamplebuffers,
18
- :multisamplesamples,
19
- :accelerated_visual,
20
- :retained_backing,
21
- :context_major_version,
22
- :context_minor_version,
23
- :context_egl,
24
- :context_flags,
25
- :context_profile_mask,
26
- :share_with_current_context,
27
- :framebuffer_srgb_capable ]
28
-
29
- attach_function :loadLibrary, [:pointer], :int
30
- attach_function :unloadLibrary, [], :void
31
- attach_function :createContext, [:pointer], :pointer
32
- attach_function :deleteContext, [:pointer], :void
33
- attach_function :setAttribute, [:attr, :int], :int
34
- attach_function :makeCurrent, [:pointer, :pointer], :int
35
- attach_function :setSwapInterval, [:int], :int
36
- attach_function :swapWindow, [:pointer], :void
37
-
38
- # SDL_GLcontextFlag
39
- attach_variable :CONTEXT_DEBUG_FLAG, :int
40
- attach_variable :CONTEXT_FORWARD_COMPATIBLE_FLAG, :int
41
- attach_variable :CONTEXT_ROBUST_ACCESS_FLAG, :int
42
- attach_variable :CONTEXT_RESET_ISOLATION_FLAG, :int
43
-
44
- # SDL_GLprofile
45
- attach_variable :CONTEXT_PROFILE_CORE, :int
46
- attach_variable :CONTEXT_PROFILE_COMPATIBILITY, :int
47
- attach_variable :CONTEXT_PROFILE_ES, :int
1
+ require 'ffi'
2
+ require_relative './all_enums'
3
+
4
+ module RubyGL::Native
5
+ attach_function :loadLibrary, [:pointer], :int
6
+ attach_function :unloadLibrary, [], :void
7
+ attach_function :createContext, [:pointer], :pointer
8
+ attach_function :deleteContext, [:pointer], :void
9
+ attach_function :setAttribute, [:attribute, :int], :int
10
+ attach_function :makeCurrent, [:pointer, :pointer], :int
11
+ attach_function :setSwapInterval, [:int], :int
12
+ attach_function :swapWindow, [:pointer], :void
13
+
14
+ # SDL_GLcontextFlag
15
+ attach_variable :CONTEXT_DEBUG_FLAG, :int
16
+ attach_variable :CONTEXT_FORWARD_COMPATIBLE_FLAG, :int
17
+ attach_variable :CONTEXT_ROBUST_ACCESS_FLAG, :int
18
+ attach_variable :CONTEXT_RESET_ISOLATION_FLAG, :int
19
+
20
+ # SDL_GLprofile
21
+ attach_variable :CONTEXT_PROFILE_CORE, :int
22
+ attach_variable :CONTEXT_PROFILE_COMPATIBILITY, :int
23
+ attach_variable :CONTEXT_PROFILE_ES, :int
48
24
  end
@@ -1,37 +1,37 @@
1
- #ifndef GLCONTEXT_H
2
- #define GLCONTEXT_H
3
-
4
- #include "SDL.h"
5
-
6
- int loadLibrary(const char* path);
7
-
8
- void unloadLibrary(void);
9
-
10
- SDL_GLContext createContext(SDL_Window* window);
11
-
12
- void deleteContext(SDL_GLContext context);
13
-
14
- int setAttribute(SDL_GLattr attr, int value);
15
-
16
- int makeCurrent(SDL_Window* window, SDL_GLContext context);
17
-
18
- int setSwapInterval(int interval);
19
-
20
- void swapWindow(SDL_Window* window);
21
-
22
- const SDL_GLattr RED_SIZE, GREEN_SIZE, BLUE_SIZE, ALPHA_SIZE, BUFFER_SIZE,
23
- DOUBLEBUFFER, DEPTH_SIZE, STENCIL_SIZE, ACCUM_RED_SIZE,
24
- ACCUM_GREEN_SIZE, ACCUM_BLUE_SIZE, ACCUM_ALPHA_SIZE, STEREO,
25
- MULTISAMPLEBUFFERS, MULTISAMPLESAMPLES, ACCELERATED_VISUAL,
26
- CONTEXT_MAJOR_VERSION, CONTEXT_MINOR_VERSION, CONTEXT_FLAGS,
27
- CONTEXT_PROFILE_MASK, SHARE_WITH_CURRENT_CONTEXT,
28
- FRAMEBUFFER_SRGB_CAPABLE;
29
-
30
- const SDL_GLcontextFlag CONTEXT_DEBUG_FLAG, CONTEXT_FORWARD_COMPATIBLE_FLAG,
31
- CONTEXT_ROBUST_ACCESS_FLAG,
32
- CONTEXT_RESET_ISOLATION_FLAG;
33
-
34
- const SDL_GLprofile CONTEXT_PROFILE_CORE, CONTEXT_PROFILE_COMPATIBILITY,
35
- CONTEXT_PROFILE_ES;
36
-
1
+ #ifndef GLCONTEXT_H
2
+ #define GLCONTEXT_H
3
+
4
+ #include "SDL.h"
5
+
6
+ int loadLibrary(const char* path);
7
+
8
+ void unloadLibrary(void);
9
+
10
+ SDL_GLContext createContext(SDL_Window* window);
11
+
12
+ void deleteContext(SDL_GLContext context);
13
+
14
+ int setAttribute(SDL_GLattr attr, int value);
15
+
16
+ int makeCurrent(SDL_Window* window, SDL_GLContext context);
17
+
18
+ int setSwapInterval(int interval);
19
+
20
+ void swapWindow(SDL_Window* window);
21
+
22
+ const SDL_GLattr RED_SIZE, GREEN_SIZE, BLUE_SIZE, ALPHA_SIZE, BUFFER_SIZE,
23
+ DOUBLEBUFFER, DEPTH_SIZE, STENCIL_SIZE, ACCUM_RED_SIZE,
24
+ ACCUM_GREEN_SIZE, ACCUM_BLUE_SIZE, ACCUM_ALPHA_SIZE, STEREO,
25
+ MULTISAMPLEBUFFERS, MULTISAMPLESAMPLES, ACCELERATED_VISUAL,
26
+ CONTEXT_MAJOR_VERSION, CONTEXT_MINOR_VERSION, CONTEXT_FLAGS,
27
+ CONTEXT_PROFILE_MASK, SHARE_WITH_CURRENT_CONTEXT,
28
+ FRAMEBUFFER_SRGB_CAPABLE;
29
+
30
+ const SDL_GLcontextFlag CONTEXT_DEBUG_FLAG, CONTEXT_FORWARD_COMPATIBLE_FLAG,
31
+ CONTEXT_ROBUST_ACCESS_FLAG,
32
+ CONTEXT_RESET_ISOLATION_FLAG;
33
+
34
+ const SDL_GLprofile CONTEXT_PROFILE_CORE, CONTEXT_PROFILE_COMPATIBILITY,
35
+ CONTEXT_PROFILE_ES;
36
+
37
37
  #endif // GLCONTEXT_H
@@ -1,16 +1,16 @@
1
- #ifndef INPUT_H
2
- #define INPUT_H
3
-
4
- #include "SDL.h"
5
-
6
- int initInput();
7
-
8
- void quitInput();
9
-
10
- void addEventWatch(SDL_EventFilter filter, void* userdata);
11
-
12
- void deleteEventWatch(SDL_EventFilter filter, void* userdata);
13
-
14
- void pumpEvents(void);
15
-
1
+ #ifndef INPUT_H
2
+ #define INPUT_H
3
+
4
+ #include "SDL.h"
5
+
6
+ int initInput();
7
+
8
+ void quitInput();
9
+
10
+ void addEventWatch(SDL_EventFilter filter, void* userdata);
11
+
12
+ void deleteEventWatch(SDL_EventFilter filter, void* userdata);
13
+
14
+ void pumpEvents(void);
15
+
16
16
  #endif // INPUT_H
@@ -1,28 +1,28 @@
1
- #ifndef WINDOW_H
2
- #define WINDOW_H
3
-
4
- #include "SDL.h"
5
-
6
- int initWindow();
7
-
8
- void quitWindow();
9
-
10
- SDL_Window* createWindow(const char* title, int x, int y, int w, int h,
11
- Uint32 flags);
12
-
13
- void destroyWindow(SDL_Window* window);
14
-
15
- void hideWindow(SDL_Window* window);
16
-
17
- void showWindow(SDL_Window* window);
18
-
19
- int setWindowBrightness(SDL_Window* window, float brightness);
20
-
21
- int showSimpleMessageBox(Uint32 flags, const char* title, const char* message,
22
- SDL_Window* window);
23
-
24
- const SDL_WindowFlags FULLSCREEN, OPENGL, SHOWN, HIDDEN, BORDERLESS, RESIZABLE,
25
- MINIMIZED, MAXIMIZED, INPUT_GRABBED, INPUT_FOCUS,
26
- MOUSE_FOCUS, FULLSCREEN_DESKTOP , FOREIGN, ALLOW_HIGHDPI;
27
-
1
+ #ifndef WINDOW_H
2
+ #define WINDOW_H
3
+
4
+ #include "SDL.h"
5
+
6
+ int initWindow();
7
+
8
+ void quitWindow();
9
+
10
+ SDL_Window* createWindow(const char* title, int x, int y, int w, int h,
11
+ Uint32 flags);
12
+
13
+ void destroyWindow(SDL_Window* window);
14
+
15
+ void hideWindow(SDL_Window* window);
16
+
17
+ void showWindow(SDL_Window* window);
18
+
19
+ int setWindowBrightness(SDL_Window* window, float brightness);
20
+
21
+ int showSimpleMessageBox(Uint32 flags, const char* title, const char* message,
22
+ SDL_Window* window);
23
+
24
+ const SDL_WindowFlags FULLSCREEN, OPENGL, SHOWN, HIDDEN, BORDERLESS, RESIZABLE,
25
+ MINIMIZED, MAXIMIZED, INPUT_GRABBED, INPUT_FOCUS,
26
+ MOUSE_FOCUS, FULLSCREEN_DESKTOP , FOREIGN, ALLOW_HIGHDPI;
27
+
28
28
  #endif // WINDOW_H
@@ -0,0 +1,247 @@
1
+ require 'ffi'
2
+ require_relative './all_enums'
3
+
4
+ module RubyGL::Native
5
+ attach_function :initInput, [], :int
6
+ attach_function :quitInput, [], :void
7
+ attach_function :addEventWatch, [:pointer, :pointer], :void
8
+ attach_function :deleteEventWatch, [:pointer, :pointer], :void
9
+ attach_function :pumpEvents, [], :void
10
+
11
+ # Overlaps With Layout Of Other Events; Used To Figure Out Current Event
12
+ class CommonEvent < FFI::Struct
13
+ layout :type, :uint32,
14
+ :timestamp, :uint32
15
+ end
16
+
17
+ # WindowEvents Are Identified By:
18
+ # :window_event
19
+ class WindowEvent < FFI::Struct
20
+ layout :type, :uint32,
21
+ :timestamp, :uint32,
22
+ :window_id, :uint32,
23
+ :event, :uint8,
24
+ :padding1, :uint8,
25
+ :padding2, :uint8,
26
+ :padding3, :uint8,
27
+ :data1, :int32,
28
+ :data2, :int32
29
+ end
30
+
31
+ # KeyboardEvents Are Identified By:
32
+ # :key_down
33
+ # :key_up
34
+ class Keysym < FFI::Struct
35
+ layout :scan_code, :scancode,
36
+ :sym, :keycode,
37
+ :mod, :uint16,
38
+ :unused, :uint32
39
+ end
40
+ class KeyboardEvent < FFI::Struct
41
+ layout :type, :uint32,
42
+ :timestamp, :uint32,
43
+ :window_id, :uint32,
44
+ :state, :uint8,
45
+ :repeat, :uint8,
46
+ :padding1, :uint8,
47
+ :padding2, :uint8,
48
+ :keysym, Keysym
49
+ end
50
+
51
+ # TextEditingEvents Are Identified By:
52
+ # :text_editing
53
+ class TextEditingEvent < FFI::Struct
54
+ layout :type, :uint32,
55
+ :timestamp, :uint32,
56
+ :window_id, :uint32,
57
+ :text, [:uint8, 32], # The Value Of SDL_TEXTEDITINGEVENT_TEXT_SIZE Is 32
58
+ :start, :int32,
59
+ :length, :int32
60
+ end
61
+
62
+ # TextInputEvents Are Identified By:
63
+ # :text_input
64
+ class TextInputEvent < FFI::Struct
65
+ layout :type, :uint32,
66
+ :timestamp, :uint32,
67
+ :window_id, :uint32,
68
+ :text, [:uint8, 32] # The Value Of SDL_TEXTEDITINGEVENT_TEXT_SIZE Is 32
69
+ end
70
+
71
+ # MouseMotionEvents Are Identified By:
72
+ # :mouse_motion
73
+ class MouseMotionEvent < FFI::Struct
74
+ layout :type, :uint32,
75
+ :timestamp, :uint32,
76
+ :window_id, :uint32,
77
+ :which, :uint32,
78
+ :state, :uint32,
79
+ :x, :int32,
80
+ :y, :int32,
81
+ :xrel, :int32,
82
+ :yrel, :int32
83
+ end
84
+
85
+ # MouseButtonEvents Are Identified By:
86
+ # :mouse_button_down
87
+ # :mouse_button_up
88
+ class MouseButtonEvent < FFI::Struct
89
+ layout :type, :uint32,
90
+ :timestamp, :uint32,
91
+ :window_id, :uint32,
92
+ :which, :uint32,
93
+ :button, :uint8,
94
+ :state, :uint8,
95
+ :clicks, :uint8,
96
+ :padding1, :uint8,
97
+ :x, :int32,
98
+ :y, :int32
99
+ end
100
+
101
+ # MouseWheelEvents Are Identified By:
102
+ # :mouse_wheel
103
+ class MouseWheelEvent < FFI::Struct
104
+ layout :type, :uint32,
105
+ :timestamp, :uint32,
106
+ :window_id, :uint32,
107
+ :which, :uint32,
108
+ :x, :int32,
109
+ :y, :int32
110
+ end
111
+
112
+ # JoyAxisEvents Are Identified By:
113
+ # :joy_axis_motion
114
+ class JoyAxisEvent < FFI::Struct
115
+ layout :type, :uint32,
116
+ :timestamp, :uint32,
117
+ :which, :int32,
118
+ :axis, :uint8,
119
+ :padding1, :uint8,
120
+ :padding2, :uint8,
121
+ :padding3, :uint8,
122
+ :value, :int16,
123
+ :padding4, :uint16
124
+ end
125
+
126
+ # JoyBallEvents Are Identified By:
127
+ # :joy_ball_motion
128
+ class JoyBallEvent < FFI::Struct
129
+ layout :type, :uint32,
130
+ :timestamp, :uint32,
131
+ :which, :int32,
132
+ :ball, :uint8,
133
+ :padding1, :uint8,
134
+ :padding2, :uint8,
135
+ :padding3, :uint8,
136
+ :xrel, :int16,
137
+ :yrel, :int16
138
+ end
139
+
140
+ # JoyHatEvents Are Identified By:
141
+ # :joy_hat_motion
142
+ class JoyHatEvent < FFI::Struct
143
+ layout :type, :uint32,
144
+ :timestamp, :uint32,
145
+ :which, :int32,
146
+ :hat, :uint8,
147
+ :value, :uint8,
148
+ :padding1, :uint8,
149
+ :padding2, :uint8
150
+ end
151
+
152
+ # JoyButtonEvents Are Identified By:
153
+ # :joy_button_down
154
+ # :joy_button_up
155
+ class JoyButtonEvent < FFI::Struct
156
+ layout :type, :uint32,
157
+ :timestamp, :uint32,
158
+ :which, :int32,
159
+ :button, :uint8,
160
+ :state, :uint8,
161
+ :padding1, :uint8,
162
+ :padding2, :uint8
163
+ end
164
+
165
+ # JoyDeviceEvents Are Identified By:
166
+ # :joy_device_added
167
+ # :joy_device_removed
168
+ class JoyDeviceEvent < FFI::Struct
169
+ layout :type, :uint32,
170
+ :timestamp, :uint32,
171
+ :which, :int32
172
+ end
173
+
174
+ # ControllerAxisEvents Are Identified By:
175
+ # :conroller_axis_motion
176
+ class ControllerAxisEvent < FFI::Struct
177
+ layout :type, :uint32,
178
+ :timestamp, :uint32,
179
+ :which, :int32,
180
+ :axis, :uint8,
181
+ :padding1, :uint8,
182
+ :padding2, :uint8,
183
+ :padding3, :uint8,
184
+ :value, :int16,
185
+ :padding4, :uint16
186
+ end
187
+
188
+ # ControllerButtonEvents Are Identified By:
189
+ # :controller_button_down
190
+ # :controller_button_up
191
+ class ControllerButtonEvent < FFI::Struct
192
+ layout :type, :uint32,
193
+ :timestamp, :uint32,
194
+ :which, :int32,
195
+ :button, :uint8,
196
+ :state, :uint8,
197
+ :padding1, :uint8,
198
+ :padding2, :uint8
199
+ end
200
+
201
+ # ControllerDeviceEvents Are Identified By:
202
+ # :controller_device_added
203
+ # :controller_device_removed
204
+ # :controller_device_remapped
205
+ class ControllerDeviceEvent < FFI::Struct
206
+ layout :type, :uint32,
207
+ :timestamp, :uint32,
208
+ :which, :int32
209
+ end
210
+
211
+ # DropEvents Are Identified By:
212
+ # :drop_file
213
+ class DropEvent < FFI::Struct
214
+ layout :type, :uint32,
215
+ :timestamp, :uint32,
216
+ :file, :string
217
+ end
218
+
219
+ # QuitEvents Are Identified By:
220
+ # :quit
221
+ class QuitEvent < FFI::Struct
222
+ layout :type, :uint32,
223
+ :timestamp, :uint32
224
+ end
225
+
226
+ class Event < FFI::Union
227
+ layout :common, CommonEvent,
228
+ :window, WindowEvent,
229
+ :key, KeyboardEvent,
230
+ :edit, TextEditingEvent,
231
+ :text, TextInputEvent,
232
+ :motion, MouseMotionEvent,
233
+ :button, MouseButtonEvent,
234
+ :wheel, MouseWheelEvent,
235
+ :jaxis, JoyAxisEvent,
236
+ :jball, JoyBallEvent,
237
+ :jhat, JoyHatEvent,
238
+ :jbutton, JoyButtonEvent,
239
+ :jdevice, JoyDeviceEvent,
240
+ :caxis, ControllerAxisEvent,
241
+ :cbutton, ControllerButtonEvent,
242
+ :cdevice, ControllerDeviceEvent,
243
+ :quit, QuitEvent,
244
+ :drop, DropEvent
245
+ end
246
+
247
+ end