rubysdl 1.3.1 → 2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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_smpeg.c CHANGED
@@ -25,319 +25,318 @@
25
25
  #include "SDL_mixer.h"
26
26
  #endif
27
27
 
28
+ static VALUE cMPEG;
29
+ static VALUE cMPEGInfo;
30
+
28
31
  static SMPEG_Filter* filters[3];
29
32
  #define NULL_FILTER 0
30
33
  #define BILINEAR_FILTER 1
31
34
  #define DEBLOCKING_FILTER 2
32
35
  #define NUM_FILTERS 3
33
36
 
34
- static void setInfoToSMPEGInfo(VALUE obj,SMPEG_Info info)
37
+ typedef struct{
38
+ SMPEG* smpeg;
39
+ int audio_enable;
40
+ }MPEG;
41
+
42
+ DEFINE_GET_STRUCT(MPEG, Get_MPEG, cMPEG, "SDL::MPEG");
43
+
44
+ static SMPEG* Get_SMPEG(VALUE self)
45
+ {
46
+ MPEG* mpeg = Get_MPEG(self);
47
+ if(mpeg->smpeg)
48
+ return mpeg->smpeg;
49
+ else
50
+ rb_raise(eSDLError, "MPEG is already deleted");
51
+ /* NOT REACHED */
52
+ }
53
+
54
+ static void MPEG_free(MPEG* mpg)
55
+ {
56
+ if(!rubysdl_is_quit() && mpg->smpeg)
57
+ SMPEG_delete(mpg->smpeg);
58
+ free(mpg);
59
+ }
60
+
61
+ static VALUE MPEG_s_alloc(VALUE klass)
62
+ {
63
+ MPEG* mpg = ALLOC(MPEG);
64
+ mpg->smpeg = NULL;
65
+ mpg->audio_enable = 1;
66
+ return Data_Wrap_Struct(klass, 0, MPEG_free, mpg);
67
+ }
68
+
69
+ static VALUE MPEG_create(SMPEG* smpeg)
35
70
  {
36
- rb_iv_set(obj,"@has_audio",BOOL(info.has_audio));
37
- rb_iv_set(obj,"@has_video",BOOL(info.has_video));
38
- rb_iv_set(obj,"@width",INT2NUM(info.width));
39
- rb_iv_set(obj,"@height",INT2NUM(info.height));
40
- rb_iv_set(obj,"@current_frame",INT2NUM(info.current_frame));
41
- rb_iv_set(obj,"@current_fps",INT2NUM(info.current_fps));
42
- rb_iv_set(obj,"@audio_string",rb_str_new2(info.audio_string));
43
- rb_iv_set(obj,"@audio_current_frame",INT2NUM(info.audio_current_frame));
44
- rb_iv_set(obj,"@current_offset",UINT2NUM(info.current_offset));
45
- rb_iv_set(obj,"@total_size",UINT2NUM(info.total_size));
46
- rb_iv_set(obj,"@current_time",UINT2NUM(info.current_time));
47
- rb_iv_set(obj,"@total_time",UINT2NUM(info.total_time));
71
+ VALUE newobj = MPEG_s_alloc(cMPEG);
72
+ Get_MPEG(newobj)->smpeg = smpeg;
73
+ return newobj;
48
74
  }
49
75
 
50
- static VALUE smpeg_load(VALUE class,VALUE filename)
76
+ static VALUE MPEG_delete(VALUE self)
51
77
  {
52
- SMPEG *mpeg;
53
- VALUE obj;
78
+ MPEG* mpg = Get_MPEG(self);
79
+ SMPEG_delete(mpg->smpeg);
80
+ mpg->smpeg = NULL;
81
+ return Qnil;
82
+ }
83
+
84
+ static VALUE MPEG_s_load(VALUE klass, VALUE filename)
85
+ {
86
+ SMPEG *smpeg;
87
+ VALUE mpeg;
54
88
  char error_msg[2048];
55
-
56
- mpeg = SMPEG_new(GETCSTR(filename),NULL,0);
57
- if( SMPEG_error(mpeg) ){
58
- snprintf(error_msg,sizeof(error_msg),"Couldn't load %s: %s",
59
- GETCSTR(filename),SMPEG_error(mpeg));
60
- SMPEG_delete(mpeg);
61
- rb_raise(eSDLError,"%s",error_msg);
89
+
90
+ rb_secure(4);
91
+ SafeStringValue(filename);
92
+
93
+ smpeg = SMPEG_new(RSTRING_PTR(filename), NULL, 0);
94
+ if( SMPEG_error(smpeg) ){
95
+ snprintf(error_msg, sizeof(error_msg), "Couldn't load %s: %s",
96
+ RSTRING_PTR(filename), SMPEG_error(smpeg));
97
+ SMPEG_delete(smpeg);
98
+ rb_raise(eSDLError, "%s", error_msg);
62
99
  }
100
+ return MPEG_create(smpeg);
101
+ }
63
102
 
64
- obj = Data_Wrap_Struct(cMPEG,0,SMPEG_delete,mpeg);
65
- rb_iv_set(obj,"enable_audio",Qtrue);
103
+ static VALUE MPEGInfo_create(SMPEG_Info info)
104
+ {
105
+ VALUE obj = rb_obj_alloc(cMPEGInfo);
106
+
107
+ rb_iv_set(obj, "@has_audio", INT2BOOL(info.has_audio));
108
+ rb_iv_set(obj, "@has_video", INT2BOOL(info.has_video));
109
+ rb_iv_set(obj, "@width", INT2NUM(info.width));
110
+ rb_iv_set(obj, "@height", INT2NUM(info.height));
111
+ rb_iv_set(obj, "@current_frame", INT2NUM(info.current_frame));
112
+ rb_iv_set(obj, "@current_fps", INT2NUM(info.current_fps));
113
+ rb_iv_set(obj, "@audio_string", rb_str_new2(info.audio_string));
114
+ rb_iv_set(obj, "@audio_current_frame", INT2NUM(info.audio_current_frame));
115
+ rb_iv_set(obj, "@current_offset", UINT2NUM(info.current_offset));
116
+ rb_iv_set(obj, "@total_size", UINT2NUM(info.total_size));
117
+ rb_iv_set(obj, "@current_time", UINT2NUM(info.current_time));
118
+ rb_iv_set(obj, "@total_time", UINT2NUM(info.total_time));
66
119
  return obj;
67
120
  }
68
121
 
69
- static VALUE smpeg_getInfo(VALUE obj,VALUE infoObj)
122
+
123
+ static VALUE MPEG_info(VALUE self)
70
124
  {
71
- SMPEG *mpeg;
72
125
  SMPEG_Info info;
73
126
 
74
- if( !rb_obj_is_kind_of(infoObj,cMPEGInfo) )
75
- rb_raise(rb_eArgError,"type mismatch(expect SDL::MPEG::Info)");
76
- Data_Get_Struct(obj,SMPEG,mpeg);
77
-
78
- SMPEG_getinfo(mpeg,&info);
79
- setInfoToSMPEGInfo(infoObj,info);
80
-
81
- return Qnil;
127
+ SMPEG_getinfo(Get_SMPEG(self), &info);
128
+ return MPEGInfo_create(info);
82
129
  }
83
130
 
84
- static VALUE smpeg_enableAudio(VALUE obj,VALUE enable)
131
+ static VALUE MPEG_enableAudio(VALUE self, VALUE enable)
85
132
  {
86
- SMPEG *mpeg;
87
- Data_Get_Struct(obj,SMPEG,mpeg);
88
- rb_iv_set(obj,"enable_audio",enable);
133
+ Get_MPEG(self)->audio_enable = RTEST(enable);
89
134
  return Qnil;
90
135
  }
91
136
 
92
- static VALUE smpeg_enableVideo(VALUE obj,VALUE enable)
137
+ static VALUE MPEG_enableVideo(VALUE self, VALUE enable)
93
138
  {
94
- SMPEG *mpeg;
95
- Data_Get_Struct(obj,SMPEG,mpeg);
96
- SMPEG_enablevideo(mpeg,RTEST(enable));
139
+ SMPEG_enablevideo(Get_SMPEG(self), RTEST(enable));
97
140
  return Qnil;
98
141
  }
99
142
 
100
- static VALUE smpeg_status(VALUE obj)
143
+ static VALUE MPEG_status(VALUE self)
101
144
  {
102
- SMPEG *mpeg;
103
- Data_Get_Struct(obj,SMPEG,mpeg);
104
- return INT2FIX(SMPEG_status(mpeg));
145
+ return INT2FIX(SMPEG_status(Get_SMPEG(self)));
105
146
  }
106
147
 
107
- static VALUE smpeg_setVolume(VALUE obj,VALUE volume)
148
+ static VALUE MPEG_setVolume(VALUE self, VALUE volume)
108
149
  {
109
- SMPEG *mpeg;
110
- Data_Get_Struct(obj,SMPEG,mpeg);
111
- SMPEG_setvolume(mpeg,NUM2INT(volume));
150
+ SMPEG_setvolume(Get_SMPEG(self), NUM2INT(volume));
112
151
  return Qnil;
113
152
  }
114
153
 
115
- static VALUE smpeg_setDisplay(VALUE obj,VALUE dst)
154
+ static VALUE MPEG_setDisplay(VALUE self, VALUE dst)
116
155
  {
117
- SMPEG *mpeg;
118
- SDL_Surface *surface;
119
- if( !rb_obj_is_kind_of(dst,cSurface) )
120
- rb_raise(rb_eArgError,"type mismatchi(expect Surface)");
121
-
122
- Data_Get_Struct(obj,SMPEG,mpeg);
123
- Data_Get_Struct(dst,SDL_Surface,surface);
124
-
125
- SMPEG_setdisplay(mpeg,surface,NULL,NULL);
126
- rb_iv_set(obj,"surface",dst);
156
+ SMPEG_setdisplay(Get_SMPEG(self),
157
+ Get_SDL_Surface(dst), NULL, NULL);
158
+ rb_iv_set(self, "display", dst);
127
159
  return Qnil;
128
160
  }
129
161
 
130
- static VALUE smpeg_setLoop(VALUE obj,VALUE repeat)
162
+ static VALUE MPEG_setLoop(VALUE self, VALUE repeat)
131
163
  {
132
- SMPEG *mpeg;
133
- Data_Get_Struct(obj,SMPEG,mpeg);
134
- SMPEG_loop(mpeg,RTEST(repeat));
164
+ SMPEG_loop(Get_SMPEG(self), RTEST(repeat));
135
165
  return Qnil;
136
166
  }
137
167
 
138
- static VALUE smpeg_scaleXY(VALUE obj,VALUE w,VALUE h)
168
+ static VALUE MPEG_scaleXY(VALUE self, VALUE w, VALUE h)
139
169
  {
140
- SMPEG *mpeg;
141
- Data_Get_Struct(obj,SMPEG,mpeg);
142
- SMPEG_scaleXY(mpeg,NUM2INT(w),NUM2INT(h));
170
+ SMPEG_scaleXY(Get_SMPEG(self), NUM2INT(w), NUM2INT(h));
143
171
  return Qnil;
144
172
  }
145
173
 
146
- static VALUE smpeg_scale(VALUE obj,VALUE scale)
174
+ static VALUE MPEG_scale(VALUE self, VALUE scale)
147
175
  {
148
- SMPEG *mpeg;
149
- Data_Get_Struct(obj,SMPEG,mpeg);
150
- SMPEG_scale(mpeg,NUM2INT(scale));
176
+ SMPEG_scale(Get_SMPEG(self), NUM2INT(scale));
151
177
  return Qnil;
152
178
  }
153
179
 
154
- static VALUE smpeg_move(VALUE obj,VALUE x,VALUE y)
180
+ static VALUE MPEG_move(VALUE self, VALUE x, VALUE y)
155
181
  {
156
- SMPEG *mpeg;
157
- Data_Get_Struct(obj,SMPEG,mpeg);
158
- SMPEG_move(mpeg,NUM2INT(x),NUM2INT(y));
182
+ SMPEG_move(Get_SMPEG(self), NUM2INT(x), NUM2INT(y));
159
183
  return Qnil;
160
184
  }
161
185
 
162
- static VALUE smpeg_setDisplayRegion(VALUE obj,VALUE x,VALUE y,VALUE w,
186
+ static VALUE MPEG_setDisplayRegion(VALUE self, VALUE x, VALUE y, VALUE w,
163
187
  VALUE h)
164
188
  {
165
- SMPEG *mpeg;
166
- Data_Get_Struct(obj,SMPEG,mpeg);
167
- SMPEG_setdisplayregion(mpeg,NUM2INT(x),NUM2INT(y),NUM2INT(w),NUM2INT(h));
189
+ SMPEG_setdisplayregion(Get_SMPEG(self), NUM2INT(x), NUM2INT(y),
190
+ NUM2INT(w), NUM2INT(h));
168
191
  return Qnil;
169
192
  }
170
193
 
171
- static VALUE smpeg_play(VALUE obj)
194
+ static VALUE MPEG_play(VALUE self)
172
195
  {
173
- SMPEG *mpeg;
196
+ SMPEG *mpeg = Get_SMPEG(self);
174
197
  int use_audio;
175
198
 
176
- Data_Get_Struct(obj,SMPEG,mpeg);
177
-
178
199
  #ifdef HAVE_SDL_MIXER
179
- use_audio = RTEST(rb_iv_get(obj,"enable_audio")) &&
180
- Mix_QuerySpec( NULL, NULL, NULL );
181
-
200
+ use_audio = Get_MPEG(self)->audio_enable && Mix_QuerySpec(NULL, NULL, NULL);
182
201
  if( use_audio ){
183
202
  SDL_AudioSpec audiofmt;
184
203
  Uint16 format;
185
- int freq, channels;
204
+ int freq, channels;
186
205
 
187
- SMPEG_enableaudio(mpeg, 0);
206
+ SMPEG_enableaudio(mpeg, 0);
188
207
  /* Tell SMPEG what the audio format is */
189
- Mix_QuerySpec(&freq, &format, &channels);
208
+ Mix_QuerySpec(&freq, &format, &channels);
190
209
  audiofmt.format = format;
191
210
  audiofmt.freq = freq;
192
211
  audiofmt.channels = channels;
193
- SMPEG_actualSpec(mpeg, &audiofmt);
212
+ SMPEG_actualSpec(mpeg, &audiofmt);
194
213
 
195
214
  /* Hook in the MPEG music mixer */
196
- Mix_HookMusic(NULL,NULL);
197
- Mix_HookMusic(SMPEG_playAudioSDL, mpeg);
198
- SMPEG_enableaudio(mpeg, 1);
215
+ Mix_HookMusic(NULL, NULL);
216
+ Mix_HookMusic(SMPEG_playAudioSDL, mpeg);
217
+ SMPEG_enableaudio(mpeg, 1);
199
218
  }
200
219
  #else
201
- SMPEG_enableaudio(mpeg, RTEST(rb_iv_get(obj,"enable_audio")));
220
+ SMPEG_enableaudio(mpeg, Get_MPEG(self)->audio_enable);
202
221
  #endif
203
222
 
204
223
  SMPEG_play(mpeg);
205
224
  return Qnil;
206
225
  }
207
226
 
208
- static VALUE smpeg_pause(VALUE obj)
227
+ static VALUE MPEG_pause(VALUE self)
209
228
  {
210
- SMPEG *mpeg;
211
- Data_Get_Struct(obj,SMPEG,mpeg);
212
- SMPEG_pause(mpeg);
229
+ SMPEG_pause(Get_SMPEG(self));
213
230
  return Qnil;
214
231
  }
215
232
 
216
- static VALUE smpeg_stop(VALUE obj)
233
+ static VALUE MPEG_stop(VALUE self)
217
234
  {
218
- SMPEG *mpeg;
219
- Data_Get_Struct(obj,SMPEG,mpeg);
220
- SMPEG_stop(mpeg);
235
+ SMPEG_stop(Get_SMPEG(self));
221
236
  #ifdef HAVE_SDL_MIXER
222
237
  Mix_HookMusic(NULL,NULL);
223
238
  #endif
224
239
  return Qnil;
225
240
  }
226
241
 
227
- static VALUE smpeg_rewind(VALUE obj)
242
+ static VALUE MPEG_rewind(VALUE self)
228
243
  {
229
- SMPEG *mpeg;
230
- Data_Get_Struct(obj,SMPEG,mpeg);
231
- SMPEG_rewind(mpeg);
244
+ SMPEG_rewind(Get_SMPEG(self));
232
245
  return Qnil;
233
246
  }
234
247
 
235
- static VALUE smpeg_seek(VALUE obj,VALUE bytes)
248
+ static VALUE MPEG_seek(VALUE self, VALUE bytes)
236
249
  {
237
- SMPEG *mpeg;
238
- Data_Get_Struct(obj,SMPEG,mpeg);
239
- SMPEG_seek(mpeg,NUM2INT(bytes));
250
+ SMPEG_seek(Get_SMPEG(self), NUM2INT(bytes));
240
251
  return Qnil;
241
252
  }
242
253
 
243
- static VALUE smpeg_skip(VALUE obj,VALUE seconds)
254
+ static VALUE MPEG_skip(VALUE self, VALUE seconds)
244
255
  {
245
- SMPEG *mpeg;
246
- Data_Get_Struct(obj,SMPEG,mpeg);
247
- SMPEG_skip(mpeg,NUM2DBL(seconds));
256
+ SMPEG_skip(Get_SMPEG(self), NUM2DBL(seconds));
248
257
  return Qnil;
249
258
  }
250
259
 
251
- static VALUE smpeg_renderFrame(VALUE obj,VALUE framenum)
260
+ static VALUE MPEG_renderFrame(VALUE self, VALUE framenum)
252
261
  {
253
- SMPEG *mpeg;
254
- Data_Get_Struct(obj,SMPEG,mpeg);
255
- SMPEG_renderFrame(mpeg,NUM2INT(framenum));
262
+ SMPEG_renderFrame(Get_SMPEG(self), NUM2INT(framenum));
256
263
  return Qnil;
257
264
  }
258
265
 
259
- static VALUE smpeg_renderFinal(VALUE obj,VALUE dst, VALUE x, VALUE y)
266
+ static VALUE MPEG_renderFinal(VALUE self, VALUE dst,
267
+ VALUE x, VALUE y)
260
268
  {
261
- SMPEG *mpeg;
262
- SDL_Surface *surface;
263
- if( !rb_obj_is_kind_of(dst,cSurface) )
264
- rb_raise(rb_eArgError,"type mismatchi(expect Surface)");
265
-
266
- Data_Get_Struct(obj,SMPEG,mpeg);
267
- Data_Get_Struct(dst,SDL_Surface,surface);
268
-
269
- SMPEG_renderFinal(mpeg, surface, NUM2INT(x), NUM2INT(y));
269
+ SMPEG_renderFinal(Get_SMPEG(self), Get_SDL_Surface(dst),
270
+ NUM2INT(x), NUM2INT(y));
270
271
  return Qnil;
271
272
  }
272
-
273
- static VALUE smpeg_setFilter(VALUE obj,VALUE filter)
273
+
274
+ static VALUE MPEG_setFilter(VALUE self, VALUE filter)
274
275
  {
275
- SMPEG *mpeg;
276
-
277
- Data_Get_Struct(obj,SMPEG,mpeg);
278
276
  if( (NUM2INT(filter)<0) || (NUM2INT(filter)>=NUM_FILTERS) )
279
- rb_raise(eSDLError,"There isn't that filter");
280
- SMPEG_filter(mpeg,filters[NUM2INT(filter)]);
277
+ rb_raise(eSDLError, "There isn't that filter");
278
+ SMPEG_filter(Get_SMPEG(self), filters[NUM2INT(filter)]);
281
279
  return Qnil;
282
280
  }
283
281
 
284
- static void defineConstForSMPEG()
285
- {
286
- rb_define_const(cMPEG,"ERROR",INT2FIX(SMPEG_ERROR));
287
- rb_define_const(cMPEG,"STOPPED",INT2FIX(SMPEG_STOPPED));
288
- rb_define_const(cMPEG,"PLAYING",INT2FIX(SMPEG_PLAYING));
289
- rb_define_const(cMPEG,"NULL_FILTER",INT2FIX(NULL_FILTER));
290
- rb_define_const(cMPEG,"BILINEAR_FILTER",INT2FIX(BILINEAR_FILTER));
291
- rb_define_const(cMPEG,"DEBLOCKING_FILTER",INT2FIX(DEBLOCKING_FILTER));
292
- }
293
-
294
- void init_smpeg()
282
+ void rubysdl_init_MPEG(VALUE mSDL)
295
283
  {
296
- cMPEG = rb_define_class_under(mSDL,"MPEG",rb_cObject);
297
- cMPEGInfo = rb_define_class_under(cMPEG,"Info",rb_cObject);
284
+ cMPEG = rb_define_class_under(mSDL, "MPEG", rb_cObject);
285
+ cMPEGInfo = rb_define_class_under(cMPEG, "Info", rb_cObject);
298
286
 
287
+ rb_define_alloc_func(cMPEG, MPEG_s_alloc);
288
+
299
289
  filters[NULL_FILTER] = SMPEGfilter_null();
300
290
  filters[BILINEAR_FILTER] = SMPEGfilter_bilinear();
301
291
  filters[DEBLOCKING_FILTER] = SMPEGfilter_deblocking();
302
-
303
- defineConstForSMPEG();
304
-
305
- rb_define_attr(cMPEGInfo,"has_audio",1,0);
306
- rb_define_attr(cMPEGInfo,"has_video",1,0);
307
- rb_define_attr(cMPEGInfo,"width",1,0);
308
- rb_define_attr(cMPEGInfo,"height",1,0);
309
- rb_define_attr(cMPEGInfo,"current_frame",1,0);
310
- rb_define_attr(cMPEGInfo,"current_fps",1,0);
311
- rb_define_attr(cMPEGInfo,"audio_string",1,0);
312
- rb_define_attr(cMPEGInfo,"audio_current_frame",1,0);
313
- rb_define_attr(cMPEGInfo,"current_offset",1,0);
314
- rb_define_attr(cMPEGInfo,"total_size",1,0);
315
- rb_define_attr(cMPEGInfo,"current_time",1,0);
316
- rb_define_attr(cMPEGInfo,"total_time",1,0);
317
-
318
- rb_define_singleton_method(cMPEG,"load",smpeg_load,1);
319
- rb_define_singleton_method(cMPEG,"new",smpeg_load,1);
320
-
321
- rb_define_method(cMPEG,"info",smpeg_getInfo,1);
322
- rb_define_method(cMPEG,"enableAudio",smpeg_enableAudio,1);
323
- rb_define_method(cMPEG,"enableVideo",smpeg_enableVideo,1);
324
- rb_define_method(cMPEG,"status",smpeg_status,0);
325
- rb_define_method(cMPEG,"setVolume",smpeg_setVolume,1);
326
- rb_define_method(cMPEG,"setDisplay",smpeg_setDisplay,1);
327
- rb_define_method(cMPEG,"setLoop",smpeg_setLoop,1);
328
- rb_define_method(cMPEG,"scaleXY",smpeg_scaleXY,2);
329
- rb_define_method(cMPEG,"scale",smpeg_scale,1);
330
- rb_define_method(cMPEG,"move",smpeg_move,1);
331
- rb_define_method(cMPEG,"setDisplayRegion",smpeg_setDisplayRegion,4);
332
- rb_define_method(cMPEG,"play",smpeg_play,0);
333
- rb_define_method(cMPEG,"pause",smpeg_pause,0);
334
- rb_define_method(cMPEG,"stop",smpeg_stop,0);
335
- rb_define_method(cMPEG,"rewind",smpeg_rewind,0);
336
- rb_define_method(cMPEG,"seek",smpeg_seek,1);
337
- rb_define_method(cMPEG,"skip",smpeg_skip,1);
338
- rb_define_method(cMPEG,"renderFrame",smpeg_renderFrame,1);
339
- rb_define_method(cMPEG,"renderFinal",smpeg_renderFinal,3);
340
- rb_define_method(cMPEG,"setFilter",smpeg_setFilter,1);
341
292
 
293
+ rb_define_attr(cMPEGInfo, "has_audio", 1, 0);
294
+ rb_define_attr(cMPEGInfo, "has_video", 1, 0);
295
+ rb_define_attr(cMPEGInfo, "width", 1, 0);
296
+ rb_define_attr(cMPEGInfo, "height", 1, 0);
297
+ rb_define_attr(cMPEGInfo, "current_frame", 1, 0);
298
+ rb_define_attr(cMPEGInfo, "current_fps", 1, 0);
299
+ rb_define_attr(cMPEGInfo, "audio_string", 1, 0);
300
+ rb_define_attr(cMPEGInfo, "audio_current_frame", 1, 0);
301
+ rb_define_attr(cMPEGInfo, "current_offset", 1, 0);
302
+ rb_define_attr(cMPEGInfo, "total_size", 1, 0);
303
+ rb_define_attr(cMPEGInfo, "current_time", 1, 0);
304
+ rb_define_attr(cMPEGInfo, "total_time", 1, 0);
305
+
306
+ rb_define_singleton_method(cMPEG, "load", MPEG_s_load, 1);
307
+
308
+ rb_define_method(cMPEG, "info", MPEG_info, 0);
309
+ rb_define_method(cMPEG, "delete", MPEG_delete, 0);
310
+ rb_define_method(cMPEG, "enableAudio", MPEG_enableAudio, 1);
311
+ rb_define_method(cMPEG, "enableVideo", MPEG_enableVideo, 1);
312
+ rb_define_method(cMPEG, "status", MPEG_status, 0);
313
+ rb_define_method(cMPEG, "setVolume", MPEG_setVolume, 1);
314
+ rb_define_method(cMPEG, "setDisplay", MPEG_setDisplay, 1);
315
+ rb_define_method(cMPEG, "setLoop", MPEG_setLoop, 1);
316
+ rb_define_method(cMPEG, "scaleXY", MPEG_scaleXY, 2);
317
+ rb_define_method(cMPEG, "scale", MPEG_scale, 1);
318
+ rb_define_method(cMPEG, "move", MPEG_move, 1);
319
+ rb_define_method(cMPEG, "setDisplayRegion", MPEG_setDisplayRegion, 4);
320
+ rb_define_method(cMPEG, "play", MPEG_play, 0);
321
+ rb_define_method(cMPEG, "pause", MPEG_pause, 0);
322
+ rb_define_method(cMPEG, "stop", MPEG_stop, 0);
323
+ rb_define_method(cMPEG, "rewind", MPEG_rewind, 0);
324
+ rb_define_method(cMPEG, "seek", MPEG_seek, 1);
325
+ rb_define_method(cMPEG, "skip", MPEG_skip, 1);
326
+ rb_define_method(cMPEG, "renderFrame", MPEG_renderFrame, 1);
327
+ rb_define_method(cMPEG, "renderFinal", MPEG_renderFinal, 3);
328
+ rb_define_method(cMPEG, "setFilter", MPEG_setFilter, 1);
329
+
330
+ rb_define_const(cMPEG, "ERROR", INT2FIX(SMPEG_ERROR));
331
+ rb_define_const(cMPEG, "STOPPED", INT2FIX(SMPEG_STOPPED));
332
+ rb_define_const(cMPEG, "PLAYING", INT2FIX(SMPEG_PLAYING));
333
+ rb_define_const(cMPEG, "NULL_FILTER", INT2FIX(NULL_FILTER));
334
+ rb_define_const(cMPEG, "BILINEAR_FILTER", INT2FIX(BILINEAR_FILTER));
335
+ rb_define_const(cMPEG, "DEBLOCKING_FILTER", INT2FIX(DEBLOCKING_FILTER));
336
+ }
337
+ #else
338
+ #include "rubysdl.h"
339
+ void rubysdl_init_MPEG(VALUE mSDL)
340
+ {
342
341
  }
343
342
  #endif /* HAVE_SMPEG */