ruby2d 0.9.0 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/README.md +8 -8
- data/assets/Rakefile +85 -0
- data/assets/include/SDL2/SDL.h +1 -1
- data/assets/include/SDL2/SDL_assert.h +1 -1
- data/assets/include/SDL2/SDL_atomic.h +20 -2
- data/assets/include/SDL2/SDL_audio.h +47 -14
- data/assets/include/SDL2/SDL_bits.h +10 -1
- data/assets/include/SDL2/SDL_blendmode.h +7 -7
- data/assets/include/SDL2/SDL_clipboard.h +1 -1
- data/assets/include/SDL2/SDL_config.h +24 -390
- data/assets/include/SDL2/SDL_config_android.h +178 -0
- data/assets/include/SDL2/SDL_config_iphoneos.h +201 -0
- data/assets/include/SDL2/SDL_config_macosx.h +240 -0
- data/assets/include/SDL2/SDL_config_minimal.h +85 -0
- data/assets/include/SDL2/SDL_config_os2.h +170 -0
- data/assets/include/SDL2/SDL_config_pandora.h +133 -0
- data/assets/include/SDL2/SDL_config_psp.h +164 -0
- data/assets/include/SDL2/SDL_config_windows.h +257 -0
- data/assets/include/SDL2/SDL_config_winrt.h +240 -0
- data/assets/include/SDL2/SDL_config_wiz.h +146 -0
- data/assets/include/SDL2/SDL_copying.h +20 -0
- data/assets/include/SDL2/SDL_cpuinfo.h +90 -8
- data/assets/include/SDL2/SDL_egl.h +1 -1
- data/assets/include/SDL2/SDL_endian.h +1 -1
- data/assets/include/SDL2/SDL_error.h +1 -1
- data/assets/include/SDL2/SDL_events.h +4 -1
- data/assets/include/SDL2/SDL_filesystem.h +1 -1
- data/assets/include/SDL2/SDL_gamecontroller.h +1 -1
- data/assets/include/SDL2/SDL_gesture.h +1 -1
- data/assets/include/SDL2/SDL_haptic.h +1 -1
- data/assets/include/SDL2/SDL_hints.h +145 -14
- data/assets/include/SDL2/SDL_image.h +2 -2
- data/assets/include/SDL2/SDL_joystick.h +1 -1
- data/assets/include/SDL2/SDL_keyboard.h +1 -1
- data/assets/include/SDL2/SDL_keycode.h +1 -1
- data/assets/include/SDL2/SDL_loadso.h +1 -1
- data/assets/include/SDL2/SDL_log.h +1 -1
- data/assets/include/SDL2/SDL_main.h +28 -16
- data/assets/include/SDL2/SDL_messagebox.h +1 -1
- data/assets/include/SDL2/SDL_mouse.h +1 -1
- data/assets/include/SDL2/SDL_mutex.h +1 -1
- data/assets/include/SDL2/SDL_name.h +1 -1
- data/assets/include/SDL2/SDL_opengl.h +1 -1
- data/assets/include/SDL2/SDL_opengles.h +1 -1
- data/assets/include/SDL2/SDL_opengles2.h +1 -1
- data/assets/include/SDL2/SDL_pixels.h +3 -3
- data/assets/include/SDL2/SDL_platform.h +1 -1
- data/assets/include/SDL2/SDL_power.h +1 -1
- data/assets/include/SDL2/SDL_quit.h +1 -1
- data/assets/include/SDL2/SDL_rect.h +29 -3
- data/assets/include/SDL2/SDL_render.h +168 -1
- data/assets/include/SDL2/SDL_revision.h +2 -2
- data/assets/include/SDL2/SDL_rwops.h +50 -13
- data/assets/include/SDL2/SDL_scancode.h +2 -2
- data/assets/include/SDL2/SDL_sensor.h +4 -4
- data/assets/include/SDL2/SDL_shape.h +1 -1
- data/assets/include/SDL2/SDL_stdinc.h +1 -1
- data/assets/include/SDL2/SDL_surface.h +2 -1
- data/assets/include/SDL2/SDL_system.h +1 -1
- data/assets/include/SDL2/SDL_syswm.h +11 -8
- data/assets/include/SDL2/SDL_test.h +1 -1
- data/assets/include/SDL2/SDL_test_assert.h +1 -1
- data/assets/include/SDL2/SDL_test_common.h +22 -5
- data/assets/include/SDL2/SDL_test_compare.h +1 -1
- data/assets/include/SDL2/SDL_test_crc32.h +1 -1
- data/assets/include/SDL2/SDL_test_font.h +1 -1
- data/assets/include/SDL2/SDL_test_fuzzer.h +1 -1
- data/assets/include/SDL2/SDL_test_harness.h +1 -1
- data/assets/include/SDL2/SDL_test_images.h +1 -1
- data/assets/include/SDL2/SDL_test_log.h +1 -1
- data/assets/include/SDL2/SDL_test_md5.h +1 -1
- data/assets/include/SDL2/SDL_test_memory.h +3 -3
- data/assets/include/SDL2/SDL_test_random.h +1 -1
- data/assets/include/SDL2/SDL_thread.h +1 -1
- data/assets/include/SDL2/SDL_timer.h +1 -1
- data/assets/include/SDL2/SDL_touch.h +17 -1
- data/assets/include/SDL2/SDL_types.h +1 -1
- data/assets/include/SDL2/SDL_version.h +2 -2
- data/assets/include/SDL2/SDL_video.h +1 -1
- data/assets/include/SDL2/SDL_vulkan.h +3 -3
- data/assets/include/SDL2/begin_code.h +4 -1
- data/assets/include/SDL2/close_code.h +4 -1
- data/assets/macos/lib/libFLAC.a +0 -0
- data/assets/macos/lib/libSDL2.a +0 -0
- data/assets/macos/lib/libSDL2_image.a +0 -0
- data/assets/macos/lib/libSDL2_mixer.a +0 -0
- data/assets/macos/lib/libSDL2_ttf.a +0 -0
- data/assets/macos/lib/libfreetype.a +0 -0
- data/assets/macos/lib/libjpeg.a +0 -0
- data/assets/macos/lib/libmpg123.a +0 -0
- data/assets/macos/lib/libogg.a +0 -0
- data/assets/macos/lib/libpng16.a +0 -0
- data/assets/macos/lib/libtiff.a +0 -0
- data/assets/macos/lib/libwebp.a +0 -0
- data/assets/mingw/bin/SDL2.dll +0 -0
- data/assets/mingw/bin/SDL2_image.dll +0 -0
- data/assets/mingw/bin/libpng16-16.dll +0 -0
- data/assets/mingw/bin/libtiff-5.dll +0 -0
- data/assets/mingw/bin/libwebp-7.dll +0 -0
- data/assets/mingw/lib/libSDL2.a +0 -0
- data/assets/mingw/lib/libSDL2.dll.a +0 -0
- data/assets/mingw/lib/libSDL2_image.a +0 -0
- data/assets/mingw/lib/libSDL2_image.dll.a +0 -0
- data/assets/mingw/lib/libSDL2_test.a +0 -0
- data/assets/mingw/lib/libSDL2main.a +0 -0
- data/bin/ruby2d +2 -1
- data/ext/ruby2d/common.c +185 -0
- data/ext/ruby2d/controllers.c +110 -0
- data/ext/ruby2d/extconf.rb +97 -46
- data/ext/ruby2d/gl.c +430 -0
- data/ext/ruby2d/gl2.c +146 -0
- data/ext/ruby2d/gl3.c +348 -0
- data/ext/ruby2d/gles.c +308 -0
- data/ext/ruby2d/image.c +138 -0
- data/ext/ruby2d/input.c +48 -0
- data/ext/ruby2d/music.c +114 -0
- data/ext/ruby2d/ruby2d.c +125 -126
- data/{assets/include/simple2d.h → ext/ruby2d/ruby2d.h} +223 -201
- data/ext/ruby2d/shapes.c +154 -0
- data/ext/ruby2d/sound.c +93 -0
- data/ext/ruby2d/sprite.c +147 -0
- data/ext/ruby2d/text.c +129 -0
- data/ext/ruby2d/window.c +414 -0
- data/lib/ruby2d.rb +1 -1
- data/lib/ruby2d/cli/build.rb +3 -8
- data/lib/ruby2d/cli/colorize.rb +10 -0
- data/lib/ruby2d/version.rb +1 -1
- metadata +34 -10
- data/assets/macos/lib/libsimple2d.a +0 -0
- data/assets/mingw/lib/libsimple2d.a +0 -0
- data/lib/ruby2d/colorize.rb +0 -10
@@ -1,4 +1,4 @@
|
|
1
|
-
//
|
1
|
+
// ruby2d.h
|
2
2
|
|
3
3
|
#ifdef __cplusplus
|
4
4
|
extern "C" {
|
@@ -101,93 +101,93 @@ extern "C" {
|
|
101
101
|
#include <SDL2/SDL_ttf.h>
|
102
102
|
#endif
|
103
103
|
|
104
|
-
//
|
104
|
+
// Ruby 2D Definitions /////////////////////////////////////////////////////////
|
105
105
|
|
106
106
|
// Messages
|
107
|
-
#define
|
108
|
-
#define
|
109
|
-
#define
|
107
|
+
#define R2D_INFO 1
|
108
|
+
#define R2D_WARN 2
|
109
|
+
#define R2D_ERROR 3
|
110
110
|
|
111
111
|
// Window attributes
|
112
|
-
#define
|
113
|
-
#define
|
114
|
-
#define
|
115
|
-
#define
|
116
|
-
#define
|
117
|
-
#define
|
112
|
+
#define R2D_RESIZABLE SDL_WINDOW_RESIZABLE
|
113
|
+
#define R2D_BORDERLESS SDL_WINDOW_BORDERLESS
|
114
|
+
#define R2D_FULLSCREEN SDL_WINDOW_FULLSCREEN_DESKTOP
|
115
|
+
#define R2D_HIGHDPI SDL_WINDOW_ALLOW_HIGHDPI
|
116
|
+
#define R2D_DISPLAY_WIDTH 0
|
117
|
+
#define R2D_DISPLAY_HEIGHT 0
|
118
118
|
|
119
119
|
// Viewport scaling modes
|
120
|
-
#define
|
121
|
-
#define
|
122
|
-
#define
|
123
|
-
#define
|
120
|
+
#define R2D_FIXED 1
|
121
|
+
#define R2D_EXPAND 2
|
122
|
+
#define R2D_SCALE 3
|
123
|
+
#define R2D_STRETCH 4
|
124
124
|
|
125
125
|
// Positions
|
126
|
-
#define
|
127
|
-
#define
|
128
|
-
#define
|
129
|
-
#define
|
130
|
-
#define
|
126
|
+
#define R2D_CENTER 1
|
127
|
+
#define R2D_TOP_LEFT 2
|
128
|
+
#define R2D_TOP_RIGHT 3
|
129
|
+
#define R2D_BOTTOM_LEFT 4
|
130
|
+
#define R2D_BOTTOM_RIGHT 5
|
131
131
|
|
132
132
|
// Keyboard events
|
133
|
-
#define
|
134
|
-
#define
|
135
|
-
#define
|
133
|
+
#define R2D_KEY_DOWN 1 // key is pressed
|
134
|
+
#define R2D_KEY_HELD 2 // key is held down
|
135
|
+
#define R2D_KEY_UP 3 // key is released
|
136
136
|
|
137
137
|
// Mouse events
|
138
|
-
#define
|
139
|
-
#define
|
140
|
-
#define
|
141
|
-
#define
|
142
|
-
#define
|
143
|
-
#define
|
144
|
-
#define
|
145
|
-
#define
|
146
|
-
#define
|
147
|
-
#define
|
148
|
-
#define
|
138
|
+
#define R2D_MOUSE_DOWN 1 // mouse button pressed
|
139
|
+
#define R2D_MOUSE_UP 2 // mouse button released
|
140
|
+
#define R2D_MOUSE_SCROLL 3 // mouse scrolling or wheel movement
|
141
|
+
#define R2D_MOUSE_MOVE 4 // mouse movement
|
142
|
+
#define R2D_MOUSE_LEFT SDL_BUTTON_LEFT
|
143
|
+
#define R2D_MOUSE_MIDDLE SDL_BUTTON_MIDDLE
|
144
|
+
#define R2D_MOUSE_RIGHT SDL_BUTTON_RIGHT
|
145
|
+
#define R2D_MOUSE_X1 SDL_BUTTON_X1
|
146
|
+
#define R2D_MOUSE_X2 SDL_BUTTON_X2
|
147
|
+
#define R2D_MOUSE_SCROLL_NORMAL SDL_MOUSEWHEEL_NORMAL
|
148
|
+
#define R2D_MOUSE_SCROLL_INVERTED SDL_MOUSEWHEEL_FLIPPED
|
149
149
|
|
150
150
|
// Controller events
|
151
|
-
#define
|
152
|
-
#define
|
153
|
-
#define
|
151
|
+
#define R2D_AXIS 1
|
152
|
+
#define R2D_BUTTON_DOWN 2
|
153
|
+
#define R2D_BUTTON_UP 3
|
154
154
|
|
155
155
|
// Controller axis labels
|
156
|
-
#define
|
157
|
-
#define
|
158
|
-
#define
|
159
|
-
#define
|
160
|
-
#define
|
161
|
-
#define
|
162
|
-
#define
|
163
|
-
#define
|
156
|
+
#define R2D_AXIS_INVALID SDL_CONTROLLER_AXIS_INVALID
|
157
|
+
#define R2D_AXIS_LEFTX SDL_CONTROLLER_AXIS_LEFTX
|
158
|
+
#define R2D_AXIS_LEFTY SDL_CONTROLLER_AXIS_LEFTY
|
159
|
+
#define R2D_AXIS_RIGHTX SDL_CONTROLLER_AXIS_RIGHTX
|
160
|
+
#define R2D_AXIS_RIGHTY SDL_CONTROLLER_AXIS_RIGHTY
|
161
|
+
#define R2D_AXIS_TRIGGERLEFT SDL_CONTROLLER_AXIS_TRIGGERLEFT
|
162
|
+
#define R2D_AXIS_TRIGGERRIGHT SDL_CONTROLLER_AXIS_TRIGGERRIGHT
|
163
|
+
#define R2D_AXIS_MAX SDL_CONTROLLER_AXIS_MAX
|
164
164
|
|
165
165
|
// Controller button labels
|
166
|
-
#define
|
167
|
-
#define
|
168
|
-
#define
|
169
|
-
#define
|
170
|
-
#define
|
171
|
-
#define
|
172
|
-
#define
|
173
|
-
#define
|
174
|
-
#define
|
175
|
-
#define
|
176
|
-
#define
|
177
|
-
#define
|
178
|
-
#define
|
179
|
-
#define
|
180
|
-
#define
|
181
|
-
#define
|
182
|
-
#define
|
166
|
+
#define R2D_BUTTON_INVALID SDL_CONTROLLER_BUTTON_INVALID
|
167
|
+
#define R2D_BUTTON_A SDL_CONTROLLER_BUTTON_A
|
168
|
+
#define R2D_BUTTON_B SDL_CONTROLLER_BUTTON_B
|
169
|
+
#define R2D_BUTTON_X SDL_CONTROLLER_BUTTON_X
|
170
|
+
#define R2D_BUTTON_Y SDL_CONTROLLER_BUTTON_Y
|
171
|
+
#define R2D_BUTTON_BACK SDL_CONTROLLER_BUTTON_BACK
|
172
|
+
#define R2D_BUTTON_GUIDE SDL_CONTROLLER_BUTTON_GUIDE
|
173
|
+
#define R2D_BUTTON_START SDL_CONTROLLER_BUTTON_START
|
174
|
+
#define R2D_BUTTON_LEFTSTICK SDL_CONTROLLER_BUTTON_LEFTSTICK
|
175
|
+
#define R2D_BUTTON_RIGHTSTICK SDL_CONTROLLER_BUTTON_RIGHTSTICK
|
176
|
+
#define R2D_BUTTON_LEFTSHOULDER SDL_CONTROLLER_BUTTON_LEFTSHOULDER
|
177
|
+
#define R2D_BUTTON_RIGHTSHOULDER SDL_CONTROLLER_BUTTON_RIGHTSHOULDER
|
178
|
+
#define R2D_BUTTON_DPAD_UP SDL_CONTROLLER_BUTTON_DPAD_UP
|
179
|
+
#define R2D_BUTTON_DPAD_DOWN SDL_CONTROLLER_BUTTON_DPAD_DOWN
|
180
|
+
#define R2D_BUTTON_DPAD_LEFT SDL_CONTROLLER_BUTTON_DPAD_LEFT
|
181
|
+
#define R2D_BUTTON_DPAD_RIGHT SDL_CONTROLLER_BUTTON_DPAD_RIGHT
|
182
|
+
#define R2D_BUTTON_MAX SDL_CONTROLLER_BUTTON_MAX
|
183
183
|
|
184
184
|
// Internal Shared Data ////////////////////////////////////////////////////////
|
185
185
|
|
186
|
-
extern bool
|
186
|
+
extern bool R2D_diagnostics; // flag for whether to print diagnostics with R2D_Log
|
187
187
|
|
188
188
|
// Type Definitions ////////////////////////////////////////////////////////////
|
189
189
|
|
190
|
-
//
|
190
|
+
// R2D_Event
|
191
191
|
typedef struct {
|
192
192
|
int which;
|
193
193
|
int type;
|
@@ -201,68 +201,68 @@ typedef struct {
|
|
201
201
|
int direction;
|
202
202
|
int axis;
|
203
203
|
int value;
|
204
|
-
}
|
204
|
+
} R2D_Event;
|
205
205
|
|
206
|
-
typedef void (*
|
207
|
-
typedef void (*
|
208
|
-
typedef void (*
|
209
|
-
typedef void (*
|
210
|
-
typedef void (*
|
206
|
+
typedef void (*R2D_Update)();
|
207
|
+
typedef void (*R2D_Render)();
|
208
|
+
typedef void (*R2D_On_Key)(R2D_Event e);
|
209
|
+
typedef void (*R2D_On_Mouse)(R2D_Event e);
|
210
|
+
typedef void (*R2D_On_Controller)(R2D_Event e);
|
211
211
|
|
212
|
-
//
|
212
|
+
// R2D_GL_Point, for graphics calculations
|
213
213
|
typedef struct {
|
214
214
|
GLfloat x;
|
215
215
|
GLfloat y;
|
216
|
-
}
|
216
|
+
} R2D_GL_Point;
|
217
217
|
|
218
|
-
//
|
218
|
+
// R2D_Color
|
219
219
|
typedef struct {
|
220
220
|
GLfloat r;
|
221
221
|
GLfloat g;
|
222
222
|
GLfloat b;
|
223
223
|
GLfloat a;
|
224
|
-
}
|
224
|
+
} R2D_Color;
|
225
225
|
|
226
|
-
//
|
226
|
+
// R2D_Mouse
|
227
227
|
typedef struct {
|
228
228
|
int visible;
|
229
229
|
int x;
|
230
230
|
int y;
|
231
|
-
}
|
231
|
+
} R2D_Mouse;
|
232
232
|
|
233
|
-
//
|
233
|
+
// R2D_Viewport
|
234
234
|
typedef struct {
|
235
235
|
int width;
|
236
236
|
int height;
|
237
237
|
int mode;
|
238
|
-
}
|
238
|
+
} R2D_Viewport;
|
239
239
|
|
240
|
-
//
|
240
|
+
// R2D_Window
|
241
241
|
typedef struct {
|
242
242
|
SDL_Window *sdl;
|
243
243
|
SDL_GLContext glcontext;
|
244
|
-
const GLubyte *
|
245
|
-
const GLubyte *
|
246
|
-
const GLubyte *
|
247
|
-
GLint
|
248
|
-
GLint
|
249
|
-
const GLubyte *
|
244
|
+
const GLubyte *R2D_GL_VENDOR;
|
245
|
+
const GLubyte *R2D_GL_RENDERER;
|
246
|
+
const GLubyte *R2D_GL_VERSION;
|
247
|
+
GLint R2D_GL_MAJOR_VERSION;
|
248
|
+
GLint R2D_GL_MINOR_VERSION;
|
249
|
+
const GLubyte *R2D_GL_SHADING_LANGUAGE_VERSION;
|
250
250
|
const char *title;
|
251
251
|
int width;
|
252
252
|
int height;
|
253
253
|
int orig_width;
|
254
254
|
int orig_height;
|
255
|
-
|
256
|
-
|
257
|
-
|
255
|
+
R2D_Viewport viewport;
|
256
|
+
R2D_Update update;
|
257
|
+
R2D_Render render;
|
258
258
|
int flags;
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
259
|
+
R2D_Mouse mouse;
|
260
|
+
R2D_On_Key on_key;
|
261
|
+
R2D_On_Mouse on_mouse;
|
262
|
+
R2D_On_Controller on_controller;
|
263
263
|
bool vsync;
|
264
264
|
int fps_cap;
|
265
|
-
|
265
|
+
R2D_Color background;
|
266
266
|
const char *icon;
|
267
267
|
Uint32 frames;
|
268
268
|
Uint32 elapsed_ms;
|
@@ -270,15 +270,15 @@ typedef struct {
|
|
270
270
|
Uint32 delay_ms;
|
271
271
|
double fps;
|
272
272
|
bool close;
|
273
|
-
}
|
273
|
+
} R2D_Window;
|
274
274
|
|
275
|
-
//
|
275
|
+
// R2D_Image
|
276
276
|
typedef struct {
|
277
277
|
const char *path;
|
278
278
|
SDL_Surface *surface;
|
279
279
|
int format;
|
280
280
|
GLuint texture_id;
|
281
|
-
|
281
|
+
R2D_Color color;
|
282
282
|
int x;
|
283
283
|
int y;
|
284
284
|
int width;
|
@@ -288,13 +288,13 @@ typedef struct {
|
|
288
288
|
GLfloat rotate; // Rotation angle in degrees
|
289
289
|
GLfloat rx; // X coordinate to be rotated around
|
290
290
|
GLfloat ry; // Y coordinate to be rotated around
|
291
|
-
}
|
291
|
+
} R2D_Image;
|
292
292
|
|
293
|
-
//
|
293
|
+
// R2D_Sprite
|
294
294
|
typedef struct {
|
295
295
|
const char *path;
|
296
|
-
|
297
|
-
|
296
|
+
R2D_Image *img;
|
297
|
+
R2D_Color color;
|
298
298
|
int x;
|
299
299
|
int y;
|
300
300
|
int width;
|
@@ -312,15 +312,15 @@ typedef struct {
|
|
312
312
|
GLfloat ty3;
|
313
313
|
GLfloat tx4;
|
314
314
|
GLfloat ty4;
|
315
|
-
}
|
315
|
+
} R2D_Sprite;
|
316
316
|
|
317
|
-
//
|
317
|
+
// R2D_Text
|
318
318
|
typedef struct {
|
319
319
|
const char *font;
|
320
320
|
SDL_Surface *surface;
|
321
321
|
GLuint texture_id;
|
322
322
|
TTF_Font *font_data;
|
323
|
-
|
323
|
+
R2D_Color color;
|
324
324
|
char *msg;
|
325
325
|
int x;
|
326
326
|
int y;
|
@@ -329,61 +329,61 @@ typedef struct {
|
|
329
329
|
GLfloat rotate; // Rotation angle in degrees
|
330
330
|
GLfloat rx; // X coordinate to be rotated around
|
331
331
|
GLfloat ry; // Y coordinate to be rotated around
|
332
|
-
}
|
332
|
+
} R2D_Text;
|
333
333
|
|
334
|
-
//
|
334
|
+
// R2D_Sound
|
335
335
|
typedef struct {
|
336
336
|
const char *path;
|
337
337
|
Mix_Chunk *data;
|
338
|
-
}
|
338
|
+
} R2D_Sound;
|
339
339
|
|
340
|
-
//
|
340
|
+
// R2D_Music
|
341
341
|
typedef struct {
|
342
342
|
const char *path;
|
343
343
|
Mix_Music *data;
|
344
|
-
}
|
344
|
+
} R2D_Music;
|
345
345
|
|
346
|
-
//
|
346
|
+
// Ruby 2D Functions ///////////////////////////////////////////////////////////
|
347
347
|
|
348
348
|
/*
|
349
349
|
* Checks if a file exists and can be accessed
|
350
350
|
*/
|
351
|
-
bool
|
351
|
+
bool R2D_FileExists(const char *path);
|
352
352
|
|
353
353
|
/*
|
354
354
|
* Logs standard messages to the console
|
355
355
|
*/
|
356
|
-
void
|
356
|
+
void R2D_Log(int type, const char *msg, ...);
|
357
357
|
|
358
358
|
/*
|
359
|
-
* Logs
|
359
|
+
* Logs Ruby 2D errors to the console, with caller and message body
|
360
360
|
*/
|
361
|
-
void
|
361
|
+
void R2D_Error(const char *caller, const char *msg, ...);
|
362
362
|
|
363
363
|
/*
|
364
364
|
* Enable/disable logging of diagnostics
|
365
365
|
*/
|
366
|
-
void
|
366
|
+
void R2D_Diagnostics(bool status);
|
367
367
|
|
368
368
|
/*
|
369
369
|
* Enable terminal colors in Windows
|
370
370
|
*/
|
371
|
-
void
|
371
|
+
void R2D_Windows_EnableTerminalColors();
|
372
372
|
|
373
373
|
/*
|
374
|
-
* Initialize
|
374
|
+
* Initialize Ruby 2D subsystems
|
375
375
|
*/
|
376
|
-
bool
|
376
|
+
bool R2D_Init();
|
377
377
|
|
378
378
|
/*
|
379
|
-
* Gets the primary display's
|
379
|
+
* Gets the primary display's dimensions
|
380
380
|
*/
|
381
|
-
void
|
381
|
+
void R2D_GetDisplayDimensions(int *w, int *h);
|
382
382
|
|
383
383
|
/*
|
384
|
-
* Quits
|
384
|
+
* Quits Ruby 2D subsystems
|
385
385
|
*/
|
386
|
-
void
|
386
|
+
void R2D_Quit(void);
|
387
387
|
|
388
388
|
// Shapes //////////////////////////////////////////////////////////////////////
|
389
389
|
|
@@ -395,17 +395,17 @@ void S2D_Quit(void);
|
|
395
395
|
* rx The x coordinate to rotate around
|
396
396
|
* ry The y coordinate to rotate around
|
397
397
|
*/
|
398
|
-
|
398
|
+
R2D_GL_Point R2D_RotatePoint(R2D_GL_Point p, GLfloat angle, GLfloat rx, GLfloat ry);
|
399
399
|
|
400
400
|
/*
|
401
401
|
* Get the point to be rotated around given a position in a rectangle
|
402
402
|
*/
|
403
|
-
|
403
|
+
R2D_GL_Point R2D_GetRectRotationPoint(int x, int y, int w, int h, int position);
|
404
404
|
|
405
405
|
/*
|
406
406
|
* Draw a triangle
|
407
407
|
*/
|
408
|
-
void
|
408
|
+
void R2D_DrawTriangle(
|
409
409
|
GLfloat x1, GLfloat y1,
|
410
410
|
GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
|
411
411
|
GLfloat x2, GLfloat y2,
|
@@ -417,7 +417,7 @@ void S2D_DrawTriangle(
|
|
417
417
|
/*
|
418
418
|
* Draw a quad, using two triangles
|
419
419
|
*/
|
420
|
-
void
|
420
|
+
void R2D_DrawQuad(
|
421
421
|
GLfloat x1, GLfloat y1,
|
422
422
|
GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
|
423
423
|
GLfloat x2, GLfloat y2,
|
@@ -431,7 +431,7 @@ void S2D_DrawQuad(
|
|
431
431
|
/*
|
432
432
|
* Draw a line from a quad
|
433
433
|
*/
|
434
|
-
void
|
434
|
+
void R2D_DrawLine(
|
435
435
|
GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,
|
436
436
|
GLfloat width,
|
437
437
|
GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
|
@@ -443,7 +443,7 @@ void S2D_DrawLine(
|
|
443
443
|
/*
|
444
444
|
* Draw a circle from triangles
|
445
445
|
*/
|
446
|
-
void
|
446
|
+
void R2D_DrawCircle(
|
447
447
|
GLfloat x, GLfloat y, GLfloat radius, int sectors,
|
448
448
|
GLfloat r, GLfloat g, GLfloat b, GLfloat a
|
449
449
|
);
|
@@ -453,281 +453,303 @@ void S2D_DrawCircle(
|
|
453
453
|
/*
|
454
454
|
* Create an image, given a file path
|
455
455
|
*/
|
456
|
-
|
456
|
+
R2D_Image *R2D_CreateImage(const char *path);
|
457
457
|
|
458
458
|
/*
|
459
459
|
* Rotate an image
|
460
460
|
*/
|
461
|
-
void
|
461
|
+
void R2D_RotateImage(R2D_Image *img, GLfloat angle, int position);
|
462
462
|
|
463
463
|
/*
|
464
464
|
* Draw an image
|
465
465
|
*/
|
466
|
-
void
|
466
|
+
void R2D_DrawImage(R2D_Image *img);
|
467
467
|
|
468
468
|
/*
|
469
469
|
* Free an image
|
470
470
|
*/
|
471
|
-
void
|
471
|
+
void R2D_FreeImage(R2D_Image *img);
|
472
472
|
|
473
473
|
// Sprite //////////////////////////////////////////////////////////////////////
|
474
474
|
|
475
475
|
/*
|
476
476
|
* Create a sprite, given an image file path
|
477
477
|
*/
|
478
|
-
|
478
|
+
R2D_Sprite *R2D_CreateSprite(const char *path);
|
479
479
|
|
480
480
|
/*
|
481
481
|
* Clip a sprite
|
482
482
|
*/
|
483
|
-
void
|
483
|
+
void R2D_ClipSprite(R2D_Sprite *spr, int x, int y, int w, int h);
|
484
484
|
|
485
485
|
/*
|
486
486
|
* Rotate a sprite
|
487
487
|
*/
|
488
|
-
void
|
488
|
+
void R2D_RotateSprite(R2D_Sprite *spr, GLfloat angle, int position);
|
489
489
|
|
490
490
|
/*
|
491
491
|
* Draw a sprite
|
492
492
|
*/
|
493
|
-
void
|
493
|
+
void R2D_DrawSprite(R2D_Sprite *spr);
|
494
494
|
|
495
495
|
/*
|
496
496
|
* Free a sprite
|
497
497
|
*/
|
498
|
-
void
|
498
|
+
void R2D_FreeSprite(R2D_Sprite *spr);
|
499
499
|
|
500
500
|
// Text ////////////////////////////////////////////////////////////////////////
|
501
501
|
|
502
502
|
/*
|
503
503
|
* Create text, given a font file path, the message, and size
|
504
504
|
*/
|
505
|
-
|
505
|
+
R2D_Text *R2D_CreateText(const char *font, const char *msg, int size);
|
506
506
|
|
507
507
|
/*
|
508
508
|
* Set the text message
|
509
509
|
*/
|
510
|
-
void
|
510
|
+
void R2D_SetText(R2D_Text *txt, const char *msg, ...);
|
511
511
|
|
512
512
|
/*
|
513
513
|
* Rotate text
|
514
514
|
*/
|
515
|
-
void
|
515
|
+
void R2D_RotateText(R2D_Text *txt, GLfloat angle, int position);
|
516
516
|
|
517
517
|
/*
|
518
518
|
* Draw text
|
519
519
|
*/
|
520
|
-
void
|
520
|
+
void R2D_DrawText(R2D_Text *txt);
|
521
521
|
|
522
522
|
/*
|
523
523
|
* Free the text
|
524
524
|
*/
|
525
|
-
void
|
525
|
+
void R2D_FreeText(R2D_Text *txt);
|
526
526
|
|
527
527
|
// Sound ///////////////////////////////////////////////////////////////////////
|
528
528
|
|
529
529
|
/*
|
530
530
|
* Create a sound, given an audio file path
|
531
531
|
*/
|
532
|
-
|
532
|
+
R2D_Sound *R2D_CreateSound(const char *path);
|
533
533
|
|
534
534
|
/*
|
535
535
|
* Play the sound
|
536
536
|
*/
|
537
|
-
void
|
537
|
+
void R2D_PlaySound(R2D_Sound *snd);
|
538
|
+
|
539
|
+
/*
|
540
|
+
* Get the sound's volume
|
541
|
+
*/
|
542
|
+
int R2D_GetSoundVolume(R2D_Sound *snd);
|
543
|
+
|
544
|
+
/*
|
545
|
+
* Set the sound's volume a given percentage
|
546
|
+
*/
|
547
|
+
void R2D_SetSoundVolume(R2D_Sound *snd, int volume);
|
548
|
+
|
549
|
+
/*
|
550
|
+
* Get the sound mixer volume
|
551
|
+
*/
|
552
|
+
int R2D_GetSoundMixVolume();
|
553
|
+
|
554
|
+
/*
|
555
|
+
* Set the sound mixer volume a given percentage
|
556
|
+
*/
|
557
|
+
void R2D_SetSoundMixVolume(int volume);
|
538
558
|
|
539
559
|
/*
|
540
560
|
* Free the sound
|
541
561
|
*/
|
542
|
-
void
|
562
|
+
void R2D_FreeSound(R2D_Sound *snd);
|
543
563
|
|
544
564
|
// Music ///////////////////////////////////////////////////////////////////////
|
545
565
|
|
546
566
|
/*
|
547
567
|
* Create the music, given an audio file path
|
548
568
|
*/
|
549
|
-
|
569
|
+
R2D_Music *R2D_CreateMusic(const char *path);
|
550
570
|
|
551
571
|
/*
|
552
572
|
* Play the music
|
553
573
|
*/
|
554
|
-
void
|
574
|
+
void R2D_PlayMusic(R2D_Music *mus, bool loop);
|
555
575
|
|
556
576
|
/*
|
557
577
|
* Pause the playing music
|
558
578
|
*/
|
559
|
-
void
|
579
|
+
void R2D_PauseMusic();
|
560
580
|
|
561
581
|
/*
|
562
582
|
* Resume the current music
|
563
583
|
*/
|
564
|
-
void
|
584
|
+
void R2D_ResumeMusic();
|
565
585
|
|
566
586
|
/*
|
567
587
|
* Stop the playing music; interrupts fader effects
|
568
588
|
*/
|
569
|
-
void
|
589
|
+
void R2D_StopMusic();
|
570
590
|
|
571
591
|
/*
|
572
592
|
* Get the music volume
|
573
593
|
*/
|
574
|
-
int
|
594
|
+
int R2D_GetMusicVolume();
|
575
595
|
|
576
596
|
/*
|
577
597
|
* Set the music volume a given percentage
|
578
598
|
*/
|
579
|
-
void
|
599
|
+
void R2D_SetMusicVolume(int volume);
|
580
600
|
|
581
601
|
/*
|
582
602
|
* Fade out the playing music
|
583
603
|
*/
|
584
|
-
void
|
604
|
+
void R2D_FadeOutMusic(int ms);
|
585
605
|
|
586
606
|
/*
|
587
607
|
* Free the music
|
588
608
|
*/
|
589
|
-
void
|
609
|
+
void R2D_FreeMusic(R2D_Music *mus);
|
590
610
|
|
591
611
|
// Input ///////////////////////////////////////////////////////////////////////
|
592
612
|
|
593
613
|
/*
|
594
614
|
* Get the mouse coordinates relative to the viewport
|
595
615
|
*/
|
596
|
-
void
|
616
|
+
void R2D_GetMouseOnViewport(R2D_Window *window, int wx, int wy, int *x, int *y);
|
597
617
|
|
598
618
|
/*
|
599
619
|
* Show the cursor over the window
|
600
620
|
*/
|
601
|
-
void
|
621
|
+
void R2D_ShowCursor();
|
602
622
|
|
603
623
|
/*
|
604
624
|
* Hide the cursor over the window
|
605
625
|
*/
|
606
|
-
void
|
626
|
+
void R2D_HideCursor();
|
607
627
|
|
608
628
|
// Controllers /////////////////////////////////////////////////////////////////
|
609
629
|
|
610
630
|
/*
|
611
631
|
* Add controller mapping from string
|
612
632
|
*/
|
613
|
-
void
|
633
|
+
void R2D_AddControllerMapping(const char *map);
|
614
634
|
|
615
635
|
/*
|
616
636
|
* Load controller mappings from the specified file
|
617
637
|
*/
|
618
|
-
void
|
638
|
+
void R2D_AddControllerMappingsFromFile(const char *path);
|
619
639
|
|
620
640
|
/*
|
621
641
|
* Check if joystick is a controller
|
622
642
|
*/
|
623
|
-
bool
|
643
|
+
bool R2D_IsController(SDL_JoystickID id);
|
624
644
|
|
625
645
|
/*
|
626
646
|
* Open controllers and joysticks
|
627
647
|
*/
|
628
|
-
void
|
648
|
+
void R2D_OpenControllers();
|
629
649
|
|
630
650
|
// Window //////////////////////////////////////////////////////////////////////
|
631
651
|
|
632
652
|
/*
|
633
653
|
* Create a window
|
634
654
|
*/
|
635
|
-
|
636
|
-
const char *title, int width, int height,
|
655
|
+
R2D_Window *R2D_CreateWindow(
|
656
|
+
const char *title, int width, int height, R2D_Update, R2D_Render, int flags
|
637
657
|
);
|
638
658
|
|
639
659
|
/*
|
640
660
|
* Show the window
|
641
661
|
*/
|
642
|
-
int
|
662
|
+
int R2D_Show(R2D_Window *window);
|
643
663
|
|
644
664
|
/*
|
645
665
|
* Set the icon for the window
|
646
666
|
*/
|
647
|
-
void
|
667
|
+
void R2D_SetIcon(R2D_Window *window, const char *icon);
|
648
668
|
|
649
669
|
/*
|
650
670
|
* Take a screenshot of the window
|
651
671
|
*/
|
652
|
-
void
|
672
|
+
void R2D_Screenshot(R2D_Window *window, const char *path);
|
653
673
|
|
654
674
|
/*
|
655
675
|
* Close the window
|
656
676
|
*/
|
657
|
-
int
|
677
|
+
int R2D_Close(R2D_Window *window);
|
658
678
|
|
659
679
|
/*
|
660
680
|
* Free all resources
|
661
681
|
*/
|
662
|
-
int
|
682
|
+
int R2D_FreeWindow(R2D_Window *window);
|
663
683
|
|
664
|
-
//
|
684
|
+
// Ruby 2D OpenGL Functions ////////////////////////////////////////////////////
|
665
685
|
|
666
|
-
int
|
667
|
-
void
|
668
|
-
void
|
669
|
-
void
|
670
|
-
GLuint
|
671
|
-
int
|
672
|
-
void
|
673
|
-
void
|
674
|
-
void
|
686
|
+
int R2D_GL_Init(R2D_Window *window);
|
687
|
+
void R2D_GL_PrintError(char *error);
|
688
|
+
void R2D_GL_PrintContextInfo(R2D_Window *window);
|
689
|
+
void R2D_GL_StoreContextInfo(R2D_Window *window);
|
690
|
+
GLuint R2D_GL_LoadShader(GLenum type, const GLchar *shaderSrc, char *shaderName);
|
691
|
+
int R2D_GL_CheckLinked(GLuint program, char *name);
|
692
|
+
void R2D_GL_GetViewportScale(R2D_Window *window, int *w, int *h, double *scale);
|
693
|
+
void R2D_GL_SetViewport(R2D_Window *window);
|
694
|
+
void R2D_GL_CreateTexture(
|
675
695
|
GLuint *id, GLint format,
|
676
696
|
int w, int h,
|
677
697
|
const GLvoid *data, GLint filter);
|
678
|
-
void
|
698
|
+
void R2D_GL_DrawTriangle(
|
679
699
|
GLfloat x1, GLfloat y1,
|
680
700
|
GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
|
681
701
|
GLfloat x2, GLfloat y2,
|
682
702
|
GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
|
683
703
|
GLfloat x3, GLfloat y3,
|
684
704
|
GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3);
|
685
|
-
void
|
686
|
-
void
|
687
|
-
void
|
688
|
-
void
|
689
|
-
void
|
705
|
+
void R2D_GL_DrawImage(R2D_Image *img);
|
706
|
+
void R2D_GL_DrawSprite(R2D_Sprite *spr);
|
707
|
+
void R2D_GL_DrawText(R2D_Text *txt);
|
708
|
+
void R2D_GL_FreeTexture(GLuint *id);
|
709
|
+
void R2D_GL_Clear(R2D_Color clr);
|
710
|
+
void R2D_GL_FlushBuffers();
|
690
711
|
|
691
712
|
// OpenGL & GLES Internal Functions ////////////////////////////////////////////
|
692
713
|
|
693
714
|
#if GLES
|
694
|
-
int
|
695
|
-
void
|
696
|
-
void
|
715
|
+
int R2D_GLES_Init();
|
716
|
+
void R2D_GLES_ApplyProjection(GLfloat orthoMatrix[16]);
|
717
|
+
void R2D_GLES_DrawTriangle(
|
697
718
|
GLfloat x1, GLfloat y1,
|
698
719
|
GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
|
699
720
|
GLfloat x2, GLfloat y2,
|
700
721
|
GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
|
701
722
|
GLfloat x3, GLfloat y3,
|
702
723
|
GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3);
|
703
|
-
void
|
704
|
-
void
|
705
|
-
void
|
724
|
+
void R2D_GLES_DrawImage(R2D_Image *img);
|
725
|
+
void R2D_GLES_DrawSprite(R2D_Sprite *spr);
|
726
|
+
void R2D_GLES_DrawText(R2D_Text *txt);
|
706
727
|
#else
|
707
|
-
int
|
708
|
-
int
|
709
|
-
void
|
710
|
-
void
|
711
|
-
void
|
728
|
+
int R2D_GL2_Init();
|
729
|
+
int R2D_GL3_Init();
|
730
|
+
void R2D_GL2_ApplyProjection(int w, int h);
|
731
|
+
void R2D_GL3_ApplyProjection(GLfloat orthoMatrix[16]);
|
732
|
+
void R2D_GL2_DrawTriangle(
|
712
733
|
GLfloat x1, GLfloat y1,
|
713
734
|
GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
|
714
735
|
GLfloat x2, GLfloat y2,
|
715
736
|
GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
|
716
737
|
GLfloat x3, GLfloat y3,
|
717
738
|
GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3);
|
718
|
-
void
|
739
|
+
void R2D_GL3_DrawTriangle(
|
719
740
|
GLfloat x1, GLfloat y1,
|
720
741
|
GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
|
721
742
|
GLfloat x2, GLfloat y2,
|
722
743
|
GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
|
723
744
|
GLfloat x3, GLfloat y3,
|
724
745
|
GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3);
|
725
|
-
void
|
726
|
-
void
|
727
|
-
void
|
728
|
-
void
|
729
|
-
void
|
730
|
-
void
|
746
|
+
void R2D_GL2_DrawImage(R2D_Image *img);
|
747
|
+
void R2D_GL3_DrawImage(R2D_Image *img);
|
748
|
+
void R2D_GL2_DrawSprite(R2D_Sprite *spr);
|
749
|
+
void R2D_GL3_DrawSprite(R2D_Sprite *spr);
|
750
|
+
void R2D_GL2_DrawText(R2D_Text *txt);
|
751
|
+
void R2D_GL3_DrawText(R2D_Text *txt);
|
752
|
+
void R2D_GL3_FlushBuffers();
|
731
753
|
#endif
|
732
754
|
|
733
755
|
#ifdef __cplusplus
|