retrograph_easy 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/Rakefile +1 -1
  2. data/lib/retrograph/easy/display.rb +24 -5
  3. metadata +2 -2
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ rescue LoadError
9
9
  end
10
10
  require 'rake/clean'
11
11
 
12
- GEM_VERSION = '0.1'
12
+ GEM_VERSION = '0.1.1'
13
13
 
14
14
  task :clobber => [:clean]
15
15
 
@@ -92,8 +92,16 @@ class Display
92
92
 
93
93
  def open
94
94
  @sdl.init SDL::INIT_VIDEO
95
- info = @sdl::Screen.info
96
- @managed = info.wm_available
95
+
96
+ @managed = true
97
+ begin
98
+ info = @sdl::Screen.info
99
+ rescue NameError
100
+ # earlier versions of Ruby/SDL don't have SDL::Screen.info
101
+ info = nil
102
+ end
103
+ @managed = info.wm_available if info
104
+
97
105
  @vdu = @vdu_class.new
98
106
  @surface = @vdu.render_frame_sdl
99
107
  _set_mode
@@ -122,9 +130,20 @@ class Display
122
130
  end
123
131
  private :_bezel_func
124
132
 
133
+ def _surface_format(surface)
134
+ # compatibility with older Ruby/SDL versions, where surfaces do much
135
+ # of the work of PixelFormat objects
136
+ if @sdl::VERSION =~ /^1\./
137
+ surface
138
+ else
139
+ surface.format
140
+ end
141
+ end
142
+ private :_surface_format
143
+
125
144
  def _generate_bezel
126
- bezel_color = @bezel_image.format.map_rgb(8, 8, 8)
127
- clear_color = @bezel_image.format.map_rgb(255, 255, 255)
145
+ bezel_color = _surface_format(@bezel_image).map_rgb(8, 8, 8)
146
+ clear_color = _surface_format(@bezel_image).map_rgb(255, 255, 255)
128
147
  @bezel_image.fill_rect(0, 0, OUTPUT_WIDTH, OUTPUT_HEIGHT, clear_color)
129
148
  for i in 0...BEZEL_THICKNESS
130
149
  section = _bezel_func(i.to_f / (BEZEL_THICKNESS-1))
@@ -149,7 +168,7 @@ class Display
149
168
  flags |= SDL::FULLSCREEN if fullscreen?
150
169
  @screen = @sdl::Screen.open(OUTPUT_WIDTH, OUTPUT_HEIGHT, 32, flags)
151
170
  @bezel_image = @sdl::Surface.new(0, OUTPUT_WIDTH, OUTPUT_HEIGHT,
152
- @screen.format)
171
+ _surface_format(@screen))
153
172
  _generate_bezel
154
173
  @sdl::WM.set_caption(@title, @title)
155
174
  @sdl::Mouse.hide
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: retrograph_easy
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.1"
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - MenTaLguY <mental@rydia.net>
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-24 00:00:00 -04:00
12
+ date: 2009-07-25 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency