ray 0.0.1 → 0.1.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/.yardopts +4 -0
- data/README.md +17 -21
- data/Rakefile +18 -139
- data/VERSION +1 -1
- data/ext/audio.cpp +723 -0
- data/ext/{color.c → color.cpp} +25 -13
- data/ext/drawable.cpp +91 -0
- data/ext/event.cpp +460 -0
- data/ext/extconf.rb +5 -104
- data/ext/font.cpp +190 -0
- data/ext/image.cpp +733 -0
- data/ext/input.cpp +74 -0
- data/ext/ray.cpp +168 -0
- data/ext/ray.hpp +356 -0
- data/ext/{rect.c → rect.cpp} +51 -37
- data/ext/shader.cpp +169 -0
- data/ext/shape.cpp +409 -0
- data/ext/sprite.cpp +306 -0
- data/ext/text.cpp +181 -0
- data/ext/vector.cpp +215 -0
- data/guide.md +619 -0
- data/lib/ray/audio.rb +0 -41
- data/lib/ray/color.rb +32 -10
- data/lib/ray/drawable.rb +16 -0
- data/lib/ray/dsl/event_listener.rb +25 -2
- data/lib/ray/dsl/event_runner.rb +33 -5
- data/lib/ray/dsl/event_translator.rb +66 -30
- data/lib/ray/dsl/handler.rb +3 -2
- data/lib/ray/dsl/matcher.rb +58 -14
- data/lib/ray/font.rb +38 -96
- data/lib/ray/font_set.rb +8 -8
- data/lib/ray/game.rb +87 -66
- data/lib/ray/helper.rb +105 -10
- data/lib/ray/image.rb +150 -24
- data/lib/ray/image_set.rb +3 -1
- data/lib/ray/input.rb +10 -0
- data/lib/ray/music_set.rb +5 -3
- data/lib/ray/ray.rb +21 -9
- data/lib/ray/rect.rb +48 -7
- data/lib/ray/rmagick.rb +41 -0
- data/lib/ray/scene.rb +99 -43
- data/lib/ray/scene_list.rb +67 -0
- data/lib/ray/shape.rb +132 -0
- data/lib/ray/sound_set.rb +4 -2
- data/lib/ray/sprite.rb +49 -111
- data/lib/ray/text.rb +101 -0
- data/lib/ray/text_helper.rb +37 -0
- data/lib/ray/turtle.rb +215 -0
- data/lib/ray/vector.rb +226 -0
- data/samples/audio/spacial.rb +44 -0
- data/samples/hello_world/hello.rb +9 -13
- data/samples/hello_world/hello_dsl.rb +8 -12
- data/samples/hello_world/text.rb +15 -0
- data/samples/opengl/binding.rb +38 -0
- data/samples/opengl/image.rb +32 -0
- data/samples/opengl/opengl.rb +34 -0
- data/samples/opengl/shader.rb +42 -0
- data/samples/pong/pong.rb +14 -10
- data/samples/run_scene.rb +53 -0
- data/samples/shaders/scene.rb +40 -0
- data/samples/shaders/shaders.rb +42 -0
- data/samples/shaders/shape.rb +34 -0
- data/samples/sokoban/sokoban.rb +18 -18
- data/samples/test/actual_scene.rb +41 -0
- data/samples/test/scene_riot.rb +39 -0
- data/samples/test/scene_spec.rb +32 -0
- data/samples/test/scene_test_unit.rb +25 -0
- data/samples/turtle/byzantium.rb +45 -0
- data/samples/turtle/hilbert.rb +48 -0
- data/samples/turtle/koch.rb +55 -0
- data/samples/turtle/mandala.rb +61 -0
- data/samples/turtle/tree.rb +57 -0
- data/test/audio_test.rb +69 -0
- data/test/color_test.rb +77 -0
- data/test/drawable_test.rb +19 -0
- data/test/dsl_test.rb +93 -0
- data/test/font_test.rb +57 -0
- data/test/helpers.rb +94 -0
- data/test/image_test.rb +82 -0
- data/test/ray_test.rb +25 -0
- data/test/rect_test.rb +121 -0
- data/{spec → test}/res/VeraMono.ttf +0 -0
- data/{spec → test}/res/aqua.bmp +0 -0
- data/{spec → test}/res/aqua.png +0 -0
- data/{spec → test}/res/aqua2.bmp +0 -0
- data/{spec → test}/res/not_a_jpeg.jpeg +0 -0
- data/{spec → test}/res/pop.wav +0 -0
- data/test/resource_set_test.rb +99 -0
- data/test/run_all.rb +7 -0
- data/test/shape_test.rb +101 -0
- data/test/sprite_test.rb +89 -0
- data/test/text_test.rb +78 -0
- data/test/turtle_test.rb +176 -0
- data/test/vector_test.rb +111 -0
- data/yard_ext.rb +0 -28
- metadata +95 -139
- data/.gitignore +0 -23
- data/.gitmodules +0 -3
- data/.rspec +0 -3
- data/ext/audio.c +0 -473
- data/ext/event.c +0 -557
- data/ext/font.c +0 -287
- data/ext/image.c +0 -933
- data/ext/joystick.c +0 -145
- data/ext/ray.c +0 -489
- data/ext/ray.h +0 -245
- data/ext/ray_osx.m +0 -161
- data/lib/ray/joystick.rb +0 -30
- data/psp/SDL_psp_main.c +0 -84
- data/psp/bigdecimal/README +0 -60
- data/psp/bigdecimal/bigdecimal.c +0 -4697
- data/psp/bigdecimal/bigdecimal.h +0 -216
- data/psp/bigdecimal/lib/bigdecimal/jacobian.rb +0 -85
- data/psp/bigdecimal/lib/bigdecimal/ludcmp.rb +0 -84
- data/psp/bigdecimal/lib/bigdecimal/math.rb +0 -235
- data/psp/bigdecimal/lib/bigdecimal/newton.rb +0 -77
- data/psp/bigdecimal/lib/bigdecimal/util.rb +0 -65
- data/psp/digest/bubblebabble/bubblebabble.c +0 -142
- data/psp/digest/defs.h +0 -20
- data/psp/digest/digest.c +0 -643
- data/psp/digest/digest.h +0 -32
- data/psp/digest/lib/digest.rb +0 -50
- data/psp/digest/lib/md5.rb +0 -27
- data/psp/digest/lib/sha1.rb +0 -27
- data/psp/digest/md5/md5.c +0 -420
- data/psp/digest/md5/md5.h +0 -80
- data/psp/digest/md5/md5init.c +0 -40
- data/psp/digest/rmd160/rmd160.c +0 -457
- data/psp/digest/rmd160/rmd160.h +0 -56
- data/psp/digest/rmd160/rmd160init.c +0 -40
- data/psp/digest/sha1/sha1.c +0 -269
- data/psp/digest/sha1/sha1.h +0 -39
- data/psp/digest/sha1/sha1init.c +0 -40
- data/psp/digest/sha2/lib/sha2.rb +0 -73
- data/psp/digest/sha2/sha2.c +0 -919
- data/psp/digest/sha2/sha2.h +0 -109
- data/psp/digest/sha2/sha2init.c +0 -52
- data/psp/enumerator/enumerator.c +0 -298
- data/psp/etc/etc.c +0 -559
- data/psp/ext.c +0 -289
- data/psp/fcntl/fcntl.c +0 -187
- data/psp/lib/rbconfig.rb +0 -178
- data/psp/nkf/lib/kconv.rb +0 -367
- data/psp/nkf/nkf-utf8/config.h +0 -88
- data/psp/nkf/nkf-utf8/nkf.c +0 -6040
- data/psp/nkf/nkf-utf8/utf8tbl.c +0 -8500
- data/psp/nkf/nkf-utf8/utf8tbl.h +0 -34
- data/psp/nkf/nkf.c +0 -654
- data/psp/socket/addrinfo.h +0 -173
- data/psp/socket/getaddrinfo.c +0 -676
- data/psp/socket/getnameinfo.c +0 -270
- data/psp/socket/pspsocket.c +0 -71
- data/psp/socket/pspsocket.h +0 -28
- data/psp/socket/socket.c +0 -4662
- data/psp/socket/sockport.h +0 -76
- data/psp/stringio/stringio.c +0 -1306
- data/psp/strscan/strscan.c +0 -1320
- data/psp/syck/bytecode.c +0 -1166
- data/psp/syck/emitter.c +0 -1242
- data/psp/syck/gram.c +0 -1894
- data/psp/syck/gram.h +0 -79
- data/psp/syck/handler.c +0 -174
- data/psp/syck/implicit.c +0 -2990
- data/psp/syck/node.c +0 -408
- data/psp/syck/rubyext.c +0 -2367
- data/psp/syck/syck.c +0 -504
- data/psp/syck/syck.h +0 -456
- data/psp/syck/token.c +0 -2725
- data/psp/syck/yaml2byte.c +0 -257
- data/psp/syck/yamlbyte.h +0 -170
- data/psp/thread/thread.c +0 -1175
- data/psp/zlib/zlib.c +0 -3547
- data/script.rb +0 -10
- data/spec/ray/audio_spec.rb +0 -146
- data/spec/ray/color_spec.rb +0 -57
- data/spec/ray/event_spec.rb +0 -80
- data/spec/ray/font_spec.rb +0 -93
- data/spec/ray/image_set_spec.rb +0 -48
- data/spec/ray/image_spec.rb +0 -162
- data/spec/ray/joystick_spec.rb +0 -21
- data/spec/ray/matcher_spec.rb +0 -50
- data/spec/ray/ray_spec.rb +0 -88
- data/spec/ray/rect_spec.rb +0 -154
- data/spec/ray/resource_set_spec.rb +0 -105
- data/spec/ray/sprite_spec.rb +0 -163
- data/spec/spec.opts +0 -4
- data/spec/spec_helper.rb +0 -8
data/ext/font.c
DELETED
@@ -1,287 +0,0 @@
|
|
1
|
-
#include "ray.h"
|
2
|
-
|
3
|
-
#ifdef HAVE_SDL_TTF
|
4
|
-
|
5
|
-
enum ray_encoding {
|
6
|
-
RAY_ENCODING_LATIN1,
|
7
|
-
RAY_ENCODING_UTF8,
|
8
|
-
RAY_ENCODING_UNICODE
|
9
|
-
};
|
10
|
-
|
11
|
-
VALUE ray_cFont = Qnil;
|
12
|
-
|
13
|
-
TTF_Font *ray_rb2font(VALUE object) {
|
14
|
-
if (!RAY_IS_A(object, ray_cFont)) {
|
15
|
-
rb_raise(rb_eTypeError, "Can't convert %s into Ray::Font",
|
16
|
-
RAY_OBJ_CLASSNAME(object));
|
17
|
-
}
|
18
|
-
|
19
|
-
ray_font *ptr = NULL;
|
20
|
-
Data_Get_Struct(object, ray_font, ptr);
|
21
|
-
|
22
|
-
return ptr->font;
|
23
|
-
}
|
24
|
-
|
25
|
-
void ray_free_font(ray_font *font) {
|
26
|
-
if (font->font) TTF_CloseFont(font->font);
|
27
|
-
free(font);
|
28
|
-
}
|
29
|
-
|
30
|
-
VALUE ray_alloc_font(VALUE self) {
|
31
|
-
ray_font *ptr = malloc(sizeof(ray_font));
|
32
|
-
VALUE ret = Data_Wrap_Struct(self, 0, ray_free_font, ptr);
|
33
|
-
|
34
|
-
ptr->font = NULL;
|
35
|
-
return ret;
|
36
|
-
}
|
37
|
-
|
38
|
-
void ray_init_font_with_filename(VALUE self, VALUE filename, int size) {
|
39
|
-
ray_font *font = NULL;
|
40
|
-
Data_Get_Struct(self, ray_font, font);
|
41
|
-
|
42
|
-
font->font = TTF_OpenFont(StringValuePtr(filename), size);
|
43
|
-
if (!font->font) {
|
44
|
-
rb_raise(rb_eRuntimeError, "Could not load the font (%s)",
|
45
|
-
TTF_GetError());
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
void ray_init_font_with_io(VALUE self, VALUE io, int size) {
|
50
|
-
ray_font *font = NULL;
|
51
|
-
Data_Get_Struct(self, ray_font, font);
|
52
|
-
|
53
|
-
VALUE string = rb_funcall2(io, RAY_METH("read"), 0, NULL);
|
54
|
-
char *content = StringValuePtr(string);
|
55
|
-
|
56
|
-
SDL_RWops *data = SDL_RWFromMem(content, (int)RSTRING_LEN(string));
|
57
|
-
if (!data) {
|
58
|
-
rb_raise(rb_eRuntimeError, "Could not create image data (%s)",
|
59
|
-
SDL_GetError());
|
60
|
-
}
|
61
|
-
|
62
|
-
font->font = TTF_OpenFontRW(data, 1, size);
|
63
|
-
if (!font->font) {
|
64
|
-
printf("Could not load the font (%s)\n", TTF_GetError());
|
65
|
-
rb_raise(rb_eRuntimeError, "Could not load the font (%s)",
|
66
|
-
TTF_GetError());
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
|
-
/*
|
71
|
-
Creates a new font.
|
72
|
-
|
73
|
-
@param [String, #read] arg Filename of the font or IO object containing
|
74
|
-
the content of the font.
|
75
|
-
@param [Integer] size Point size (based on 72DPI).
|
76
|
-
*/
|
77
|
-
VALUE ray_init_font(VALUE self, VALUE arg, VALUE size) {
|
78
|
-
if (rb_respond_to(arg, RAY_METH("to_str")))
|
79
|
-
ray_init_font_with_filename(self, rb_String(arg), NUM2INT(size));
|
80
|
-
else if (rb_respond_to(arg, RAY_METH("read")))
|
81
|
-
ray_init_font_with_io(self, arg, NUM2INT(size));
|
82
|
-
else {
|
83
|
-
rb_raise(rb_eTypeError, "Can't convert %s into String",
|
84
|
-
RAY_OBJ_CLASSNAME(arg));
|
85
|
-
}
|
86
|
-
|
87
|
-
return Qnil;
|
88
|
-
}
|
89
|
-
|
90
|
-
/*
|
91
|
-
@return [Integer] Bitmask describing the style of the font.
|
92
|
-
STYLE_NORMAL for a normal font.
|
93
|
-
*/
|
94
|
-
VALUE ray_font_style(VALUE self) {
|
95
|
-
TTF_Font *font = ray_rb2font(self);
|
96
|
-
return INT2FIX(TTF_GetFontStyle(font));
|
97
|
-
}
|
98
|
-
|
99
|
-
/* Sets the font style. */
|
100
|
-
VALUE ray_font_set_style(VALUE self, VALUE style) {
|
101
|
-
TTF_Font *font = ray_rb2font(self);
|
102
|
-
TTF_SetFontStyle(font, NUM2INT(style));
|
103
|
-
return style;
|
104
|
-
}
|
105
|
-
|
106
|
-
/* @return [Integer] the height of the font */
|
107
|
-
VALUE ray_font_height(VALUE self) {
|
108
|
-
TTF_Font *font = ray_rb2font(self);
|
109
|
-
return INT2FIX(TTF_FontHeight(font));
|
110
|
-
}
|
111
|
-
|
112
|
-
/* @return [Integer] the recommended spacing between lines for this font */
|
113
|
-
VALUE ray_font_line_skip(VALUE self) {
|
114
|
-
TTF_Font *font = ray_rb2font(self);
|
115
|
-
return INT2FIX(TTF_FontLineSkip(font));
|
116
|
-
}
|
117
|
-
|
118
|
-
/*
|
119
|
-
@overload size_of(text, encoding = nil)
|
120
|
-
@param [Symbol, nil] encoding nil (for Latin1), :latin1, :utf8, or :unicode.
|
121
|
-
@return [Ray::Rect] Size of the text.
|
122
|
-
*/
|
123
|
-
VALUE ray_font_size_of(int argc, VALUE *argv, VALUE self) {
|
124
|
-
TTF_Font *font = ray_rb2font(self);
|
125
|
-
|
126
|
-
VALUE string = Qnil, encoding = Qnil;
|
127
|
-
rb_scan_args(argc, argv, "11", &string, &encoding);
|
128
|
-
|
129
|
-
char *c_string = StringValuePtr(string);
|
130
|
-
|
131
|
-
int w, h;
|
132
|
-
|
133
|
-
if (NIL_P(encoding) || encoding == RAY_SYM("latin1"))
|
134
|
-
TTF_SizeText(font, c_string, &w, &h);
|
135
|
-
else if (encoding == RAY_SYM("utf8"))
|
136
|
-
TTF_SizeUTF8(font, c_string, &w, &h);
|
137
|
-
else if (encoding == RAY_SYM("unicode"))
|
138
|
-
TTF_SizeUNICODE(font, (uint16_t*)c_string, &w, &h);
|
139
|
-
else
|
140
|
-
rb_raise(rb_eArgError, "Invalid encoding.");
|
141
|
-
|
142
|
-
SDL_Rect rect = {0, 0, w, h};
|
143
|
-
return ray_rect2rb(rect);
|
144
|
-
}
|
145
|
-
|
146
|
-
/*
|
147
|
-
@overload draw(string, opts = {})
|
148
|
-
@param [String] string The string which should be drawn.
|
149
|
-
|
150
|
-
@option opts [Symbol] :mode Drawing mode. :solid (fastest),
|
151
|
-
:shaded (requires a background set
|
152
|
-
with :background) or :blended
|
153
|
-
@option opts [Symbol] :encoding :latin1, :utf8, or :unicode. Defaults
|
154
|
-
to :latin1.
|
155
|
-
@option opts [Ray::Color] :color Color to draw the text in. Defaults to
|
156
|
-
white.
|
157
|
-
@option opts [Ray::Color] :background The background color in :shaded mode.
|
158
|
-
defaults to black.
|
159
|
-
@option opts [Ray::Image] :on The image to draw on. In this case,
|
160
|
-
it will directly draw instead of returning
|
161
|
-
an image containing nothing but the string.
|
162
|
-
@option opts [Ray::Rect, Array<Integer>] :to, :at where to draw on the image.
|
163
|
-
|
164
|
-
@return The surface it drew the string on.
|
165
|
-
*/
|
166
|
-
VALUE ray_font_draw(int argc, VALUE *argv, VALUE self) {
|
167
|
-
VALUE string, hash;
|
168
|
-
rb_scan_args(argc, argv, "11", &string, &hash);
|
169
|
-
|
170
|
-
if (NIL_P(hash))
|
171
|
-
hash = rb_hash_new();
|
172
|
-
|
173
|
-
TTF_Font *font = ray_rb2font(self);
|
174
|
-
|
175
|
-
char *c_string = StringValuePtr(string);
|
176
|
-
|
177
|
-
/* solid, shaded, blended */
|
178
|
-
VALUE drawing_mode = rb_hash_aref(hash, RAY_SYM("mode"));
|
179
|
-
|
180
|
-
VALUE encoding = rb_hash_aref(hash, RAY_SYM("encoding"));
|
181
|
-
int c_encoding = 0;
|
182
|
-
|
183
|
-
if (NIL_P(encoding) || encoding == RAY_SYM("latin1"))
|
184
|
-
c_encoding = RAY_ENCODING_LATIN1;
|
185
|
-
else if (encoding == RAY_SYM("utf8"))
|
186
|
-
c_encoding = RAY_ENCODING_UTF8;
|
187
|
-
else if (encoding == RAY_SYM("unicode"))
|
188
|
-
c_encoding = RAY_ENCODING_UNICODE;
|
189
|
-
else
|
190
|
-
rb_raise(rb_eArgError, "Invalid encoding.");
|
191
|
-
|
192
|
-
VALUE rb_color = rb_hash_aref(hash, RAY_SYM("color"));
|
193
|
-
ray_color c_color = {255, 255, 255, 255};
|
194
|
-
if (!NIL_P(rb_color))
|
195
|
-
c_color = ray_rb2col(rb_color);
|
196
|
-
|
197
|
-
SDL_Color color = {c_color.r, c_color.g, c_color.b};
|
198
|
-
|
199
|
-
SDL_Surface *surface = NULL;
|
200
|
-
|
201
|
-
if (NIL_P(drawing_mode) || drawing_mode == RAY_SYM("solid")) {
|
202
|
-
if (c_encoding == RAY_ENCODING_LATIN1)
|
203
|
-
surface = TTF_RenderText_Solid(font, c_string, color);
|
204
|
-
else if (c_encoding == RAY_ENCODING_UTF8)
|
205
|
-
surface = TTF_RenderUTF8_Solid(font, c_string, color);
|
206
|
-
else
|
207
|
-
surface = TTF_RenderUNICODE_Solid(font, (uint16_t*)c_string, color);
|
208
|
-
}
|
209
|
-
else if (drawing_mode == RAY_SYM("shaded")) {
|
210
|
-
VALUE rb_bg = rb_hash_aref(hash, RAY_SYM("background"));
|
211
|
-
ray_color c_bg = {0, 0, 0, 255};
|
212
|
-
if (!NIL_P(rb_bg))
|
213
|
-
c_bg = ray_rb2col(rb_bg);
|
214
|
-
SDL_Color bg = {c_bg.r, c_bg.g, c_bg.b};
|
215
|
-
|
216
|
-
if (c_encoding == RAY_ENCODING_LATIN1)
|
217
|
-
surface = TTF_RenderText_Shaded(font, c_string, color, bg);
|
218
|
-
else if (c_encoding == RAY_ENCODING_UTF8)
|
219
|
-
surface = TTF_RenderUTF8_Shaded(font, c_string, color, bg);
|
220
|
-
else
|
221
|
-
surface = TTF_RenderUNICODE_Shaded(font, (uint16_t*)c_string, color, bg);
|
222
|
-
}
|
223
|
-
else if (drawing_mode == RAY_SYM("blended")) {
|
224
|
-
if (c_encoding == RAY_ENCODING_LATIN1)
|
225
|
-
surface = TTF_RenderText_Blended(font, c_string, color);
|
226
|
-
else if (c_encoding == RAY_ENCODING_UTF8)
|
227
|
-
surface = TTF_RenderUTF8_Blended(font, c_string, color);
|
228
|
-
else
|
229
|
-
surface = TTF_RenderUNICODE_Blended(font, (uint16_t*)c_string, color);
|
230
|
-
}
|
231
|
-
else
|
232
|
-
rb_raise(rb_eArgError, "Invalid drawing mode.");
|
233
|
-
|
234
|
-
if (!surface) {
|
235
|
-
rb_raise(rb_eRuntimeError, "Could not drawstring (%s)",
|
236
|
-
TTF_GetError());
|
237
|
-
}
|
238
|
-
|
239
|
-
VALUE on = rb_hash_aref(hash, RAY_SYM("on"));
|
240
|
-
if (NIL_P(on))
|
241
|
-
return ray_create_gc_image(surface);
|
242
|
-
|
243
|
-
SDL_Surface *target = ray_rb2surface(on);
|
244
|
-
|
245
|
-
VALUE rb_rect = rb_hash_aref(hash, RAY_SYM("at"));
|
246
|
-
if (NIL_P(rb_rect))
|
247
|
-
rb_rect = rb_hash_aref(hash, RAY_SYM("to"));
|
248
|
-
|
249
|
-
SDL_Rect rect;
|
250
|
-
|
251
|
-
if (RTEST(rb_obj_is_kind_of(rb_rect, ray_cRect)))
|
252
|
-
rect = ray_rb2rect(rb_rect);
|
253
|
-
else if (RTEST(rb_obj_is_kind_of(rb_rect, rb_cArray)))
|
254
|
-
rect = ray_rb2rect(rb_apply(ray_cRect, RAY_METH("new"), rb_rect));
|
255
|
-
else {
|
256
|
-
rb_raise(rb_eTypeError, "Can't convert %s into Ray::Rect",
|
257
|
-
RAY_OBJ_CLASSNAME(rb_rect));
|
258
|
-
}
|
259
|
-
|
260
|
-
SDL_BlitSurface(surface, NULL, target, &rect);
|
261
|
-
SDL_FreeSurface(surface);
|
262
|
-
|
263
|
-
return on;
|
264
|
-
}
|
265
|
-
|
266
|
-
void Init_ray_font() {
|
267
|
-
ray_cFont = rb_define_class_under(ray_mRay, "Font", rb_cObject);
|
268
|
-
rb_define_alloc_func(ray_cFont, ray_alloc_font);
|
269
|
-
rb_define_method(ray_cFont, "initialize", ray_init_font, 2);
|
270
|
-
|
271
|
-
rb_define_method(ray_cFont, "style", ray_font_style, 0);
|
272
|
-
rb_define_method(ray_cFont, "style=", ray_font_set_style, 1);
|
273
|
-
|
274
|
-
rb_define_method(ray_cFont, "height", ray_font_height, 0);
|
275
|
-
rb_define_method(ray_cFont, "line_skip", ray_font_line_skip, 0);
|
276
|
-
|
277
|
-
rb_define_method(ray_cFont, "size_of", ray_font_size_of, -1);
|
278
|
-
|
279
|
-
rb_define_method(ray_cFont, "draw", ray_font_draw, -1);
|
280
|
-
|
281
|
-
rb_define_const(ray_cFont, "STYLE_NORMAL", INT2FIX(TTF_STYLE_NORMAL));
|
282
|
-
rb_define_const(ray_cFont, "STYLE_ITALIC", INT2FIX(TTF_STYLE_ITALIC));
|
283
|
-
rb_define_const(ray_cFont, "STYLE_BOLD", INT2FIX(TTF_STYLE_BOLD));
|
284
|
-
rb_define_const(ray_cFont, "STYLE_UNDERLINE", INT2FIX(TTF_STYLE_UNDERLINE));
|
285
|
-
}
|
286
|
-
|
287
|
-
#endif
|
data/ext/image.c
DELETED
@@ -1,933 +0,0 @@
|
|
1
|
-
#include "ray.h"
|
2
|
-
|
3
|
-
VALUE ray_cImage = Qnil;
|
4
|
-
|
5
|
-
ray_image *ray_rb2image(VALUE object) {
|
6
|
-
if (!RAY_IS_A(object, ray_cImage)) {
|
7
|
-
rb_raise(rb_eTypeError, "Can't convert %s into Ray::Image",
|
8
|
-
RAY_OBJ_CLASSNAME(object));
|
9
|
-
}
|
10
|
-
|
11
|
-
ray_image *ptr = NULL;
|
12
|
-
Data_Get_Struct(object, ray_image, ptr);
|
13
|
-
|
14
|
-
return ptr;
|
15
|
-
}
|
16
|
-
|
17
|
-
SDL_Surface *ray_rb2surface(VALUE object) {
|
18
|
-
return ray_rb2image(object)->surface;
|
19
|
-
}
|
20
|
-
|
21
|
-
void ray_init_image_with_hash(VALUE self, VALUE arg) {
|
22
|
-
VALUE width = rb_hash_aref(arg, RAY_SYM("width"));
|
23
|
-
if (NIL_P(width)) width = rb_hash_aref(arg, RAY_SYM("w"));
|
24
|
-
|
25
|
-
VALUE height = rb_hash_aref(arg, RAY_SYM("height"));
|
26
|
-
if (NIL_P(height)) height = rb_hash_aref(arg, RAY_SYM("h"));
|
27
|
-
|
28
|
-
VALUE bitsperpixel = rb_hash_aref(arg, RAY_SYM("bits_per_pixel"));
|
29
|
-
if (NIL_P(bitsperpixel)) bitsperpixel = rb_hash_aref(arg, RAY_SYM("bpp"));
|
30
|
-
if (NIL_P(bitsperpixel)) bitsperpixel = INT2FIX(32);
|
31
|
-
|
32
|
-
uint32_t flags = 0;
|
33
|
-
if (RTEST(rb_hash_aref(arg, RAY_SYM("sw_surface"))))
|
34
|
-
flags = SDL_SWSURFACE;
|
35
|
-
else
|
36
|
-
flags = SDL_HWSURFACE;
|
37
|
-
|
38
|
-
ray_image *image = ray_rb2image(self);
|
39
|
-
image->surface = SDL_CreateRGBSurface(flags,
|
40
|
-
NUM2INT(width),
|
41
|
-
NUM2INT(height),
|
42
|
-
NUM2INT(bitsperpixel),
|
43
|
-
0, 0, 0, 0);
|
44
|
-
|
45
|
-
if (!image->surface) {
|
46
|
-
rb_raise(rb_eRuntimeError, "Could not create the image (%s)",
|
47
|
-
SDL_GetError());
|
48
|
-
}
|
49
|
-
}
|
50
|
-
|
51
|
-
void ray_init_image_with_filename(VALUE self, VALUE filename) {
|
52
|
-
char *c_filename = StringValuePtr(filename);
|
53
|
-
ray_image *image = ray_rb2image(self);
|
54
|
-
|
55
|
-
#ifdef HAVE_SDL_IMAGE
|
56
|
-
image->surface = IMG_Load(c_filename);
|
57
|
-
|
58
|
-
if (!image->surface) {
|
59
|
-
rb_raise(rb_eRuntimeError, "Could not create the image (%s)",
|
60
|
-
IMG_GetError());
|
61
|
-
}
|
62
|
-
#else
|
63
|
-
image->surface = SDL_LoadBMP(c_filename);
|
64
|
-
|
65
|
-
if (!image->surface) {
|
66
|
-
rb_raise(rb_eRuntimeError, "Could not create the image (%s)",
|
67
|
-
SDL_GetError());
|
68
|
-
}
|
69
|
-
#endif
|
70
|
-
}
|
71
|
-
|
72
|
-
void ray_init_image_with_io(VALUE self, VALUE io) {
|
73
|
-
VALUE string = rb_funcall2(io, RAY_METH("read"), 0, NULL);
|
74
|
-
char *content = StringValuePtr(string);
|
75
|
-
|
76
|
-
SDL_RWops *data = SDL_RWFromMem(content, (int)RSTRING_LEN(string));
|
77
|
-
|
78
|
-
if (!data) {
|
79
|
-
rb_raise(rb_eRuntimeError, "Could not create image data (%s)",
|
80
|
-
SDL_GetError());
|
81
|
-
}
|
82
|
-
|
83
|
-
ray_image *image = ray_rb2image(self);
|
84
|
-
|
85
|
-
#ifdef HAVE_SDL_IMAGE
|
86
|
-
image->surface = IMG_Load_RW(data, 1);
|
87
|
-
|
88
|
-
if (!image->surface) {
|
89
|
-
rb_raise(rb_eRuntimeError, "Could not create the image (%s)",
|
90
|
-
IMG_GetError());
|
91
|
-
}
|
92
|
-
#else
|
93
|
-
image->surface = SDL_LoadBMP_RW(data, 1);
|
94
|
-
|
95
|
-
if (!image->surface) {
|
96
|
-
rb_raise(rb_eRuntimeError, "Could not create the image (%s)",
|
97
|
-
SDL_GetError());
|
98
|
-
}
|
99
|
-
#endif
|
100
|
-
}
|
101
|
-
|
102
|
-
/*
|
103
|
-
Creates a new image.
|
104
|
-
|
105
|
-
@overload initialize(hash)
|
106
|
-
@option hash [Integer] :width Width of the surface
|
107
|
-
@option hash [Integer] :height Height of the surface
|
108
|
-
|
109
|
-
@option hash [Integer] :w Alias for width
|
110
|
-
@option hash [Integer] :h Alias for height
|
111
|
-
|
112
|
-
@option hash [Integer] :bits_per_pixel See Ray.create_window
|
113
|
-
@option hash [Integer] :bpp Alias for bits_per_pixel
|
114
|
-
|
115
|
-
@option hash [true, false] :hw_surface See Ray.create_window
|
116
|
-
@option hash [true, false] :sw_surface See Ray.create_window
|
117
|
-
|
118
|
-
@overload initialize(filename)
|
119
|
-
Loads the image from a file.
|
120
|
-
@param [String, #to_str] filename The name of the file to open
|
121
|
-
|
122
|
-
@overload initialize(io)
|
123
|
-
Loads the image friom an IO object.
|
124
|
-
@param [IO, #read] io Object the data will be loaded from.
|
125
|
-
*/
|
126
|
-
VALUE ray_init_image(VALUE self, VALUE arg) {
|
127
|
-
if (RAY_IS_A(arg, rb_cHash))
|
128
|
-
ray_init_image_with_hash(self, arg);
|
129
|
-
else if (rb_respond_to(arg, RAY_METH("to_str")))
|
130
|
-
ray_init_image_with_filename(self, rb_String(arg));
|
131
|
-
else if (rb_respond_to(arg, RAY_METH("read")))
|
132
|
-
ray_init_image_with_io(self, arg);
|
133
|
-
else {
|
134
|
-
rb_raise(rb_eTypeError, "Can't convert %s into Hash",
|
135
|
-
RAY_OBJ_CLASSNAME(arg));
|
136
|
-
}
|
137
|
-
|
138
|
-
return Qnil;
|
139
|
-
}
|
140
|
-
|
141
|
-
VALUE ray_init_image_copy(VALUE self, VALUE obj) {
|
142
|
-
ray_image *img = ray_rb2image(self);
|
143
|
-
|
144
|
-
SDL_Surface *src = ray_rb2surface(obj);
|
145
|
-
img->surface = SDL_ConvertSurface(src, src->format, src->flags);
|
146
|
-
if (!img->surface) {
|
147
|
-
rb_raise(rb_eRuntimeError, "Could not create the image (%s)",
|
148
|
-
SDL_GetError());
|
149
|
-
}
|
150
|
-
|
151
|
-
return self;
|
152
|
-
}
|
153
|
-
|
154
|
-
void ray_free_image(ray_image *ptr) {
|
155
|
-
if (ptr->must_free && ptr->surface) SDL_FreeSurface(ptr->surface);
|
156
|
-
free(ptr);
|
157
|
-
}
|
158
|
-
|
159
|
-
VALUE ray_create_image(SDL_Surface *surface) {
|
160
|
-
ray_image *ptr = malloc(sizeof(ray_image));
|
161
|
-
VALUE ret = Data_Wrap_Struct(ray_cImage, 0, ray_free_image, ptr);
|
162
|
-
|
163
|
-
ptr->surface = surface;
|
164
|
-
ptr->must_free = 0;
|
165
|
-
|
166
|
-
return ret;
|
167
|
-
}
|
168
|
-
|
169
|
-
VALUE ray_create_gc_image(SDL_Surface *surface) {
|
170
|
-
ray_image *ptr = malloc(sizeof(ray_image));
|
171
|
-
VALUE ret = Data_Wrap_Struct(ray_cImage, 0, ray_free_image, ptr);
|
172
|
-
|
173
|
-
ptr->surface = surface;
|
174
|
-
ptr->must_free = 1;
|
175
|
-
|
176
|
-
return ret;
|
177
|
-
}
|
178
|
-
|
179
|
-
VALUE ray_alloc_image(VALUE self) {
|
180
|
-
ray_image *ptr = malloc(sizeof(ray_image));
|
181
|
-
VALUE ret = Data_Wrap_Struct(self, 0, ray_free_image, ptr);
|
182
|
-
|
183
|
-
ptr->surface = NULL;
|
184
|
-
ptr->must_free = 1;
|
185
|
-
|
186
|
-
return ret;
|
187
|
-
}
|
188
|
-
|
189
|
-
/*
|
190
|
-
Fills the image with a given color.
|
191
|
-
@param [Ray::Color] col The color used to fill the image.
|
192
|
-
*/
|
193
|
-
VALUE ray_image_fill(VALUE self, VALUE col) {
|
194
|
-
ray_color rcol = ray_rb2col(col);
|
195
|
-
|
196
|
-
SDL_Surface *surf = ray_rb2surface(self);
|
197
|
-
uint32_t specific_col = SDL_MapRGBA(surf->format,
|
198
|
-
rcol.r, rcol.g, rcol.b,
|
199
|
-
rcol.a);
|
200
|
-
|
201
|
-
SDL_FillRect(surf, NULL, specific_col);
|
202
|
-
return self;
|
203
|
-
}
|
204
|
-
|
205
|
-
/* Updates the image. */
|
206
|
-
VALUE ray_image_flip(VALUE self) {
|
207
|
-
SDL_Flip(ray_rb2surface(self));
|
208
|
-
return self;
|
209
|
-
}
|
210
|
-
|
211
|
-
/*
|
212
|
-
@overload blit(hash)
|
213
|
-
Blits the receiver on another image.
|
214
|
-
|
215
|
-
@option hash [Ray::Rect, Array] :at Rects in which the image will be
|
216
|
-
drawn. If an array is given, it
|
217
|
-
passed to Ray::Rect.new. Only the
|
218
|
-
position is read.
|
219
|
-
@option hash [Ray::Rect, Array] :rect Rects that will be copied.
|
220
|
-
If an array is given, it
|
221
|
-
passed to Ray::Rect.new.
|
222
|
-
If the size is (0, 0), it will
|
223
|
-
be reset to the image's size.
|
224
|
-
@option hash [Ray::Rect, Array] :from Alias for rect
|
225
|
-
|
226
|
-
@option hash [Ray::Image, required] :on The image on which the receiver should
|
227
|
-
be drawn.
|
228
|
-
|
229
|
-
@option hash [Ray::Image, required] :to Alias for on.
|
230
|
-
|
231
|
-
@option hash [Float] :angle Rotation in degrees.
|
232
|
-
@option hash [Float] :zoom Zoom level. 1.0 for the current size.
|
233
|
-
*/
|
234
|
-
VALUE ray_image_blit(VALUE self, VALUE hash) {
|
235
|
-
SDL_Surface *origin = ray_rb2surface(self);
|
236
|
-
|
237
|
-
SDL_Rect from_rect = {0, 0, 0, 0};
|
238
|
-
SDL_Rect to_rect = {0, 0, 0, 0};
|
239
|
-
|
240
|
-
VALUE rect = rb_hash_aref(hash, RAY_SYM("at"));
|
241
|
-
|
242
|
-
if (RTEST(rb_obj_is_kind_of(rect, ray_cRect)))
|
243
|
-
to_rect = ray_rb2rect(rect);
|
244
|
-
else if (RTEST(rb_obj_is_kind_of(rect, rb_cArray)))
|
245
|
-
to_rect = ray_rb2rect(rb_apply(ray_cRect, RAY_METH("new"), rect));
|
246
|
-
else if (rect != Qnil) {
|
247
|
-
rb_raise(rb_eTypeError, "Can't convert %s into Ray::Rect",
|
248
|
-
RAY_OBJ_CLASSNAME(rect));
|
249
|
-
}
|
250
|
-
|
251
|
-
rect = Qnil;
|
252
|
-
rect = rb_hash_aref(hash, RAY_SYM("rect"));
|
253
|
-
if (rect == Qnil) rect = rb_hash_aref(hash, RAY_SYM("from"));
|
254
|
-
|
255
|
-
if (RAY_IS_A(rect, ray_cRect))
|
256
|
-
from_rect = ray_rb2rect(rect);
|
257
|
-
else if (RAY_IS_A(rect, rb_cArray))
|
258
|
-
from_rect = ray_rb2rect(rb_apply(ray_cRect, RAY_METH("new"), rect));
|
259
|
-
else if (!NIL_P(rect)) {
|
260
|
-
rb_raise(rb_eTypeError, "Can't convert %s into Ray::Rect",
|
261
|
-
RAY_OBJ_CLASSNAME(rect));
|
262
|
-
}
|
263
|
-
|
264
|
-
VALUE surf = rb_hash_aref(hash, RAY_SYM("on"));
|
265
|
-
if (surf == Qnil) surf = rb_hash_aref(hash, RAY_SYM("to"));
|
266
|
-
|
267
|
-
/* avoid raising an exception, which would prevent us from freeing the surface */
|
268
|
-
SDL_Surface *target = ray_rb2surface(surf);
|
269
|
-
|
270
|
-
#ifdef HAVE_SDL_GFX
|
271
|
-
VALUE rb_angle = Qnil, rb_zoom = Qnil;
|
272
|
-
double angle = 0.0, zoom = 1.0;
|
273
|
-
|
274
|
-
if (!NIL_P(rb_angle = rb_hash_aref(hash, RAY_SYM("angle"))))
|
275
|
-
angle = NUM2DBL(rb_angle);
|
276
|
-
|
277
|
-
if (!NIL_P(rb_zoom = rb_hash_aref(hash, RAY_SYM("zoom"))))
|
278
|
-
zoom = NUM2DBL(rb_zoom);
|
279
|
-
|
280
|
-
if (!NIL_P(rb_angle) || !NIL_P(rb_zoom)) {
|
281
|
-
SDL_Surface *res = rotozoomSurface(origin, angle, zoom, 1);
|
282
|
-
if (!res) {
|
283
|
-
rb_raise(rb_eRuntimeError, "Could not create the image (%s)",
|
284
|
-
SDL_GetError());
|
285
|
-
}
|
286
|
-
|
287
|
-
if (from_rect.w == 0 && from_rect.h == 0) {
|
288
|
-
from_rect.w = res->w;
|
289
|
-
from_rect.h = res->h;
|
290
|
-
}
|
291
|
-
|
292
|
-
if (SDL_BlitSurface(res, &from_rect, target, &to_rect) == -1) {
|
293
|
-
SDL_FreeSurface(res); /* Don't leak when an error occurs */
|
294
|
-
rb_raise(rb_eRuntimeError, "Couldn't blit the image (%s)",
|
295
|
-
SDL_GetError());
|
296
|
-
}
|
297
|
-
|
298
|
-
SDL_FreeSurface(res);
|
299
|
-
|
300
|
-
return surf;
|
301
|
-
}
|
302
|
-
#endif
|
303
|
-
|
304
|
-
if (from_rect.w == 0 && from_rect.h == 0) {
|
305
|
-
from_rect.w = origin->w;
|
306
|
-
from_rect.h = origin->h;
|
307
|
-
}
|
308
|
-
|
309
|
-
if (SDL_BlitSurface(origin, &from_rect, target,
|
310
|
-
&to_rect) == -1) {
|
311
|
-
rb_raise(rb_eRuntimeError, "Couldn't blit the image (%s)",
|
312
|
-
SDL_GetError());
|
313
|
-
}
|
314
|
-
|
315
|
-
return surf;
|
316
|
-
}
|
317
|
-
|
318
|
-
/*
|
319
|
-
@overload alpha=(alpha)
|
320
|
-
Sets the alpha transparency.
|
321
|
-
@param [Integer, 0..255] alpha the new transparency
|
322
|
-
*/
|
323
|
-
VALUE ray_image_set_alpha(VALUE self, VALUE alpha) {
|
324
|
-
SDL_SetAlpha(ray_rb2surface(self), SDL_SRCALPHA | SDL_RLEACCEL,
|
325
|
-
NUM2INT(alpha));
|
326
|
-
return alpha;
|
327
|
-
}
|
328
|
-
|
329
|
-
/*
|
330
|
-
Returns the flags of an image (an OR'd combination of the Ray::Image::FLAG_*
|
331
|
-
constants)
|
332
|
-
*/
|
333
|
-
VALUE ray_image_flags(VALUE self) {
|
334
|
-
uint32_t flags = ray_rb2surface(self)->flags;
|
335
|
-
return INT2NUM(flags);
|
336
|
-
}
|
337
|
-
|
338
|
-
/* @return [Integer] Width of the surface */
|
339
|
-
VALUE ray_image_width(VALUE self) {
|
340
|
-
return INT2FIX(ray_rb2surface(self)->w);
|
341
|
-
}
|
342
|
-
|
343
|
-
/* @return [Integer] Height of the surface */
|
344
|
-
VALUE ray_image_height(VALUE self) {
|
345
|
-
return INT2FIX(ray_rb2surface(self)->h);
|
346
|
-
}
|
347
|
-
|
348
|
-
/* @return [Integer] Bits per pixel */
|
349
|
-
VALUE ray_image_bpp(VALUE self) {
|
350
|
-
SDL_Surface *surf = ray_rb2surface(self);
|
351
|
-
if (surf->format)
|
352
|
-
return INT2FIX(ray_rb2surface(self)->format->BitsPerPixel);
|
353
|
-
return Qnil;
|
354
|
-
}
|
355
|
-
|
356
|
-
/*
|
357
|
-
@overload ==(obj)
|
358
|
-
@return [true, false] true if obj manipulates the same surface as the
|
359
|
-
receiver.
|
360
|
-
*/
|
361
|
-
VALUE ray_image_is_equal(VALUE self, VALUE obj) {
|
362
|
-
if (!RAY_IS_A(obj, ray_cImage))
|
363
|
-
return Qfalse;
|
364
|
-
|
365
|
-
SDL_Surface *first_surface = ray_rb2surface(self);
|
366
|
-
SDL_Surface *sec_surface = ray_rb2surface(obj);
|
367
|
-
|
368
|
-
return (first_surface == sec_surface) ? Qtrue : Qfalse;
|
369
|
-
}
|
370
|
-
|
371
|
-
VALUE ray_image_ensure_unlock(VALUE self) {
|
372
|
-
SDL_Surface *surface = ray_rb2surface(self);
|
373
|
-
SDL_UnlockSurface(surface);
|
374
|
-
|
375
|
-
return self;
|
376
|
-
}
|
377
|
-
|
378
|
-
/*
|
379
|
-
Locks the image (allow pixel-per-pixel modifications).
|
380
|
-
Don't forget to call unlock when you're done. You can also
|
381
|
-
pass a bock which will be called before the image gets unlocked
|
382
|
-
automatically.
|
383
|
-
*/
|
384
|
-
VALUE ray_image_lock(VALUE self) {
|
385
|
-
SDL_Surface *surface = ray_rb2surface(self);
|
386
|
-
SDL_LockSurface(surface);
|
387
|
-
|
388
|
-
if (rb_block_given_p())
|
389
|
-
rb_ensure(rb_yield, Qnil, ray_image_ensure_unlock, self);
|
390
|
-
|
391
|
-
return self;
|
392
|
-
}
|
393
|
-
|
394
|
-
/*
|
395
|
-
Unlocks the image. You must call this once you are done
|
396
|
-
modifying the image.
|
397
|
-
*/
|
398
|
-
VALUE ray_image_unlock(VALUE self) {
|
399
|
-
return ray_image_ensure_unlock(self);
|
400
|
-
}
|
401
|
-
|
402
|
-
/*
|
403
|
-
@overload [](x, y)
|
404
|
-
@return [Ray::Color, nil] Pixel at (x, y). Nil if the point is outside the
|
405
|
-
image.
|
406
|
-
*/
|
407
|
-
VALUE ray_image_at(VALUE self, VALUE rb_x, VALUE rb_y) {
|
408
|
-
SDL_Surface *surface = ray_rb2surface(self);
|
409
|
-
|
410
|
-
int x = NUM2INT(rb_x);
|
411
|
-
int y = NUM2INT(rb_y);
|
412
|
-
|
413
|
-
/* (w, h) is not a valid point. Surfaces use 0-based indexing. */
|
414
|
-
if (x >= surface->w || y >= surface->h)
|
415
|
-
return Qnil;
|
416
|
-
|
417
|
-
int bytes = surface->format->BytesPerPixel;
|
418
|
-
|
419
|
-
uint8_t *pix = (uint8_t*)surface->pixels + y * surface->pitch + x * bytes;
|
420
|
-
|
421
|
-
uint32_t res;
|
422
|
-
switch (bytes) {
|
423
|
-
case 1:
|
424
|
-
res = *pix;
|
425
|
-
break;
|
426
|
-
case 2:
|
427
|
-
res = *(uint16_t*)pix;
|
428
|
-
break;
|
429
|
-
case 3:
|
430
|
-
if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
431
|
-
res = pix[0] << 16 | pix[1] << 8 | pix[2];
|
432
|
-
else
|
433
|
-
res = pix[0] | pix[1] << 8 | pix[2] << 16;
|
434
|
-
break;
|
435
|
-
case 4:
|
436
|
-
res = *(uint32_t*)pix;
|
437
|
-
break;
|
438
|
-
default: /* should never happen */
|
439
|
-
res = 0;
|
440
|
-
break;
|
441
|
-
}
|
442
|
-
|
443
|
-
ray_color col;
|
444
|
-
SDL_GetRGBA(res, surface->format, &(col.r), &(col.g), &(col.b), &(col.a));
|
445
|
-
|
446
|
-
return ray_col2rb(col);
|
447
|
-
}
|
448
|
-
|
449
|
-
/*
|
450
|
-
@overload [](x, y, color)
|
451
|
-
Sets the color of the point at (x, y)
|
452
|
-
@raise ArgumentError If (x, y) is outside the image.
|
453
|
-
*/
|
454
|
-
VALUE ray_image_set_at(VALUE self, VALUE rb_x, VALUE rb_y, VALUE rb_col) {
|
455
|
-
SDL_Surface *surface = ray_rb2surface(self);
|
456
|
-
|
457
|
-
int x = NUM2INT(rb_x);
|
458
|
-
int y = NUM2INT(rb_y);
|
459
|
-
|
460
|
-
if (x >= surface->w || y >= surface->h) {
|
461
|
-
VALUE inspect = rb_inspect(self);
|
462
|
-
rb_raise(rb_eArgError, "(%d, %d) is outside %s",
|
463
|
-
x, y, StringValuePtr(inspect));
|
464
|
-
}
|
465
|
-
|
466
|
-
int bytes = surface->format->BytesPerPixel;
|
467
|
-
|
468
|
-
uint8_t *pix = (uint8_t*)surface->pixels + y * surface->pitch + x * bytes;
|
469
|
-
|
470
|
-
ray_color col = ray_rb2col(rb_col);
|
471
|
-
|
472
|
-
uint32_t val = SDL_MapRGBA(surface->format, col.r, col.g, col.b, col.a);
|
473
|
-
|
474
|
-
switch (bytes) {
|
475
|
-
case 1:
|
476
|
-
*pix = val;
|
477
|
-
break;
|
478
|
-
case 2:
|
479
|
-
*(uint16_t*)pix = val;
|
480
|
-
break;
|
481
|
-
case 3:
|
482
|
-
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) {
|
483
|
-
pix[0] = (val >> 16) & 0xff;
|
484
|
-
pix[1] = (val >> 8) & 0xff;
|
485
|
-
pix[2] = val & 0xff;
|
486
|
-
}
|
487
|
-
else {
|
488
|
-
pix[0] = val & 0xff;
|
489
|
-
pix[1] = (val >> 8) & 0xff;
|
490
|
-
pix[2] = (val >> 16) & 0xff;
|
491
|
-
}
|
492
|
-
break;
|
493
|
-
case 4:
|
494
|
-
*(uint32_t*)pix = val;
|
495
|
-
break;
|
496
|
-
}
|
497
|
-
|
498
|
-
return rb_col;
|
499
|
-
}
|
500
|
-
|
501
|
-
VALUE ray_image_ensure_unclip(VALUE ary) {
|
502
|
-
SDL_Surface *surface = ray_rb2surface(rb_ary_entry(ary, 0));
|
503
|
-
SDL_Rect rect = ray_rb2rect(rb_ary_entry(ary, 1));
|
504
|
-
|
505
|
-
SDL_SetClipRect(surface, &rect);
|
506
|
-
|
507
|
-
rb_gc_unregister_address(&ary);
|
508
|
-
|
509
|
-
return Qnil;
|
510
|
-
}
|
511
|
-
|
512
|
-
/*
|
513
|
-
@overload clip
|
514
|
-
@return [Ray::Rect] The current clipping rect
|
515
|
-
|
516
|
-
@overload clip(rect)
|
517
|
-
Changes the clipping rect (the rect which will be changed if something is
|
518
|
-
drawn on this image, the rest of the image being ignored.)
|
519
|
-
|
520
|
-
If a block is given, it is executed, and the old clipping rect is reset
|
521
|
-
afterwards.
|
522
|
-
|
523
|
-
@param [Ray::Rect, Array<Integer>] rect New clipping rect.
|
524
|
-
*/
|
525
|
-
VALUE ray_image_clip(int argc, VALUE *argv, VALUE self) {
|
526
|
-
VALUE rb_rect = Qnil;
|
527
|
-
rb_scan_args(argc, argv, "01", &rb_rect);
|
528
|
-
|
529
|
-
SDL_Rect old_rect;
|
530
|
-
SDL_GetClipRect(ray_rb2surface(self), &old_rect);
|
531
|
-
|
532
|
-
if (NIL_P(rb_rect))
|
533
|
-
return ray_rect2rb(old_rect);
|
534
|
-
|
535
|
-
SDL_Rect rect = ray_convert_to_rect(rb_rect);
|
536
|
-
SDL_SetClipRect(ray_rb2surface(self), &rect);
|
537
|
-
|
538
|
-
if (rb_block_given_p()) {
|
539
|
-
VALUE ary = rb_ary_new();
|
540
|
-
rb_ary_push(ary, self);
|
541
|
-
rb_ary_push(ary, ray_rect2rb(old_rect));
|
542
|
-
|
543
|
-
rb_gc_register_address(&ary);
|
544
|
-
|
545
|
-
rb_ensure(rb_yield, Qnil, ray_image_ensure_unclip, ary);
|
546
|
-
}
|
547
|
-
|
548
|
-
return ray_rect2rb(rect);
|
549
|
-
}
|
550
|
-
|
551
|
-
#ifdef HAVE_SDL_GFX
|
552
|
-
|
553
|
-
/*
|
554
|
-
@overload rotozoom(angle, zoom)
|
555
|
-
Rotates and zoomes on the image.
|
556
|
-
@param [Float] angle Angle in degrees
|
557
|
-
@param [Float] zoom
|
558
|
-
@return [SDL::Image] the modified image.
|
559
|
-
|
560
|
-
@see #rotozoom!
|
561
|
-
*/
|
562
|
-
VALUE ray_image_rotozoom(VALUE self, VALUE angle, VALUE zoom) {
|
563
|
-
SDL_Surface *surface = ray_rb2surface(self);
|
564
|
-
SDL_Surface *res = rotozoomSurface(surface, NUM2DBL(angle),
|
565
|
-
NUM2DBL(zoom), 1);
|
566
|
-
|
567
|
-
if (!res) {
|
568
|
-
rb_raise(rb_eRuntimeError, "Could not create the image (%s)",
|
569
|
-
SDL_GetError());
|
570
|
-
}
|
571
|
-
|
572
|
-
return ray_create_gc_image(res);
|
573
|
-
}
|
574
|
-
|
575
|
-
/*
|
576
|
-
@overload rotozoom!(angle, zoom)
|
577
|
-
Rotates and zoomes on the image, but does not create a new instance
|
578
|
-
of Ray::Image, which may be better for memory management.
|
579
|
-
|
580
|
-
Notice Ray.create_window(...).rotozoom!(...) will not modify
|
581
|
-
the image used as the screen.
|
582
|
-
|
583
|
-
@see #rotozoom
|
584
|
-
*/
|
585
|
-
VALUE ray_image_rotozoom_bang(VALUE self, VALUE angle, VALUE zoom) {
|
586
|
-
ray_image *img = ray_rb2image(self);
|
587
|
-
SDL_Surface *res = rotozoomSurface(img->surface, NUM2DBL(angle),
|
588
|
-
NUM2DBL(zoom), 1);
|
589
|
-
|
590
|
-
if (!res) {
|
591
|
-
rb_raise(rb_eRuntimeError, "Could not create the image (%s)",
|
592
|
-
SDL_GetError());
|
593
|
-
}
|
594
|
-
|
595
|
-
if (img->must_free)
|
596
|
-
SDL_FreeSurface(img->surface);
|
597
|
-
|
598
|
-
img->surface = res;
|
599
|
-
img->must_free = 1;
|
600
|
-
|
601
|
-
return self;
|
602
|
-
}
|
603
|
-
|
604
|
-
/*
|
605
|
-
@overload draw_pixel(point, color)
|
606
|
-
Draws a point.
|
607
|
-
|
608
|
-
@param [Ray::Rect, Array<Integer>] point The point which should be changed.
|
609
|
-
@param [Ray::Color] color Its new color.
|
610
|
-
*/
|
611
|
-
VALUE ray_image_draw_pixel(VALUE self, VALUE rb_point, VALUE rb_color) {
|
612
|
-
SDL_Surface *surface = ray_rb2surface(self);
|
613
|
-
|
614
|
-
SDL_Rect point = ray_convert_to_rect(rb_point);
|
615
|
-
ray_color color = ray_rb2col(rb_color);
|
616
|
-
|
617
|
-
pixelRGBA(surface, point.x, point.y, color.r, color.g, color.b, color.a);
|
618
|
-
|
619
|
-
return self;
|
620
|
-
}
|
621
|
-
|
622
|
-
/*
|
623
|
-
@overload draw_line(p1, p2, color)
|
624
|
-
Draws a line.
|
625
|
-
|
626
|
-
@param [Ray::Rect, Array<Integer>] p1 First point of the line.
|
627
|
-
@param [Ray::Rect, Array<Integer>] p2 Second point of the line.
|
628
|
-
@param [Ray::Color] color Color of the line.
|
629
|
-
*/
|
630
|
-
VALUE ray_image_draw_line(VALUE self, VALUE p1, VALUE p2, VALUE rb_color) {
|
631
|
-
SDL_Surface *surface = ray_rb2surface(self);
|
632
|
-
|
633
|
-
SDL_Rect first_point = ray_convert_to_rect(p1);
|
634
|
-
SDL_Rect second_point = ray_convert_to_rect(p2);
|
635
|
-
ray_color color = ray_rb2col(rb_color);
|
636
|
-
|
637
|
-
aalineRGBA(surface, first_point.x, first_point.y,
|
638
|
-
second_point.x, second_point.y,
|
639
|
-
color.r, color.g, color.b, color.a);
|
640
|
-
return self;
|
641
|
-
}
|
642
|
-
|
643
|
-
/*
|
644
|
-
@overload draw_rect(rect, color)
|
645
|
-
Draws a rect.
|
646
|
-
|
647
|
-
@param [Ray::Rect, Array<Integer>] rect Rect to draw
|
648
|
-
@param [Ray::Color] color color of the rect
|
649
|
-
*/
|
650
|
-
VALUE ray_image_draw_rect(VALUE self, VALUE rb_rect, VALUE rb_color) {
|
651
|
-
SDL_Surface *surface = ray_rb2surface(self);
|
652
|
-
SDL_Rect rect = ray_convert_to_rect(rb_rect);
|
653
|
-
ray_color color = ray_rb2col(rb_color);
|
654
|
-
|
655
|
-
rectangleRGBA(surface, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h,
|
656
|
-
color.r, color.g, color.b, color.a);
|
657
|
-
|
658
|
-
return self;
|
659
|
-
}
|
660
|
-
|
661
|
-
/*
|
662
|
-
@overload draw_filled_rect(rect, color)
|
663
|
-
Draws a filled rect.
|
664
|
-
|
665
|
-
@param [Ray::Rect, Array<Integer>] rb_rect Rect to draw.
|
666
|
-
@param [Ray::Color] rb_color Color of the rect.
|
667
|
-
*/
|
668
|
-
VALUE ray_image_draw_filled_rect(VALUE self, VALUE rb_rect, VALUE rb_color) {
|
669
|
-
SDL_Surface *surface = ray_rb2surface(self);
|
670
|
-
SDL_Rect rect = ray_convert_to_rect(rb_rect);
|
671
|
-
ray_color color = ray_rb2col(rb_color);
|
672
|
-
|
673
|
-
boxRGBA(surface, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h,
|
674
|
-
color.r, color.g, color.b, color.a);
|
675
|
-
|
676
|
-
return self;
|
677
|
-
}
|
678
|
-
|
679
|
-
/*
|
680
|
-
@overload draw_circle(center, radius, color)
|
681
|
-
Draws a circle
|
682
|
-
|
683
|
-
@param [Ray::Rect, Array<Integer>] center Center of the circle.
|
684
|
-
@param [Integer] radius Radius of the circle.
|
685
|
-
@param [Ray::Color] color Color of the circle.
|
686
|
-
*/
|
687
|
-
VALUE ray_image_draw_circle(VALUE self, VALUE center, VALUE radius,
|
688
|
-
VALUE rb_color) {
|
689
|
-
SDL_Surface *surface = ray_rb2surface(self);
|
690
|
-
SDL_Rect rect = ray_convert_to_rect(center);
|
691
|
-
ray_color color = ray_rb2col(rb_color);
|
692
|
-
|
693
|
-
aacircleRGBA(surface, rect.x, rect.y, NUM2INT(radius),
|
694
|
-
color.r, color.g, color.b, color.a);
|
695
|
-
|
696
|
-
return self;
|
697
|
-
}
|
698
|
-
|
699
|
-
/*
|
700
|
-
@overload draw_filled_circle(center, radius, color)
|
701
|
-
Draws a filled circle
|
702
|
-
|
703
|
-
@param [Ray::Rect, Array<Integer>] center Center of the circle.
|
704
|
-
@param [Integer] radius Radius of the circle.
|
705
|
-
@param [Ray::Color] color Color of the circle.
|
706
|
-
*/
|
707
|
-
VALUE ray_image_draw_filled_circle(VALUE self, VALUE center, VALUE radius,
|
708
|
-
VALUE rb_color) {
|
709
|
-
SDL_Surface *surface = ray_rb2surface(self);
|
710
|
-
SDL_Rect rect = ray_convert_to_rect(center);
|
711
|
-
ray_color color = ray_rb2col(rb_color);
|
712
|
-
|
713
|
-
filledCircleRGBA(surface, rect.x, rect.y, NUM2INT(radius),
|
714
|
-
color.r, color.g, color.b, color.a);
|
715
|
-
|
716
|
-
return self;
|
717
|
-
}
|
718
|
-
|
719
|
-
/*
|
720
|
-
@overload draw_ellipse(rect, color)
|
721
|
-
Draws an ellipse.
|
722
|
-
|
723
|
-
@param [Ray::Rect, Array<Integer>] rect Rect in which the ellipse should be drawn.
|
724
|
-
@param [Ray::Color] color Color in which the ellipse should be drawn.
|
725
|
-
*/
|
726
|
-
VALUE ray_image_draw_ellipse(VALUE self, VALUE rb_rect, VALUE rb_color) {
|
727
|
-
SDL_Surface *surface = ray_rb2surface(self);
|
728
|
-
SDL_Rect rect = ray_convert_to_rect(rb_rect);
|
729
|
-
ray_color color = ray_rb2col(rb_color);
|
730
|
-
|
731
|
-
aaellipseRGBA(surface, rect.x + rect.w / 2,
|
732
|
-
rect.y + rect.h / 2, rect.w / 2, rect.h / 2,
|
733
|
-
color.r, color.g, color.b, color.a);
|
734
|
-
return self;
|
735
|
-
}
|
736
|
-
|
737
|
-
/*
|
738
|
-
@overload draw_flled_ellipse(rect, color)
|
739
|
-
Draws a filled ellipse.
|
740
|
-
|
741
|
-
@param [Ray::Rect, Array<Integer>] rect Rect in which the ellipse should be drawn.
|
742
|
-
@param [Ray::Color] color Color in which the ellipse should be drawn.
|
743
|
-
*/
|
744
|
-
VALUE ray_image_draw_filled_ellipse(VALUE self, VALUE rb_rect, VALUE rb_color) {
|
745
|
-
SDL_Surface *surface = ray_rb2surface(self);
|
746
|
-
SDL_Rect rect = ray_convert_to_rect(rb_rect);
|
747
|
-
ray_color color = ray_rb2col(rb_color);
|
748
|
-
|
749
|
-
filledEllipseRGBA(surface, rect.x + rect.w / 2,
|
750
|
-
rect.y + rect.h / 2, rect.w / 2, rect.h / 2,
|
751
|
-
color.r, color.g, color.b, color.a);
|
752
|
-
return self;
|
753
|
-
}
|
754
|
-
|
755
|
-
/*
|
756
|
-
@overload draw_triangle(p1, p2, p3, color)
|
757
|
-
Draws a triangle.
|
758
|
-
*/
|
759
|
-
VALUE ray_image_draw_triangle(VALUE self, VALUE p1, VALUE p2, VALUE p3,
|
760
|
-
VALUE rb_color) {
|
761
|
-
SDL_Surface *surface = ray_rb2surface(self);
|
762
|
-
|
763
|
-
SDL_Rect first_point = ray_convert_to_rect(p1);
|
764
|
-
SDL_Rect second_point = ray_convert_to_rect(p2);
|
765
|
-
SDL_Rect third_point = ray_convert_to_rect(p3);
|
766
|
-
|
767
|
-
ray_color color = ray_rb2col(rb_color);
|
768
|
-
|
769
|
-
aatrigonRGBA(surface, first_point.x, first_point.y,
|
770
|
-
second_point.x, second_point.y,
|
771
|
-
third_point.x, third_point.y,
|
772
|
-
color.r, color.g, color.b, color.a);
|
773
|
-
|
774
|
-
return self;
|
775
|
-
}
|
776
|
-
|
777
|
-
/*
|
778
|
-
@overload draw_filled_triangle(p1, p2, p3, color)
|
779
|
-
Draws a filled triangle.
|
780
|
-
*/
|
781
|
-
VALUE ray_image_draw_filled_triangle(VALUE self, VALUE p1, VALUE p2, VALUE p3,
|
782
|
-
VALUE rb_color) {
|
783
|
-
SDL_Surface *surface = ray_rb2surface(self);
|
784
|
-
|
785
|
-
SDL_Rect first_point = ray_convert_to_rect(p1);
|
786
|
-
SDL_Rect second_point = ray_convert_to_rect(p2);
|
787
|
-
SDL_Rect third_point = ray_convert_to_rect(p3);
|
788
|
-
|
789
|
-
ray_color color = ray_rb2col(rb_color);
|
790
|
-
|
791
|
-
filledTrigonRGBA(surface, first_point.x, first_point.y,
|
792
|
-
second_point.x, second_point.y,
|
793
|
-
third_point.x, third_point.y,
|
794
|
-
color.r, color.g, color.b, color.a);
|
795
|
-
|
796
|
-
return self;
|
797
|
-
}
|
798
|
-
|
799
|
-
/*
|
800
|
-
@overload draw_polygon(points, color)
|
801
|
-
Draws a polygon.
|
802
|
-
|
803
|
-
@param [Array<Array<Integer>, Ray::Rect>] points Points which should be joined
|
804
|
-
to draw the polygon.
|
805
|
-
@param [Ray::Color] color The color in which the polygon should be drawn.
|
806
|
-
*/
|
807
|
-
VALUE ray_image_draw_polygon(VALUE self, VALUE points, VALUE rb_color) {
|
808
|
-
SDL_Surface *surface = ray_rb2surface(self);
|
809
|
-
|
810
|
-
size_t size = RARRAY_LEN(points);
|
811
|
-
int16_t *x_array = malloc(sizeof(int16_t) * size);
|
812
|
-
int16_t *y_array = malloc(sizeof(int16_t) * size);
|
813
|
-
|
814
|
-
size_t i = 0;
|
815
|
-
for (; i < size; i++) {
|
816
|
-
SDL_Rect rect = ray_convert_to_rect(rb_ary_entry(points, i));
|
817
|
-
|
818
|
-
x_array[i] = (int16_t)rect.x;
|
819
|
-
y_array[i] = (int16_t)rect.y;
|
820
|
-
}
|
821
|
-
|
822
|
-
ray_color color = ray_rb2col(rb_color);
|
823
|
-
aapolygonRGBA(surface, x_array, y_array, (int)size,
|
824
|
-
color.r, color.g, color.b, color.a);
|
825
|
-
|
826
|
-
free(x_array);
|
827
|
-
free(y_array);
|
828
|
-
|
829
|
-
return self;
|
830
|
-
}
|
831
|
-
|
832
|
-
/*
|
833
|
-
@overload draw_filled_polygon(points, color)
|
834
|
-
Draws a filled polygon.
|
835
|
-
|
836
|
-
@param [Array<Array<Integer>, Ray::Rect>] points Points which should be joined
|
837
|
-
to draw the polygon.
|
838
|
-
@param [Ray::Color] color The color in which the polygon should be drawn.
|
839
|
-
*/
|
840
|
-
VALUE ray_image_draw_filled_polygon(VALUE self, VALUE points, VALUE rb_color) {
|
841
|
-
SDL_Surface *surface = ray_rb2surface(self);
|
842
|
-
|
843
|
-
size_t size = RARRAY_LEN(points);
|
844
|
-
int16_t *x_array = malloc(sizeof(int16_t) * size);
|
845
|
-
int16_t *y_array = malloc(sizeof(int16_t) * size);
|
846
|
-
|
847
|
-
size_t i = 0;
|
848
|
-
for (; i < size; i++) {
|
849
|
-
SDL_Rect rect = ray_convert_to_rect(rb_ary_entry(points, i));
|
850
|
-
|
851
|
-
x_array[i] = (int16_t)rect.x;
|
852
|
-
y_array[i] = (int16_t)rect.y;
|
853
|
-
}
|
854
|
-
|
855
|
-
ray_color color = ray_rb2col(rb_color);
|
856
|
-
filledPolygonRGBA(surface, x_array, y_array, (int)size,
|
857
|
-
color.r, color.g, color.b, color.a);
|
858
|
-
|
859
|
-
free(x_array);
|
860
|
-
free(y_array);
|
861
|
-
|
862
|
-
return self;
|
863
|
-
}
|
864
|
-
|
865
|
-
#endif
|
866
|
-
|
867
|
-
void Init_ray_image() {
|
868
|
-
ray_cImage = rb_define_class_under(ray_mRay, "Image", rb_cObject);
|
869
|
-
|
870
|
-
rb_define_alloc_func(ray_cImage, ray_alloc_image);
|
871
|
-
rb_define_method(ray_cImage, "initialize", ray_init_image, 1);
|
872
|
-
rb_define_method(ray_cImage, "initialize_copy", ray_init_image_copy, 1);
|
873
|
-
|
874
|
-
rb_define_method(ray_cImage, "fill", ray_image_fill, 1);
|
875
|
-
rb_define_method(ray_cImage, "flip", ray_image_flip, 0);
|
876
|
-
|
877
|
-
rb_define_method(ray_cImage, "blit", ray_image_blit, 1);
|
878
|
-
|
879
|
-
rb_define_method(ray_cImage, "alpha=", ray_image_set_alpha, 1);
|
880
|
-
|
881
|
-
rb_define_method(ray_cImage, "flags", ray_image_flags, 0);
|
882
|
-
|
883
|
-
rb_define_method(ray_cImage, "width", ray_image_width, 0);
|
884
|
-
rb_define_method(ray_cImage, "height", ray_image_height, 0);
|
885
|
-
rb_define_method(ray_cImage, "bpp", ray_image_bpp, 0);
|
886
|
-
|
887
|
-
rb_define_method(ray_cImage, "==", ray_image_is_equal, 1);
|
888
|
-
|
889
|
-
rb_define_method(ray_cImage, "lock", ray_image_lock, 0);
|
890
|
-
rb_define_method(ray_cImage, "unlock", ray_image_unlock, 0);
|
891
|
-
rb_define_method(ray_cImage, "[]", ray_image_at, 2);
|
892
|
-
rb_define_method(ray_cImage, "[]=", ray_image_set_at, 3);
|
893
|
-
|
894
|
-
rb_define_method(ray_cImage, "clip", ray_image_clip, -1);
|
895
|
-
|
896
|
-
#ifdef HAVE_SDL_GFX
|
897
|
-
rb_define_method(ray_cImage, "rotozoom", ray_image_rotozoom, 2);
|
898
|
-
rb_define_method(ray_cImage, "rotozoom!", ray_image_rotozoom_bang, 2);
|
899
|
-
|
900
|
-
rb_define_method(ray_cImage, "draw_pixel", ray_image_draw_pixel, 2);
|
901
|
-
rb_define_method(ray_cImage, "draw_line", ray_image_draw_line, 3);
|
902
|
-
rb_define_method(ray_cImage, "draw_rect", ray_image_draw_rect, 2);
|
903
|
-
rb_define_method(ray_cImage, "draw_filled_rect", ray_image_draw_filled_rect,
|
904
|
-
2);
|
905
|
-
rb_define_method(ray_cImage, "draw_circle", ray_image_draw_circle, 3);
|
906
|
-
rb_define_method(ray_cImage, "draw_filled_circle",
|
907
|
-
ray_image_draw_filled_circle, 3);
|
908
|
-
rb_define_method(ray_cImage, "draw_ellipse", ray_image_draw_ellipse, 2);
|
909
|
-
rb_define_method(ray_cImage, "draw_filled_ellipse",
|
910
|
-
ray_image_draw_filled_ellipse, 2);
|
911
|
-
rb_define_method(ray_cImage, "draw_triangle", ray_image_draw_triangle, 4);
|
912
|
-
rb_define_method(ray_cImage, "draw_filled_triangle",
|
913
|
-
ray_image_draw_filled_triangle, 4);
|
914
|
-
rb_define_method(ray_cImage, "draw_polygon", ray_image_draw_polygon, 2);
|
915
|
-
rb_define_method(ray_cImage, "draw_filled_polygon",
|
916
|
-
ray_image_draw_filled_polygon, 2);
|
917
|
-
#endif
|
918
|
-
|
919
|
-
rb_define_const(ray_cImage, "FLAG_ANYFORMAT", INT2FIX(SDL_ANYFORMAT));
|
920
|
-
rb_define_const(ray_cImage, "FLAG_ASYNCBLIT", INT2FIX(SDL_ASYNCBLIT));
|
921
|
-
rb_define_const(ray_cImage, "FLAG_DOUBLEBUF", INT2FIX(SDL_DOUBLEBUF));
|
922
|
-
rb_define_const(ray_cImage, "FLAG_HWPALETTE", INT2FIX(SDL_HWPALETTE));
|
923
|
-
rb_define_const(ray_cImage, "FLAG_HWACCEL", INT2FIX(SDL_HWACCEL));
|
924
|
-
rb_define_const(ray_cImage, "FLAG_HWSURFACE", INT2FIX(SDL_HWSURFACE));
|
925
|
-
rb_define_const(ray_cImage, "FLAG_FULLSCREEN", INT2FIX(SDL_FULLSCREEN));
|
926
|
-
rb_define_const(ray_cImage, "FLAG_OPENGL", INT2FIX(SDL_OPENGL));
|
927
|
-
rb_define_const(ray_cImage, "FLAG_OPENGLBLIT", INT2FIX(SDL_OPENGLBLIT));
|
928
|
-
rb_define_const(ray_cImage, "FLAG_RESIZABLE", INT2FIX(SDL_RESIZABLE));
|
929
|
-
rb_define_const(ray_cImage, "FLAG_RLEACCEL", INT2FIX(SDL_RLEACCEL));
|
930
|
-
rb_define_const(ray_cImage, "FLAG_SRCALPHA", INT2FIX(SDL_SRCALPHA));
|
931
|
-
rb_define_const(ray_cImage, "FLAG_SRCCOLORKEY", INT2FIX(SDL_SRCCOLORKEY));
|
932
|
-
rb_define_const(ray_cImage, "FLAG_PREALLOC", INT2FIX(SDL_PREALLOC));
|
933
|
-
}
|