rubygame 2.5.3 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/CREDITS +6 -4
  2. data/NEWS +79 -0
  3. data/README +55 -72
  4. data/ROADMAP +20 -13
  5. data/doc/custom_sdl_load_paths.rdoc +79 -0
  6. data/doc/getting_started.rdoc +65 -36
  7. data/doc/keyboard_symbols.rdoc +243 -0
  8. data/doc/macosx_install.rdoc +49 -35
  9. data/doc/windows_install.rdoc +36 -108
  10. data/lib/rubygame.rb +62 -24
  11. data/lib/rubygame/audio.rb +147 -0
  12. data/lib/rubygame/clock.rb +164 -1
  13. data/lib/rubygame/color.rb +40 -7
  14. data/lib/rubygame/color/models/hsl.rb +1 -1
  15. data/lib/rubygame/color/models/hsv.rb +1 -1
  16. data/lib/rubygame/color/models/rgb.rb +1 -1
  17. data/lib/rubygame/color/palettes/css.rb +1 -3
  18. data/lib/rubygame/color/palettes/x11.rb +1 -2
  19. data/lib/rubygame/constants.rb +297 -0
  20. data/lib/rubygame/deprecated_mixer.rb +555 -0
  21. data/lib/rubygame/event.rb +122 -6
  22. data/lib/rubygame/event_handler.rb +3 -1
  23. data/lib/rubygame/event_hook.rb +6 -2
  24. data/lib/rubygame/event_triggers.rb +1 -1
  25. data/lib/rubygame/events.rb +416 -1
  26. data/lib/rubygame/ftor.rb +1 -7
  27. data/lib/rubygame/gfx.rb +583 -0
  28. data/lib/rubygame/gl.rb +107 -0
  29. data/lib/rubygame/image.rb +140 -0
  30. data/lib/rubygame/joystick.rb +184 -0
  31. data/lib/rubygame/main.rb +82 -0
  32. data/lib/rubygame/mediabag.rb +1 -1
  33. data/lib/rubygame/mixer.rb +30 -0
  34. data/lib/rubygame/music.rb +493 -0
  35. data/lib/rubygame/queue.rb +3 -1
  36. data/lib/rubygame/rect.rb +9 -9
  37. data/lib/rubygame/screen.rb +357 -0
  38. data/lib/rubygame/shared.rb +40 -4
  39. data/lib/rubygame/sound.rb +428 -0
  40. data/lib/rubygame/surface.rb +626 -0
  41. data/lib/rubygame/ttf.rb +311 -0
  42. data/samples/FreeSans.ttf +0 -0
  43. data/samples/README +6 -5
  44. data/samples/demo_draw.rb +1 -1
  45. data/samples/demo_gl.rb +3 -1
  46. data/samples/demo_gl_tex.rb +4 -2
  47. data/samples/demo_rubygame.rb +114 -105
  48. data/samples/demo_sfont.rb +1 -1
  49. data/samples/demo_ttf.rb +3 -1
  50. data/samples/demo_utf8.rb +1 -1
  51. data/samples/image_viewer.rb +118 -0
  52. data/samples/load_and_blit.rb +1 -1
  53. data/samples/rubygame.png +0 -0
  54. metadata +34 -40
  55. data/Rakefile +0 -537
  56. data/doc/extended_readme.rdoc +0 -49
  57. data/ext/body/rubygame_body.so +0 -0
  58. data/ext/rubygame/rubygame_clock.c +0 -301
  59. data/ext/rubygame/rubygame_clock.h +0 -32
  60. data/ext/rubygame/rubygame_event.c +0 -760
  61. data/ext/rubygame/rubygame_event.h +0 -48
  62. data/ext/rubygame/rubygame_event2.c +0 -661
  63. data/ext/rubygame/rubygame_event2.h +0 -29
  64. data/ext/rubygame/rubygame_gfx.c +0 -942
  65. data/ext/rubygame/rubygame_gfx.h +0 -101
  66. data/ext/rubygame/rubygame_gl.c +0 -154
  67. data/ext/rubygame/rubygame_gl.h +0 -32
  68. data/ext/rubygame/rubygame_image.c +0 -252
  69. data/ext/rubygame/rubygame_image.h +0 -41
  70. data/ext/rubygame/rubygame_joystick.c +0 -336
  71. data/ext/rubygame/rubygame_joystick.h +0 -41
  72. data/ext/rubygame/rubygame_main.c +0 -158
  73. data/ext/rubygame/rubygame_main.h +0 -36
  74. data/ext/rubygame/rubygame_mixer.c +0 -1024
  75. data/ext/rubygame/rubygame_mixer.h +0 -36
  76. data/ext/rubygame/rubygame_music.c +0 -1017
  77. data/ext/rubygame/rubygame_music.h +0 -29
  78. data/ext/rubygame/rubygame_screen.c +0 -572
  79. data/ext/rubygame/rubygame_screen.h +0 -45
  80. data/ext/rubygame/rubygame_shared.c +0 -269
  81. data/ext/rubygame/rubygame_shared.h +0 -69
  82. data/ext/rubygame/rubygame_sound.c +0 -863
  83. data/ext/rubygame/rubygame_sound.h +0 -29
  84. data/ext/rubygame/rubygame_surface.c +0 -1153
  85. data/ext/rubygame/rubygame_surface.h +0 -62
  86. data/ext/rubygame/rubygame_ttf.c +0 -599
  87. data/ext/rubygame/rubygame_ttf.h +0 -69
  88. data/samples/keys.rb +0 -52
@@ -1,29 +0,0 @@
1
- /*
2
- * Interface to SDL_mixer sound playback and mixing.
3
- *--
4
- * Rubygame -- Ruby code and bindings to SDL to facilitate game creation
5
- * Copyright (C) 2004-2008 John Croisant
6
- *
7
- * This library is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU Lesser General Public
9
- * License as published by the Free Software Foundation; either
10
- * version 2.1 of the License, or (at your option) any later version.
11
- *
12
- * This library is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
- * Lesser General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Lesser General Public
18
- * License along with this library; if not, write to the Free Software
19
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
- *++
21
- */
22
-
23
-
24
- #ifndef _RUBYGAME_SOUND_H
25
- #define _RUBYGAME_SOUND_H
26
-
27
- extern void Rubygame_Init_Sound();
28
-
29
- #endif
@@ -1,1153 +0,0 @@
1
- /*
2
- * Rubygame binding to SDL Surface class.
3
- *--
4
- * Rubygame -- Ruby code and bindings to SDL to facilitate game creation
5
- * Copyright (C) 2004-2007 John Croisant
6
- *
7
- * This library is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU Lesser General Public
9
- * License as published by the Free Software Foundation; either
10
- * version 2.1 of the License, or (at your option) any later version.
11
- *
12
- * This library is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
- * Lesser General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Lesser General Public
18
- * License along with this library; if not, write to the Free Software
19
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
- *++
21
- */
22
-
23
- #include "rubygame_shared.h"
24
- #include "rubygame_surface.h"
25
-
26
- void Rubygame_Init_Surface();
27
-
28
- VALUE rbgm_surface_new(int, VALUE*, VALUE);
29
-
30
- VALUE rbgm_surface_get_w(VALUE);
31
- VALUE rbgm_surface_get_h(VALUE);
32
- VALUE rbgm_surface_get_size(VALUE);
33
-
34
- VALUE rbgm_surface_get_depth(VALUE);
35
- VALUE rbgm_surface_get_flags(VALUE);
36
- VALUE rbgm_surface_get_masks(VALUE);
37
-
38
- VALUE rbgm_surface_get_alpha(VALUE);
39
- VALUE rbgm_surface_set_alpha(int, VALUE*, VALUE);
40
-
41
- VALUE rbgm_surface_get_colorkey(VALUE);
42
- VALUE rbgm_surface_set_colorkey(int, VALUE*, VALUE);
43
-
44
- VALUE rbgm_surface_blit(int, VALUE*, VALUE);
45
-
46
- VALUE rbgm_surface_fill(int, VALUE*, VALUE);
47
-
48
- VALUE rbgm_surface_getat(int, VALUE*, VALUE);
49
-
50
- VALUE rbgm_surface_pixels(VALUE);
51
-
52
- VALUE rbgm_surface_get_cliprect(VALUE);
53
- VALUE rbgm_surface_set_cliprect(VALUE, VALUE);
54
-
55
- VALUE rbgm_surface_convert(int, VALUE*, VALUE);
56
- VALUE rbgm_surface_displayformat(VALUE);
57
- VALUE rbgm_surface_displayformatalpha(VALUE);
58
-
59
- VALUE rbgm_image_savebmp(VALUE, VALUE);
60
-
61
- VALUE rbgm_transform_flip(VALUE, VALUE, VALUE);
62
-
63
- /*
64
- * call-seq:
65
- * new(size, depth=0, flags=0) -> Surface
66
- *
67
- * Create and initialize a new Surface object.
68
- *
69
- * A Surface is a grid of image data which you blit (i.e. copy) onto other
70
- * Surfaces. Since the Rubygame display is also a Surface (see the Screen
71
- * class), Surfaces can be blit to the screen; this is the most common way
72
- * to display images on the screen.
73
- *
74
- * This method may raise SDLError if the SDL video subsystem could
75
- * not be initialized for some reason.
76
- *
77
- * This function takes these arguments:
78
- * size:: requested surface size; an array of the form [width, height].
79
- * depth:: requested color depth (in bits per pixel). If depth is 0 (default),
80
- * automatically choose a color depth: either the depth of the Screen
81
- * mode (if one has been set), or the greatest color depth available
82
- * on the system.
83
- * flags:: an Array or Bitwise-OR'd list of zero or more of the following
84
- * flags (located in the Rubygame module, e.g. Rubygame::SWSURFACE).
85
- * This argument may be omitted, in which case the Surface
86
- * will be a normal software surface (this is not necessarily a bad
87
- * thing).
88
- * SWSURFACE:: (default) request a software surface.
89
- * HWSURFACE:: request a hardware-accelerated surface (using a
90
- * graphics card), if available. Creates a software
91
- * surface if hardware surfaces are not available.
92
- * SRCCOLORKEY:: request a colorkeyed surface. #set_colorkey will
93
- * also enable colorkey as needed. For a description
94
- * of colorkeys, see #set_colorkey.
95
- * SRCALPHA:: request an alpha channel. #set_alpha will
96
- * also enable alpha. as needed. For a description
97
- * of alpha, see #alpha.
98
- */
99
- VALUE rbgm_surface_new(int argc, VALUE *argv, VALUE class)
100
- {
101
- VALUE self;
102
- SDL_Surface *self_surf;
103
- SDL_PixelFormat* pixformat;
104
- Uint32 flags, Rmask, Gmask, Bmask, Amask;
105
- int w, h, depth;
106
- VALUE vsize, vdepth, vflags;
107
-
108
- rb_scan_args(argc, argv, "12", &vsize, &vdepth, &vflags);
109
-
110
- if( SDL_GetVideoSurface() )
111
- {
112
- /* Pixel format is retrieved from the video surface. */
113
- pixformat = (SDL_GetVideoSurface())->format;
114
- }
115
- else
116
- {
117
- /* We can only get the system color depth when the video system
118
- * has been initialized. */
119
- if( init_video_system() == 0 )
120
- {
121
- pixformat = SDL_GetVideoInfo()->vfmt;
122
- }
123
- else
124
- {
125
- rb_raise(eSDLError,"Could not initialize SDL video subsystem.");
126
- return Qnil;
127
- }
128
- }
129
-
130
- Rmask = pixformat->Rmask;
131
- Gmask = pixformat->Gmask;
132
- Bmask = pixformat->Bmask;
133
- Amask = pixformat->Amask;
134
-
135
- if( !NIL_P(vdepth) && NUM2INT(vdepth) > 0 )
136
- {
137
- /* TODO: We might want to check that the requested depth makes sense. */
138
- depth = NUM2INT(vdepth);
139
- }
140
- else
141
- {
142
- depth = pixformat->BitsPerPixel;
143
- }
144
-
145
-
146
- /* Get width and height for new surface from vsize */
147
- vsize = convert_to_array(vsize);
148
-
149
- if(RARRAY_LEN(vsize) >= 2)
150
- {
151
- w = NUM2INT(rb_ary_entry(vsize,0));
152
- h = NUM2INT(rb_ary_entry(vsize,1));
153
- }
154
- else
155
- rb_raise(rb_eArgError,"Array is too short for Surface size (%d for 2)",\
156
- RARRAY_LEN(vsize));
157
-
158
- flags = collapse_flags(vflags); /* in rubygame_shared */
159
-
160
- /* Finally, we can create the new Surface! Or try, anyway... */
161
- self_surf = SDL_CreateRGBSurface(flags,w,h,depth,Rmask,Gmask,Bmask,Amask);
162
-
163
- if( self_surf == NULL )
164
- rb_raise(eSDLError,"Could not create new surface: %s",SDL_GetError());
165
-
166
-
167
- /* Wrap the new surface in a crunchy candy VALUE shell. */
168
- self = Data_Wrap_Struct( cSurface,0,SDL_FreeSurface,self_surf );
169
- /* The default initialize() does nothing, but may be overridden. */
170
- rb_obj_call_init(self,argc,argv);
171
- return self;
172
- }
173
-
174
- /* :nodoc: */
175
- VALUE rbgm_surface_initialize(int argc, VALUE *argv, VALUE self)
176
- {
177
- return self;
178
- }
179
-
180
-
181
- /*
182
- * call-seq:
183
- * width
184
- * w
185
- *
186
- * Return the width (in pixels) of the surface.
187
- */
188
- VALUE rbgm_surface_get_w(VALUE self)
189
- {
190
- SDL_Surface *surf;
191
- Data_Get_Struct(self, SDL_Surface, surf);
192
- return INT2NUM(surf->w);
193
- }
194
-
195
- /*
196
- * call-seq:
197
- * height
198
- * h
199
- *
200
- * Return the height (in pixels) of the surface.
201
- */
202
- VALUE rbgm_surface_get_h(VALUE self)
203
- {
204
- SDL_Surface *surf;
205
- Data_Get_Struct(self, SDL_Surface, surf);
206
- return INT2NUM(surf->h);
207
- }
208
-
209
- /* call-seq:
210
- * size -> [w,h]
211
- *
212
- * Return the surface's width and height (in pixels) in an Array.
213
- */
214
- VALUE rbgm_surface_get_size(VALUE self)
215
- {
216
- SDL_Surface *surf;
217
- Data_Get_Struct(self, SDL_Surface, surf);
218
- return rb_ary_new3( 2, INT2NUM(surf->w), INT2NUM(surf->h) );
219
- }
220
-
221
- /* call-seq:
222
- * depth
223
- *
224
- * Return the color depth (in bits per pixel) of the surface.
225
- */
226
- VALUE rbgm_surface_get_depth(VALUE self)
227
- {
228
- SDL_Surface *surf;
229
- Data_Get_Struct(self, SDL_Surface, surf);
230
- return UINT2NUM(surf->format->BitsPerPixel);
231
- }
232
-
233
- /* call-seq:
234
- * flags
235
- *
236
- * Return any flags the surface was initialized with
237
- * (as a bitwise OR'd integer).
238
- */
239
- VALUE rbgm_surface_get_flags(VALUE self)
240
- {
241
- SDL_Surface *surf;
242
- Data_Get_Struct(self, SDL_Surface, surf);
243
- return UINT2NUM(surf->flags);
244
- }
245
-
246
- /*
247
- * call-seq:
248
- * masks -> [r,g,b,a]
249
- *
250
- * Return the color masks [r,g,b,a] of the surface. Almost everyone can
251
- * ignore this function. Color masks are used to separate an
252
- * integer representation of a color into its seperate channels.
253
- */
254
- VALUE rbgm_surface_get_masks(VALUE self)
255
- {
256
- SDL_Surface *surf;
257
- SDL_PixelFormat *format;
258
-
259
- Data_Get_Struct(self, SDL_Surface, surf);
260
- format = surf->format;
261
- return rb_ary_new3(4,\
262
- UINT2NUM(format->Rmask),\
263
- UINT2NUM(format->Gmask),\
264
- UINT2NUM(format->Bmask),\
265
- UINT2NUM(format->Amask));
266
- }
267
-
268
- /*
269
- * call-seq:
270
- * alpha
271
- *
272
- * Return the per-surface alpha (opacity; non-transparency) of the surface.
273
- * It can range from 0 (full transparent) to 255 (full opaque).
274
- */
275
- VALUE rbgm_surface_get_alpha(VALUE self)
276
- {
277
- SDL_Surface *surf;
278
- Data_Get_Struct(self, SDL_Surface, surf);
279
- return INT2NUM(surf->format->alpha);
280
- }
281
-
282
- /*
283
- * call-seq:
284
- * set_alpha(alpha, flags=Rubygame::SRC_ALPHA)
285
- *
286
- * Set the per-surface alpha (opacity; non-transparency) of the surface.
287
- *
288
- * This function takes these arguments:
289
- * alpha:: requested opacity of the surface. Alpha must be from 0
290
- * (fully transparent) to 255 (fully opaque).
291
- * flags:: 0 or Rubygame::SRC_ALPHA (default). Most people will want the
292
- * default, in which case this argument can be omitted. For advanced
293
- * users: this flag affects the surface as described in the docs for
294
- * the SDL C function, SDL_SetAlpha.
295
- */
296
- VALUE rbgm_surface_set_alpha(int argc, VALUE *argv, VALUE self)
297
- {
298
- SDL_Surface *surf;
299
- Uint8 alpha;
300
- Uint32 flags = SDL_SRCALPHA;
301
- VALUE valpha, vflags;
302
-
303
- rb_scan_args(argc, argv, "11", &valpha, &vflags);
304
-
305
- if( !NIL_P(vflags) )
306
- {
307
- flags = NUM2UINT(vflags);
308
- }
309
-
310
- alpha = NUM2UINT(valpha);
311
-
312
- Data_Get_Struct(self, SDL_Surface, surf);
313
- if( SDL_SetAlpha(surf,flags,alpha) != 0 )
314
- rb_raise(eSDLError, "%s", SDL_GetError());
315
- return self;
316
- }
317
-
318
- /*
319
- * call-seq:
320
- * colorkey -> [r,g,b] or nil
321
- *
322
- * Return the colorkey of the surface in the form [r,g,b] (or +nil+ if there
323
- * is no key). The colorkey of a surface is the exact color which will be
324
- * ignored when the surface is blitted, effectively turning that color
325
- * transparent. This is often used to make a blue (for example) background
326
- * on an image seem transparent.
327
- */
328
- VALUE rbgm_surface_get_colorkey( VALUE self )
329
- {
330
- SDL_Surface *surf;
331
- Uint32 colorkey;
332
- Uint8 r,g,b;
333
-
334
- Data_Get_Struct(self, SDL_Surface, surf);
335
- colorkey = surf->format->colorkey;
336
-
337
- if( surf->flags & SDL_SRCCOLORKEY )
338
- {
339
- SDL_GetRGB(colorkey, surf->format, &r, &g, &b);
340
- return rb_ary_new3(3,UINT2NUM(r),UINT2NUM(g),UINT2NUM(b));
341
- }
342
- else
343
- {
344
- /* No colorkey set. */
345
- return Qnil;
346
- }
347
-
348
- }
349
-
350
- /*
351
- * call-seq:
352
- * set_colorkey(color,flags=0)
353
- *
354
- * Set the colorkey of the surface. See Surface#colorkey for a description
355
- * of colorkeys.
356
- *
357
- * This method takes these arguments:
358
- * color:: color to use as the key, in the form [r,g,b]. Can be +nil+ to
359
- * un-set the colorkey.
360
- * flags:: 0 or Rubygame::SRC_COLORKEY (default) or
361
- * Rubygame::SRC_COLORKEY|Rubygame::SDL_RLEACCEL. Most people will
362
- * want the default, in which case this argument can be omitted. For
363
- * advanced users: this flag affects the surface as described in the
364
- * docs for the SDL C function, SDL_SetColorkey.
365
- */
366
- VALUE rbgm_surface_set_colorkey( int argc, VALUE *argv, VALUE self)
367
- {
368
- SDL_Surface *surf;
369
- Uint32 color;
370
- Uint32 flags;
371
- Uint8 r,g,b;
372
- VALUE vcolor, vflags;
373
-
374
- Data_Get_Struct(self, SDL_Surface, surf);
375
-
376
- rb_scan_args(argc, argv, "11", &vcolor, &vflags);
377
-
378
- if( !NIL_P(vflags) )
379
- {
380
- flags = NUM2UINT(vflags);
381
- }
382
- else
383
- {
384
- flags = SDL_SRCCOLORKEY;
385
- }
386
-
387
-
388
- if( RTEST(vcolor) )
389
- {
390
- vcolor = convert_color(vcolor);
391
- extract_rgb_u8_as_u8(vcolor, &r, &g, &b);
392
- color = SDL_MapRGB(surf->format, r,g,b);
393
- }
394
- else
395
- {
396
- flags = 0;
397
- color = 0;
398
- }
399
-
400
- if(SDL_SetColorKey(surf,flags,color)!=0)
401
- rb_raise(eSDLError,"could not set colorkey: %s",SDL_GetError());
402
- return self;
403
- }
404
-
405
- /*
406
- * call-seq:
407
- * blit(target,dest,source=nil) -> Rect
408
- *
409
- * Blit (copy) all or part of the surface's image to another surface,
410
- * at a given position. Returns a Rect representing the area of
411
- * +target+ which was affected by the blit.
412
- *
413
- * This method takes these arguments:
414
- * target:: the target Surface on which to paste the image.
415
- * dest:: the coordinates of the top-left corner of the blit. Affects the
416
- * area of +other+ the image data is /pasted/ over.
417
- * Can also be a Rect or an Array larger than 2, but
418
- * width and height will be ignored.
419
- * source:: a Rect representing the area of the source surface to get data
420
- * from. Affects where the image data is /copied/ from.
421
- * Can also be an Array of no less than 4 values.
422
- */
423
- VALUE rbgm_surface_blit(int argc, VALUE *argv, VALUE self)
424
- {
425
- int left, top, right, bottom;
426
- int blit_x,blit_y,blit_w,blit_h;
427
- //int dest_x,dest_y,dest_w,dest_h;
428
- int src_x,src_y,src_w,src_h;
429
- VALUE returnrect;
430
- SDL_Surface *src, *dest;
431
- SDL_Rect *src_rect, *blit_rect;
432
-
433
- VALUE vtarget, vdest, vsource;
434
-
435
- rb_scan_args( argc, argv, "21", &vtarget, &vdest, &vsource );
436
-
437
- Data_Get_Struct(self, SDL_Surface, src);
438
- Data_Get_Struct(vtarget, SDL_Surface, dest);
439
-
440
- vdest = convert_to_array(vdest);
441
- blit_x = NUM2INT(rb_ary_entry(vdest,0));
442
- blit_y = NUM2INT(rb_ary_entry(vdest,1));
443
-
444
- /* did we get a src_rect argument or not? */
445
- if( !NIL_P(vsource) )
446
- {
447
- /* it might be good to check that it's actually a rect */
448
- vsource = convert_to_array(vsource);
449
- src_x = NUM2INT( rb_ary_entry(vsource,0) );
450
- src_y = NUM2INT( rb_ary_entry(vsource,1) );
451
- src_w = NUM2INT( rb_ary_entry(vsource,2) );
452
- src_h = NUM2INT( rb_ary_entry(vsource,3) );
453
- }
454
- else
455
- {
456
- src_x = 0;
457
- src_y = 0;
458
- src_w = src->w;
459
- src_h = src->h;
460
- }
461
- src_rect = make_rect( src_x, src_y, src_w, src_h );
462
-
463
- /* experimental (broken) rectangle cropping code */
464
- /* crop if it went off left/top/right/bottom */
465
- //left = max(blit_x,0);
466
- //top = max(blit_y,0);
467
- //right = min(blit_x+src_w,dest->w);
468
- //bottom = min(blit_y+src_h,dest->h);
469
-
470
- left = blit_x;
471
- top = blit_y;
472
- right = blit_x+src_w;
473
- bottom = blit_y+src_h;
474
-
475
- //blit_w = min(blit_x+blit_w,dest->w) - max(blit_x,0);
476
- //blit_h = min(blit_y+blit_h,dest->h) - max(blit_y,0);
477
- blit_w = right - left;
478
- blit_h = bottom - top;
479
-
480
- blit_rect = make_rect( left, top, blit_w, blit_h );
481
-
482
- SDL_BlitSurface(src,src_rect,dest,blit_rect);
483
-
484
- returnrect = rb_funcall(cRect,rb_intern("new"),4,
485
- INT2NUM(left),INT2NUM(top),\
486
- INT2NUM(blit_w),INT2NUM(blit_h));
487
-
488
- free(blit_rect);
489
- free(src_rect);
490
- return returnrect;
491
- }
492
-
493
- /*
494
- * call-seq:
495
- * fill(color,rect=nil)
496
- *
497
- * Fill all or part of a Surface with a color.
498
- *
499
- * This method takes these arguments:
500
- * color:: color to fill with, in the form +[r,g,b]+ or +[r,g,b,a]+ (for
501
- * partially transparent fills).
502
- * rect:: a Rubygame::Rect representing the area of the surface to fill
503
- * with color. Omit to fill the entire surface.
504
- */
505
- VALUE rbgm_surface_fill( int argc, VALUE *argv, VALUE self )
506
- {
507
- SDL_Surface *surf;
508
- SDL_Rect *rect;
509
- Uint32 color;
510
- Uint8 r,g,b,a;
511
- VALUE vcolor, vrect;
512
-
513
- Data_Get_Struct(self, SDL_Surface, surf);
514
-
515
- rb_scan_args(argc, argv, "11", &vcolor, &vrect);
516
-
517
- vcolor = convert_color(vcolor);
518
- extract_rgba_u8_as_u8(vcolor, &r, &g, &b, &a);
519
- color = SDL_MapRGBA(surf->format, r,g,b,a);
520
-
521
- if( NIL_P(vrect) )
522
- {
523
- SDL_FillRect(surf,NULL,color);
524
- }
525
- else
526
- {
527
- vrect = convert_to_array(vrect);
528
-
529
- rect = make_rect(\
530
- NUM2INT(rb_ary_entry(vrect,0)),\
531
- NUM2INT(rb_ary_entry(vrect,1)),\
532
- NUM2INT(rb_ary_entry(vrect,2)),\
533
- NUM2INT(rb_ary_entry(vrect,3))\
534
- );
535
- SDL_FillRect(surf,rect,color);
536
- free(rect);
537
- }
538
-
539
- return self;
540
- }
541
-
542
- /*
543
- * call-seq:
544
- * get_at(x,y)
545
- * get_at([x,y]) # deprecated
546
- *
547
- * Return the color [r,g,b,a] of the pixel at the given coordinate.
548
- *
549
- * Raises IndexError if the coordinates are out of bounds.
550
- */
551
- VALUE rbgm_surface_getat( int argc, VALUE *argv, VALUE self )
552
- {
553
- SDL_Surface *surf;
554
- int x, y, locked;
555
- Uint32 color;
556
- Uint8 *pixels, *pix;
557
- Uint8 r,g,b,a;
558
- VALUE vx, vy;
559
-
560
- Data_Get_Struct(self, SDL_Surface, surf);
561
-
562
- rb_scan_args(argc, argv, "11", &vx, &vy);
563
-
564
- /* Still support passing position as an Array... for now. */
565
- switch( TYPE(vx) )
566
- {
567
- case T_ARRAY: {
568
- x = NUM2INT( rb_ary_entry(vx,0) );
569
- y = NUM2INT( rb_ary_entry(vx,1) );
570
- break;
571
- }
572
- default: {
573
- x = NUM2INT(vx);
574
- y = NUM2INT(vy);
575
- break;
576
- }
577
- }
578
-
579
- if( x < 0 || x > surf->w )
580
- rb_raise(rb_eIndexError,"x index out of bounds (%d, min 0, max %d)",\
581
- x,surf->w);
582
- if( y < 0 || y > surf->h )
583
- rb_raise(rb_eIndexError,"y index out of bounds (%d, min 0, max %d)",\
584
- y,surf->h);
585
-
586
- locked = 0;
587
- /* lock surface */
588
- if(SDL_MUSTLOCK(surf))
589
- {
590
- if(SDL_LockSurface(surf)==0)
591
- locked += 1;
592
- else
593
- rb_raise(eSDLError,"could not lock surface: %s",SDL_GetError());
594
- }
595
-
596
- /* borrowed from pygame */
597
- pixels = (Uint8 *) surf->pixels;
598
-
599
- switch(surf->format->BytesPerPixel)
600
- {
601
- case 1:
602
- color = (Uint32)*((Uint8 *)(pixels + y * surf->pitch) + x);
603
- break;
604
- case 2:
605
- color = (Uint32)*((Uint16 *)(pixels + y * surf->pitch) + x);
606
- break;
607
- case 3:
608
- pix = ((Uint8 *)(pixels + y * surf->pitch) + x * 3);
609
- #if SDL_BYTEORDER == SDL_LIL_ENDIAN
610
- color = (pix[0]) + (pix[1]<<8) + (pix[2]<<16);
611
- #else
612
- color = (pix[2]) + (pix[1]<<8) + (pix[0]<<16);
613
- #endif
614
- break;
615
- default: /*case 4:*/
616
- color = *((Uint32*)(pixels + y * surf->pitch) + x);
617
- break;
618
- }
619
-
620
- /* end borrowed from pygame */
621
-
622
- /* recursively unlock surface*/
623
- while(locked>1)
624
- {
625
- SDL_UnlockSurface(surf);
626
- locked -= 1;
627
- }
628
-
629
- SDL_GetRGBA(color, surf->format, &r, &g, &b, &a);
630
- return rb_ary_new3(4,UINT2NUM(r),UINT2NUM(g),UINT2NUM(b),UINT2NUM(a));
631
- }
632
-
633
-
634
- /*
635
- * call-seq:
636
- * set_at([x,y], color)
637
- *
638
- * Set the color of the pixel at the given coordinate.
639
- *
640
- * color can be one of:
641
- * * an Array, [r,g,b] or [r,g,b,a] with each component in 0-255
642
- * * an instance of ColorRGB, ColorHSV, etc.
643
- * * the name of a color in Rubygame::Color, as a Symbol or String
644
- *
645
- * Raises IndexError if the coordinates are out of bounds.
646
- *
647
- *--
648
- *
649
- * I'm lazy and just using SDL_FillRect. ;-P
650
- * It's easier and less bug-prone this way.
651
- * I have no idea about speed comparisons.
652
- *
653
- */
654
- VALUE rbgm_surface_setat( int argc, VALUE *argv, VALUE self )
655
- {
656
- SDL_Surface *surf;
657
- SDL_Rect *rect;
658
- Uint32 color;
659
- Uint8 r,g,b,a;
660
- VALUE vpos, vcolor;
661
-
662
- Data_Get_Struct(self, SDL_Surface, surf);
663
-
664
- rb_scan_args(argc, argv, "2", &vpos, &vcolor);
665
-
666
- vcolor = convert_color(vcolor);
667
- extract_rgba_u8_as_u8(vcolor, &r, &g, &b, &a);
668
- color = SDL_MapRGBA(surf->format, r,g,b,a);
669
-
670
- vpos = convert_to_array(vpos);
671
- rect = make_rect( NUM2INT(rb_ary_entry(vpos,0)),
672
- NUM2INT(rb_ary_entry(vpos,1)),
673
- 1, 1 );
674
-
675
- SDL_FillRect(surf,rect,color);
676
-
677
- free(rect);
678
-
679
- return self;
680
- }
681
-
682
-
683
-
684
- /*
685
- * call-seq:
686
- * pixels -> String
687
- *
688
- * Return a string of pixel data for the Surface. Most users will not
689
- * need to use this method. If you want to convert a Surface into an
690
- * OpenGL texture, pass the returned string to the TexImage2D method
691
- * of the ruby-opengl library. (See samples/demo_gl_tex.rb for an example.)
692
- *
693
- * (Please note that the dimensions of OpenGL textures must be powers of 2
694
- * (e.g. 64x128, 512x512), so if you want to use a Surface as an OpenGL
695
- * texture, the Surface's dimensions must also be powers of 2!)
696
- */
697
- VALUE rbgm_surface_pixels( VALUE self )
698
- {
699
- SDL_Surface *surf;
700
- Data_Get_Struct(self, SDL_Surface, surf);
701
- return rb_str_new(surf->pixels, (long)surf->pitch * surf->h);
702
- }
703
-
704
- /*
705
- * call-seq:
706
- * clip -> Rect
707
- *
708
- * Return the clipping area for this Surface. See also #cliprect=.
709
- *
710
- * The clipping area of a Surface is the only part which can be drawn upon
711
- * by other Surface's #blits. By default, the clipping area is the entire area
712
- * of the Surface.
713
- */
714
- VALUE rbgm_surface_get_clip( VALUE self )
715
- {
716
- SDL_Rect rect;
717
- SDL_Surface *surf;
718
- Data_Get_Struct(self, SDL_Surface, surf);
719
-
720
- SDL_GetClipRect(surf, &rect);
721
-
722
- return rb_funcall(cRect,rb_intern("new"),4,
723
- INT2NUM(rect.x),INT2NUM(rect.y),
724
- INT2NUM(rect.w),INT2NUM(rect.h));
725
- }
726
-
727
- /*
728
- * call-seq:
729
- * clip = Rect or nil
730
- *
731
- * Set the current clipping area of the Surface. See also #cliprect.
732
- *
733
- * The clipping area of a Surface is the only part which can be drawn upon
734
- * by other Surface's #blits. The clipping area will be clipped to the edges
735
- * of the surface so that the clipping area for a Surface can never fall
736
- * outside the edges of the Surface.
737
- *
738
- * By default, the clipping area is the entire area of the Surface.
739
- * You may set clip to +nil+, which will reset the clipping area to cover
740
- * the entire Surface.
741
- */
742
- VALUE rbgm_surface_set_clip( VALUE self, VALUE clip )
743
- {
744
- SDL_Rect *rect;
745
- SDL_Surface *surf;
746
- Data_Get_Struct(self, SDL_Surface, surf);
747
-
748
-
749
- if( NIL_P(clip) )
750
- {
751
- SDL_SetClipRect(surf,NULL);
752
- }
753
- else
754
- {
755
- clip = convert_to_array(clip);
756
- rect = make_rect(\
757
- NUM2INT(rb_ary_entry(clip,0)),\
758
- NUM2INT(rb_ary_entry(clip,1)),\
759
- NUM2INT(rb_ary_entry(clip,2)),\
760
- NUM2INT(rb_ary_entry(clip,3))\
761
- );
762
-
763
- SDL_SetClipRect(surf,rect);
764
- free(rect);
765
- }
766
-
767
- return self;
768
- }
769
-
770
- /*
771
- * call-seq:
772
- * convert( other=nil, flags=nil ) -> Surface
773
- *
774
- * Copies the Surface to a new Surface with the pixel format of another
775
- * Surface, for fast blitting. May raise SDLError if a problem occurs.
776
- *
777
- * This method takes these arguments:
778
- * - other:: The Surface to match pixel format against. If +nil+, the
779
- * display surface (i.e. Screen) is used, if available; if no
780
- * display surface is available, raises SDLError.
781
- * - flags:: An array of flags to pass when the new Surface is created.
782
- * See Surface#new.
783
- *
784
- */
785
- VALUE rbgm_surface_convert(int argc, VALUE *argv, VALUE self)
786
- {
787
- SDL_Surface *surf, *othersurf, *newsurf;
788
- Uint32 flags = 0;
789
- VALUE vother, vflags;
790
-
791
- Data_Get_Struct(self, SDL_Surface, surf);
792
-
793
- rb_scan_args(argc, argv, "02", &vother, &vflags );
794
-
795
- if( !NIL_P(vother) )
796
- {
797
- Data_Get_Struct(vother, SDL_Surface, othersurf);
798
- }
799
- else
800
- {
801
- othersurf = SDL_GetVideoSurface();
802
- if( othersurf == NULL )
803
- {
804
- rb_raise(eSDLError, "Cannot convert Surface with no target given and no Screen made: %s", SDL_GetError());
805
- }
806
- }
807
-
808
- flags = collapse_flags(vflags); /* in rubygame_shared.c */
809
-
810
- if( init_video_system() == 0 )
811
- {
812
- newsurf = SDL_ConvertSurface( surf, othersurf->format, flags );
813
- }
814
- else
815
- {
816
- newsurf = NULL;
817
- }
818
-
819
- if( newsurf == NULL )
820
- {
821
- rb_raise(eSDLError,\
822
- "Could not convert the Surface: %s",\
823
- SDL_GetError());
824
- }
825
-
826
- return Data_Wrap_Struct( cSurface,0,SDL_FreeSurface,newsurf );
827
- }
828
-
829
- /*
830
- * call-seq:
831
- * to_display() -> Surface
832
- *
833
- * Copies the Surface to a new Surface with the pixel format of the display,
834
- * suitable for fast blitting to the display surface (i.e. Screen).
835
- * May raise SDLError if a problem occurs.
836
- *
837
- * If you want to take advantage of hardware colorkey or alpha blit
838
- * acceleration, you should set the colorkey and alpha value before calling
839
- * this function.
840
- *
841
- */
842
- VALUE rbgm_surface_dispform(VALUE self)
843
- {
844
- SDL_Surface *surf, *newsurf;
845
- Data_Get_Struct(self, SDL_Surface, surf);
846
-
847
- if( init_video_system() == 0 )
848
- {
849
- newsurf = SDL_DisplayFormat( surf );
850
- }
851
- else
852
- {
853
- newsurf = NULL;
854
- }
855
-
856
- if( newsurf == NULL )
857
- {
858
- rb_raise(eSDLError,\
859
- "Could not convert the Surface to display format: %s",\
860
- SDL_GetError());
861
- }
862
-
863
- return Data_Wrap_Struct( cSurface,0,SDL_FreeSurface,newsurf );
864
- }
865
-
866
- /*
867
- * call-seq:
868
- * to_display_alpha() -> Surface
869
- *
870
- * Like #to_display except the Surface has an extra channel for alpha (i.e.
871
- * opacity). May raise SDLError if a problem occurs.
872
- *
873
- * This function can be used to convert a colorkey to an alpha channel, if the
874
- * SRCCOLORKEY flag is set on the surface. The generated surface will then be
875
- * transparent (alpha=0) where the pixels match the colorkey, and opaque
876
- * (alpha=255) elsewhere.
877
- */
878
- VALUE rbgm_surface_dispformalpha(VALUE self)
879
- {
880
- SDL_Surface *surf, *newsurf;
881
- Data_Get_Struct(self, SDL_Surface, surf);
882
-
883
- if( init_video_system() == 0 )
884
- {
885
- newsurf = SDL_DisplayFormatAlpha( surf );
886
- }
887
- else
888
- {
889
- newsurf = NULL;
890
- }
891
-
892
- if( newsurf == NULL )
893
- {
894
- rb_raise(eSDLError,\
895
- "Could not convert the Surface to display format with alpha channel: %s",\
896
- SDL_GetError());
897
- }
898
-
899
- return Data_Wrap_Struct( cSurface,0,SDL_FreeSurface,newsurf );
900
- }
901
-
902
-
903
- /*
904
- * call-seq:
905
- * savebmp( filename ) -> nil
906
- *
907
- * Save the Surface as a Windows Bitmap (BMP) file with the given filename.
908
- */
909
- VALUE rbgm_image_savebmp( VALUE self, VALUE filename )
910
- {
911
- char *name;
912
- SDL_Surface *surf;
913
-
914
- name = StringValuePtr(filename);
915
- Data_Get_Struct(self,SDL_Surface,surf);
916
- if(SDL_SaveBMP(surf,name)!=0)
917
- {
918
- rb_raise(eSDLError,\
919
- "Couldn't save surface to file %s: %s",name,SDL_GetError());
920
- }
921
- return Qnil;
922
- }
923
-
924
-
925
- /* --
926
- * Borrowed from Pygame:
927
- * ++
928
- */
929
- static SDL_Surface* newsurf_fromsurf(SDL_Surface* surf, int width, int height)
930
- {
931
- SDL_Surface* newsurf;
932
-
933
- if(surf->format->BytesPerPixel <= 0 || surf->format->BytesPerPixel > 4)
934
- rb_raise(eSDLError,"unsupported Surface bit depth for transform");
935
-
936
- newsurf = SDL_CreateRGBSurface(surf->flags, width, height, surf->format->BitsPerPixel,
937
- surf->format->Rmask, surf->format->Gmask, surf->format->Bmask, surf->format->Amask);
938
- if(!newsurf)
939
- rb_raise(eSDLError,"%s",SDL_GetError());
940
-
941
- /* Copy palette, colorkey, etc info */
942
- if(surf->format->BytesPerPixel==1 && surf->format->palette)
943
- SDL_SetColors(newsurf, surf->format->palette->colors, 0, surf->format->palette->ncolors);
944
- if(surf->flags & SDL_SRCCOLORKEY)
945
- SDL_SetColorKey(newsurf, (surf->flags&SDL_RLEACCEL)|SDL_SRCCOLORKEY, surf->format->colorkey);
946
-
947
- return newsurf;
948
- }
949
-
950
- /*
951
- * call-seq:
952
- * flip(horz, vert) -> Surface
953
- *
954
- * Flips the source surface horizontally (if +horz+ is true), vertically
955
- * (if +vert+ is true), or both (if both are true). This operation is
956
- * non-destructive; the original image can be perfectly reconstructed by
957
- * flipping the resultant image again.
958
- *
959
- * This operation does NOT require SDL_gfx.
960
- *
961
- * A similar effect can (supposedly) be achieved by giving X or Y zoom
962
- * factors of -1 to #rotozoom (only if compiled with SDL_gfx 2.0.13 or
963
- * greater). Your mileage may vary.
964
- */
965
- VALUE rbgm_transform_flip(VALUE self, VALUE vhorz, VALUE vvert)
966
- {
967
- SDL_Surface *surf, *newsurf;
968
- int xaxis, yaxis;
969
-
970
- int loopx, loopy;
971
- int pixsize, srcpitch, dstpitch;
972
- Uint8 *srcpix, *dstpix;
973
-
974
- xaxis = RTEST(vhorz);
975
- yaxis = RTEST(vvert);
976
-
977
- Data_Get_Struct(self,SDL_Surface,surf);
978
-
979
- /* Borrowed from Pygame: */
980
- newsurf = newsurf_fromsurf(surf, surf->w, surf->h);
981
- if(!newsurf)
982
- return Qnil;
983
-
984
- pixsize = surf->format->BytesPerPixel;
985
- srcpitch = surf->pitch;
986
- dstpitch = newsurf->pitch;
987
-
988
- SDL_LockSurface(newsurf);
989
-
990
- srcpix = (Uint8*)surf->pixels;
991
- dstpix = (Uint8*)newsurf->pixels;
992
-
993
- if(!xaxis)
994
- {
995
- if(!yaxis)
996
- {
997
- for(loopy = 0; loopy < surf->h; ++loopy)
998
- memcpy(dstpix+loopy*dstpitch, srcpix+loopy*srcpitch, surf->w*surf->format->BytesPerPixel);
999
- }
1000
- else
1001
- {
1002
- for(loopy = 0; loopy < surf->h; ++loopy)
1003
- memcpy(dstpix+loopy*dstpitch, srcpix+(surf->h-1-loopy)*srcpitch, surf->w*surf->format->BytesPerPixel);
1004
- }
1005
- }
1006
- else /*if (xaxis)*/
1007
- {
1008
- if(yaxis)
1009
- {
1010
- switch(surf->format->BytesPerPixel)
1011
- {
1012
- case 1:
1013
- for(loopy = 0; loopy < surf->h; ++loopy) {
1014
- Uint8* dst = (Uint8*)(dstpix+loopy*dstpitch);
1015
- Uint8* src = ((Uint8*)(srcpix+(surf->h-1-loopy)*srcpitch)) + surf->w - 1;
1016
- for(loopx = 0; loopx < surf->w; ++loopx)
1017
- *dst++ = *src--;
1018
- }break;
1019
- case 2:
1020
- for(loopy = 0; loopy < surf->h; ++loopy) {
1021
- Uint16* dst = (Uint16*)(dstpix+loopy*dstpitch);
1022
- Uint16* src = ((Uint16*)(srcpix+(surf->h-1-loopy)*srcpitch)) + surf->w - 1;
1023
- for(loopx = 0; loopx < surf->w; ++loopx)
1024
- *dst++ = *src--;
1025
- }break;
1026
- case 4:
1027
- for(loopy = 0; loopy < surf->h; ++loopy) {
1028
- Uint32* dst = (Uint32*)(dstpix+loopy*dstpitch);
1029
- Uint32* src = ((Uint32*)(srcpix+(surf->h-1-loopy)*srcpitch)) + surf->w - 1;
1030
- for(loopx = 0; loopx < surf->w; ++loopx)
1031
- *dst++ = *src--;
1032
- }break;
1033
- case 3:
1034
- for(loopy = 0; loopy < surf->h; ++loopy) {
1035
- Uint8* dst = (Uint8*)(dstpix+loopy*dstpitch);
1036
- Uint8* src = ((Uint8*)(srcpix+(surf->h-1-loopy)*srcpitch)) + surf->w*3 - 3;
1037
- for(loopx = 0; loopx < surf->w; ++loopx)
1038
- {
1039
- dst[0] = src[0]; dst[1] = src[1]; dst[2] = src[2];
1040
- dst += 3;
1041
- src -= 3;
1042
- }
1043
- }break;
1044
- }
1045
- }
1046
- else
1047
- {
1048
- switch(surf->format->BytesPerPixel)
1049
- {
1050
- case 1:
1051
- for(loopy = 0; loopy < surf->h; ++loopy) {
1052
- Uint8* dst = (Uint8*)(dstpix+loopy*dstpitch);
1053
- Uint8* src = ((Uint8*)(srcpix+loopy*srcpitch)) + surf->w - 1;
1054
- for(loopx = 0; loopx < surf->w; ++loopx)
1055
- *dst++ = *src--;
1056
- }break;
1057
- case 2:
1058
- for(loopy = 0; loopy < surf->h; ++loopy) {
1059
- Uint16* dst = (Uint16*)(dstpix+loopy*dstpitch);
1060
- Uint16* src = ((Uint16*)(srcpix+loopy*srcpitch)) + surf->w - 1;
1061
- for(loopx = 0; loopx < surf->w; ++loopx)
1062
- *dst++ = *src--;
1063
- }break;
1064
- case 4:
1065
- for(loopy = 0; loopy < surf->h; ++loopy) {
1066
- Uint32* dst = (Uint32*)(dstpix+loopy*dstpitch);
1067
- Uint32* src = ((Uint32*)(srcpix+loopy*srcpitch)) + surf->w - 1;
1068
- for(loopx = 0; loopx < surf->w; ++loopx)
1069
- *dst++ = *src--;
1070
- }break;
1071
- case 3:
1072
- for(loopy = 0; loopy < surf->h; ++loopy) {
1073
- Uint8* dst = (Uint8*)(dstpix+loopy*dstpitch);
1074
- Uint8* src = ((Uint8*)(srcpix+loopy*srcpitch)) + surf->w*3 - 3;
1075
- for(loopx = 0; loopx < surf->w; ++loopx)
1076
- {
1077
- dst[0] = src[0]; dst[1] = src[1]; dst[2] = src[2];
1078
- dst += 3;
1079
- src -= 3;
1080
- }
1081
- }break;
1082
- }
1083
- }
1084
- }
1085
-
1086
- SDL_UnlockSurface(newsurf);
1087
- /* Thanks, Pygame :) */
1088
-
1089
-
1090
- if(newsurf == NULL)
1091
- rb_raise(eSDLError,"Could not flip surface: %s",SDL_GetError());
1092
- return Data_Wrap_Struct(cSurface,0,SDL_FreeSurface,newsurf);
1093
- }
1094
-
1095
- /*
1096
- * See rubygame_image.c for the Surface class overview docs.
1097
- * I hate RDoc's C parser.
1098
- *
1099
- */
1100
- void Rubygame_Init_Surface()
1101
- {
1102
-
1103
- #if 0
1104
- mRubygame = rb_define_module("Rubygame");
1105
- cSurface = rb_define_class_under(mRubygame,"Surface",rb_cObject);
1106
- #endif
1107
-
1108
- rb_define_singleton_method(cSurface,"new",rbgm_surface_new,-1);
1109
- rb_define_method(cSurface,"initialize",rbgm_surface_initialize,-1);
1110
- rb_define_method(cSurface,"w",rbgm_surface_get_w,0);
1111
- rb_define_alias(cSurface,"width","w");
1112
- rb_define_method(cSurface,"h",rbgm_surface_get_h,0);
1113
- rb_define_alias(cSurface,"height","h");
1114
- rb_define_method(cSurface,"size",rbgm_surface_get_size,0);
1115
- rb_define_method(cSurface,"depth",rbgm_surface_get_depth,0);
1116
- rb_define_method(cSurface,"flags",rbgm_surface_get_flags,0);
1117
- rb_define_method(cSurface,"masks",rbgm_surface_get_masks,0);
1118
- rb_define_method(cSurface,"alpha",rbgm_surface_get_alpha,0);
1119
- rb_define_method(cSurface,"set_alpha",rbgm_surface_set_alpha,-1);
1120
- rb_define_method(cSurface,"colorkey",rbgm_surface_get_colorkey,0);
1121
- rb_define_method(cSurface,"set_colorkey",rbgm_surface_set_colorkey,-1);
1122
- rb_define_method(cSurface,"blit",rbgm_surface_blit,-1);
1123
- rb_define_method(cSurface,"fill",rbgm_surface_fill,-1);
1124
- rb_define_method(cSurface,"get_at",rbgm_surface_getat,-1);
1125
- rb_define_method(cSurface,"set_at",rbgm_surface_setat,-1);
1126
- rb_define_method(cSurface,"pixels",rbgm_surface_pixels,0);
1127
- rb_define_method(cSurface,"clip",rbgm_surface_get_clip,0);
1128
- rb_define_method(cSurface,"clip=",rbgm_surface_set_clip,1);
1129
- rb_define_method(cSurface,"convert",rbgm_surface_convert,-1);
1130
- rb_define_method(cSurface,"to_display",rbgm_surface_dispform,0);
1131
- rb_define_method(cSurface,"to_display_alpha",rbgm_surface_dispformalpha,0);
1132
- rb_define_method(cSurface,"savebmp",rbgm_image_savebmp,1);
1133
- rb_define_method(cSurface,"flip",rbgm_transform_flip,2);
1134
-
1135
-
1136
- /* Include the Rubygame::NamedResource mixin module. */
1137
- rg_include_named_resource(cSurface);
1138
-
1139
-
1140
- /* Surface initialization flags */
1141
- rb_define_const(mRubygame,"SWSURFACE",UINT2NUM(SDL_SWSURFACE));
1142
- rb_define_const(mRubygame,"HWSURFACE",UINT2NUM(SDL_HWSURFACE));
1143
- rb_define_const(mRubygame,"ASYNCBLIT",UINT2NUM(SDL_ASYNCBLIT));
1144
- rb_define_const(mRubygame,"ANYFORMAT",UINT2NUM(SDL_ANYFORMAT));
1145
- rb_define_const(mRubygame,"HWPALETTE",UINT2NUM(SDL_HWPALETTE));
1146
- rb_define_const(mRubygame,"HWACCEL",UINT2NUM(SDL_HWACCEL));
1147
- rb_define_const(mRubygame,"SRCCOLORKEY",UINT2NUM(SDL_SRCCOLORKEY));
1148
- rb_define_const(mRubygame,"RLEACCELOK",UINT2NUM(SDL_RLEACCELOK));
1149
- rb_define_const(mRubygame,"RLEACCEL",UINT2NUM(SDL_RLEACCEL));
1150
- rb_define_const(mRubygame,"SRCALPHA",UINT2NUM(SDL_SRCALPHA));
1151
- rb_define_const(mRubygame,"PREALLOC",UINT2NUM(SDL_PREALLOC));
1152
-
1153
- }