8000 Update ruby2d.rb by richpeck · Pull Request #228 · ruby2d/ruby2d · GitHub
[go: up one dir, main page]

Skip to content

Update ruby2d.rb #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/ruby2d.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@
if defined?(RubyInstaller)
s2d_dll_path = Gem::Specification.find_by_name('ruby2d').gem_dir + '/assets/mingw/bin'
RubyInstaller::Runtime.add_dll_directory(File.expand_path(s2d_dll_path))
elsif RUBY_PLATFORM =~ /mingw/
# https://stackoverflow.com/a/59045531/1143732
require 'fiddle/import'
require 'fiddle/types'
module WinAPI
extend Fiddle::Importer
dlload 'kernel32.dll'
include Fiddle::Win32Types
extern 'int SetDllDirectory(LPCSTR)'
end
WinAPI.SetDllDirectory(Gem::Specification.find_by_name('ruby2d').gem_dir + '/assets/mingw/bin')
end

require 'ruby2d/ruby2d' # load native extension
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby2d/cli/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def build_native(rb_file)
check_build_src_file(rb_file)

# Check if MRuby exists; if not, quit
if `which mruby`.empty?
if `which mruby`.empty? || `where mruby`.empty?
puts "#{'Error:'.error} Can't find MRuby, which is needed to build native Ruby 2D applications.\n"
exit
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby2d/window.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def remove(o)
raise Error, "Cannot remove '#{o.class}' from window!"
end

collection = o.class.ancestors.include?(Ruby2D::Entity) ? @entities : @objects
collection = o.class.ancestors.include?('Ruby2D::Entity') ? @entities : @objects
if i = collection.index(o)
collection.delete_at(i)
true
Expand Down
0