Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Can't load images Windows 7
- - By PhusionDev Date 2011-07-04 11:58
Windows 7 x64
ruby 1.9.2p180 (2011-02-18) [i386-mingw32]
gosu (0.7.33 i386-mingw32)

Hello all I'm new to these forums and relatively new to Ruby in general, but I've been having some issues getting started. When I follow the windows tutorial I can get a window loaded, and give it a caption but when I try to do the image tutorial I get an error related to FreeImage.dll and not being able to load it.

M:/ruby/gosu/GameWindow/main.rb:9:in initialize': unable to locate FreeImage.dll (RuntimeError)

Which is annoying because I've put the FreeImage.dll in my relative folder, and in the windows system32+64 folders with no luck so I can't quite figure that out.

Also I downloaded another user's Starfighter game in hopes to learn from it but I get greeted with a nasty require error:

<internal:lib/rubygems/custom_require>:29:in
require': no such file to load - lib/zorder (LoadError)

The above error I know is because of some issue relating to "relative path" which I founda  fix for using require_relative and some code snippet but why is this? Is there a better way to go about it?

Hopefully there is somebody that can help and if I'm not the only person that's been faced with this issue then maybe we can get it solved. Thanks for your time and dedication :)
Parent - By Spooner Date 2011-07-04 14:18
The first issue probably means that the path to the image is wrong (can't be sure since you don't include more info/code snippet). The Gosu binary gem includes Freeimage.dll, so you don't need to provide it yourself. This is just an attack of the terrible error messages again...

For your second issue, the problem will be that you are using 1.9.2 and they used an earlier version (it used to be that Ruby added the current file's folder to the require path). Just change require "lib/zorder" to require_relative "lib/zorder"
Parent - - By jlnr (dev) Date 2011-07-04 14:27

> M:/ruby/gosu/GameWindow/main.rb:9:in initialize': unable to locate FreeImage.dll (RuntimeError)


You actually don't need to use FreeImage.dll, unless the file was saved in some exotic file format. The problem with the current Gosu version is that it does always complain about FreeImage.dll, no matter what's going wrong exactly.
If you can zip & attach a sample Ruby and image file to illustrate the problem, we maybe able to explain what is going wrong.

> using require_relative and some code snippet but why is this?


See Spooner's post. Ruby 1.9.x also has some other syntax changes to watch out for, like "when X:" in case statements that is "when X then" now.
Parent - By bestguigui Date 2011-07-04 15:46
I had that problem too, and Spooner is right : the image path is wrong. Be sure to add ".png" extension to your path.
and +1 for require_relative, I was really surprised too the first time I upgraded to Ruby 1.9.x.

Thanks Julian BTW, you confirmed what I thought about error's handling.
Parent - - By PhusionDev Date 2011-07-04 22:11
First of all thank you to everybody that is helping me resolve the issue. I am having issues with even the tutorial about loading images. I've attached a file to illustrate the problem.
Parent - - By jlnr (dev) Date 2011-07-05 10:52
It looks as if you are running your script from within the Notepad++ directory. There is a difference between
cd my_game; ruby main.rb
and
ruby C:\my_game\main.rb
Only in the first case can the game find its resources via media/my_image.png. If you want to change the script so it can be run from anywhere, you could add Dir.chdir File.dirname(__FILE__) to the top of the script. All files will be sought relative to the script's directory then.
Parent - - By PhusionDev Date 2011-07-05 11:28
I don't believe it's actually running from the notepad directory, I have a run command in notepad++

cmd /K ruby "$(FULL_CURRENT_PATH)"

It just defaults to the notepad++ directory after the file is run, as far as I know anyways because it's listing my main.rb file accurately in its proper directory.
Parent - - By PhusionDev Date 2011-07-05 11:31
Okay nevermind, when I change dir into my folder everything works 100% sorry

Thank you for your help in fixing my very noob problem :) I appreciate it!

edit: now that I look back at your post I fully understand exactly what you mean and it makes total sense now why it wasn't working before. Well here's to many great debugs in ruby/gosu ahead!! Thanks once more.
Parent - By PhusionDev Date 2011-07-05 22:21
Also for anybody else using Notepad++ this may be useful:

I downloaded the NPPExec plugin, then from within Notepad++ if you hit F6 you can bring up an exec script. Using the following script works very well and has solved my problem:

cd "$(CURRENT_DIRECTORY)"
cmd /K ruby "$(FILE_NAME)"
Up Topic Gosu / Gosu Exchange / Can't load images Windows 7

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill