rubygame 2.2.0 → 2.3.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.
- data/NEWS +55 -4
- data/README +23 -39
- data/ROADMAP +85 -19
- data/Rakefile +49 -20
- data/doc/windows_install.rdoc +1 -1
- data/ext/rubygame/rubygame_image.c +145 -1
- data/ext/rubygame/rubygame_main.h +6 -3
- data/ext/rubygame/rubygame_mixer.c +323 -63
- data/ext/rubygame/rubygame_mixer.h +5 -31
- data/ext/rubygame/rubygame_music.c +1017 -0
- data/ext/rubygame/rubygame_music.h +29 -0
- data/ext/rubygame/rubygame_shared.c +63 -0
- data/ext/rubygame/rubygame_shared.h +8 -0
- data/ext/rubygame/rubygame_sound.c +863 -0
- data/ext/rubygame/rubygame_sound.h +29 -0
- data/ext/rubygame/rubygame_surface.c +4 -0
- data/lib/rubygame/color/models/base.rb +5 -0
- data/lib/rubygame/named_resource.rb +254 -0
- data/samples/chimp.rb +52 -63
- data/samples/demo_gl.rb +0 -0
- data/samples/demo_gl_tex.rb +0 -0
- data/samples/demo_music.rb +10 -8
- data/samples/demo_rubygame.rb +15 -3
- data/samples/demo_sfont.rb +0 -0
- data/samples/demo_ttf.rb +0 -0
- data/samples/demo_utf8.rb +0 -0
- metadata +55 -45
- data/ext/rubygame/MANIFEST +0 -25
- data/lib/rubygame/MANIFEST +0 -12
data/NEWS
CHANGED
@@ -1,4 +1,55 @@
|
|
1
|
-
|
1
|
+
= NEWS
|
2
|
+
|
3
|
+
== Rubygame 2.3.0
|
4
|
+
|
5
|
+
Release focus: Media resources.
|
6
|
+
|
7
|
+
=== Features
|
8
|
+
|
9
|
+
- Add: Rubygame::NamedResource mixin module
|
10
|
+
- Provides per-class resource repository and on-demand auto-loading
|
11
|
+
behavior.
|
12
|
+
|
13
|
+
- Add: Rubygame::Music class.
|
14
|
+
- Intended as a full replacement for Rubygame::Mixer::Music.
|
15
|
+
- Includes NamedResources mixin.
|
16
|
+
- NOTE: Requires SDL_mixer support.
|
17
|
+
|
18
|
+
- Add: Rubygame::Sound class.
|
19
|
+
- Intended as a full replacement for Rubygame::Mixer::Sample.
|
20
|
+
- Includes NamedResources mixin.
|
21
|
+
- NOTE: Requires SDL_mixer support.
|
22
|
+
|
23
|
+
- Update: Rubygame::Surface class.
|
24
|
+
- Includes NamedResources mixin.
|
25
|
+
- Add: Surface.load_from_string (NOTE: Requires SDL_image support.)
|
26
|
+
|
27
|
+
=== Fixes
|
28
|
+
|
29
|
+
- ColorBase had been accidently placed in the top level namespace in
|
30
|
+
Rubygame 2.2.0. It is now correctly placed in the Rubygame::Color
|
31
|
+
module.
|
32
|
+
|
33
|
+
=== Other Stuff
|
34
|
+
|
35
|
+
- Deprecation (will be removed in Rubygame 3.0):
|
36
|
+
- Rubygame::Mixer module and methods are deprecated.
|
37
|
+
- Rubygame::Mixer::Music class is deprecated.
|
38
|
+
Use Rubygame::Music class instead.
|
39
|
+
- Rubygame::Mixer::Sample class is deprecated.
|
40
|
+
Use Rubygame::Sound class instead.
|
41
|
+
- Rubygame::Surface.load_image is deprecated.
|
42
|
+
Use Rubygame::Surface.load instead.
|
43
|
+
|
44
|
+
- NOTE: Run ruby with -w flag or set $_v = true to enable run-time
|
45
|
+
deprecation warnings.
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
== Rubygame 2.2.0
|
51
|
+
|
52
|
+
Release focus: Colors.
|
2
53
|
|
3
54
|
=== Features
|
4
55
|
|
@@ -36,7 +87,7 @@
|
|
36
87
|
|
37
88
|
|
38
89
|
|
39
|
-
==
|
90
|
+
== Rubygame 2.1.0
|
40
91
|
|
41
92
|
=== Features
|
42
93
|
|
@@ -82,7 +133,7 @@
|
|
82
133
|
|
83
134
|
|
84
135
|
|
85
|
-
==
|
136
|
+
== Rubygame 2.0.1
|
86
137
|
|
87
138
|
=== Bug Fixes
|
88
139
|
|
@@ -103,7 +154,7 @@
|
|
103
154
|
|
104
155
|
|
105
156
|
|
106
|
-
==
|
157
|
+
== Rubygame 2.0.0:
|
107
158
|
|
108
159
|
*NOTICE*: version 2.0.0 is not totally backward-compatible with 1.1.0.
|
109
160
|
You may have to update existing applications to the new syntax.
|
data/README
CHANGED
@@ -8,24 +8,15 @@
|
|
8
8
|
worrying about low-level technical details, you can focus your energy on
|
9
9
|
more interesting things (like making a fun game).
|
10
10
|
|
11
|
-
Rubygame's core is written in C to bind low-level SDL functions
|
12
|
-
On top of that is a pure
|
11
|
+
Rubygame's core is written in C to bind low-level SDL functions into Ruby.
|
12
|
+
On top of that is a pure Ruby library for higher-level behavior like
|
13
13
|
event and game object management.
|
14
14
|
|
15
|
-
There are two other Ruby-SDL bindings which are worth mentioning: Ruby/SDL
|
16
|
-
and RUDL. Ruby/SDL is a simple wrapper which closely mirrors SDL's C API,
|
17
|
-
while RUDL tries to provide some high-level concepts.
|
18
|
-
The main differences with Rubygame come down to a matter of priorities:
|
19
|
-
a great deal of care and effort goes into making Rubygame especially clean,
|
20
|
-
well-documented, powerful, and easy to use.
|
21
|
-
|
22
15
|
=== Relevant Links
|
23
16
|
1. Rubygame: http://rubygame.sourceforge.net
|
24
17
|
2. Ruby: http://www.ruby-lang.org
|
25
18
|
3. Pygame: http://www.pygame.org
|
26
19
|
4. SDL: http://www.libsdl.org
|
27
|
-
5. Ruby/SDL: http://www.kmc.gr.jp/~ohai/rubysdl.en.html
|
28
|
-
6. RUDL: http://rudl.sourceforge.net
|
29
20
|
|
30
21
|
== Requirements
|
31
22
|
|
@@ -72,32 +63,33 @@
|
|
72
63
|
The build and install tasks can be configured by providing certain commands
|
73
64
|
to rake:
|
74
65
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
66
|
+
no-sdl-gfx:: do not build modules which depend on SDL_gfx
|
67
|
+
no-sdl-image:: do not build modules which depend on SDL_image
|
68
|
+
no-sdl-mixer:: do not build modules which depend on SDL_mixer
|
69
|
+
no-sdl-ttf:: do not build modules which depend on SDL_ttf
|
70
|
+
no-opengl:: do not build modules which depend on OpenGL
|
80
71
|
|
81
|
-
|
72
|
+
no-sdl-config:: do not guess compiler/linker flags using `sdl-config'
|
82
73
|
|
83
|
-
|
84
|
-
|
74
|
+
debug:: build modules with debbugging flags enabled
|
75
|
+
universal:: on MacOS X, try to compile for both PPC and Intel
|
76
|
+
verbose:: display the build commands as they are run
|
85
77
|
|
86
78
|
Additionally, the build process respects certain environmental variables.
|
87
79
|
In particular, CFLAGS and LDFLAGS are important for users compiling with
|
88
80
|
the no-sdl-config command.
|
89
81
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
82
|
+
CC:: C compiler command
|
83
|
+
CFLAGS:: flags passed to the C compiler
|
84
|
+
LDSHARED:: linker command
|
85
|
+
LDFLAGS:: flags passed to the linker
|
86
|
+
RUBYARCHDIR:: where to install platform-specific compiled extensions
|
87
|
+
RUBYLIBDIR:: where to install platform-independent interpreted libs
|
96
88
|
|
97
89
|
IMPORTANT: if you are missing any optional SDL_* libraries, you must specify
|
98
90
|
"no-*" flags for those libraries. For example, if you don't have SDL_gfx:
|
99
91
|
|
100
|
-
$ rake no-gfx build
|
92
|
+
$ rake no-sdl-gfx build
|
101
93
|
|
102
94
|
If you don't disable the features, the compile will probably fail when it
|
103
95
|
looks for the headers and libraries. (The build system is not smart enough to
|
@@ -114,26 +106,18 @@
|
|
114
106
|
|
115
107
|
== Usage
|
116
108
|
|
117
|
-
|
118
|
-
|
119
|
-
require 'rubygame'
|
120
|
-
|
121
|
-
You will probably also want a display window and event queue:
|
122
|
-
|
123
|
-
screen = Rubygame::Screen.new( [640,480] )
|
124
|
-
queue = Rubygame::EventQueue.new()
|
109
|
+
See the documentation (online at http://rubygame.sourceforge.net, or
|
110
|
+
generated locally with the 'rake rdoc' command).
|
125
111
|
|
126
|
-
|
127
|
-
|
128
|
-
'rake rdoc' command). You should also take a peek at the demo applications
|
129
|
-
in the 'samples' directory.
|
112
|
+
We also recommend that you take a peek at the demo applications in
|
113
|
+
the 'samples' directory, especially chimp.rb.
|
130
114
|
|
131
115
|
== License
|
132
116
|
|
133
117
|
Rubygame is distributed under the terms of the GNU Lesser GPL.
|
134
118
|
See LICENSE for more details.
|
135
119
|
|
136
|
-
Some of the sample files are distributed under other
|
120
|
+
Some of the sample files are distributed under licenses other than the
|
137
121
|
GNU Lesser GPL. See 'samples/README' and 'samples/GPL' for more details.
|
138
122
|
|
139
123
|
John Croisant (jacius at users.sourceforge.net)
|
data/ROADMAP
CHANGED
@@ -1,24 +1,92 @@
|
|
1
1
|
= ROADMAP
|
2
2
|
|
3
|
-
|
3
|
+
This represents the direction Rubygame will be going in, but
|
4
|
+
keep in mind that specific details may change over time.
|
4
5
|
|
5
|
-
- Backwards compatibility will be broken:
|
6
|
-
- Surface#get_at
|
7
|
-
- Sprites::Group#collide_group
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
== 2.4.0 (next minor release)
|
8
|
+
|
9
|
+
Release focus: Events.
|
10
|
+
|
11
|
+
- New EventHook class, has 3 parts: owner, trigger, and action.
|
12
|
+
- New trigger classes, e.g. KeyPressedTrigger (matches key presses)
|
13
|
+
- New action classes, e.g. MethodAction (calls a method on owner)
|
14
|
+
|
15
|
+
- New EventHandler class
|
16
|
+
- Holds many EventHook instances, feeds the event to each
|
17
|
+
matching hook.
|
18
|
+
|
19
|
+
- New HasEventHandler mixin, can embed in sprite, etc. classes
|
20
|
+
for easy event handling and hook creation.
|
21
|
+
|
22
|
+
- New Events module, with a suite of new and revised event classes.
|
23
|
+
|
24
|
+
- Eliminate integer constants in favor of symbols
|
25
|
+
- Keyboard keys are symbols (e.g. :up, :a, :space)
|
26
|
+
- Mouse buttons are symbols (e.g. :mouse_left, :mouse_wheel_up)
|
27
|
+
|
28
|
+
- Nicer, more natural naming scheme
|
29
|
+
- Drop the word "Event" from the class names.
|
30
|
+
- "Down" and "Up" (e.g. in KeyDownEvent) become "Pressed"
|
31
|
+
and "Released" (e.g. KeyPressed).
|
32
|
+
- MouseMotionEvent becomes MouseMoved.
|
33
|
+
- Other miscellaneous changes.
|
34
|
+
|
35
|
+
- Better unicode / international keyboard support
|
36
|
+
- KeyPress#string gives a UTF8 bytestring with the glyph that was
|
37
|
+
generated by the keypress (useful for text input in GUIs).
|
38
|
+
|
39
|
+
- Old versions of the event classes stay the same, but are deprecated.
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
== 2.X.0 (_possible_ minor releases before 3.0.0)
|
44
|
+
|
45
|
+
=== Focus: Time
|
12
46
|
|
13
|
-
-
|
47
|
+
- New Events::Tick class with lots of information
|
48
|
+
- Time since last frame, in both seconds and milliseconds.
|
49
|
+
- Current time
|
50
|
+
- Current framerate
|
14
51
|
|
15
|
-
-
|
16
|
-
-
|
52
|
+
- New clock class
|
53
|
+
- Based on Ruby's timer (allows multi-threading).
|
54
|
+
- Better framerate calculation algorithm
|
55
|
+
- #tick returns an instance of Events::Tick.
|
56
|
+
|
57
|
+
=== Focus: Sprites
|
58
|
+
|
59
|
+
- New sprite system
|
60
|
+
- New Sprite, Scene, and Camera classes.
|
61
|
+
- More powerful and simpler to use.
|
62
|
+
- Integration with the Chipmunk physics library.
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
== 3.0.0 (next major release)
|
67
|
+
|
68
|
+
- Backwards compatibility is broken:
|
69
|
+
- Deprecated classes / methods retired:
|
70
|
+
- Rubygame::Mixer module.
|
71
|
+
- Rubygame::Mixer::Sample class. Use Rubygame::Sound.
|
72
|
+
- Rubygame::Mixer::Music class. Use Rubygame::Music.
|
73
|
+
- Rubygame::Surface.load_image method. User Rubygame::Surface.load.
|
74
|
+
- Surface#get_at
|
75
|
+
- Sprites::Group#collide_group
|
17
76
|
|
18
77
|
- Change Sprites::Group#collide_group to scrap the 'killa/killb' stuff,
|
19
78
|
take a block instead.
|
20
79
|
|
21
|
-
|
80
|
+
|
81
|
+
|
82
|
+
== On the horizon...
|
83
|
+
|
84
|
+
- Polygon, circle, and other geometric primitives
|
85
|
+
- Drawing, with styles?
|
86
|
+
- OpenGL drawing?
|
87
|
+
- Collision detection?
|
88
|
+
- Physical shapes w/ Chipmunk?
|
89
|
+
- Generate bounding Polygon from an image automatically?
|
22
90
|
|
23
91
|
- Path (Curve?) (graphs/plots for tracing position and other uses)
|
24
92
|
- Can find the position N units along the path.
|
@@ -27,17 +95,15 @@
|
|
27
95
|
- BezierPath (chain of continuous cubic Bézier curves)
|
28
96
|
- CodePath (calculated from a code block)
|
29
97
|
|
30
|
-
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
-
|
35
|
-
|
36
|
-
- Flesh out Rect unit tests.
|
98
|
+
- Effect (Action?)
|
99
|
+
- "Attach" to an instance, does something over time.
|
100
|
+
- E.g. moves a sprite from point A to point B over N seconds.
|
101
|
+
- Many types of effects, easy to define custom ones.
|
102
|
+
- Takes parameters: start/end time, others depending on effect.
|
37
103
|
|
38
104
|
- C equivalent of Rect.new_from_object (see rect.rb)
|
39
105
|
- Screen#update (cannot pass object with rect attribute)
|
40
106
|
- Screen#update_rects (same as above)
|
41
107
|
- Why not just call the ruby function from within C?
|
42
108
|
|
43
|
-
|
109
|
+
|
data/Rakefile
CHANGED
@@ -48,11 +48,11 @@ end
|
|
48
48
|
OBJEXT = from_env_or_config("OBJEXT")
|
49
49
|
DLEXT = from_env_or_config("DLEXT")
|
50
50
|
|
51
|
-
RUBYGAME_VERSION =
|
51
|
+
RUBYGAME_VERSION = [2,3,0]
|
52
52
|
|
53
|
-
|
53
|
+
gem_spec = Gem::Specification.new do |s|
|
54
54
|
s.name = "rubygame"
|
55
|
-
s.version = RUBYGAME_VERSION
|
55
|
+
s.version = RUBYGAME_VERSION.join(".")
|
56
56
|
s.author = "John Croisant"
|
57
57
|
s.email = "jacius@users.sourceforge.net"
|
58
58
|
s.homepage = "http://rubygame.sourceforge.net/"
|
@@ -66,7 +66,6 @@ spec = Gem::Specification.new do |s|
|
|
66
66
|
end
|
67
67
|
|
68
68
|
s.require_paths = ["lib", "lib/rubygame/", "ext/rubygame/"]
|
69
|
-
s.autorequire = "rubygame.rb"
|
70
69
|
s.extensions = ["Rakefile"]
|
71
70
|
|
72
71
|
s.extra_rdoc_files = FileList.new do |fl|
|
@@ -75,25 +74,17 @@ spec = Gem::Specification.new do |s|
|
|
75
74
|
end
|
76
75
|
end
|
77
76
|
|
78
|
-
task :
|
79
|
-
|
77
|
+
task :binary do
|
78
|
+
gem_spec.platform = Gem::Platform::CURRENT
|
80
79
|
end
|
81
80
|
|
82
|
-
|
83
|
-
spec.platform = Gem::Platform::DARWIN
|
84
|
-
end
|
85
|
-
|
86
|
-
task :win32 do
|
87
|
-
spec.platform = Gem::Platform::WIN32
|
88
|
-
end
|
89
|
-
|
90
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
81
|
+
Rake::GemPackageTask.new(gem_spec) do |pkg|
|
91
82
|
pkg.need_tar_bz2 = true
|
92
83
|
end
|
93
84
|
|
94
85
|
Rake::RDocTask.new do |rd|
|
95
86
|
rd.main = "README"
|
96
|
-
rd.title = "Rubygame #{RUBYGAME_VERSION} Docs"
|
87
|
+
rd.title = "Rubygame #{RUBYGAME_VERSION.join(".")} Docs"
|
97
88
|
rd.rdoc_files.include("ext/rubygame/*.c",
|
98
89
|
"lib/rubygame/**/*.rb",
|
99
90
|
"doc/*.rdoc",
|
@@ -123,6 +114,7 @@ $options = {
|
|
123
114
|
:"sdl-mixer" => true,
|
124
115
|
:opengl => true,
|
125
116
|
:"sdl-config" => true,
|
117
|
+
:universal => false,
|
126
118
|
:debug => false,
|
127
119
|
:verbose => false,
|
128
120
|
:sitearchdir => CONFIG["sitearchdir"],
|
@@ -186,8 +178,9 @@ bool_option :"sdl-mixer", nil, "SDL_mixer support"
|
|
186
178
|
bool_option :"sdl-ttf", nil, "SDL_ttf support"
|
187
179
|
bool_option :"sdl-config", nil, "guess compiler flags for SDL"
|
188
180
|
bool_option :opengl, nil, "OpenGL support"
|
189
|
-
bool_option :debug, nil, "
|
181
|
+
bool_option :debug, nil, "compile with debug symbols"
|
190
182
|
bool_option :verbose, nil, "show compiler commands"
|
183
|
+
bool_option :universal, nil, "universal binary (MacOS X Intel)"
|
191
184
|
|
192
185
|
string_option "RUBYARCHDIR", :sitearchdir
|
193
186
|
string_option :sitearchdir
|
@@ -199,7 +192,11 @@ string_option :sitelibdir
|
|
199
192
|
CFLAGS = [from_env_or_config("CFLAGS"),
|
200
193
|
try_sdl_config("--cflags"),
|
201
194
|
"-I. -I#{CONFIG['topdir']}",
|
202
|
-
("-g" if $options[:debug])
|
195
|
+
("-g" if $options[:debug]),
|
196
|
+
"-DRUBYGAME_MAJOR_VERSION=#{RUBYGAME_VERSION[0]}",
|
197
|
+
"-DRUBYGAME_MINOR_VERSION=#{RUBYGAME_VERSION[1]}",
|
198
|
+
"-DRUBYGAME_PATCHLEVEL=#{RUBYGAME_VERSION[2]}"
|
199
|
+
].join(" ")
|
203
200
|
|
204
201
|
LINK_FLAGS = [from_env_or_config("LIBRUBYARG_SHARED"),
|
205
202
|
from_env_or_config("LDFLAGS"),
|
@@ -241,7 +238,7 @@ class ExtensionModule
|
|
241
238
|
#
|
242
239
|
# This is done so that the prerequisites don't have to be compiled when
|
243
240
|
# the final product already exists (such as in the precompiled win32 gem).
|
244
|
-
|
241
|
+
#
|
245
242
|
def create_dl_task
|
246
243
|
dynlib_full = File.join( @directory, "#{dynlib}.#{DLEXT}" )
|
247
244
|
objs_full = @objs.collect { |obj|
|
@@ -250,7 +247,16 @@ class ExtensionModule
|
|
250
247
|
|
251
248
|
desc "Compile the #{@dynlib} extension"
|
252
249
|
file dynlib_full => objs_full do |task|
|
250
|
+
|
253
251
|
link_command = "#{from_env_or_config('LDSHARED')} #{LINK_FLAGS} #{@lflags} -o #{dynlib_full} #{task.prerequisites.join(' ')}"
|
252
|
+
|
253
|
+
|
254
|
+
# If link command includes i386 arch, and we're not allowing universal
|
255
|
+
if( /-arch i386/ === link_command and not $options[:universal] )
|
256
|
+
# Strip "-arch ppc" to prevent building a universal binary.
|
257
|
+
link_command.gsub!("-arch ppc","")
|
258
|
+
end
|
259
|
+
|
254
260
|
if( $options[:verbose] )
|
255
261
|
try_shell { sh link_command }
|
256
262
|
else
|
@@ -276,7 +282,15 @@ class ExtensionModule
|
|
276
282
|
end
|
277
283
|
])\
|
278
284
|
do |t|
|
285
|
+
|
279
286
|
compile_command = "#{from_env_or_config('CC')} -c #{CFLAGS} #{t.source} -o #{t.name}"
|
287
|
+
|
288
|
+
# If compile command includes i386 arch, and we're not allowing universal
|
289
|
+
if( /-arch i386/ === compile_command and not $options[:universal] )
|
290
|
+
# Strip "-arch ppc" to prevent building a universal binary.
|
291
|
+
compile_command.gsub!("-arch ppc","")
|
292
|
+
end
|
293
|
+
|
280
294
|
if( $options[:verbose] )
|
281
295
|
try_shell { sh compile_command }
|
282
296
|
else
|
@@ -350,7 +364,7 @@ end
|
|
350
364
|
|
351
365
|
rubygame_mixer = ExtensionModule.new do |mixer|
|
352
366
|
mixer.dynlib = 'rubygame_mixer'
|
353
|
-
mixer.objs = ['rubygame_shared', 'rubygame_mixer']
|
367
|
+
mixer.objs = ['rubygame_shared', 'rubygame_mixer', 'rubygame_sound', 'rubygame_music']
|
354
368
|
mixer.add_lib('SDL_mixer')
|
355
369
|
mixer.add_header('SDL_mixer.h')
|
356
370
|
mixer.create_all_tasks() if $options[:"sdl-mixer"]
|
@@ -407,3 +421,18 @@ end
|
|
407
421
|
|
408
422
|
desc "Install both the extensions and the library"
|
409
423
|
task :install => [:install_ext, :install_lib]
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
begin
|
428
|
+
require 'spec/rake/spectask'
|
429
|
+
|
430
|
+
desc "Run all specs (tests)"
|
431
|
+
Spec::Rake::SpecTask.new do |t|
|
432
|
+
t.spec_files = FileList['test/*_spec.rb']
|
433
|
+
end
|
434
|
+
rescue LoadError
|
435
|
+
task :spec do
|
436
|
+
puts "ERROR: RSpec is not installed?"
|
437
|
+
end
|
438
|
+
end
|
data/doc/windows_install.rdoc
CHANGED
@@ -113,7 +113,7 @@ disable optional features by passing a "no-???" command to rake before the word
|
|
113
113
|
type this instead of the above:
|
114
114
|
|
115
115
|
envsetup.bat
|
116
|
-
rake no-gfx install
|
116
|
+
rake no-sdl-gfx install
|
117
117
|
|
118
118
|
If all goes well, you have built and installed Rubygame.
|
119
119
|
Try to execute <code>require 'rubygame'</code> in an irb session and run
|
@@ -26,11 +26,64 @@
|
|
26
26
|
|
27
27
|
void Rubygame_Init_Image();
|
28
28
|
VALUE rbgm_image_load(VALUE, VALUE);
|
29
|
+
VALUE rbgm_from_string(int, VALUE*, VALUE);
|
29
30
|
|
30
31
|
/*
|
31
32
|
* call-seq:
|
32
33
|
* Surface.load_image( filename ) -> Surface
|
33
34
|
*
|
35
|
+
* **NOTE:** This method name is DEPRECATED and will be removed in
|
36
|
+
* Rubygame 3.0. Please use the Surface.load instead.
|
37
|
+
*
|
38
|
+
* Load an image file from the disk to a Surface. If the image has an alpha
|
39
|
+
* channel (e.g. PNG with transparency), the Surface will as well. If the
|
40
|
+
* image cannot be loaded (for example if the image format is unsupported),
|
41
|
+
* will raise SDLError.
|
42
|
+
*
|
43
|
+
* This method is only usable if Rubygame was compiled with the SDL_image
|
44
|
+
* library; you can check Rubygame::VERSIONS[:sdl_image] to see if it was.
|
45
|
+
*
|
46
|
+
* This method takes this argument:
|
47
|
+
* filename:: a string containing the relative or absolute path to the
|
48
|
+
* image file. The file must have the proper file extension,
|
49
|
+
* as it is used to determine image format.
|
50
|
+
*
|
51
|
+
* These formats may be supported, but some may not be available on a
|
52
|
+
* particular system.
|
53
|
+
* BMP:: "Windows Bitmap" format.
|
54
|
+
* GIF:: "Graphics Interchange Format."
|
55
|
+
* JPG:: "Independent JPEG Group" format.
|
56
|
+
* LBM:: "Linear Bitmap" format (?)
|
57
|
+
* PCX:: "PC Paintbrush" format
|
58
|
+
* PNG:: "Portable Network Graphics" format.
|
59
|
+
* PNM:: "Portable Any Map" format. (i.e., PPM, PGM, or PBM)
|
60
|
+
* TGA:: "Truevision TARGA" format.
|
61
|
+
* TIF:: "Tagged Image File Format"
|
62
|
+
* XCF:: "eXperimental Computing Facility" (GIMP native format).
|
63
|
+
* XPM:: "XPixMap" format.
|
64
|
+
*/
|
65
|
+
VALUE rbgm_image_load_image( VALUE class, VALUE filename )
|
66
|
+
{
|
67
|
+
|
68
|
+
/* This feature will be removed in Rubygame 3.0. */
|
69
|
+
rg_deprecated("Rubygame::Surface.load_image", "3.0");
|
70
|
+
|
71
|
+
char *name;
|
72
|
+
SDL_Surface *surf;
|
73
|
+
|
74
|
+
name = StringValuePtr(filename);
|
75
|
+
surf = IMG_Load( name );
|
76
|
+
if(surf == NULL)
|
77
|
+
{
|
78
|
+
rb_raise(eSDLError,"Couldn't load image `%s': %s", name, IMG_GetError());
|
79
|
+
}
|
80
|
+
return Data_Wrap_Struct( cSurface,0,SDL_FreeSurface,surf );
|
81
|
+
}
|
82
|
+
|
83
|
+
/*
|
84
|
+
* call-seq:
|
85
|
+
* Surface.load( filename ) -> Surface
|
86
|
+
*
|
34
87
|
* Load an image file from the disk to a Surface. If the image has an alpha
|
35
88
|
* channel (e.g. PNG with transparency), the Surface will as well. If the
|
36
89
|
* image cannot be loaded (for example if the image format is unsupported),
|
@@ -72,6 +125,91 @@ VALUE rbgm_image_load( VALUE class, VALUE filename )
|
|
72
125
|
return Data_Wrap_Struct( cSurface,0,SDL_FreeSurface,surf );
|
73
126
|
}
|
74
127
|
|
128
|
+
|
129
|
+
/*
|
130
|
+
* call-seq:
|
131
|
+
* Surface.autoload( filename ) -> Surface or nil
|
132
|
+
*
|
133
|
+
* Searches each directory in Surface.autoload_dirs for a file with
|
134
|
+
* the given filename. If it finds that file, loads it and returns
|
135
|
+
* a Surface instance. If it doesn't find the file, returns nil.
|
136
|
+
*
|
137
|
+
* See Rubygame::NamedResource for more information about this
|
138
|
+
* functionality.
|
139
|
+
*
|
140
|
+
*/
|
141
|
+
VALUE rbgm_image_autoload( VALUE class, VALUE namev )
|
142
|
+
{
|
143
|
+
VALUE pathv = rb_funcall( class, rb_intern("find_file"), 1, namev );
|
144
|
+
|
145
|
+
if( RTEST(pathv) )
|
146
|
+
{
|
147
|
+
return rbgm_image_load( class, pathv );
|
148
|
+
}
|
149
|
+
else
|
150
|
+
{
|
151
|
+
return Qnil;
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
/*
|
156
|
+
* call-seq:
|
157
|
+
* Surface.load_from_string( data [,type] ) -> Surface
|
158
|
+
*
|
159
|
+
* Load an image file from memory (in the form of the given data) to a Surface.
|
160
|
+
* If the image has an alpha channel (e.g. PNG with transparency), the Surface
|
161
|
+
* will as well. If the image cannot be loaded (for example if the image
|
162
|
+
* format is unsupported), will raise SDLError.
|
163
|
+
*
|
164
|
+
* This method is only usable if Rubygame was compiled with the SDL_image
|
165
|
+
* library; you can check Rubygame::VERSIONS[:sdl_image] to see if it was.
|
166
|
+
*
|
167
|
+
* This method takes these arguments:
|
168
|
+
* data:: a string containing the data for the image, such as IO::read would
|
169
|
+
* return.
|
170
|
+
* type:: The type of file that the image is (i.e. 'TGA'). Case is not
|
171
|
+
* important. If absent, the library will try to automatically
|
172
|
+
* detect the type.
|
173
|
+
*
|
174
|
+
* These formats may be supported, but some may not be available on a
|
175
|
+
* particular system.
|
176
|
+
* BMP:: "Windows Bitmap" format.
|
177
|
+
* GIF:: "Graphics Interchange Format."
|
178
|
+
* JPG:: "Independent JPEG Group" format.
|
179
|
+
* LBM:: "Linear Bitmap" format (?)
|
180
|
+
* PCX:: "PC Paintbrush" format
|
181
|
+
* PNG:: "Portable Network Graphics" format.
|
182
|
+
* PNM:: "Portable Any Map" format. (i.e., PPM, PGM, or PBM)
|
183
|
+
* TGA:: "Truevision TARGA" format.
|
184
|
+
* TIF:: "Tagged Image File Format"
|
185
|
+
* XCF:: "eXperimental Computing Facility" (GIMP native format).
|
186
|
+
* XPM:: "XPixMap" format.
|
187
|
+
*/
|
188
|
+
VALUE rbgm_image_load_from_string( int argc, VALUE *argv, VALUE obj)
|
189
|
+
{
|
190
|
+
Check_Type(argv[0], T_STRING);
|
191
|
+
/* There's probably a better way of using a string as raw data than this,
|
192
|
+
* but I don't know it. */
|
193
|
+
void *raw = (void *)RSTRING_PTR(argv[0]);
|
194
|
+
int len = RSTRING_LEN(argv[0]);
|
195
|
+
|
196
|
+
SDL_RWops *rw = SDL_RWFromMem(raw,len);
|
197
|
+
|
198
|
+
SDL_Surface *surf;
|
199
|
+
if(argc > 1) {
|
200
|
+
Check_Type(argv[1], T_STRING);
|
201
|
+
surf = IMG_LoadTyped_RW(rw, 1,StringValuePtr(argv[1]));
|
202
|
+
} else {
|
203
|
+
surf = IMG_Load_RW(rw,1);
|
204
|
+
}
|
205
|
+
|
206
|
+
if(surf == NULL)
|
207
|
+
{
|
208
|
+
rb_raise(eSDLError,"Couldn't load image from string: %s", IMG_GetError());
|
209
|
+
}
|
210
|
+
return Data_Wrap_Struct( cSurface, 0, SDL_FreeSurface, surf);
|
211
|
+
}
|
212
|
+
|
75
213
|
/*
|
76
214
|
* Document-class: Rubygame::Surface
|
77
215
|
*
|
@@ -85,6 +223,9 @@ VALUE rbgm_image_load( VALUE class, VALUE filename )
|
|
85
223
|
* Screen (which is a special type of Surface) and then using Screen#update,
|
86
224
|
* you can make images appear for the player to see.
|
87
225
|
*
|
226
|
+
* As of Rubygame 2.3.0, Surface includes the Rubygame::NamedResource mixin
|
227
|
+
* module, which can perform autoloading of images on demand, among other
|
228
|
+
* things.
|
88
229
|
*/
|
89
230
|
void Init_rubygame_image()
|
90
231
|
{
|
@@ -104,5 +245,8 @@ void Init_rubygame_image()
|
|
104
245
|
INT2NUM(SDL_IMAGE_PATCHLEVEL)));
|
105
246
|
|
106
247
|
/* Image methods */
|
107
|
-
rb_define_singleton_method(cSurface,"load_image",
|
248
|
+
rb_define_singleton_method(cSurface, "load_image", rbgm_image_load_image, 1);
|
249
|
+
rb_define_singleton_method(cSurface, "load", rbgm_image_load, 1);
|
250
|
+
rb_define_singleton_method(cSurface, "autoload", rbgm_image_autoload, 1);
|
251
|
+
rb_define_singleton_method(cSurface, "load_from_string", rbgm_image_load_from_string, -1);
|
108
252
|
}
|
@@ -21,13 +21,16 @@
|
|
21
21
|
#ifndef _RUBYGAME_H
|
22
22
|
#define _RUBYGAME_H
|
23
23
|
|
24
|
-
#
|
24
|
+
#ifndef RUBYGAME_MAJOR_VERSION
|
25
|
+
|
26
|
+
#define RUBYGAME_MAJOR_VERSION 0
|
25
27
|
#define RUBYGAME_MINOR_VERSION 0
|
26
|
-
#define RUBYGAME_PATCHLEVEL
|
28
|
+
#define RUBYGAME_PATCHLEVEL 0
|
29
|
+
|
30
|
+
#endif
|
27
31
|
|
28
32
|
extern VALUE rbgm_keyname(VALUE, VALUE);
|
29
33
|
extern VALUE rbgm_init(VALUE);
|
30
34
|
extern VALUE rbgm_quit(VALUE);
|
31
|
-
extern void Define_Rubygame_Constants();
|
32
35
|
|
33
36
|
#endif
|