ruby2d 0.9.3 → 0.11.0
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 +7 -9
- data/assets/Rakefile +85 -0
- data/assets/include/SDL2/SDL.h +4 -1
- data/assets/include/SDL2/SDL_assert.h +3 -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 +10 -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 +182 -0
- data/assets/include/SDL2/SDL_config_iphoneos.h +207 -0
- data/assets/include/SDL2/SDL_config_macosx.h +266 -0
- data/assets/include/SDL2/SDL_config_minimal.h +85 -0
- data/assets/include/SDL2/SDL_config_os2.h +188 -0
- data/assets/include/SDL2/SDL_config_pandora.h +135 -0
- data/assets/include/SDL2/SDL_config_psp.h +165 -0
- data/assets/include/SDL2/SDL_config_windows.h +288 -0
- data/assets/include/SDL2/SDL_config_winrt.h +243 -0
- data/assets/include/SDL2/SDL_config_wiz.h +149 -0
- data/assets/include/SDL2/SDL_copying.h +20 -0
- data/assets/include/SDL2/SDL_cpuinfo.h +119 -8
- data/assets/include/SDL2/SDL_egl.h +4 -1
- data/assets/include/SDL2/SDL_endian.h +6 -3
- data/assets/include/SDL2/SDL_error.h +38 -2
- data/assets/include/SDL2/SDL_events.h +67 -28
- data/assets/include/SDL2/SDL_filesystem.h +1 -1
- data/assets/include/SDL2/SDL_gamecontroller.h +160 -9
- data/assets/include/SDL2/SDL_gesture.h +1 -1
- data/assets/include/SDL2/SDL_haptic.h +10 -1
- data/assets/include/SDL2/SDL_hints.h +460 -17
- data/assets/include/SDL2/SDL_image.h +2 -2
- data/assets/include/SDL2/SDL_joystick.h +115 -24
- data/assets/include/SDL2/SDL_keyboard.h +1 -1
- data/assets/include/SDL2/SDL_keycode.h +11 -9
- data/assets/include/SDL2/SDL_loadso.h +1 -1
- data/assets/include/SDL2/SDL_locale.h +101 -0
- data/assets/include/SDL2/SDL_log.h +3 -3
- data/assets/include/SDL2/SDL_main.h +28 -16
- data/assets/include/SDL2/SDL_messagebox.h +6 -4
- data/assets/include/SDL2/SDL_metal.h +117 -0
- data/assets/include/SDL2/SDL_misc.h +75 -0
- 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_opengl_glext.h +3 -0
- 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 +27 -18
- 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 +230 -3
- data/assets/include/SDL2/SDL_revision.h +2 -2
- data/assets/include/SDL2/SDL_rwops.h +51 -22
- data/assets/include/SDL2/SDL_scancode.h +2 -2
- data/assets/include/SDL2/SDL_sensor.h +28 -12
- data/assets/include/SDL2/SDL_shape.h +1 -1
- data/assets/include/SDL2/SDL_stdinc.h +44 -4
- data/assets/include/SDL2/SDL_surface.h +12 -2
- data/assets/include/SDL2/SDL_system.h +50 -4
- data/assets/include/SDL2/SDL_syswm.h +39 -9
- 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 +32 -2
- 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 +34 -11
- 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 +11 -5
- data/assets/include/SDL2/SDL_vulkan.h +9 -11
- data/assets/include/SDL2/begin_code.h +8 -9
- 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/libvorbis.a +0 -0
- data/assets/macos/lib/libvorbisfile.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 +1 -0
- data/{assets/linux/simple2d/src/simple2d.c → ext/ruby2d/common.c} +32 -32
- data/{assets/linux/simple2d/src → ext/ruby2d}/controllers.c +17 -17
- data/ext/ruby2d/extconf.rb +36 -58
- data/ext/ruby2d/font.c +35 -0
- data/{assets/linux/simple2d/src → ext/ruby2d}/gl.c +72 -100
- data/ext/ruby2d/gl2.c +86 -0
- data/ext/ruby2d/gl3.c +305 -0
- data/{assets/linux/simple2d/src → ext/ruby2d}/gles.c +22 -81
- data/ext/ruby2d/image.c +58 -0
- data/{assets/linux/simple2d/src → ext/ruby2d}/input.c +8 -8
- data/{assets/linux/simple2d/src → ext/ruby2d}/music.c +30 -17
- data/ext/ruby2d/ruby2d.c +449 -439
- data/ext/ruby2d/ruby2d.h +652 -0
- data/{assets/linux/simple2d/src → ext/ruby2d}/shapes.c +18 -18
- data/ext/ruby2d/sound.c +118 -0
- data/ext/ruby2d/text.c +22 -0
- data/{assets/linux/simple2d/src → ext/ruby2d}/window.c +73 -62
- data/lib/ruby2d/circle.rb +21 -3
- data/lib/ruby2d/cli/build.rb +4 -7
- data/lib/ruby2d/dsl.rb +16 -9
- data/lib/ruby2d/entity.rb +17 -0
- data/lib/ruby2d/font.rb +23 -3
- data/lib/ruby2d/image.rb +35 -7
- data/lib/ruby2d/line.rb +23 -1
- data/lib/ruby2d/music.rb +5 -0
- data/lib/ruby2d/pixel.rb +17 -0
- data/lib/ruby2d/quad.rb +21 -1
- data/lib/ruby2d/rectangle.rb +12 -3
- data/lib/ruby2d/renderable.rb +4 -20
- data/lib/ruby2d/sound.rb +30 -0
- data/lib/ruby2d/sprite.rb +57 -75
- data/lib/ruby2d/square.rb +10 -1
- data/lib/ruby2d/text.rb +55 -12
- data/lib/ruby2d/texture.rb +28 -0
- data/lib/ruby2d/tileset.rb +87 -0
- data/lib/ruby2d/triangle.rb +19 -1
- data/lib/ruby2d/version.rb +1 -1
- data/lib/ruby2d/vertices.rb +84 -0
- data/lib/ruby2d/window.rb +259 -22
- data/lib/ruby2d.rb +6 -1
- metadata +41 -26
- data/assets/include/simple2d.h +0 -735
- data/assets/linux/simple2d/Makefile +0 -257
- data/assets/linux/simple2d/bin/simple2d.sh +0 -1312
- data/assets/linux/simple2d/include/simple2d.h +0 -735
- data/assets/linux/simple2d/src/gl2.c +0 -146
- data/assets/linux/simple2d/src/gl3.c +0 -275
- data/assets/linux/simple2d/src/image.c +0 -138
- data/assets/linux/simple2d/src/sound.c +0 -56
- data/assets/linux/simple2d/src/sprite.c +0 -147
- data/assets/linux/simple2d/src/text.c +0 -129
- data/assets/macos/lib/libsimple2d.a +0 -0
- data/assets/mingw/lib/libsimple2d.a +0 -0
@@ -1,735 +0,0 @@
|
|
1
|
-
// simple2d.h
|
2
|
-
|
3
|
-
#ifdef __cplusplus
|
4
|
-
extern "C" {
|
5
|
-
#endif
|
6
|
-
|
7
|
-
#include <stdbool.h>
|
8
|
-
|
9
|
-
// Set Platform Constants //////////////////////////////////////////////////////
|
10
|
-
|
11
|
-
// Apple
|
12
|
-
#ifdef __APPLE__
|
13
|
-
#ifndef __TARGETCONDITIONALS__
|
14
|
-
#include "TargetConditionals.h"
|
15
|
-
#endif
|
16
|
-
#if TARGET_OS_OSX
|
17
|
-
#define MACOS true
|
18
|
-
#elif TARGET_OS_IOS
|
19
|
-
#define IOS true
|
20
|
-
#elif TARGET_OS_TV
|
21
|
-
#define TVOS true
|
22
|
-
#endif
|
23
|
-
#endif
|
24
|
-
|
25
|
-
// Windows
|
26
|
-
#ifdef _WIN32
|
27
|
-
#define WINDOWS true
|
28
|
-
#endif
|
29
|
-
|
30
|
-
// Windows and MinGW
|
31
|
-
#ifdef __MINGW32__
|
32
|
-
#define MINGW true
|
33
|
-
#endif
|
34
|
-
|
35
|
-
// GLES
|
36
|
-
#if defined(__arm__) || IOS || TVOS
|
37
|
-
#define GLES true
|
38
|
-
#else
|
39
|
-
#define GLES false
|
40
|
-
#endif
|
41
|
-
|
42
|
-
// Includes ////////////////////////////////////////////////////////////////////
|
43
|
-
|
44
|
-
// Define to get GNU extension functions and types, like `vasprintf()` and M_PI
|
45
|
-
#ifndef _GNU_SOURCE
|
46
|
-
#define _GNU_SOURCE 1
|
47
|
-
#endif
|
48
|
-
|
49
|
-
#if WINDOWS && !MINGW
|
50
|
-
#include <io.h>
|
51
|
-
#define F_OK 0 // For testing file existence
|
52
|
-
#else
|
53
|
-
#include <unistd.h>
|
54
|
-
#endif
|
55
|
-
|
56
|
-
#if WINDOWS
|
57
|
-
#include <stdio.h>
|
58
|
-
#include <math.h>
|
59
|
-
#include <windows.h>
|
60
|
-
// For terminal colors
|
61
|
-
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
62
|
-
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
|
63
|
-
#endif
|
64
|
-
#endif
|
65
|
-
|
66
|
-
// SDL
|
67
|
-
#if IOS || TVOS
|
68
|
-
#include "SDL2/SDL.h"
|
69
|
-
#else
|
70
|
-
#include <SDL2/SDL.h>
|
71
|
-
#endif
|
72
|
-
|
73
|
-
// If MinGW, undefine `main()` from SDL_main.c
|
74
|
-
#if MINGW
|
75
|
-
#undef main
|
76
|
-
#endif
|
77
|
-
|
78
|
-
// OpenGL
|
79
|
-
#if GLES
|
80
|
-
#if IOS || TVOS
|
81
|
-
#include "SDL2/SDL_opengles2.h"
|
82
|
-
#else
|
83
|
-
#include <SDL2/SDL_opengles2.h>
|
84
|
-
#endif
|
85
|
-
#else
|
86
|
-
#define GL_GLEXT_PROTOTYPES 1
|
87
|
-
#if WINDOWS
|
88
|
-
#include <glew.h>
|
89
|
-
#endif
|
90
|
-
#include <SDL2/SDL_opengl.h>
|
91
|
-
#endif
|
92
|
-
|
93
|
-
// SDL libraries
|
94
|
-
#if IOS || TVOS
|
95
|
-
#include "SDL2/SDL_image.h"
|
96
|
-
#include "SDL2/SDL_mixer.h"
|
97
|
-
#include "SDL2/SDL_ttf.h"
|
98
|
-
#else
|
99
|
-
#include <SDL2/SDL_image.h>
|
100
|
-
#include <SDL2/SDL_mixer.h>
|
101
|
-
#include <SDL2/SDL_ttf.h>
|
102
|
-
#endif
|
103
|
-
|
104
|
-
// Simple 2D Definitions ///////////////////////////////////////////////////////
|
105
|
-
|
106
|
-
// Messages
|
107
|
-
#define S2D_INFO 1
|
108
|
-
#define S2D_WARN 2
|
109
|
-
#define S2D_ERROR 3
|
110
|
-
|
111
|
-
// Window attributes
|
112
|
-
#define S2D_RESIZABLE SDL_WINDOW_RESIZABLE
|
113
|
-
#define S2D_BORDERLESS SDL_WINDOW_BORDERLESS
|
114
|
-
#define S2D_FULLSCREEN SDL_WINDOW_FULLSCREEN_DESKTOP
|
115
|
-
#define S2D_HIGHDPI SDL_WINDOW_ALLOW_HIGHDPI
|
116
|
-
#define S2D_DISPLAY_WIDTH 0
|
117
|
-
#define S2D_DISPLAY_HEIGHT 0
|
118
|
-
|
119
|
-
// Viewport scaling modes
|
120
|
-
#define S2D_FIXED 1
|
121
|
-
#define S2D_EXPAND 2
|
122
|
-
#define S2D_SCALE 3
|
123
|
-
#define S2D_STRETCH 4
|
124
|
-
|
125
|
-
// Positions
|
126
|
-
#define S2D_CENTER 1
|
127
|
-
#define S2D_TOP_LEFT 2
|
128
|
-
#define S2D_TOP_RIGHT 3
|
129
|
-
#define S2D_BOTTOM_LEFT 4
|
130
|
-
#define S2D_BOTTOM_RIGHT 5
|
131
|
-
|
132
|
-
// Keyboard events
|
133
|
-
#define S2D_KEY_DOWN 1 // key is pressed
|
134
|
-
#define S2D_KEY_HELD 2 // key is held down
|
135
|
-
#define S2D_KEY_UP 3 // key is released
|
136
|
-
|
137
|
-
// Mouse events
|
138
|
-
#define S2D_MOUSE_DOWN 1 // mouse button pressed
|
139
|
-
#define S2D_MOUSE_UP 2 // mouse button released
|
140
|
-
#define S2D_MOUSE_SCROLL 3 // mouse scrolling or wheel movement
|
141
|
-
#define S2D_MOUSE_MOVE 4 // mouse movement
|
142
|
-
#define S2D_MOUSE_LEFT SDL_BUTTON_LEFT
|
143
|
-
#define S2D_MOUSE_MIDDLE SDL_BUTTON_MIDDLE
|
144
|
-
#define S2D_MOUSE_RIGHT SDL_BUTTON_RIGHT
|
145
|
-
#define S2D_MOUSE_X1 SDL_BUTTON_X1
|
146
|
-
#define S2D_MOUSE_X2 SDL_BUTTON_X2
|
147
|
-
#define S2D_MOUSE_SCROLL_NORMAL SDL_MOUSEWHEEL_NORMAL
|
148
|
-
#define S2D_MOUSE_SCROLL_INVERTED SDL_MOUSEWHEEL_FLIPPED
|
149
|
-
|
150
|
-
// Controller events
|
151
|
-
#define S2D_AXIS 1
|
152
|
-
#define S2D_BUTTON_DOWN 2
|
153
|
-
#define S2D_BUTTON_UP 3
|
154
|
-
|
155
|
-
// Controller axis labels
|
156
|
-
#define S2D_AXIS_INVALID SDL_CONTROLLER_AXIS_INVALID
|
157
|
-
#define S2D_AXIS_LEFTX SDL_CONTROLLER_AXIS_LEFTX
|
158
|
-
#define S2D_AXIS_LEFTY SDL_CONTROLLER_AXIS_LEFTY
|
159
|
-
#define S2D_AXIS_RIGHTX SDL_CONTROLLER_AXIS_RIGHTX
|
160
|
-
#define S2D_AXIS_RIGHTY SDL_CONTROLLER_AXIS_RIGHTY
|
161
|
-
#define S2D_AXIS_TRIGGERLEFT SDL_CONTROLLER_AXIS_TRIGGERLEFT
|
162
|
-
#define S2D_AXIS_TRIGGERRIGHT SDL_CONTROLLER_AXIS_TRIGGERRIGHT
|
163
|
-
#define S2D_AXIS_MAX SDL_CONTROLLER_AXIS_MAX
|
164
|
-
|
165
|
-
// Controller button labels
|
166
|
-
#define S2D_BUTTON_INVALID SDL_CONTROLLER_BUTTON_INVALID
|
167
|
-
#define S2D_BUTTON_A SDL_CONTROLLER_BUTTON_A
|
168
|
-
#define S2D_BUTTON_B SDL_CONTROLLER_BUTTON_B
|
169
|
-
#define S2D_BUTTON_X SDL_CONTROLLER_BUTTON_X
|
170
|
-
#define S2D_BUTTON_Y SDL_CONTROLLER_BUTTON_Y
|
171
|
-
#define S2D_BUTTON_BACK SDL_CONTROLLER_BUTTON_BACK
|
172
|
-
#define S2D_BUTTON_GUIDE SDL_CONTROLLER_BUTTON_GUIDE
|
173
|
-
#define S2D_BUTTON_START SDL_CONTROLLER_BUTTON_START
|
174
|
-
#define S2D_BUTTON_LEFTSTICK SDL_CONTROLLER_BUTTON_LEFTSTICK
|
175
|
-
#define S2D_BUTTON_RIGHTSTICK SDL_CONTROLLER_BUTTON_RIGHTSTICK
|
176
|
-
#define S2D_BUTTON_LEFTSHOULDER SDL_CONTROLLER_BUTTON_LEFTSHOULDER
|
177
|
-
#define S2D_BUTTON_RIGHTSHOULDER SDL_CONTROLLER_BUTTON_RIGHTSHOULDER
|
178
|
-
#define S2D_BUTTON_DPAD_UP SDL_CONTROLLER_BUTTON_DPAD_UP
|
179
|
-
#define S2D_BUTTON_DPAD_DOWN SDL_CONTROLLER_BUTTON_DPAD_DOWN
|
180
|
-
#define S2D_BUTTON_DPAD_LEFT SDL_CONTROLLER_BUTTON_DPAD_LEFT
|
181
|
-
#define S2D_BUTTON_DPAD_RIGHT SDL_CONTROLLER_BUTTON_DPAD_RIGHT
|
182
|
-
#define S2D_BUTTON_MAX SDL_CONTROLLER_BUTTON_MAX
|
183
|
-
|
184
|
-
// Internal Shared Data ////////////////////////////////////////////////////////
|
185
|
-
|
186
|
-
extern bool S2D_diagnostics; // flag for whether to print diagnostics with S2D_Log
|
187
|
-
|
188
|
-
// Type Definitions ////////////////////////////////////////////////////////////
|
189
|
-
|
190
|
-
// S2D_Event
|
191
|
-
typedef struct {
|
192
|
-
int which;
|
193
|
-
int type;
|
194
|
-
int button;
|
195
|
-
bool dblclick;
|
196
|
-
const char *key;
|
197
|
-
int x;
|
198
|
-
int y;
|
199
|
-
int delta_x;
|
200
|
-
int delta_y;
|
201
|
-
int direction;
|
202
|
-
int axis;
|
203
|
-
int value;
|
204
|
-
} S2D_Event;
|
205
|
-
|
206
|
-
typedef void (*S2D_Update)();
|
207
|
-
typedef void (*S2D_Render)();
|
208
|
-
typedef void (*S2D_On_Key)(S2D_Event e);
|
209
|
-
typedef void (*S2D_On_Mouse)(S2D_Event e);
|
210
|
-
typedef void (*S2D_On_Controller)(S2D_Event e);
|
211
|
-
|
212
|
-
// S2D_GL_Point, for graphics calculations
|
213
|
-
typedef struct {
|
214
|
-
GLfloat x;
|
215
|
-
GLfloat y;
|
216
|
-
} S2D_GL_Point;
|
217
|
-
|
218
|
-
// S2D_Color
|
219
|
-
typedef struct {
|
220
|
-
GLfloat r;
|
221
|
-
GLfloat g;
|
222
|
-
GLfloat b;
|
223
|
-
GLfloat a;
|
224
|
-
} S2D_Color;
|
225
|
-
|
226
|
-
// S2D_Mouse
|
227
|
-
typedef struct {
|
228
|
-
int visible;
|
229
|
-
int x;
|
230
|
-
int y;
|
231
|
-
} S2D_Mouse;
|
232
|
-
|
233
|
-
// S2D_Viewport
|
234
|
-
typedef struct {
|
235
|
-
int width;
|
236
|
-
int height;
|
237
|
-
int mode;
|
238
|
-
} S2D_Viewport;
|
239
|
-
|
240
|
-
// S2D_Window
|
241
|
-
typedef struct {
|
242
|
-
SDL_Window *sdl;
|
243
|
-
SDL_GLContext glcontext;
|
244
|
-
const GLubyte *S2D_GL_VENDOR;
|
245
|
-
const GLubyte *S2D_GL_RENDERER;
|
246
|
-
const GLubyte *S2D_GL_VERSION;
|
247
|
-
GLint S2D_GL_MAJOR_VERSION;
|
248
|
-
GLint S2D_GL_MINOR_VERSION;
|
249
|
-
const GLubyte *S2D_GL_SHADING_LANGUAGE_VERSION;
|
250
|
-
const char *title;
|
251
|
-
int width;
|
252
|
-
int height;
|
253
|
-
int orig_width;
|
254
|
-
int orig_height;
|
255
|
-
S2D_Viewport viewport;
|
256
|
-
S2D_Update update;
|
257
|
-
S2D_Render render;
|
258
|
-
int flags;
|
259
|
-
S2D_Mouse mouse;
|
260
|
-
S2D_On_Key on_key;
|
261
|
-
S2D_On_Mouse on_mouse;
|
262
|
-
S2D_On_Controller on_controller;
|
263
|
-
bool vsync;
|
264
|
-
int fps_cap;
|
265
|
-
S2D_Color background;
|
266
|
-
const char *icon;
|
267
|
-
Uint32 frames;
|
268
|
-
Uint32 elapsed_ms;
|
269
|
-
Uint32 loop_ms;
|
270
|
-
Uint32 delay_ms;
|
271
|
-
double fps;
|
272
|
-
bool close;
|
273
|
-
} S2D_Window;
|
274
|
-
|
275
|
-
// S2D_Image
|
276
|
-
typedef struct {
|
277
|
-
const char *path;
|
278
|
-
SDL_Surface *surface;
|
279
|
-
int format;
|
280
|
-
GLuint texture_id;
|
281
|
-
S2D_Color color;
|
282
|
-
int x;
|
283
|
-
int y;
|
284
|
-
int width;
|
285
|
-
int height;
|
286
|
-
int orig_width;
|
287
|
-
int orig_height;
|
288
|
-
GLfloat rotate; // Rotation angle in degrees
|
289
|
-
GLfloat rx; // X coordinate to be rotated around
|
290
|
-
GLfloat ry; // Y coordinate to be rotated around
|
291
|
-
} S2D_Image;
|
292
|
-
|
293
|
-
// S2D_Sprite
|
294
|
-
typedef struct {
|
295
|
-
const char *path;
|
296
|
-
S2D_Image *img;
|
297
|
-
S2D_Color color;
|
298
|
-
int x;
|
299
|
-
int y;
|
300
|
-
int width;
|
301
|
-
int height;
|
302
|
-
int clip_width;
|
303
|
-
int clip_height;
|
304
|
-
GLfloat rotate; // Rotation angle in degrees
|
305
|
-
GLfloat rx; // X coordinate to be rotated around
|
306
|
-
GLfloat ry; // Y coordinate to be rotated around
|
307
|
-
GLfloat tx1;
|
308
|
-
GLfloat ty1;
|
309
|
-
GLfloat tx2;
|
310
|
-
GLfloat ty2;
|
311
|
-
GLfloat tx3;
|
312
|
-
GLfloat ty3;
|
313
|
-
GLfloat tx4;
|
314
|
-
GLfloat ty4;
|
315
|
-
} S2D_Sprite;
|
316
|
-
|
317
|
-
// S2D_Text
|
318
|
-
typedef struct {
|
319
|
-
const char *font;
|
320
|
-
SDL_Surface *surface;
|
321
|
-
GLuint texture_id;
|
322
|
-
TTF_Font *font_data;
|
323
|
-
S2D_Color color;
|
324
|
-
char *msg;
|
325
|
-
int x;
|
326
|
-
int y;
|
327
|
-
int width;
|
328
|
-
int height;
|
329
|
-
GLfloat rotate; // Rotation angle in degrees
|
330
|
-
GLfloat rx; // X coordinate to be rotated around
|
331
|
-
GLfloat ry; // Y coordinate to be rotated around
|
332
|
-
} S2D_Text;
|
333
|
-
|
334
|
-
// S2D_Sound
|
335
|
-
typedef struct {
|
336
|
-
const char *path;
|
337
|
-
Mix_Chunk *data;
|
338
|
-
} S2D_Sound;
|
339
|
-
|
340
|
-
// S2D_Music
|
341
|
-
typedef struct {
|
342
|
-
const char *path;
|
343
|
-
Mix_Music *data;
|
344
|
-
} S2D_Music;
|
345
|
-
|
346
|
-
// Simple 2D Functions /////////////////////////////////////////////////////////
|
347
|
-
|
348
|
-
/*
|
349
|
-
* Checks if a file exists and can be accessed
|
350
|
-
*/
|
351
|
-
bool S2D_FileExists(const char *path);
|
352
|
-
|
353
|
-
/*
|
354
|
-
* Logs standard messages to the console
|
355
|
-
*/
|
356
|
-
void S2D_Log(int type, const char *msg, ...);
|
357
|
-
|
358
|
-
/*
|
359
|
-
* Logs Simple 2D errors to the console, with caller and message body
|
360
|
-
*/
|
361
|
-
void S2D_Error(const char *caller, const char *msg, ...);
|
362
|
-
|
363
|
-
/*
|
364
|
-
* Enable/disable logging of diagnostics
|
365
|
-
*/
|
366
|
-
void S2D_Diagnostics(bool status);
|
367
|
-
|
368
|
-
/*
|
369
|
-
* Enable terminal colors in Windows
|
370
|
-
*/
|
371
|
-
void S2D_Windows_EnableTerminalColors();
|
372
|
-
|
373
|
-
/*
|
374
|
-
* Initialize Simple 2D subsystems
|
375
|
-
*/
|
376
|
-
bool S2D_Init();
|
377
|
-
|
378
|
-
/*
|
379
|
-
* Gets the primary display's dimentions
|
380
|
-
*/
|
381
|
-
void S2D_GetDisplayDimensions(int *w, int *h);
|
382
|
-
|
383
|
-
/*
|
384
|
-
* Quits Simple 2D subsystems
|
385
|
-
*/
|
386
|
-
void S2D_Quit(void);
|
387
|
-
|
388
|
-
// Shapes //////////////////////////////////////////////////////////////////////
|
389
|
-
|
390
|
-
/*
|
391
|
-
* Rotate a point around a given point
|
392
|
-
* Params:
|
393
|
-
* p The point to rotate
|
394
|
-
* angle The angle in degrees
|
395
|
-
* rx The x coordinate to rotate around
|
396
|
-
* ry The y coordinate to rotate around
|
397
|
-
*/
|
398
|
-
S2D_GL_Point S2D_RotatePoint(S2D_GL_Point p, GLfloat angle, GLfloat rx, GLfloat ry);
|
399
|
-
|
400
|
-
/*
|
401
|
-
* Get the point to be rotated around given a position in a rectangle
|
402
|
-
*/
|
403
|
-
S2D_GL_Point S2D_GetRectRotationPoint(int x, int y, int w, int h, int position);
|
404
|
-
|
405
|
-
/*
|
406
|
-
* Draw a triangle
|
407
|
-
*/
|
408
|
-
void S2D_DrawTriangle(
|
409
|
-
GLfloat x1, GLfloat y1,
|
410
|
-
GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
|
411
|
-
GLfloat x2, GLfloat y2,
|
412
|
-
GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
|
413
|
-
GLfloat x3, GLfloat y3,
|
414
|
-
GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3
|
415
|
-
);
|
416
|
-
|
417
|
-
/*
|
418
|
-
* Draw a quad, using two triangles
|
419
|
-
*/
|
420
|
-
void S2D_DrawQuad(
|
421
|
-
GLfloat x1, GLfloat y1,
|
422
|
-
GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
|
423
|
-
GLfloat x2, GLfloat y2,
|
424
|
-
GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
|
425
|
-
GLfloat x3, GLfloat y3,
|
426
|
-
GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3,
|
427
|
-
GLfloat x4, GLfloat y4,
|
428
|
-
GLfloat r4, GLfloat g4, GLfloat b4, GLfloat a4
|
429
|
-
);
|
430
|
-
|
431
|
-
/*
|
432
|
-
* Draw a line from a quad
|
433
|
-
*/
|
434
|
-
void S2D_DrawLine(
|
435
|
-
GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,
|
436
|
-
GLfloat width,
|
437
|
-
GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
|
438
|
-
GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
|
439
|
-
GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3,
|
440
|
-
GLfloat r4, GLfloat g4, GLfloat b4, GLfloat a4
|
441
|
-
);
|
442
|
-
|
443
|
-
/*
|
444
|
-
* Draw a circle from triangles
|
445
|
-
*/
|
446
|
-
void S2D_DrawCircle(
|
447
|
-
GLfloat x, GLfloat y, GLfloat radius, int sectors,
|
448
|
-
GLfloat r, GLfloat g, GLfloat b, GLfloat a
|
449
|
-
);
|
450
|
-
|
451
|
-
// Image ///////////////////////////////////////////////////////////////////////
|
452
|
-
|
453
|
-
/*
|
454
|
-
* Create an image, given a file path
|
455
|
-
*/
|
456
|
-
S2D_Image *S2D_CreateImage(const char *path);
|
457
|
-
|
458
|
-
/*
|
459
|
-
* Rotate an image
|
460
|
-
*/
|
461
|
-
void S2D_RotateImage(S2D_Image *img, GLfloat angle, int position);
|
462
|
-
|
463
|
-
/*
|
464
|
-
* Draw an image
|
465
|
-
*/
|
466
|
-
void S2D_DrawImage(S2D_Image *img);
|
467
|
-
|
468
|
-
/*
|
469
|
-
* Free an image
|
470
|
-
*/
|
471
|
-
void S2D_FreeImage(S2D_Image *img);
|
472
|
-
|
473
|
-
// Sprite //////////////////////////////////////////////////////////////////////
|
474
|
-
|
475
|
-
/*
|
476
|
-
* Create a sprite, given an image file path
|
477
|
-
*/
|
478
|
-
S2D_Sprite *S2D_CreateSprite(const char *path);
|
479
|
-
|
480
|
-
/*
|
481
|
-
* Clip a sprite
|
482
|
-
*/
|
483
|
-
void S2D_ClipSprite(S2D_Sprite *spr, int x, int y, int w, int h);
|
484
|
-
|
485
|
-
/*
|
486
|
-
* Rotate a sprite
|
487
|
-
*/
|
488
|
-
void S2D_RotateSprite(S2D_Sprite *spr, GLfloat angle, int position);
|
489
|
-
|
490
|
-
/*
|
491
|
-
* Draw a sprite
|
492
|
-
*/
|
493
|
-
void S2D_DrawSprite(S2D_Sprite *spr);
|
494
|
-
|
495
|
-
/*
|
496
|
-
* Free a sprite
|
497
|
-
*/
|
498
|
-
void S2D_FreeSprite(S2D_Sprite *spr);
|
499
|
-
|
500
|
-
// Text ////////////////////////////////////////////////////////////////////////
|
501
|
-
|
502
|
-
/*
|
503
|
-
* Create text, given a font file path, the message, and size
|
504
|
-
*/
|
505
|
-
S2D_Text *S2D_CreateText(const char *font, const char *msg, int size);
|
506
|
-
|
507
|
-
/*
|
508
|
-
* Set the text message
|
509
|
-
*/
|
510
|
-
void S2D_SetText(S2D_Text *txt, const char *msg, ...);
|
511
|
-
|
512
|
-
/*
|
513
|
-
* Rotate text
|
514
|
-
*/
|
515
|
-
void S2D_RotateText(S2D_Text *txt, GLfloat angle, int position);
|
516
|
-
|
517
|
-
/*
|
518
|
-
* Draw text
|
519
|
-
*/
|
520
|
-
void S2D_DrawText(S2D_Text *txt);
|
521
|
-
|
522
|
-
/*
|
523
|
-
* Free the text
|
524
|
-
*/
|
525
|
-
void S2D_FreeText(S2D_Text *txt);
|
526
|
-
|
527
|
-
// Sound ///////////////////////////////////////////////////////////////////////
|
528
|
-
|
529
|
-
/*
|
530
|
-
* Create a sound, given an audio file path
|
531
|
-
*/
|
532
|
-
S2D_Sound *S2D_CreateSound(const char *path);
|
533
|
-
|
534
|
-
/*
|
535
|
-
* Play the sound
|
536
|
-
*/
|
537
|
-
void S2D_PlaySound(S2D_Sound *snd);
|
538
|
-
|
539
|
-
/*
|
540
|
-
* Free the sound
|
541
|
-
*/
|
542
|
-
void S2D_FreeSound(S2D_Sound *snd);
|
543
|
-
|
544
|
-
// Music ///////////////////////////////////////////////////////////////////////
|
545
|
-
|
546
|
-
/*
|
547
|
-
* Create the music, given an audio file path
|
548
|
-
*/
|
549
|
-
S2D_Music *S2D_CreateMusic(const char *path);
|
550
|
-
|
551
|
-
/*
|
552
|
-
* Play the music
|
553
|
-
*/
|
554
|
-
void S2D_PlayMusic(S2D_Music *mus, bool loop);
|
555
|
-
|
556
|
-
/*
|
557
|
-
* Pause the playing music
|
558
|
-
*/
|
559
|
-
void S2D_PauseMusic();
|
560
|
-
|
561
|
-
/*
|
562
|
-
* Resume the current music
|
563
|
-
*/
|
564
|
-
void S2D_ResumeMusic();
|
565
|
-
|
566
|
-
/*
|
567
|
-
* Stop the playing music; interrupts fader effects
|
568
|
-
*/
|
569
|
-
void S2D_StopMusic();
|
570
|
-
|
571
|
-
/*
|
572
|
-
* Get the music volume
|
573
|
-
*/
|
574
|
-
int S2D_GetMusicVolume();
|
575
|
-
|
576
|
-
/*
|
577
|
-
* Set the music volume a given percentage
|
578
|
-
*/
|
579
|
-
void S2D_SetMusicVolume(int volume);
|
580
|
-
|
581
|
-
/*
|
582
|
-
* Fade out the playing music
|
583
|
-
*/
|
584
|
-
void S2D_FadeOutMusic(int ms);
|
585
|
-
|
586
|
-
/*
|
587
|
-
* Free the music
|
588
|
-
*/
|
589
|
-
void S2D_FreeMusic(S2D_Music *mus);
|
590
|
-
|
591
|
-
// Input ///////////////////////////////////////////////////////////////////////
|
592
|
-
|
593
|
-
/*
|
594
|
-
* Get the mouse coordinates relative to the viewport
|
595
|
-
*/
|
596
|
-
void S2D_GetMouseOnViewport(S2D_Window *window, int wx, int wy, int *x, int *y);
|
597
|
-
|
598
|
-
/*
|
599
|
-
* Show the cursor over the window
|
600
|
-
*/
|
601
|
-
void S2D_ShowCursor();
|
602
|
-
|
603
|
-
/*
|
604
|
-
* Hide the cursor over the window
|
605
|
-
*/
|
606
|
-
void S2D_HideCursor();
|
607
|
-
|
608
|
-
// Controllers /////////////////////////////////////////////////////////////////
|
609
|
-
|
610
|
-
/*
|
611
|
-
* Add controller mapping from string
|
612
|
-
*/
|
613
|
-
void S2D_AddControllerMapping(const char *map);
|
614
|
-
|
615
|
-
/*
|
616
|
-
* Load controller mappings from the specified file
|
617
|
-
*/
|
618
|
-
void S2D_AddControllerMappingsFromFile(const char *path);
|
619
|
-
|
620
|
-
/*
|
621
|
-
* Check if joystick is a controller
|
622
|
-
*/
|
623
|
-
bool S2D_IsController(SDL_JoystickID id);
|
624
|
-
|
625
|
-
/*
|
626
|
-
* Open controllers and joysticks
|
627
|
-
*/
|
628
|
-
void S2D_OpenControllers();
|
629
|
-
|
630
|
-
// Window //////////////////////////////////////////////////////////////////////
|
631
|
-
|
632
|
-
/*
|
633
|
-
* Create a window
|
634
|
-
*/
|
635
|
-
S2D_Window *S2D_CreateWindow(
|
636
|
-
const char *title, int width, int height, S2D_Update, S2D_Render, int flags
|
637
|
-
);
|
638
|
-
|
639
|
-
/*
|
640
|
-
* Show the window
|
641
|
-
*/
|
642
|
-
int S2D_Show(S2D_Window *window);
|
643
|
-
|
644
|
-
/*
|
645
|
-
* Set the icon for the window
|
646
|
-
*/
|
647
|
-
void S2D_SetIcon(S2D_Window *window, const char *icon);
|
648
|
-
|
649
|
-
/*
|
650
|
-
* Take a screenshot of the window
|
651
|
-
*/
|
652
|
-
void S2D_Screenshot(S2D_Window *window, const char *path);
|
653
|
-
|
654
|
-
/*
|
655
|
-
* Close the window
|
656
|
-
*/
|
657
|
-
int S2D_Close(S2D_Window *window);
|
658
|
-
|
659
|
-
/*
|
660
|
-
* Free all resources
|
661
|
-
*/
|
662
|
-
int S2D_FreeWindow(S2D_Window *window);
|
663
|
-
|
664
|
-
// Simple 2D OpenGL Functions //////////////////////////////////////////////////
|
665
|
-
|
666
|
-
int S2D_GL_Init(S2D_Window *window);
|
667
|
-
void S2D_GL_PrintError(char *error);
|
668
|
-
void S2D_GL_PrintContextInfo(S2D_Window *window);
|
669
|
-
void S2D_GL_StoreContextInfo(S2D_Window *window);
|
670
|
-
GLuint S2D_GL_LoadShader(GLenum type, const GLchar *shaderSrc, char *shaderName);
|
671
|
-
int S2D_GL_CheckLinked(GLuint program, char *name);
|
672
|
-
void S2D_GL_GetViewportScale(S2D_Window *window, int *w, int *h, double *scale);
|
673
|
-
void S2D_GL_SetViewport(S2D_Window *window);
|
674
|
-
void S2D_GL_CreateTexture(
|
675
|
-
GLuint *id, GLint format,
|
676
|
-
int w, int h,
|
677
|
-
const GLvoid *data, GLint filter);
|
678
|
-
void S2D_GL_DrawTriangle(
|
679
|
-
GLfloat x1, GLfloat y1,
|
680
|
-
GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
|
681
|
-
GLfloat x2, GLfloat y2,
|
682
|
-
GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
|
683
|
-
GLfloat x3, GLfloat y3,
|
684
|
-
GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3);
|
685
|
-
void S2D_GL_DrawImage(S2D_Image *img);
|
686
|
-
void S2D_GL_DrawSprite(S2D_Sprite *spr);
|
687
|
-
void S2D_GL_DrawText(S2D_Text *txt);
|
688
|
-
void S2D_GL_FreeTexture(GLuint *id);
|
689
|
-
void S2D_GL_Clear(S2D_Color clr);
|
690
|
-
|
691
|
-
// OpenGL & GLES Internal Functions ////////////////////////////////////////////
|
692
|
-
|
693
|
-
#if GLES
|
694
|
-
int S2D_GLES_Init();
|
695
|
-
void S2D_GLES_ApplyProjection(GLfloat orthoMatrix[16]);
|
696
|
-
void S2D_GLES_DrawTriangle(
|
697
|
-
GLfloat x1, GLfloat y1,
|
698
|
-
GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
|
699
|
-
GLfloat x2, GLfloat y2,
|
700
|
-
GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
|
701
|
-
GLfloat x3, GLfloat y3,
|
702
|
-
GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3);
|
703
|
-
void S2D_GLES_DrawImage(S2D_Image *img);
|
704
|
-
void S2D_GLES_DrawSprite(S2D_Sprite *spr);
|
705
|
-
void S2D_GLES_DrawText(S2D_Text *txt);
|
706
|
-
#else
|
707
|
-
int S2D_GL2_Init();
|
708
|
-
int S2D_GL3_Init();
|
709
|
-
void S2D_GL2_ApplyProjection(int w, int h);
|
710
|
-
void S2D_GL3_ApplyProjection(GLfloat orthoMatrix[16]);
|
711
|
-
void S2D_GL2_DrawTriangle(
|
712
|
-
GLfloat x1, GLfloat y1,
|
713
|
-
GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
|
714
|
-
GLfloat x2, GLfloat y2,
|
715
|
-
GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
|
716
|
-
GLfloat x3, GLfloat y3,
|
717
|
-
GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3);
|
718
|
-
void S2D_GL3_DrawTriangle(
|
719
|
-
GLfloat x1, GLfloat y1,
|
720
|
-
GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
|
721
|
-
GLfloat x2, GLfloat y2,
|
722
|
-
GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
|
723
|
-
GLfloat x3, GLfloat y3,
|
724
|
-
GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3);
|
725
|
-
void S2D_GL2_DrawImage(S2D_Image *img);
|
726
|
-
void S2D_GL3_DrawImage(S2D_Image *img);
|
727
|
-
void S2D_GL2_DrawSprite(S2D_Sprite *spr);
|
728
|
-
void S2D_GL3_DrawSprite(S2D_Sprite *spr);
|
729
|
-
void S2D_GL2_DrawText(S2D_Text *txt);
|
730
|
-
void S2D_GL3_DrawText(S2D_Text *txt);
|
731
|
-
#endif
|
732
|
-
|
733
|
-
#ifdef __cplusplus
|
734
|
-
}
|
735
|
-
#endif
|