ogre.rb 0.1-i386-mswin32 → 0.2-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -4,7 +4,7 @@ Welcome to Ogre.rb, the Ruby wrapper around the Ogre rendering engine. This curr
4
4
  known to build and run correctly on Linux, though I expect this will work just fine on Mac as well.
5
5
  Windows support will come later.
6
6
 
7
- Ogre.rb is currently built for Ruby 1.8.5+ and Ogre 1.4.x (Eihort)
7
+ Ogre.rb is currently built for Ruby 1.8.5+ and Ogre 1.4.4 (Eihort)
8
8
 
9
9
  == Usage
10
10
 
@@ -24,13 +24,12 @@ The samples/ directory is a direct port of the Ogre sample programs.
24
24
  == Contributing
25
25
 
26
26
  Please post patches, feature requests, bug fixes to the rubyforge website at http://rubyforge.org/projects/ogrerb.
27
- As I'm not sure exactly how to unit test such a wrapper, it will be greatly appreciated if changes are proven as
28
- part of a sample application.
27
+ All patches will be considered but those with tests, if possible, are recommended.
29
28
 
30
29
  == Build Requirements
31
30
 
32
31
  * rake
33
- * Ogre 1.4.x (Eihort)
32
+ * Ogre 1.4.4 (Eihort)
34
33
  * OIS
35
34
  * swig 1.3.31+ (uses -autorename)
36
35
  * pkg-config (Linux)
@@ -45,7 +44,18 @@ The resulting files can be found in ogrerb/lib.
45
44
 
46
45
  === Mac
47
46
 
48
- TODO
47
+ rake build_all
48
+
49
+ If you get an error about OIS framework not being installed, you can download a build of the OIS framework here: http://www.shatteredruby.com/support/OIS.1.0.framework.zip.* Place it into your /Library/Frameworks directory.
50
+
51
+ After building, the resulting frameworks will be located in ogrerb/lib.
52
+
53
+ You will need to run the build_mac_rubyw Rake task, which creates a rubyw executable that's fit for opening
54
+ up windows in the foreground. See http://rubyforge.org/forum/forum.php?thread_id=15371&forum_id=14174 for details.
55
+
56
+ Remember once you do this to start ogrerb programs with 'rubyw' instead of 'ruby', otherwise keyboard input will be disabled.
57
+
58
+ *The OIS framework is made by wreckedgames.com, and the sourceforge project page is here: http://sourceforge.net/projects/wgois. The build in this document is for convenience only and is not an official release.
49
59
 
50
60
  === Windows
51
61
 
@@ -77,3 +87,31 @@ The resulting files can be found in ogrerb/lib.
77
87
  == Running Ogre.rb programs
78
88
 
79
89
  You'll either have to copy the OgreMain dll to the ogrerb/lib folder, or you'll need to set the PATH (on Windows) or LD_LIBRARY_PATH (on Linux) environment variable to point to where this file is ([OgreSDK]/bin/release for prebuilt). Then, it's simply <code>require 'ogre'</code> and off you go.
90
+
91
+ == Testing Ogre.rb programs
92
+
93
+ test/test_helper.rb contains the minimum needed setup for Ogre to properly allow testing of it's components.
94
+
95
+ == Notes
96
+
97
+ These are the classes currently not wrapped for various reasons:
98
+
99
+ * OgreConfigDialog
100
+ * OgreConfig
101
+ * OgreConfigOptionMap
102
+ * OgreErrorDialog
103
+ * OgreException
104
+ * OgreProfiler
105
+ * OgreStringConverter
106
+ * OgreZip
107
+ * OgreAlignedAllocator
108
+ * OgreBitwise
109
+ * OgreMemoryManager
110
+ * OgreFileSystem
111
+ * OgreUnifiedHighLevelGpuProgram
112
+ * OgreSearchOps
113
+ * OgreStableHeaders
114
+ * OgreUTFString
115
+ * OgreILCodecs
116
+ * OgreILImageCodec
117
+ * OgreILUtil
data/Rakefile CHANGED
@@ -4,10 +4,17 @@ require 'rake/contrib/sshpublisher'
4
4
  require 'rake/gempackagetask'
5
5
 
6
6
  require 'platform'
7
+ require 'lib/rake/project_builder'
7
8
 
8
- task :default => :build_all
9
+ task :default => :test
9
10
 
10
- OGRE_RB_VERSION = "0.1"
11
+ OGRE_RB_VERSION = "0.2"
12
+
13
+ Rake::TestTask.new do |t|
14
+ t.libs << "test"
15
+ t.test_files = FileList["test/**/*_test.rb"]
16
+ t.verbose = true
17
+ end
11
18
 
12
19
  ###########################
13
20
  # Project Managment tasks #
@@ -55,6 +62,7 @@ ogre_rb_spec = Gem::Specification.new do |s|
55
62
  if Platform.windows?
56
63
  lib_files = %w(lib/ogre.dll lib/ruby_ois.dll)
57
64
  elsif Platform.mac?
65
+ lib_files = %w(lib/ogre.bundle lib/ruby_ois.bundle)
58
66
  else # Posix environment
59
67
  lib_files = %w(lib/ogre.so lib/ruby_ois.so)
60
68
  end
@@ -74,7 +82,7 @@ ogre_rb_spec = Gem::Specification.new do |s|
74
82
  s.required_ruby_version = '>= 1.8.4'
75
83
 
76
84
  # Inform of the need to have Ogre installed and OGRE_HOME set
77
- s.requirements << "Ogre Einhort (1.4)"
85
+ s.requirements << "Ogre Einhort (1.4.4)"
78
86
  s.requirements << "Environment variable OGRE_HOME set"
79
87
 
80
88
  #s.has_rdoc = false
@@ -89,6 +97,7 @@ ogre_rb_spec = Gem::Specification.new do |s|
89
97
  lib/*.rb
90
98
  samples/**/*
91
99
  doc_src/**/*
100
+ test/**/*
92
101
  ) do |fl|
93
102
  fl.exclude(/navi/)
94
103
  end
@@ -101,191 +110,81 @@ end
101
110
  desc 'Package as gem & zip'
102
111
  Rake::GemPackageTask.new(ogre_rb_spec) do |p|
103
112
  p.gem_spec = ogre_rb_spec
104
- #p.need_tar = true
105
- p.need_zip = true
106
113
  end
107
114
 
108
115
  #############################
109
116
  # Project compilation tasks #
110
117
  #############################
111
-
112
- desc "Rebuild the OGRE and OIS wrappers. Does not work on Windows."
113
- task :build_all => ["ogre:build", "ois:build"]
114
-
115
- desc "Clean everything"
116
- task :clean_all => ["ogre:clean", "ois:clean"]
117
-
118
- namespace :ois do
119
- desc "Rebuild all of the OIS wrapper. Does not work on Windows."
120
- task :build => [:swig, :compile]
121
-
122
- desc "Run swig on the interface files"
123
- task :swig do
124
- includes = %w(-I./src_headers/OIS -I./src_headers/wrappers)
125
- sh "swig -ruby -minherit -c++ -autorename #{includes.join(' ')} -o build/ois/ois_wrap.cpp ois/ois.i"
126
- if Platform.windows?
127
- insert_headers("build/ois/ois_wrap.cpp") do
128
- <<-EOF
129
- #include "OIS.h"
130
- EOF
131
- end
132
- end
133
- end
134
-
135
- desc "Compile the extension and move the resulting library into lib/"
136
- task :compile do
137
- resulting_file = "ruby_ois.so"
138
- build_file = resulting_file
139
- cd "build/ois" do
140
- ruby "extconf.rb"
141
- if Platform.linux?
142
- sh "make all"
143
- elsif Platform.windows?
144
- sh "nmake"
145
- # Create our manifest (see http://www.codeproject.com/cpp/vcredists_x86.asp)
146
- sh "mt.exe /manifest #{resulting_file}.manifest /outputresource:#{resulting_file};#2"
147
- resulting_file = "ruby_ois.dll"
148
- build_file = "ruby_ois.so"
149
- else
150
- raise "Error: Unsupported platform " + PLATFORM
151
- end
152
- cp build_file, File.join("..", "..", "lib", resulting_file)
153
- end
154
- end
155
-
156
- desc "Clean up the build environment"
157
- task :clean do
158
- cd "build/ois" do
159
- ruby "extconf.rb"
160
- sh "make clean"
161
- rm "mkmf.log" rescue nil
162
- end
118
+ desc "Build rubyw on the mac platform, needed for ogrerb to run properly."
119
+ task :build_mac_rubyw do
120
+ if Platform.mac?
121
+ sh "ruby=`which ruby`; rubyw=${ruby}w; sudo cp $ruby $rubyw; sudo /Developer/Tools/Rez -t APPL Carbon.r -o $rubyw"
122
+ else
123
+ puts "This is only to be run on Mac OS X"
163
124
  end
164
125
  end
165
126
 
166
- namespace :ogre do
167
-
168
- desc "Rebuild all of ogre.rb. Does not work on Windows."
169
- task :build => [:swig, :compile]
170
-
171
- desc "Run swig on the interface files"
172
- task :swig do
173
- includes = %w(-I./src_headers/OGRE -I./src_headers/ExampleApplication -I./src_headers/wrappers -I./src_headers/OIS)
174
- sh "swig -ruby -minherit -c++ -autorename #{includes.join(' ')} -o build/ogre/ogre_rb_wrap.cpp ogre/ogre_rb.i"
127
+ #############################################
128
+ # Project registration helpers documentation:
129
+ #
130
+ # project.swig_file =>
131
+ # The name of the main swig interface file (sans .i) (default: project name)
132
+ #
133
+ # project.swig_includes =>
134
+ # The include declarations needed for this project to swigify
135
+ #
136
+ # project.swig =>
137
+ # Create a block that gets called after swig is done running, for post processing
138
+ #
139
+ # project.resulting_library =>
140
+ # The final name of the built library (default: project name)
141
+ #
142
+ #
143
+ # TODO Looks like I can pull the swig block into the template, as all projects seem
144
+ # to need this STL fix
145
+ #############################################
146
+
147
+ register_project :ogre do |project|
148
+ project.swig_file = "ogre_rb"
149
+ project.swig_includes = %w(-I./src_headers/OGRE -I./src_headers/wrappers -I./src_headers/OIS)
150
+ project.swig do
175
151
  if Platform.windows?
176
152
  # compensate for windows stl. Uses wrong version when ruby is first.
177
153
  insert_headers("build/ogre/ogre_rb_wrap.cpp") do
178
154
  <<-EOF
179
155
  #include "Ogre.h"
180
- #{Platform.windows? ? "#include <winsock.h>" : ""}
156
+ #include <winsock.h>
181
157
  EOF
182
158
  end
183
159
  end
184
- end
160
+ end
161
+ end
185
162
 
186
- desc "Compile the extension and move the resulting library into lib/"
187
- task :compile do
188
- resulting_file = "ogre.so"
189
- cd "build/ogre" do
190
- ruby "extconf.rb"
191
- if Platform.linux?
192
- sh "make clean all"
193
- elsif Platform.windows?
194
- sh "nmake"
195
- # Create our manifest (see http://www.codeproject.com/cpp/vcredists_x86.asp)
196
- sh "mt.exe /manifest ogre.so.manifest /outputresource:ogre.so;#2"
197
- resulting_file = "ogre.dll"
198
- else
199
- raise "Error: Unsupported platform " + PLATFORM
200
- end
201
- cp "ogre.so", File.join("..", "..", "lib", resulting_file)
163
+ register_project :ois do |project|
164
+ project.resulting_library = "ruby_ois"
165
+ project.swig_includes = %w(-I./src_headers/OIS -I./src_headers/wrappers)
166
+ project.swig do
167
+ if Platform.windows?
168
+ insert_headers("build/ois/ois_wrap.cpp") do
169
+ <<-EOF
170
+ #include "OIS.h"
171
+ EOF
172
+ end
202
173
  end
203
- end
204
-
205
- desc "Clean up the build environment"
206
- task :clean do
207
- cd "build/ogre" do
208
- ruby "extconf.rb"
209
- sh "make clean"
210
- rm "mkmf.log" rescue nil
211
- end
212
- end
213
-
214
- desc "Copy over the ogre header files from an ogre installation. Expects OGRE_HOME to be set."
215
- task :update_headers do
216
- raise "Unable to find Ogre headers, please set OGRE_HOME to the distribution path" if ENV['OGRE_HOME'].nil?
217
-
218
- File.cp_r "#{ENV['OGRE_HOME']}/include/OGRE/", "#{File.dirname(__FILE__)}/src_headers"
219
- end
220
-
221
- desc "Create default interface files for each of the ogre headers"
222
- task :create_interfaces do
223
- headers_match = File.join("src_headers", "OGRE", "Ogre*.h")
224
- ogre_headers = Dir[headers_match]
225
-
226
- ogre_headers.each do |header|
227
- filename = File.basename(header, ".h")
228
- interface_file_name = File.join("ogre", File.basename(header, ".h") + ".i")
229
- raise "Interface file for #{filename} already exists" if File.exists?(interface_file_name)
230
-
231
- File.open(interface_file_name, "w+") do |file|
232
- file.write <<END
233
- %{
234
- #include "#{filename}.h"
235
- %}
236
-
237
- %include "#{filename}.h"
238
- END
239
- end
240
- end
241
- end
174
+ end
242
175
  end
243
176
 
244
-
245
- namespace :navi do
246
-
247
- desc "Rebuild all of navi.rb"
248
- task :build => [:swig, :compile]
249
-
250
- desc "Run swig on the interface files"
251
- task :swig do
252
- includes = %w(-I./src_headers/navi -I./src_headers/wrappers)
253
- sh "swig -autorename -ruby -minherit -c++ #{includes.join(' ')} -o build/navi/navi_rb_wrap.cpp navi/navi_rb.i"
177
+ register_project :navi do |project|
178
+ project.swig_file = "navi_rb"
179
+ project.swig_includes = %w(-I./src_headers/navi -I./src_headers/wrappers)
180
+ project.swig do
254
181
  if Platform.windows?
255
- # compensate for windows stl. Uses wrong version when ruby is first.
256
-
257
182
  insert_headers("build/navi/navi_rb_wrap.cpp") do
258
183
  <<-EOF
259
184
  #include "Ogre.h"
260
- #{Platform.windows? ? "#include <winsock.h>" : ""}
185
+ #include <winsock.h>
261
186
  EOF
262
187
  end
263
188
  end
264
- end
265
-
266
- desc "Compile the extension and move the resulting library into lib/"
267
- task :compile do
268
- resulting_file = "navi.dll"
269
- cd "build/navi" do
270
- ruby "extconf.rb"
271
- if Platform.windows?
272
- sh "nmake"
273
- # Create our manifest (see http://www.codeproject.com/cpp/vcredists_x86.asp)
274
- sh "mt.exe /manifest navi.so.manifest /outputresource:navi.so;#2"
275
- else
276
- raise "Error: Unsupported platform " + PLATFORM
277
- end
278
- cp "navi.so", File.join("..", "..", "lib", resulting_file)
279
- end
280
- end
281
-
282
- desc "Clean up the build environment"
283
- task :clean do
284
- cd "build" do
285
- ruby "extconf.rb"
286
- sh "make clean"
287
- rm "mkmf.log" rescue nil
288
- end
289
- end
290
-
189
+ end
291
190
  end
data/lib/application.rb CHANGED
@@ -53,7 +53,8 @@ module Ogre
53
53
 
54
54
  destroy_scene
55
55
 
56
- @frame_listener.shutdown
56
+ ensure
57
+ @frame_listener.shutdown if @frame_listener
57
58
  end
58
59
 
59
60
  protected
@@ -111,7 +111,7 @@ module Ogre
111
111
  # Most likely won't have a joystick here, so just throw away any exceptions
112
112
  @joy_stick = nil
113
113
  begin
114
- @joy_stick = @input_manager.create_input_object( OIS::OISJoyStick, buffered_joy)
114
+ @joy_stick = @input_manager.create_input_object( OIS::OISJoyStick, buffered_joy) unless Platform.mac?
115
115
  rescue
116
116
  end
117
117
 
@@ -177,12 +177,12 @@ module Ogre
177
177
 
178
178
  # Turn Right
179
179
  if @keyboard.key_down?(OIS::KC_RIGHT)
180
- @camera.yaw(-@rot_scale)
180
+ @camera.yaw( Degree.new(-@rot_scale) )
181
181
  end
182
182
 
183
183
  # Turn Left
184
184
  if @keyboard.key_down?(OIS::KC_LEFT)
185
- @camera.yaw(@rot_scale)
185
+ @camera.yaw( Degree.new(@rot_scale) )
186
186
  end
187
187
 
188
188
  # Quit
@@ -279,24 +279,24 @@ module Ogre
279
279
  protected
280
280
 
281
281
  def update_stats
282
- gui_avg = OverlayManager.instance.get_overlay_element("Core/AverageFps")
283
- gui_curr = OverlayManager.instance.get_overlay_element("Core/CurrFps")
284
- gui_best = OverlayManager.instance.get_overlay_element("Core/BestFps")
285
- gui_worst = OverlayManager.instance.get_overlay_element("Core/WorstFps")
286
- gui_tris = OverlayManager.instance.get_overlay_element("Core/NumTris")
287
- gui_batches = OverlayManager.instance.get_overlay_element("Core/NumBatches")
288
- gui_debug = OverlayManager.instance.get_overlay_element("Core/DebugText")
282
+ @gui_avg ||= OverlayManager.instance.get_overlay_element("Core/AverageFps")
283
+ @gui_curr ||= OverlayManager.instance.get_overlay_element("Core/CurrFps")
284
+ @gui_best ||= OverlayManager.instance.get_overlay_element("Core/BestFps")
285
+ @gui_worst ||= OverlayManager.instance.get_overlay_element("Core/WorstFps")
286
+ @gui_tris ||= OverlayManager.instance.get_overlay_element("Core/NumTris")
287
+ @gui_batches ||= OverlayManager.instance.get_overlay_element("Core/NumBatches")
288
+ @gui_debug ||= OverlayManager.instance.get_overlay_element("Core/DebugText")
289
289
 
290
290
  stats = @window.get_statistics
291
291
 
292
- gui_curr.set_caption("Current FPS: #{"%.3f" % stats.last_fps}")
293
- gui_avg.set_caption("Average FPS: #{"%.3f" % stats.avg_fps}")
294
- gui_best.set_caption("Best FPS: #{"%.3f" % stats.best_fps}")
295
- gui_worst.set_caption("Worst FPS: #{"%.3f" % stats.worst_fps}")
296
- gui_tris.set_caption("Triangle Count: #{stats.triangle_count}")
297
- gui_batches.set_caption("Batch Count: #{stats.batch_count}")
292
+ @gui_curr.set_caption("Current FPS: #{"%.3f" % stats.last_fps}")
293
+ @gui_avg.set_caption("Average FPS: #{"%.3f" % stats.avg_fps}")
294
+ @gui_best.set_caption("Best FPS: #{"%.3f" % stats.best_fps}")
295
+ @gui_worst.set_caption("Worst FPS: #{"%.3f" % stats.worst_fps}")
296
+ @gui_tris.set_caption("Triangle Count: #{stats.triangle_count}")
297
+ @gui_batches.set_caption("Batch Count: #{stats.batch_count}")
298
298
 
299
- gui_debug.set_caption("#{@debug_text}")
299
+ @gui_debug.set_caption(@debug_text)
300
300
  end
301
301
  end
302
302
  end
data/lib/ogre.dll CHANGED
Binary file
data/lib/ruby_ois.dll CHANGED
Binary file
data/ogre.rb CHANGED
@@ -6,6 +6,9 @@ $LOAD_PATH << File.expand_path(File.dirname(__FILE__) + "/lib")
6
6
  # Ruby always looks for .so first, instead of .dll if on windows.
7
7
  # So, force .dll on windows environments
8
8
  if Platform.windows?
9
+ require 'env'
10
+
11
+ ENV["path"]+=";"+File.dirname(__FILE__)+"/../Ogre"
9
12
  require 'lib/ogre.dll'
10
13
  require 'lib/ruby_ois.dll'
11
14
  # require 'lib/navi.dll'