rubysdl 1.3.1 → 2.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/MANIFEST +22 -2
  2. data/NEWS.en +80 -0
  3. data/NEWS.ja +83 -0
  4. data/README.en +2 -1
  5. data/README.ja +2 -2
  6. data/doc-en/Makefile +18 -0
  7. data/doc-en/cdrom.rsd +417 -0
  8. data/doc-en/collision.rsd +174 -0
  9. data/doc-en/event.rsd +1476 -0
  10. data/doc-en/font.rsd +811 -0
  11. data/doc-en/general.rsd +43 -0
  12. data/doc-en/init.rsd +168 -0
  13. data/doc-en/joystick.rsd +401 -0
  14. data/doc-en/mixer.rsd +869 -0
  15. data/doc-en/mpeg.rsd +585 -0
  16. data/doc-en/opengl.rsd +155 -0
  17. data/doc-en/sdlskk.rsd +472 -0
  18. data/doc-en/time.rsd +46 -0
  19. data/doc-en/video.rsd +2806 -0
  20. data/doc-en/wm.rsd +112 -0
  21. data/doc/Makefile +1 -1
  22. data/doc/cdrom.rsd +3 -3
  23. data/doc/event.rsd +178 -179
  24. data/doc/general.rsd +10 -0
  25. data/doc/init.rsd +2 -2
  26. data/doc/joystick.rsd +29 -5
  27. data/doc/mixer.rsd +20 -0
  28. data/doc/rsd.rb +42 -9
  29. data/doc/sdlskk.rsd +7 -7
  30. data/doc/video.rsd +461 -168
  31. data/doc/wm.rsd +2 -2
  32. data/extconf.rb +1 -8
  33. data/lib/rubysdl_aliases.rb +52 -190
  34. data/lib/rubysdl_compatible_ver1.rb +243 -0
  35. data/lib/sdl.rb +58 -92
  36. data/rubysdl.h +59 -68
  37. data/rubysdl_cdrom.c +125 -102
  38. data/{rubysdl_doc.en.rd → rubysdl_doc_old.en.rd} +3 -2
  39. data/rubysdl_event.c +318 -255
  40. data/rubysdl_event_key.c +299 -287
  41. data/rubysdl_image.c +37 -13
  42. data/rubysdl_joystick.c +180 -67
  43. data/rubysdl_kanji.c +61 -75
  44. data/rubysdl_main.c +65 -138
  45. data/rubysdl_mixer.c +339 -214
  46. data/rubysdl_mouse.c +50 -43
  47. data/rubysdl_opengl.c +31 -28
  48. data/rubysdl_pixel.c +17 -28
  49. data/rubysdl_ref.en.html +5658 -0
  50. data/rubysdl_ref.en.rd +6337 -0
  51. data/rubysdl_ref.html +2253 -1964
  52. data/rubysdl_ref.rd +823 -469
  53. data/rubysdl_rwops.c +9 -6
  54. data/rubysdl_sdlskk.c +137 -165
  55. data/rubysdl_sge_video.c +355 -469
  56. data/rubysdl_smpeg.c +189 -190
  57. data/rubysdl_time.c +1 -1
  58. data/rubysdl_ttf.c +147 -215
  59. data/rubysdl_video.c +486 -405
  60. data/rubysdl_wm.c +30 -30
  61. data/sample/aadraw.rb +9 -9
  62. data/sample/alpha.rb +12 -13
  63. data/sample/alphadraw.rb +10 -10
  64. data/sample/bfont.rb +4 -4
  65. data/sample/cdrom.rb +11 -4
  66. data/sample/collision.rb +20 -20
  67. data/sample/cursor.rb +5 -5
  68. data/sample/ellipses.rb +20 -16
  69. data/sample/event2.rb +11 -9
  70. data/sample/font.rb +4 -4
  71. data/sample/fpstimer.rb +3 -3
  72. data/sample/icon.bmp.gz +0 -0
  73. data/sample/icon.png +0 -0
  74. data/sample/joy2.rb +14 -14
  75. data/sample/kanji.rb +7 -7
  76. data/sample/load_from_io.rb +44 -0
  77. data/sample/movesp.rb +13 -12
  78. data/sample/playmod.rb +2 -3
  79. data/sample/plaympeg.rb +8 -8
  80. data/sample/playwave.rb +5 -6
  81. data/sample/sdlskk.rb +11 -11
  82. data/sample/sgetest.rb +14 -12
  83. data/sample/stetris.rb +12 -13
  84. data/sample/testgl.rb +13 -14
  85. data/sample/testsprite.rb +12 -11
  86. data/sample/transformblit.rb +23 -22
  87. metadata +62 -35
  88. data/rubysdl_event2.c +0 -417
data/rubysdl_sge_video.c CHANGED
@@ -22,601 +22,487 @@
22
22
  #include "rubysdl.h"
23
23
  #include <sge.h>
24
24
 
25
- static VALUE sdl_get_autoLocking(VALUE mod)
26
- {
27
- return BOOL(sge_getLock());
28
- }
25
+ static VALUE cCollisionMap = Qnil;
26
+ static VALUE cBMFont = Qnil;
29
27
 
30
- static VALUE sdl_set_autoLocking(VALUE mod,VALUE bool)
31
- {
32
- if(RTEST(bool))
33
- sge_Lock_ON();
34
- else
35
- sge_Lock_OFF();
36
- return Qnil;
37
- }
28
+ DEFINE_GET_STRUCT(sge_bmpFont, Get_sge_bmpFont, cBMFont, "SDL::BMFont");
29
+ DEFINE_GET_STRUCT(sge_cdata, Get_sge_cdata, cCollisionMap, "SDL::CollisionMap");
38
30
 
39
-
40
- static VALUE sdl_getPixel(VALUE obj,VALUE x,VALUE y)
41
- {
42
- SDL_Surface *surface;
43
- Data_Get_Struct(obj,SDL_Surface,surface);
44
- return UINT2NUM( sge_GetPixel(surface,NUM2INT(x),NUM2INT(y)) );
45
- }
46
- static VALUE sdl_putPixel(VALUE obj,VALUE x,VALUE y,VALUE color)
47
- {
48
- SDL_Surface *surface;
49
- Data_Get_Struct(obj,SDL_Surface,surface);
50
- sge_PutPixel(surface,NUM2INT(x),NUM2INT(y),VALUE2COLOR(color,surface->format));
51
- return Qnil;
52
- }
53
- static VALUE sdl_drawLine(VALUE obj,VALUE x1,VALUE y1,VALUE x2,VALUE y2,VALUE color)
54
- {
55
- SDL_Surface *surface;
56
- Data_Get_Struct(obj,SDL_Surface,surface);
57
- sge_Line( surface,NUM2INT(x1),NUM2INT(y1),NUM2INT(x2),NUM2INT(y2),
58
- VALUE2COLOR(color,surface->format) );
59
- return Qnil;
60
- }
61
- static VALUE sdl_drawAALine(VALUE obj,VALUE x1,VALUE y1,VALUE x2,VALUE y2,VALUE color)
62
- {
63
- SDL_Surface *surface;
64
- Data_Get_Struct(obj,SDL_Surface,surface);
65
- sge_AALine( surface,NUM2INT(x1),NUM2INT(y1),NUM2INT(x2),NUM2INT(y2),
66
- VALUE2COLOR(color,surface->format) );
67
- return Qnil;
68
- }
69
- static VALUE sdl_drawLineAlpha(VALUE obj,VALUE x1,VALUE y1,VALUE x2,VALUE y2,VALUE color,VALUE alpha)
70
- {
71
- SDL_Surface *surface;
72
- Data_Get_Struct(obj,SDL_Surface,surface);
73
- sge_LineAlpha( surface,NUM2INT(x1),NUM2INT(y1),NUM2INT(x2),NUM2INT(y2),
74
- VALUE2COLOR(color,surface->format), NUM2UINT(alpha) );
75
- return Qnil;
76
- }
77
- static VALUE sdl_drawAALineAlpha(VALUE obj,VALUE x1,VALUE y1,VALUE x2,VALUE y2,VALUE color,VALUE alpha)
31
+ static VALUE Surface_s_autoLock_p(VALUE klass)
78
32
  {
79
- SDL_Surface *surface;
80
- Data_Get_Struct(obj,SDL_Surface,surface);
81
- sge_AALineAlpha( surface,NUM2INT(x1),NUM2INT(y1),NUM2INT(x2),NUM2INT(y2),
82
- VALUE2COLOR(color,surface->format),NUM2UINT(alpha) );
83
- return Qnil;
33
+ rb_secure(4);
34
+ return INT2BOOL(sge_getLock());
84
35
  }
85
36
 
86
- static VALUE sdl_drawRect(VALUE obj,VALUE x,VALUE y,VALUE w,VALUE h,VALUE color)
87
- {
88
- SDL_Surface *surface;
89
- Data_Get_Struct(obj,SDL_Surface,surface);
90
- sge_Rect( surface,NUM2INT(x),NUM2INT(y),NUM2INT(x)+NUM2INT(w),
91
- NUM2INT(y)+NUM2INT(h),VALUE2COLOR(color,surface->format) );
92
- return Qnil;
93
- }
94
- static VALUE sdl_drawRectAlpha(VALUE obj,VALUE x,VALUE y,VALUE w,VALUE h,VALUE color,VALUE alpha)
95
- {
96
- SDL_Surface *surface;
97
- Data_Get_Struct(obj,SDL_Surface,surface);
98
- sge_RectAlpha( surface,NUM2INT(x),NUM2INT(y),NUM2INT(x)+NUM2INT(w),
99
- NUM2INT(y)+NUM2INT(h),VALUE2COLOR(color,surface->format),
100
- NUM2UINT(alpha) );
101
- return Qnil;
102
- }
103
- static VALUE sdl_drawFilledRectAlpha(VALUE obj,VALUE x,VALUE y,VALUE w,VALUE h,VALUE color,VALUE alpha)
104
- {
105
- SDL_Surface *surface;
106
- Data_Get_Struct(obj,SDL_Surface,surface);
107
- sge_FilledRectAlpha( surface,NUM2INT(x),NUM2INT(y),NUM2INT(x)+NUM2INT(w),
108
- NUM2INT(y)+NUM2INT(h),VALUE2COLOR(color,surface->format),
109
- NUM2UINT(alpha) );
110
- return Qnil;
111
- }
112
- static VALUE sdl_drawCircle(VALUE obj,VALUE x,VALUE y,VALUE r,VALUE color)
113
- {
114
- SDL_Surface *surface;
115
- Data_Get_Struct(obj,SDL_Surface,surface);
116
- sge_Circle( surface,NUM2INT(x),NUM2INT(y),NUM2INT(r),
117
- VALUE2COLOR(color,surface->format) );
118
- return Qnil;
119
- }
120
- static VALUE sdl_drawAACircle(VALUE obj,VALUE x,VALUE y,VALUE r,VALUE color)
121
- {
122
- SDL_Surface *surface;
123
- Data_Get_Struct(obj,SDL_Surface,surface);
124
- sge_AACircle( surface,NUM2INT(x),NUM2INT(y),NUM2INT(r),
125
- VALUE2COLOR(color,surface->format) );
126
- return Qnil;
127
- }
128
- static VALUE sdl_drawCircleAlpha(VALUE obj,VALUE x,VALUE y,VALUE r,VALUE color,VALUE alpha)
129
- {
130
- SDL_Surface *surface;
131
- Data_Get_Struct(obj,SDL_Surface,surface);
132
- sge_CircleAlpha( surface,NUM2INT(x),NUM2INT(y),NUM2INT(r),
133
- VALUE2COLOR(color,surface->format),NUM2UINT(alpha) );
134
- return Qnil;
135
- }
136
- static VALUE sdl_drawAACircleAlpha(VALUE obj,VALUE x,VALUE y,VALUE r,VALUE color,
137
- VALUE alpha)
37
+ static VALUE Surface_s_autoLockON(VALUE klass)
138
38
  {
139
- SDL_Surface *surface;
140
- Data_Get_Struct(obj,SDL_Surface,surface);
141
- sge_AACircleAlpha( surface,NUM2INT(x),NUM2INT(y),NUM2INT(r),
142
- VALUE2COLOR(color,surface->format),NUM2UINT(alpha) );
143
- return Qnil;
144
- }
145
- static VALUE sdl_drawFilledCircle(VALUE obj,VALUE x,VALUE y,VALUE r,VALUE color)
146
- {
147
- SDL_Surface *surface;
148
- Data_Get_Struct(obj,SDL_Surface,surface);
149
- sge_FilledCircle( surface,NUM2INT(x),NUM2INT(y),NUM2INT(r),
150
- VALUE2COLOR(color,surface->format) );
151
- return Qnil;
152
- }
153
- static VALUE sdl_drawAAFilledCircle(VALUE obj,VALUE x,VALUE y,VALUE r,VALUE color)
154
- {
155
- SDL_Surface *surface;
156
- Data_Get_Struct(obj,SDL_Surface,surface);
157
- sge_AAFilledCircle( surface,NUM2INT(x),NUM2INT(y),NUM2INT(r),
158
- VALUE2COLOR(color,surface->format) );
159
- return Qnil;
160
- }
161
- static VALUE sdl_drawFilledCircleAlpha(VALUE obj,VALUE x,VALUE y,VALUE r,VALUE color,VALUE alpha)
162
- {
163
- SDL_Surface *surface;
164
- Data_Get_Struct(obj,SDL_Surface,surface);
165
- sge_FilledCircleAlpha( surface,NUM2INT(x),NUM2INT(y),NUM2INT(r),
166
- VALUE2COLOR(color,surface->format),NUM2UINT(alpha) );
167
- return Qnil;
168
- }
169
- static VALUE sdl_drawEllipse(VALUE obj,VALUE x,VALUE y,VALUE rx,VALUE ry,
170
- VALUE color)
171
- {
172
- SDL_Surface *surface;
173
- Data_Get_Struct(obj,SDL_Surface,surface);
174
- sge_Ellipse( surface,NUM2INT(x),NUM2INT(y),NUM2INT(rx),NUM2INT(ry),
175
- VALUE2COLOR(color,surface->format) );
176
- return Qnil;
177
- }
178
- static VALUE sdl_drawAAEllipse(VALUE obj,VALUE x,VALUE y,VALUE rx,VALUE ry,
179
- VALUE color)
180
- {
181
- SDL_Surface *surface;
182
- Data_Get_Struct(obj,SDL_Surface,surface);
183
- sge_AAEllipse( surface,NUM2INT(x),NUM2INT(y),NUM2INT(rx),NUM2INT(ry),
184
- VALUE2COLOR(color,surface->format) );
185
- return Qnil;
186
- }
187
- static VALUE sdl_drawEllipseAlpha(VALUE obj,VALUE x,VALUE y,VALUE rx,VALUE ry,
188
- VALUE color,VALUE alpha)
189
- {
190
- SDL_Surface *surface;
191
- Data_Get_Struct(obj,SDL_Surface,surface);
192
- sge_EllipseAlpha( surface,NUM2INT(x),NUM2INT(y),NUM2INT(rx),NUM2INT(ry),
193
- VALUE2COLOR(color,surface->format),NUM2UINT(alpha) );
194
- return Qnil;
195
- }
196
- static VALUE sdl_drawAAEllipseAlpha(VALUE obj,VALUE x,VALUE y,VALUE rx,VALUE ry,
197
- VALUE color,VALUE alpha)
198
- {
199
- SDL_Surface *surface;
200
- Data_Get_Struct(obj,SDL_Surface,surface);
201
- sge_AAEllipseAlpha( surface,NUM2INT(x),NUM2INT(y),NUM2INT(rx),NUM2INT(ry),
202
- VALUE2COLOR(color,surface->format),NUM2UINT(alpha) );
203
- return Qnil;
204
- }
205
- static VALUE sdl_drawFilledEllipse(VALUE obj,VALUE x,VALUE y,VALUE rx,VALUE ry,
206
- VALUE color)
207
- {
208
- SDL_Surface *surface;
209
- Data_Get_Struct(obj,SDL_Surface,surface);
210
- sge_FilledEllipse( surface,NUM2INT(x),NUM2INT(y),NUM2INT(rx),NUM2INT(ry),
211
- VALUE2COLOR(color,surface->format) );
212
- return Qnil;
213
- }
214
- static VALUE sdl_drawAAFilledEllipse(VALUE obj,VALUE x,VALUE y,VALUE rx,VALUE ry,
215
- VALUE color)
216
- {
217
- SDL_Surface *surface;
218
- Data_Get_Struct(obj,SDL_Surface,surface);
219
- sge_AAFilledEllipse( surface,NUM2INT(x),NUM2INT(y),NUM2INT(rx),NUM2INT(ry),
220
- VALUE2COLOR(color,surface->format) );
39
+ rb_secure(4);
40
+ sge_Lock_ON();
221
41
  return Qnil;
222
42
  }
223
- static VALUE sdl_drawFilledEllipseAlpha(VALUE obj,VALUE x,VALUE y,VALUE rx,VALUE ry,
224
- VALUE color,VALUE alpha)
43
+
44
+ static VALUE Surface_s_autoLockOFF(VALUE klass)
225
45
  {
226
- SDL_Surface *surface;
227
- Data_Get_Struct(obj,SDL_Surface,surface);
228
- sge_FilledEllipseAlpha( surface,NUM2INT(x),NUM2INT(y),NUM2INT(rx),NUM2INT(ry),
229
- VALUE2COLOR(color,surface->format),NUM2UINT(alpha) );
46
+ rb_secure(4);
47
+ sge_Lock_OFF();
230
48
  return Qnil;
231
49
  }
232
50
 
233
- static VALUE sdl_drawBezier(VALUE obj,VALUE x1,VALUE y1,VALUE x2,VALUE y2,
234
- VALUE x3,VALUE y3,VALUE x4,VALUE y4,
235
- VALUE level,VALUE color)
51
+ static VALUE Surface_drawLine(int argc, VALUE* argv, VALUE self)
236
52
  {
237
- SDL_Surface *surface;
238
- Data_Get_Struct(obj,SDL_Surface,surface);
239
- sge_Bezier(surface,NUM2INT(x1),NUM2INT(y1),NUM2INT(x2),NUM2INT(y2),
240
- NUM2INT(x3),NUM2INT(y3),NUM2INT(x4),NUM2INT(y4),
241
- NUM2INT(level),VALUE2COLOR(color,surface->format));
53
+ VALUE x1_, y1_, x2_, y2_, color_, aa_, alpha_;
54
+ Sint16 x1, y1, x2, y2;
55
+ Uint32 color;
56
+ SDL_Surface* surface;
57
+
58
+ rb_secure(4);
59
+ rb_scan_args(argc, argv, "52", &x1_, &y1_, &x2_, &y2_, &color_, &aa_, &alpha_);
60
+ surface = Get_SDL_Surface(self);
61
+
62
+ x1 = NUM2INT(x1_); y1 = NUM2INT(y1_);
63
+ x2 = NUM2INT(x2_); y2 = NUM2INT(y2_);
64
+ color = VALUE2COLOR(color_, surface->format);
65
+
66
+ if(RTEST(aa_) && RTEST(alpha_))
67
+ sge_AALineAlpha(surface, x1, y1, x2, y2, color, NUM2UINT(alpha_));
68
+
69
+ if(RTEST(aa_) && !RTEST(alpha_))
70
+ sge_AALine(surface, x1, y1, x2, y2, color);
71
+
72
+ if(!RTEST(aa_) && RTEST(alpha_))
73
+ sge_LineAlpha(surface, x1, y1, x2, y2, color, NUM2UINT(alpha_));
74
+
75
+ if(!RTEST(aa_) && !RTEST(alpha_))
76
+ sge_Line(surface, x1, y1, x2, y2, color);
77
+
242
78
  return Qnil;
243
79
  }
244
80
 
245
- static VALUE sdl_drawBezierAlpha(VALUE obj,VALUE x1,VALUE y1,VALUE x2,VALUE y2,
246
- VALUE x3,VALUE y3,VALUE x4,VALUE y4,
247
- VALUE level,VALUE color,VALUE alpha)
81
+ static VALUE Surface_drawRect(int argc, VALUE* argv, VALUE self)
248
82
  {
249
- SDL_Surface *surface;
250
- Data_Get_Struct(obj,SDL_Surface,surface);
251
- sge_BezierAlpha(surface,NUM2INT(x1),NUM2INT(y1),NUM2INT(x2),NUM2INT(y2),
252
- NUM2INT(x3),NUM2INT(y3),NUM2INT(x4),NUM2INT(y4),
253
- NUM2INT(level),VALUE2COLOR(color,surface->format),
254
- NUM2UINT(alpha));
83
+ VALUE x_, y_, w_, h_, color_, fill_, alpha_;
84
+ Sint16 x1, y1, x2, y2;
85
+ Uint32 color;
86
+ SDL_Surface* surface;
87
+
88
+ rb_scan_args(argc, argv, "52", &x_, &y_, &w_, &h_, &color_, &fill_, &alpha_);
89
+
90
+ surface = Get_SDL_Surface(self);
91
+ x1 = NUM2INT(x_); y1 = NUM2INT(y_);
92
+ x2 = x1 + NUM2INT(w_); y2 = y1 + NUM2INT(h_);
93
+ color = VALUE2COLOR(color_, surface->format);
94
+
95
+ if(RTEST(fill_) && RTEST(alpha_))
96
+ sge_FilledRectAlpha(surface, x1, y1, x2, y2, color, NUM2UINT(alpha_));
97
+
98
+ if(RTEST(fill_) && !RTEST(alpha_))
99
+ sge_FilledRect(surface, x1, y1, x2, y2, color);
100
+
101
+ if(!RTEST(fill_) && RTEST(alpha_))
102
+ sge_RectAlpha(surface, x1, y1, x2, y2, color, NUM2UINT(alpha_));
103
+
104
+ if(!RTEST(fill_) && !RTEST(alpha_))
105
+ sge_Rect(surface, x1, y1, x2, y2, color);
106
+
255
107
  return Qnil;
256
108
  }
257
109
 
258
- static VALUE sdl_drawAABezier(VALUE obj,VALUE x1,VALUE y1,VALUE x2,VALUE y2,
259
- VALUE x3,VALUE y3,VALUE x4,VALUE y4,
260
- VALUE level,VALUE color)
110
+ static VALUE Surface_drawCircle(int argc, VALUE* argv, VALUE self)
261
111
  {
262
- SDL_Surface *surface;
263
- Data_Get_Struct(obj,SDL_Surface,surface);
264
- sge_AABezier(surface,NUM2INT(x1),NUM2INT(y1),NUM2INT(x2),NUM2INT(y2),
265
- NUM2INT(x3),NUM2INT(y3),NUM2INT(x4),NUM2INT(y4),
266
- NUM2INT(level),VALUE2COLOR(color,surface->format));
112
+ SDL_Surface* surface;
113
+ VALUE x_, y_, r_, color_, fill_, aa_, alpha_;
114
+ Sint16 x, y, r;
115
+ Uint32 color;
116
+
117
+ rb_secure(4);
118
+ rb_scan_args(argc, argv, "43", &x_, &y_, &r_, &color_, &fill_, &aa_, &alpha_);
119
+
120
+ surface = Get_SDL_Surface(self);
121
+ x = NUM2INT(x_);
122
+ y = NUM2INT(y_);
123
+ r = NUM2INT(r_);
124
+ color = VALUE2COLOR(color_, surface->format);
125
+
126
+ if(RTEST(fill_) && RTEST(aa_) && RTEST(alpha_))
127
+ rb_raise(eSDLError, "can't draw filled antialiased alpha circle");
128
+
129
+ if(RTEST(fill_) && RTEST(aa_) && !RTEST(alpha_))
130
+ sge_AAFilledCircle(surface, x, y, r, color);
131
+
132
+ if(RTEST(fill_) && !RTEST(aa_) && RTEST(alpha_))
133
+ sge_FilledCircleAlpha(surface, x, y, r, color, NUM2UINT(alpha_));
134
+
135
+ if(RTEST(fill_) && !RTEST(aa_) && !RTEST(alpha_))
136
+ sge_FilledCircle(surface, x, y, r, color);
137
+
138
+
139
+ if(!RTEST(fill_) && RTEST(aa_) && RTEST(alpha_))
140
+ sge_AACircleAlpha(surface, x, y, r, color, NUM2UINT(alpha_));
141
+
142
+ if(!RTEST(fill_) && RTEST(aa_) && !RTEST(alpha_))
143
+ sge_AACircle(surface, x, y, r, color);
144
+
145
+ if(!RTEST(fill_) && !RTEST(aa_) && RTEST(alpha_))
146
+ sge_CircleAlpha(surface, x, y, r, color, NUM2UINT(alpha_));
147
+
148
+ if(!RTEST(fill_) && !RTEST(aa_) && !RTEST(alpha_))
149
+ sge_Circle(surface, x, y, r, color);
150
+
267
151
  return Qnil;
268
152
  }
269
153
 
270
- static VALUE sdl_drawAABezierAlpha(VALUE obj,VALUE x1,VALUE y1,VALUE x2,VALUE y2,
271
- VALUE x3,VALUE y3,VALUE x4,VALUE y4,
272
- VALUE level,VALUE color,VALUE alpha)
154
+ static VALUE Surface_drawEllipse(int argc, VALUE* argv, VALUE self)
273
155
  {
274
- SDL_Surface *surface;
275
- Data_Get_Struct(obj,SDL_Surface,surface);
276
- sge_AABezierAlpha(surface,NUM2INT(x1),NUM2INT(y1),NUM2INT(x2),NUM2INT(y2),
277
- NUM2INT(x3),NUM2INT(y3),NUM2INT(x4),NUM2INT(y4),
278
- NUM2INT(level),VALUE2COLOR(color,surface->format),
279
- NUM2UINT(alpha));
156
+ SDL_Surface* surface;
157
+ VALUE x_, y_, rx_, ry_, color_, fill_, aa_, alpha_;
158
+ Sint16 x, y, rx, ry;
159
+ Uint32 color;
160
+
161
+ rb_secure(4);
162
+ rb_scan_args(argc, argv, "53", &x_, &y_, &rx_, &ry_, &color_,
163
+ &fill_, &aa_, &alpha_);
164
+
165
+ surface = Get_SDL_Surface(self);
166
+ x = NUM2INT(x_);
167
+ y = NUM2INT(y_);
168
+ rx = NUM2INT(rx_);
169
+ ry = NUM2INT(ry_);
170
+ color = VALUE2COLOR(color_, surface->format);
171
+
172
+ if(RTEST(fill_) && RTEST(aa_) && RTEST(alpha_))
173
+ rb_raise(eSDLError, "can't draw filled antialiased alpha ellipse");
174
+
175
+ if(RTEST(fill_) && RTEST(aa_) && !RTEST(alpha_))
176
+ sge_AAFilledEllipse(surface, x, y, rx, ry, color);
177
+
178
+ if(RTEST(fill_) && !RTEST(aa_) && RTEST(alpha_))
179
+ sge_FilledEllipseAlpha(surface, x, y, rx, ry, color, NUM2UINT(alpha_));
180
+
181
+ if(RTEST(fill_) && !RTEST(aa_) && !RTEST(alpha_))
182
+ sge_FilledEllipse(surface, x, y, rx, ry, color);
183
+
184
+ if(!RTEST(fill_) && RTEST(aa_) && RTEST(alpha_))
185
+ sge_AAEllipseAlpha(surface, x, y, rx, ry, color, NUM2UINT(alpha_));
186
+
187
+ if(!RTEST(fill_) && RTEST(aa_) && !RTEST(alpha_))
188
+ sge_AAEllipse(surface, x, y, rx, ry, color);
189
+
190
+ if(!RTEST(fill_) && !RTEST(aa_) && RTEST(alpha_))
191
+ sge_EllipseAlpha(surface, x, y, rx, ry, color, NUM2UINT(alpha_));
192
+
193
+ if(!RTEST(fill_) && !RTEST(aa_) && !RTEST(alpha_))
194
+ sge_Ellipse(surface, x, y, rx, ry, color);
195
+
280
196
  return Qnil;
281
197
  }
282
198
 
283
- static VALUE sdl_rotateScaledSurface(VALUE obj,VALUE angle,VALUE scale,VALUE bgcolor)
199
+ static VALUE Surface_drawBezier(int argc, VALUE* argv, VALUE self)
284
200
  {
285
- SDL_Surface *surface,*result;
286
- Data_Get_Struct(obj,SDL_Surface,surface);
287
- result=sge_rotate_scaled_surface(surface,NUM2INT(angle),NUM2DBL(scale),
288
- VALUE2COLOR(bgcolor,surface->format) );
289
- if( result==NULL )
290
- rb_raise( eSDLError,"Couldn't Create Surface: %s",SDL_GetError() );
291
- return Data_Wrap_Struct(cSurface,0,sdl_freeSurface,result);
292
- }
293
- /* doesn't respect ColorKey */
294
- static VALUE sdl_rotateXYScaled(VALUE mod,VALUE src,VALUE dst,VALUE x,
295
- VALUE y,VALUE angle,VALUE xscale,
296
- VALUE yscale)
297
- {
298
- SDL_Surface *srcSurface,*dstSurface;
299
- if( !rb_obj_is_kind_of(src,cSurface) || !rb_obj_is_kind_of(dst,cSurface) )
300
- rb_raise(rb_eArgError,"type mismatch(expect Surface)");
301
- Data_Get_Struct(src,SDL_Surface,srcSurface);
302
- Data_Get_Struct(dst,SDL_Surface,dstSurface);
303
- sge_rotate_xyscaled(dstSurface,srcSurface,NUM2INT(x),NUM2INT(y),
304
- NUM2INT(angle),NUM2DBL(xscale),NUM2DBL(yscale));
201
+ SDL_Surface* surface;
202
+ VALUE coords_[8], level_, color_;
203
+ VALUE aa_, alpha_;
204
+ int coords[8];
205
+ Uint32 color;
206
+ int level;
207
+ int i;
208
+
209
+ rb_secure(4);
210
+ /* WARNING: ':' == '9' + 1
211
+ */
212
+ rb_scan_args(argc, argv, ":2",
213
+ &coords_[0], &coords_[1],
214
+ &coords_[2], &coords_[3],
215
+ &coords_[4], &coords_[5],
216
+ &coords_[6], &coords_[7],
217
+ &level_, &color_,
218
+ &aa_, &alpha_);
219
+ surface = Get_SDL_Surface(self);
220
+ for (i=0; i<8; i++)
221
+ coords[i] = NUM2INT(coords_[i]);
222
+ color = VALUE2COLOR(color_, surface->format);
223
+ level = NUM2INT(level_);
224
+
225
+ if(RTEST(aa_) && RTEST(alpha_))
226
+ sge_AABezierAlpha(surface,
227
+ coords[0], coords[1],
228
+ coords[2], coords[3],
229
+ coords[4], coords[5],
230
+ coords[6], coords[7],
231
+ level, color, NUM2UINT(alpha_));
232
+ if(!RTEST(aa_) && RTEST(alpha_))
233
+ sge_BezierAlpha(surface,
234
+ coords[0], coords[1],
235
+ coords[2], coords[3],
236
+ coords[4], coords[5],
237
+ coords[6], coords[7],
238
+ level, color, NUM2UINT(alpha_));
239
+ if(RTEST(aa_) && !RTEST(alpha_))
240
+ sge_AABezier(surface,
241
+ coords[0], coords[1],
242
+ coords[2], coords[3],
243
+ coords[4], coords[5],
244
+ coords[6], coords[7],
245
+ level, color);
246
+ if(!RTEST(aa_) && !RTEST(alpha_))
247
+ sge_Bezier(surface,
248
+ coords[0], coords[1],
249
+ coords[2], coords[3],
250
+ coords[4], coords[5],
251
+ coords[6], coords[7],
252
+ level, color);
305
253
  return Qnil;
306
254
  }
307
- static VALUE sdl_rotateScaledBlit(VALUE mod,VALUE src,VALUE dst,VALUE x,
308
- VALUE y,VALUE angle,VALUE scale)
309
- {
310
- SDL_Surface *srcSurface,*dstSurface,*tmpSurface;
311
- SDL_Rect destRect;
312
- Uint32 colorkey;
313
- Uint32 flags;
314
- int result;
315
255
 
316
- if( !rb_obj_is_kind_of(src,cSurface) || !rb_obj_is_kind_of(dst,cSurface) )
317
- rb_raise(rb_eArgError,"type mismatch(expect Surface)");
318
- Data_Get_Struct(src,SDL_Surface,srcSurface);
319
- Data_Get_Struct(dst,SDL_Surface,dstSurface);
320
- colorkey=srcSurface->format->colorkey;
321
- flags = srcSurface->flags & ( SDL_RLEACCEL|SDL_SRCCOLORKEY );
322
- tmpSurface = sge_rotate_scaled_surface(srcSurface,NUM2INT(angle),
323
- NUM2DBL(scale),colorkey);
324
- if( tmpSurface==NULL )
325
- rb_raise(eSDLError,"SDL memory allocate failed :%s",SDL_GetError());
326
- SDL_SetColorKey(tmpSurface,flags,colorkey);
327
- destRect.x=NUM2INT(x)-tmpSurface->h/2;
328
- destRect.y=NUM2INT(y)-tmpSurface->w/2;
329
- result = SDL_BlitSurface(tmpSurface,NULL,dstSurface,&destRect);
330
- SDL_FreeSurface(tmpSurface);
331
- if( result == -1 ){
332
- rb_raise(eSDLError,"SDL_BlitSurface fail: %s",SDL_GetError());
333
- }
334
- return INT2NUM(result);
335
- }
336
-
337
- static VALUE sdl_transform(VALUE mod,VALUE src,VALUE dst,VALUE angle,
338
- VALUE xscale,VALUE yscale,VALUE px,VALUE py,
339
- VALUE qx,VALUE qy,VALUE flags)
256
+ static VALUE Surface_s_transformDraw(VALUE klass, VALUE src, VALUE dst,
257
+ VALUE angle,
258
+ VALUE xscale, VALUE yscale,
259
+ VALUE px, VALUE py,
260
+ VALUE qx, VALUE qy,
261
+ VALUE flags)
340
262
  {
341
- SDL_Surface *srcSurface,*dstSurface;
342
- if( !rb_obj_is_kind_of(src,cSurface) || !rb_obj_is_kind_of(dst,cSurface) )
343
- rb_raise(rb_eArgError,"type mismatch(expect Surface)");
344
- Data_Get_Struct(src,SDL_Surface,srcSurface);
345
- Data_Get_Struct(dst,SDL_Surface,dstSurface);
346
- sge_transform(srcSurface,dstSurface,NUM2DBL(angle),NUM2DBL(xscale),
347
- NUM2DBL(yscale),NUM2INT(px),NUM2INT(py),NUM2INT(qx),
348
- NUM2INT(qy),NUM2UINT(flags));
263
+ rb_secure(4);
264
+ sge_transform(Get_SDL_Surface(src), Get_SDL_Surface(dst),
265
+ NUM2DBL(angle), NUM2DBL(xscale), NUM2DBL(yscale),
266
+ NUM2INT(px), NUM2INT(py), NUM2INT(qx), NUM2INT(qy),
267
+ NUM2UINT(flags));
349
268
  return Qnil;
350
269
  }
351
270
 
352
- static VALUE sdl_transformSurface(VALUE obj,VALUE bgcolor,VALUE angle,
353
- VALUE xscale,VALUE yscale,VALUE flags)
271
+ static VALUE Surface_transform(VALUE self, VALUE bgcolor, VALUE angle,
272
+ VALUE xscale, VALUE yscale, VALUE flags)
354
273
  {
355
- SDL_Surface *surface,*result;
356
- Data_Get_Struct(obj,SDL_Surface,surface);
357
- result = sge_transform_surface(surface,VALUE2COLOR(bgcolor,surface->format),
358
- NUM2DBL(angle),NUM2DBL(xscale),
359
- NUM2DBL(yscale),NUM2UINT(flags));
360
- if( result==NULL )
361
- rb_raise( eSDLError,"Couldn't Create Surface: %s",SDL_GetError() );
362
- return Data_Wrap_Struct(cSurface,0,sdl_freeSurface,result);
274
+ SDL_Surface *surface, *result;
275
+
276
+ rb_secure(4);
277
+ surface = Get_SDL_Surface(self);
278
+ result = sge_transform_surface(surface, VALUE2COLOR(bgcolor, surface->format),
279
+ NUM2DBL(angle), NUM2DBL(xscale),
280
+ NUM2DBL(yscale), NUM2UINT(flags));
281
+ if(result == NULL)
282
+ rb_raise(eSDLError, "Couldn't Create Surface: %s", SDL_GetError());
283
+ return Surface_create(result);
363
284
  }
364
285
 
365
- static VALUE sdl_makeCollisionMap(VALUE obj)
286
+ static VALUE Surface_makeCollisionMap(VALUE self)
366
287
  {
367
288
  sge_cdata * cdata;
368
- SDL_Surface *surface;
369
- Data_Get_Struct(obj,SDL_Surface,surface);
370
- cdata = sge_make_cmap(surface);
371
- if( cdata==NULL )
372
- rb_raise( eSDLError,"Couldn't Create CollisionMap: %s",SDL_GetError() );
373
- return Data_Wrap_Struct(cCollisionMap,0,sge_destroy_cmap,cdata);
289
+ rb_secure(4);
290
+ cdata = sge_make_cmap(Get_SDL_Surface(self));
291
+ if(cdata == NULL)
292
+ rb_raise(eSDLError, "Couldn't Create CollisionMap: %s", SDL_GetError());
293
+ return Data_Wrap_Struct(cCollisionMap, 0, sge_destroy_cmap, cdata);
374
294
  }
375
295
 
376
- static sge_cdata * value_to_collision_map(VALUE value)
377
- {
378
- sge_cdata * cdata;
379
- if( !rb_obj_is_kind_of(value, cCollisionMap) )
380
- rb_raise(rb_eArgError,"type mismatch(expect CollisionMap)");
381
- Data_Get_Struct(value, sge_cdata, cdata);
382
- return cdata;
383
- }
384
296
 
385
- static VALUE sdl_classBoundingBoxCheck(VALUE class,
386
- VALUE x1, VALUE y1, VALUE w1, VALUE h1,
387
- VALUE x2, VALUE y2, VALUE w2, VALUE h2)
297
+ static VALUE CollisionMap_s_boundingBoxCheck(VALUE klass,
298
+ VALUE x1, VALUE y1,
299
+ VALUE w1, VALUE h1,
300
+ VALUE x2, VALUE y2,
301
+ VALUE w2, VALUE h2)
388
302
  {
389
- return BOOL(_sge_bbcheck
390
- ((Sint16) NUM2INT(x1), (Sint16) NUM2INT(y1),
391
- (Sint16) NUM2INT(w1), (Sint16) NUM2INT(h1),
392
- (Sint16) NUM2INT(x2), (Sint16) NUM2INT(y2),
393
- (Sint16) NUM2INT(w2), (Sint16) NUM2INT(h2)));
303
+ return INT2BOOL(_sge_bbcheck
304
+ ((Sint16) NUM2INT(x1), (Sint16) NUM2INT(y1),
305
+ (Sint16) NUM2INT(w1), (Sint16) NUM2INT(h1),
306
+ (Sint16) NUM2INT(x2), (Sint16) NUM2INT(y2),
307
+ (Sint16) NUM2INT(w2), (Sint16) NUM2INT(h2)));
394
308
  }
395
309
 
396
- static VALUE sdl_collisionCheck(VALUE collisionMap1, VALUE x1, VALUE y1,
397
- VALUE collisionMap2, VALUE x2, VALUE y2)
310
+ static VALUE CollisionMap_collisionCheck(VALUE collisionMap1,
311
+ VALUE x1, VALUE y1,
312
+ VALUE collisionMap2,
313
+ VALUE x2, VALUE y2)
398
314
  {
399
- sge_cdata * cdata1 = value_to_collision_map(collisionMap1);
400
- sge_cdata * cdata2 = value_to_collision_map(collisionMap2);
315
+ sge_cdata * cdata1 = Get_sge_cdata(collisionMap1);
316
+ sge_cdata * cdata2 = Get_sge_cdata(collisionMap2);
401
317
  int collided;
402
318
  collided = sge_cmcheck
403
- (cdata1, (Sint16) NUM2INT(x1), (Sint16) NUM2INT(y1),
404
- cdata2, (Sint16) NUM2INT(x2), (Sint16) NUM2INT(y2));
319
+ (cdata1, (Sint16) NUM2INT(x1), (Sint16) NUM2INT(y1),
320
+ cdata2, (Sint16) NUM2INT(x2), (Sint16) NUM2INT(y2));
405
321
  if(!collided)
406
322
  return Qnil;
407
- return rb_ary_new3(2, INT2NUM(sge_get_cx()), INT2NUM(sge_get_cy()));
323
+ return rb_ary_new3(2, INT2NUM(sge_get_cx()), INT2NUM(sge_get_cy()));
408
324
  }
409
325
 
410
- static VALUE sdl_boundingBoxCheck(VALUE collisionMap1, VALUE x1, VALUE y1,
411
- VALUE collisionMap2, VALUE x2, VALUE y2)
326
+ static VALUE CollisionMap_boundingBoxCheck(VALUE collisionMap1,
327
+ VALUE x1, VALUE y1,
328
+ VALUE collisionMap2,
329
+ VALUE x2, VALUE y2)
412
330
  {
413
- sge_cdata * cdata1 = value_to_collision_map(collisionMap1);
414
- sge_cdata * cdata2 = value_to_collision_map(collisionMap2);
415
- return BOOL(sge_bbcheck
416
- (cdata1, (Sint16) NUM2INT(x1), (Sint16) NUM2INT(y1),
417
- cdata2, (Sint16) NUM2INT(x2), (Sint16) NUM2INT(y2)));
331
+ sge_cdata * cdata1 = Get_sge_cdata(collisionMap1);
332
+ sge_cdata * cdata2 = Get_sge_cdata(collisionMap2);
333
+ return INT2BOOL(sge_bbcheck
334
+ (cdata1, (Sint16) NUM2INT(x1), (Sint16) NUM2INT(y1),
335
+ cdata2, (Sint16) NUM2INT(x2), (Sint16) NUM2INT(y2)));
418
336
  }
419
337
 
420
- static VALUE sdl_set_cdata(VALUE obj, VALUE vx, VALUE vy, VALUE vw, VALUE vh)
338
+ static VALUE CollisionMap_set(VALUE self, VALUE vx, VALUE vy, VALUE vw, VALUE vh)
421
339
  {
422
- sge_cdata * cdata = value_to_collision_map(obj);
423
- Sint16 x, y, w, h;
424
-
340
+ sge_cdata * cdata = Get_sge_cdata(self);
341
+ Sint16 x, y, w, h;
342
+
343
+ rb_secure(4);
425
344
  x = NUM2INT(vx);
426
345
  y = NUM2INT(vy);
427
346
  w = NUM2INT(vw);
428
347
  h = NUM2INT(vh);
429
348
  if( x < 0 || y < 0 || x+w > cdata->w || y+h > cdata->h ){
430
- rb_raise(eSDLError,"Couldn't clear that area");
349
+ rb_raise(eSDLError, "Couldn't set that area");
431
350
  }
432
- sge_set_cdata(cdata, x, y, w, h );
351
+ sge_set_cdata(cdata, x, y, w, h);
433
352
  return Qnil;
434
353
  }
435
354
 
436
- static VALUE sdl_unset_cdata(VALUE obj, VALUE vx, VALUE vy, VALUE vw, VALUE vh)
355
+ static VALUE CollisionMap_clear(VALUE self, VALUE vx, VALUE vy, VALUE vw, VALUE vh)
437
356
  {
438
- sge_cdata * cdata = value_to_collision_map(obj);
439
- Sint16 x, y, w, h;
440
-
357
+ sge_cdata * cdata = Get_sge_cdata(self);
358
+ Sint16 x, y, w, h;
359
+
360
+ rb_secure(4);
441
361
  x = NUM2INT(vx);
442
362
  y = NUM2INT(vy);
443
363
  w = NUM2INT(vw);
444
364
  h = NUM2INT(vh);
445
365
  if( x < 0 || y < 0 || x+w > cdata->w || y+h > cdata->h ){
446
- rb_raise(eSDLError,"Couldn't clear that area");
366
+ rb_raise(eSDLError, "Couldn't clear that area");
447
367
  }
448
- sge_unset_cdata(cdata, x, y, w, h);
368
+ sge_unset_cdata(cdata, x, y, w, h);
449
369
  return Qnil;
450
370
  }
451
371
 
452
- static VALUE sdl_w_cdata(VALUE obj)
372
+ static VALUE CollisionMap_w(VALUE self)
453
373
  {
454
- sge_cdata * cdata = value_to_collision_map(obj);
455
- return INT2FIX(cdata->w);
374
+ return INT2FIX(Get_sge_cdata(self)->w);
456
375
  }
457
376
 
458
- static VALUE sdl_h_cdata(VALUE obj)
377
+ static VALUE CollisionMap_h(VALUE self)
459
378
  {
460
- sge_cdata * cdata = value_to_collision_map(obj);
461
- return INT2FIX(cdata->h);
379
+ return INT2FIX(Get_sge_cdata(self)->h);
462
380
  }
463
381
 
464
382
  /* bitmap font */
465
- static void sdl_bf_close(sge_bmpFont* font)
383
+ static void bf_close(sge_bmpFont* font)
466
384
  {
467
385
  if(!rubysdl_is_quit()){
468
386
  sge_BF_CloseFont(font);
469
387
  }
470
388
  }
471
389
 
472
- static VALUE sdl_bf_open(VALUE obj, VALUE file, VALUE flags)
390
+ static VALUE BMFont_open(VALUE klass, VALUE file, VALUE flags)
391
+
473
392
  {
474
393
  sge_bmpFont* font;
475
-
476
- font = sge_BF_OpenFont(GETCSTR(file),NUM2UINT(flags));
477
- if( font == NULL )
478
- rb_raise(eSDLError,"Couldn't open font: %s", GETCSTR(file));
394
+ rb_secure(4);
395
+ SafeStringValue(file);
396
+
397
+ font = sge_BF_OpenFont(RSTRING_PTR(file), NUM2UINT(flags));
398
+ if(font == NULL)
399
+ rb_raise(eSDLError, "Couldn't open font: %s", RSTRING_PTR(file));
479
400
 
480
- return Data_Wrap_Struct(cBMFont,0,sdl_bf_close,font);
401
+ return Data_Wrap_Struct(cBMFont, 0, bf_close, font);
481
402
  }
482
403
 
483
- static VALUE sdl_bf_setColor(VALUE obj,VALUE r,VALUE g,VALUE b)
404
+ static VALUE BMFont_setColor(VALUE self, VALUE r, VALUE g, VALUE b)
484
405
  {
485
- sge_bmpFont* font;
486
- Data_Get_Struct(obj,sge_bmpFont,font);
487
-
488
- sge_BF_SetColor(font,NUM2UINT(r),NUM2UINT(g),NUM2UINT(b));
406
+ sge_BF_SetColor(Get_sge_bmpFont(self),
407
+ NUM2UINT(r), NUM2UINT(g), NUM2UINT(b));
489
408
  return Qnil;
490
409
  }
491
410
 
492
- static VALUE sdl_bf_getHeight(VALUE obj)
411
+ static VALUE BMFont_getHeight(VALUE self)
493
412
  {
494
- sge_bmpFont* font;
495
- Data_Get_Struct(obj,sge_bmpFont,font);
496
- return INT2FIX(sge_BF_GetHeight(font));
413
+ return INT2FIX(sge_BF_GetHeight(Get_sge_bmpFont(self)));
497
414
  }
498
415
 
499
- static VALUE sdl_bf_getWidth(VALUE obj)
416
+ static VALUE BMFont_getWidth(VALUE self)
500
417
  {
501
- sge_bmpFont* font;
502
- Data_Get_Struct(obj,sge_bmpFont,font);
503
- return INT2FIX(sge_BF_GetWidth(font));
418
+ return INT2FIX(sge_BF_GetWidth(Get_sge_bmpFont(self)));
504
419
  }
505
420
 
506
- static VALUE sdl_bf_textSize(VALUE obj, VALUE text)
421
+ static VALUE BMFont_textSize(VALUE self, VALUE text)
507
422
  {
508
- sge_bmpFont* font;
509
423
  SDL_Rect rect;
510
- Data_Get_Struct(obj,sge_bmpFont,font);
511
- rect = sge_BF_TextSize(font, GETCSTR(text));
424
+ StringValue(text);
425
+ rect = sge_BF_TextSize(Get_sge_bmpFont(self),
426
+ RSTRING_PTR(text));
512
427
  return rb_ary_new3(2, INT2FIX(rect.w), INT2FIX(rect.h));
513
428
  }
514
429
 
515
- static VALUE sdl_bf_textout(VALUE obj,VALUE surface,VALUE string,
516
- VALUE x, VALUE y)
430
+ static VALUE BMFont_textout(VALUE self,
431
+ VALUE surface, VALUE string,
432
+ VALUE x, VALUE y)
433
+
517
434
  {
518
- sge_bmpFont* font;
519
- SDL_Surface* target;
435
+ rb_secure(4);
436
+ StringValue(string);
520
437
 
521
- if(!rb_obj_is_kind_of(surface,cSurface))
522
- rb_raise( rb_eArgError,"type mismatch(expect Surface)" );
523
- Data_Get_Struct(obj,sge_bmpFont,font);
524
- Data_Get_Struct(surface,SDL_Surface,target);
525
- sge_BF_textout(target,font,GETCSTR(string),NUM2INT(x),NUM2INT(y));
438
+ sge_BF_textout(Get_SDL_Surface(surface), Get_sge_bmpFont(self),
439
+ RSTRING_PTR(string), NUM2INT(x), NUM2INT(y));
526
440
  return Qnil;
527
441
  }
528
442
 
529
- static void defineConstForSGE()
530
- {
531
- rb_define_const(mSDL,"TRANSFORM_AA",UINT2NUM(SGE_TAA));
532
- rb_define_const(mSDL,"TRANSFORM_SAFE",UINT2NUM(SGE_TSAFE));
533
- rb_define_const(mSDL,"TRANSFORM_TMAP",UINT2NUM(SGE_TTMAP));
534
-
535
- rb_define_const(cBMFont,"TRANSPARENT",UINT2NUM(SGE_BFTRANSP));
536
- rb_define_const(cBMFont,"NOCONVERT",UINT2NUM(SGE_BFNOCONVERT));
537
- rb_define_const(cBMFont,"SFONT",UINT2NUM(SGE_BFSFONT));
538
- rb_define_const(cBMFont,"PALETTE",UINT2NUM(SGE_BFPALETTE));
539
- }
540
-
541
- void init_sge_video()
443
+ void rubysdl_init_sge(VALUE mSDL, VALUE cSurface)
542
444
  {
543
445
  sge_Update_OFF();
544
446
  sge_Lock_ON();
545
-
546
- rb_define_module_function(mSDL,"autoLock",sdl_get_autoLocking,0);
547
- rb_define_module_function(mSDL,"autoLock=",sdl_set_autoLocking,1);
548
-
549
- rb_define_method(cSurface,"getPixel",sdl_getPixel,2);
550
- rb_define_method(cSurface,"putPixel",sdl_putPixel,3);
551
- rb_define_method(cSurface,"[]",sdl_getPixel,2);
552
- rb_define_method(cSurface,"[]=",sdl_putPixel,3);
447
+
448
+ rb_define_module_function(cSurface, "autoLock?", Surface_s_autoLock_p, 0);
449
+ rb_define_module_function(cSurface, "autoLockON", Surface_s_autoLockON, 0);
450
+ rb_define_module_function(cSurface, "autoLockOFF", Surface_s_autoLockOFF, 0);
553
451
 
554
452
  /* primitive drawing */
555
- rb_define_method(cSurface,"drawLine",sdl_drawLine,5);
556
- rb_define_method(cSurface,"drawRect",sdl_drawRect,5);
557
- rb_define_method(cSurface,"drawCircle",sdl_drawCircle,4);
558
- rb_define_method(cSurface,"drawFilledCircle",sdl_drawFilledCircle,4);
559
- rb_define_method(cSurface,"drawEllispe",sdl_drawEllipse,5);
560
- rb_define_method(cSurface,"drawFilledEllispe",sdl_drawFilledEllipse,5);
561
- rb_define_method(cSurface,"drawEllipse",sdl_drawEllipse,5);
562
- rb_define_method(cSurface,"drawFilledEllipse",sdl_drawFilledEllipse,5);
563
- rb_define_method(cSurface,"drawBezier",sdl_drawBezier,10);
564
-
565
- /* antialiased primitive drawing */
566
- rb_define_method(cSurface,"drawAALine",sdl_drawAALine,5);
567
- rb_define_method(cSurface,"drawAACircle",sdl_drawAACircle,4);
568
- rb_define_method(cSurface,"drawAAFilledCircle",sdl_drawAAFilledCircle,4);
569
- rb_define_method(cSurface,"drawAAEllipse",sdl_drawAAEllipse,5);
570
- rb_define_method(cSurface,"drawAAFilledEllipse",sdl_drawAAFilledEllipse,5);
571
- rb_define_method(cSurface,"drawAABezier",sdl_drawAABezier,10);
572
-
573
- /* primitive drawing with alpha */
574
- rb_define_method(cSurface,"drawLineAlpha",sdl_drawLineAlpha,6);
575
- rb_define_method(cSurface,"drawRectAlpha",sdl_drawRectAlpha,6);
576
- rb_define_method(cSurface,"drawFilledRectAlpha",sdl_drawFilledRectAlpha,6);
577
- rb_define_method(cSurface,"drawCircleAlpha",sdl_drawCircleAlpha,5);
578
- rb_define_method(cSurface,"drawFilledCircleAlpha",sdl_drawFilledCircleAlpha,5);
579
- rb_define_method(cSurface,"drawEllipseAlpha",sdl_drawEllipseAlpha,6);
580
- rb_define_method(cSurface,"drawFilledEllipseAlpha",sdl_drawFilledEllipseAlpha,6);
581
- rb_define_method(cSurface,"drawBezierAlpha",sdl_drawBezierAlpha,11);
582
-
583
- /* antialiased primitive drawing with alpha */
584
- rb_define_method(cSurface,"drawAALineAlpha",sdl_drawAALineAlpha,6);
585
- rb_define_method(cSurface,"drawAACircleAlpha",sdl_drawAACircleAlpha,5);
586
- rb_define_method(cSurface,"drawAAEllipseAlpha",sdl_drawAAEllipseAlpha,6);
587
- rb_define_method(cSurface,"drawAABezierAlpha",sdl_drawAABezierAlpha,11);
588
-
589
- /* rotation and scaling */
590
- rb_define_method(cSurface,"rotateScaledSurface",sdl_rotateScaledSurface,3);
591
- rb_define_module_function(mSDL,"rotateScaledBlit",sdl_rotateScaledBlit,6);
592
- rb_define_module_function(mSDL,"rotateXYScaled",sdl_rotateXYScaled,7);
453
+ rb_define_method(cSurface, "drawLine", Surface_drawLine, -1);
454
+ rb_define_method(cSurface, "drawRect", Surface_drawRect, -1);
455
+ rb_define_method(cSurface, "drawCircle", Surface_drawCircle, -1);
456
+ rb_define_method(cSurface, "drawEllipse", Surface_drawEllipse, -1);
457
+ rb_define_method(cSurface, "drawBezier", Surface_drawBezier, -1);
593
458
 
594
- rb_define_module_function(mSDL,"transform",sdl_transform,10);
595
- rb_define_method(cSurface,"transformSurface",sdl_transformSurface,5);
459
+ /* rotation and scaling */
460
+ rb_define_module_function(cSurface, "transformDraw",
461
+ Surface_s_transformDraw, 10);
462
+ rb_define_method(cSurface, "transformSurface", Surface_transform, 5);
596
463
 
597
464
  /* collision detection */
598
- rb_define_method(cSurface,"makeCollisionMap", sdl_makeCollisionMap, 0);
599
-
600
- cCollisionMap = rb_define_class_under(mSDL,"CollisionMap",rb_cObject);
601
- rb_define_singleton_method(cCollisionMap,"boundingBoxCheck",
602
- sdl_classBoundingBoxCheck, 8);
603
- rb_define_method(cCollisionMap,"collisionCheck", sdl_collisionCheck, 5);
604
- rb_define_method(cCollisionMap,"boundingBoxCheck", sdl_boundingBoxCheck, 5);
605
- rb_define_method(cCollisionMap,"clear", sdl_unset_cdata, 4);
606
- rb_define_method(cCollisionMap,"set", sdl_set_cdata, 4);
607
- rb_define_method(cCollisionMap,"w", sdl_w_cdata, 0);
608
- rb_define_method(cCollisionMap,"h", sdl_h_cdata, 0);
465
+ cCollisionMap = rb_define_class_under(mSDL, "CollisionMap", rb_cObject);
466
+ rb_undef_alloc_func(cCollisionMap);
467
+
468
+ rb_define_method(cSurface, "makeCollisionMap", Surface_makeCollisionMap, 0);
469
+ rb_define_singleton_method(cCollisionMap, "boundingBoxCheck",
470
+ CollisionMap_s_boundingBoxCheck, 8);
471
+ rb_define_method(cCollisionMap, "collisionCheck",
472
+ CollisionMap_collisionCheck, 5);
473
+ rb_define_method(cCollisionMap, "boundingBoxCheck",
474
+ CollisionMap_boundingBoxCheck, 5);
475
+ rb_define_method(cCollisionMap, "clear", CollisionMap_clear, 4);
476
+ rb_define_method(cCollisionMap, "set", CollisionMap_set, 4);
477
+ rb_define_method(cCollisionMap, "w", CollisionMap_w, 0);
478
+ rb_define_method(cCollisionMap, "h", CollisionMap_h, 0);
479
+
609
480
 
610
481
  /* bitmap font */
611
- cBMFont = rb_define_class_under(mSDL,"BMFont",rb_cObject);
612
- rb_define_singleton_method(cBMFont,"open",sdl_bf_open,2);
482
+ cBMFont = rb_define_class_under(mSDL, "BMFont", rb_cObject);
483
+ rb_undef_alloc_func(cBMFont);
484
+
485
+ rb_define_singleton_method(cBMFont, "open", BMFont_open, 2);
486
+
487
+ rb_define_method(cBMFont, "setColor", BMFont_setColor, 3);
488
+ rb_define_method(cBMFont, "height", BMFont_getHeight, 0);
489
+ rb_define_method(cBMFont, "width", BMFont_getWidth, 0);
490
+ rb_define_method(cBMFont, "textSize", BMFont_textSize,1);
491
+ rb_define_method(cBMFont, "textout", BMFont_textout, 4);
613
492
 
614
- rb_define_method(cBMFont,"setColor",sdl_bf_setColor,3);
615
- rb_define_method(cBMFont,"height",sdl_bf_getHeight,0);
616
- rb_define_method(cBMFont,"width",sdl_bf_getWidth,0);
617
- rb_define_method(cBMFont,"textSize",sdl_bf_textSize, 1);
618
- rb_define_method(cBMFont,"textout",sdl_bf_textout,4);
619
493
 
620
- defineConstForSGE();
494
+ rb_define_const(cSurface, "TRANSFORM_AA", UINT2NUM(SGE_TAA));
495
+ rb_define_const(cSurface, "TRANSFORM_SAFE", UINT2NUM(SGE_TSAFE));
496
+ rb_define_const(cSurface, "TRANSFORM_TMAP", UINT2NUM(SGE_TTMAP));
497
+
498
+ rb_define_const(cBMFont, "TRANSPARENT", UINT2NUM(SGE_BFTRANSP));
499
+ rb_define_const(cBMFont, "NOCONVERT", UINT2NUM(SGE_BFNOCONVERT));
500
+ rb_define_const(cBMFont, "SFONT", UINT2NUM(SGE_BFSFONT));
501
+ rb_define_const(cBMFont, "PALETTE", UINT2NUM(SGE_BFPALETTE));
502
+ }
503
+ #else /* HAVE_SGE */
504
+ #include "rubysdl.h"
505
+ void rubysdl_init_sge(VALUE mSDL, VALUE cSurface)
506
+ {
621
507
  }
622
508
  #endif /* HAVE_SGE */