rubysdl 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/rubysdl_video.c CHANGED
@@ -237,7 +237,7 @@ static VALUE Screen_s_open(VALUE klass,VALUE w,VALUE h,VALUE bpp,
237
237
  screen=SDL_SetVideoMode(NUM2INT(w),NUM2INT(h),NUM2INT(bpp),
238
238
  NUM2UINT(flags));
239
239
  if( screen==NULL ){
240
- rb_raise(eSDLError,"Cound't set %dx%d %d bpp video mode: %s",
240
+ rb_raise(eSDLError,"Couldn't set %dx%d %d bpp video mode: %s",
241
241
  NUM2INT(w),NUM2INT(h),NUM2INT(bpp),SDL_GetError());
242
242
  }
243
243
  return Screen_create(screen);
@@ -340,7 +340,7 @@ static VALUE Surface_s_createFrom(VALUE klass,VALUE pixels,VALUE w,
340
340
  SDL_Surface *surface;
341
341
  void* pixel_data;
342
342
 
343
- StringValue(pixels);
343
+ SafeStringValue(pixels);
344
344
  pixel_data = ALLOC_N(char, RSTRING_LEN(pixels));
345
345
  memcpy(pixel_data,RSTRING_PTR(pixels),RSTRING_LEN(pixels));
346
346
 
@@ -359,7 +359,7 @@ static VALUE Surface_s_loadBMP(VALUE klass,VALUE filename)
359
359
  {
360
360
  SDL_Surface *image;
361
361
  rb_secure(4);
362
- SafeStringValue(filename);
362
+ ExportFilenameStringValue(filename);
363
363
 
364
364
  image = SDL_LoadBMP(RSTRING_PTR(filename));
365
365
  if(image == NULL){
@@ -398,7 +398,7 @@ static VALUE Surface_s_loadBMPFromString(VALUE class, VALUE str)
398
398
  static VALUE Surface_saveBMP(VALUE self,VALUE filename)
399
399
  {
400
400
  rb_secure(4);
401
- SafeStringValue(filename);
401
+ ExportFilenameStringValue(filename);
402
402
  if( SDL_SaveBMP(Get_SDL_Surface(self), RSTRING_PTR(filename))==-1 ){
403
403
  rb_raise(eSDLError,"cannot save %s: %s",RSTRING_PTR(filename),SDL_GetError());
404
404
  }
@@ -413,6 +413,11 @@ static VALUE Surface_destroy(VALUE self)
413
413
  sur->surface = NULL;
414
414
  return Qnil;
415
415
  }
416
+ static VALUE Surface_destroyed(VALUE self)
417
+ {
418
+ Surface* sur = GetSurface(self);
419
+ return INT2BOOL(sur->surface == NULL);
420
+ }
416
421
 
417
422
  static VALUE Surface_format(VALUE self)
418
423
  {
@@ -823,6 +828,7 @@ VALUE rubysdl_init_video(VALUE mSDL)
823
828
 
824
829
  rb_define_method(cSurface,"saveBMP",Surface_saveBMP,1);
825
830
  rb_define_method(cSurface,"destroy",Surface_destroy,0);
831
+ rb_define_method(cSurface,"destroyed?",Surface_destroyed,0);
826
832
  rb_define_method(cSurface,"displayFormat",Surface_displayFormat,0);
827
833
  rb_define_method(cSurface,"displayFormatAlpha",Surface_displayFormatAlpha,0);
828
834
  rb_define_method(cSurface,"setColorKey",Surface_setColorKey,2);
data/rubysdl_wm.c CHANGED
@@ -25,14 +25,19 @@ static VALUE WM_s_caption(VALUE mod)
25
25
 
26
26
  rb_secure(4);
27
27
  SDL_WM_GetCaption(&title, &icon);
28
+ #ifdef ENABLE_M17N
29
+ return rb_ary_new3(2,
30
+ ENC_STR_NEW2(title, utf8_enc),
31
+ ENC_STR_NEW2(icon, utf8_enc));
32
+ #else
28
33
  return rb_ary_new3(2, rb_str_new2(title), rb_str_new2(icon));
34
+ #endif
29
35
  }
30
36
  static VALUE WM_s_setCaption(VALUE mod, VALUE title, VALUE icon)
31
37
  {
32
38
  rb_secure(4);
33
- SafeStringValue(title);
34
- SafeStringValue(icon);
35
-
39
+ ExportStringValueToEnc(title, utf8_enc);
40
+ ExportStringValueToEnc(icon, utf8_enc);
36
41
  SDL_WM_SetCaption(RSTRING_PTR(title), RSTRING_PTR(icon));
37
42
  return Qnil;
38
43
  }
@@ -68,4 +73,5 @@ void rubysdl_init_WM(VALUE mSDL)
68
73
  rb_define_const(mWM, "GRAB_QUERY", INT2NUM(SDL_GRAB_QUERY));
69
74
  rb_define_const(mWM, "GRAB_OFF", INT2NUM(SDL_GRAB_OFF));
70
75
  rb_define_const(mWM, "GRAB_ON", INT2NUM(SDL_GRAB_ON));
76
+
71
77
  }
data/sample/font.rb CHANGED
@@ -18,6 +18,7 @@ loop do
18
18
  while event = SDL::Event2.poll
19
19
  case event
20
20
  when SDL::Event2::KeyDown, SDL::Event2::Quit
21
+ font.close
21
22
  exit
22
23
  end
23
24
  end
@@ -16,9 +16,9 @@ SDL::WM::setCaption('from_str.rb','from_str.rb')
16
16
 
17
17
  str = File.read("icon.bmp")
18
18
  img = SDL::Surface.loadBMPFromIO(StringIO.new(str))
19
- img2 = File.open("icon.bmp"){|f| SDL::Surface.loadBMPFromIO(f) }
19
+ img2 = File.open("icon.bmp", "rb"){|f| SDL::Surface.loadBMPFromIO(f) }
20
20
  img3 = Zlib::GzipReader.open("icon.bmp.gz"){|f| SDL::Surface.loadBMPFromIO(f) }
21
- img4 = File.open("icon.png"){|f| SDL::Surface.loadFromIO(f) }
21
+ img4 = File.open("icon.png", "rb"){|f| SDL::Surface.loadFromIO(f) }
22
22
 
23
23
  mus = SDL::Mixer::Music.loadFromString(File.read("track01.ogg"))
24
24
  wav = File.open('sample.wav'){|f| SDL::Mixer::Wave.loadFromIO(f) }
data/sample/plaympeg.rb CHANGED
@@ -33,15 +33,11 @@ loop do
33
33
  mpeg.play
34
34
  when SDL::Key::R
35
35
  mpeg.rewind
36
+ mpeg.play
36
37
  when SDL::Key::ESCAPE
37
38
  exit
38
39
  end
39
40
  end
40
-
41
- if mpeg.status != SDL::MPEG::PLAYING then
42
- mpeg.stop
43
- exit
44
- end
45
41
 
46
42
  sleep 0.1
47
43
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubysdl
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ohbayashi Ippei
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-23 00:00:00 +09:00
12
+ date: 2009-03-17 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  requirements: []
146
146
 
147
147
  rubyforge_project:
148
- rubygems_version: 1.0.1
148
+ rubygems_version: 1.2.0
149
149
  signing_key:
150
150
  specification_version: 2
151
151
  summary: The simple ruby extension library to use SDL