Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / [Solved] Strange image look...
- - By Nanaya Date 2013-03-06 22:07 Edited 2013-03-08 22:13

Here a little try with gosu (ruby). When I launch it (test.rbw), I got a awfull result.

As you can see, instead of this :

I've got a black squarre... Here the code I use (Ruby 1.9.3, Gosu 0.7.45, with more or less other gem) :

# Encoding: UTF-8
  Ce fichier rb ne sert qu'à tester des truc.
# Appeler Gosu.
require 'gosu'
# Créer une fenêtre principale.
class GameWindow < Gosu::Window # On crée une classe fille
  def initialize
    super(@max_width, @max_height, false, 1000/75) # False : pas en plein écran. 1000/75 = 75 FPS. Par défaut : 60.
    self.caption = "Français" # Titre de la fenêtre.
# On charge des images pour les utiliser plus tard.
    @mouse_pointer =, "pictures/Circle_Curseur_fini2.png", true)
    @background_image =, "pictures/EEE_PC_01_-_Kara_no_Kyoukai.png", false)
    @music =, "sounds/Devils_Never_Cry.ogg")
    @se =, "sounds/flash2.ogg")
   def button_down(id)
    close if id == Gosu::Button::KbEscape if button_down? char_to_button_id("m") if button_down? char_to_button_id("s")
# Ici, on gère tout ce qui ce "renouvelle".
  def update
    # du code
# Par contre, là, on gère l'affichage à proprement parler des images.'
  def draw
    @mouse_pointer.draw(mouse_x - @mouse_pointer.width, mouse_y - @mouse_pointer.height, 250)
# Création de la fenêtre.
window =
# Affichage de la fenêtre.

You can find all the image :
(Note : if OpenGL is alone, that works perfectly [see image on picasa]. When launching Gosu and chipmunks integration, there a strange text in the "dos" window [idem].])

Could you tell is it's the case for as well ?
(I suspect my Ruby-Gosu installation being the problem, but...)

Thanks !

(By the way, how could I fit to the screen my background image ?)

EDIT 1 : I'v changed the cursor file, but there still the same trouble.
EDIT 2 : Add folders with files are in the zip one in attachment.
EDIT 3 : Swapping the line code of loading part change a little the problem. More details in post below.
EDIT 4 : Listing of my gem (can't download "ashton" gem, same for "rmagick") :

"actionmailer, actionpack, active_support, activemodel, activerecord, activeresource, activesupport, activesupport, arel, bigdecimal, builder, bundler, chingu, chipmunk, crack, cri, erubis, faster_xml_simple, gosu, gosu-keyboard, gosu_extensions, hike, httpclient, i18n, io-console, journey, json, libxml-ruby, mail, mime-types, minitest, multi_json, net-github-upload, nokogiri, ocra, opengl, polyglot, rack, rack-cache, rack-ssl, rack-test, rails, railties, rake, rdoc, releasy, rest-client, ruby-opengl, rubygems, sprockets, texplay, thor, tilt, treetop, tzinfo, version."

EDIT 5 (final) : It was a graphic card problem...
Attachment: - Files (6901k)
Parent - - By Spooner Date 2013-03-06 23:37
You should only really be using PNG files (and ogg for sounds/music) in Ruby/Gosu. Both work on all platforms that Gosu supports and are much better compressed than the alternatives. [EDIT: But to answer your question, there is probably something odd about your BMP's format, but PNGs always work so easier to just convert to that format].

You could use Image#draw_as_quad to exactly fill the Window.
Parent - By Nanaya Date 2013-03-07 00:30
Great stuff for the full screen ! Thanks. Unfortunatly, still unable to have correct image show.
Note : if I don't put my backgroung, the image used as pointer (for the mouse) is correctly show. Weird.
Parent - - By Spooner Date 2013-03-07 00:48
There is a Gosu::Color::BLACK and others, so you don't have to define several standard colours yourself.

I can't see anything wrong with your code though.
Parent - - By Nanaya Date 2013-03-07 01:28
Anything wrong, ok, but did you tried it ?
Thanks for the color tip, user guide on the net aren't always up to date.
Parent - - By Spooner Date 2013-03-07 11:05
I didn't try it myself, no.
Parent - - By Nanaya Date 2013-03-07 12:05

Could you try it, please ?

After I few test, it seems that the problem comes from the loading part. Indeed, when I changed the order of the image, the first to come is the only one who's correctly show.
Here a new printscreen :

Does anyone knows why it's acting that weird ?
Parent - - By jlnr (dev) Date 2013-03-07 13:35
Wait, is the image really cut off after exactly 256px...? Do other 3D games run on your computer??! :)
Parent - - By Nanaya Date 2013-03-07 14:14 Edited 2013-03-08 12:17
Yes (more or less thoses pixels, but always at the down part),  at least, when I can see the background image (first lauch the program with only the background, then with the mouse pointer as well). Others times, I don't even can see second or third image loaded.

For 3D : herm. Is this test ok ?
This test works perfectly (see in attachment: Nehe_Lesson_36.rbw)
Here what it's look like on my screen :

But, if I launch "OpenGLIntegration.rb" in Gosu exemple, it doesn't work correctly :

A good think to know : there a few years ago, when I first use Gosu (subscribe to this forum), I'd nerver had this kind of problem.
My computer is an EEE pc 1000H.
(Re-installing the properly ruby+gosu+others gems don't solved the problem.)

So what do you think about it ?
Attachment: Nehe_Lesson_36.rbw - OpenGL (11k)
Parent - - By BlueScope Date 2013-03-08 12:35
I think what jlnr tried to find out is whether there might be graphics card problems involved. Depending on your graphics processor, you might not be able to use certain features of 3D or 3D-driven 2D display (such as textures). I don't know all that much about it, but when using OpenGL, for example, all your textures have to be square and dimensions have to be 16^n, iirc (i.e. 16, 32, 64, 128, 256, 512, 1024, ...). I often got the error that I cannot work with an image greater than 1024px for one side, which has to do with the amount of memory a texture that size would take, I think.

When saving a PNG image, note that you're working with an alpha channel for transparency. Different programs handle this different ways, so make sure you're not using a fishy program that might not have an idea about it, but something like Photoshop, PSP, IrfanView,, GIMP, ... there's a lot more, and really, most programs should know how to do it, just mentioning it for completeness' sake.
If properly saving the image as a png doesn't work, try saving your sprite with 64x64px, for example, and if that doesn't work, try it with no transparency - that should most definitely work with whatever graphics card you have.
Parent - - By Nanaya Date 2013-03-08 12:57 Edited 2013-03-08 17:26
Great answer !
If I just use 540p resolution as a max for my background, everything's ok. Seems that my higher width aivable is lower than 1024. Too bad.

Then, why the 3D game works fine, even with 1024*768 (using a another screen, of course), full screen ?
(For example : BattleField, Starcraft (+add one), Shaiya, Divina, Age of Empire 2, Ragnarok online, etc.) ?

P.S. : Playing with OpenGL (ruby-opengl) meanwhile, why can't I put UTF-8 characters ?


Doesn't work, "français" becomes just like this "français".
Parent - - By jlnr (dev) Date 2013-03-09 01:25
Maybe because you are taking an UTF-8 string (x), parsing it as an ANSI string (with unpack) and back into UTF-8 (with pack). Does it work if you just pass x by itself?
Parent - By Nanaya Date 2013-03-09 03:02
No, it doesn't. I've tried "français", x.encode("UTF-8"), ...
None of the 3 worked.
Parent - - By jlnr (dev) Date 2013-03-09 01:23
BlueScope is right. What could happen is e.g. this: Your GPU can only handle 512x512 textures, but the driver may tell Gosu that 1024x1024 is absolutely okay. Gosu would go ahead and allocate a 1024x1024 texture, place its images on there and parts of them would appear broken.

I've looked it up though, your computer has an Intel GMA950 chip and that's the exact same chip that I've developed Gosu on for years (on two Macs) :) So that shouldn't be a problem. Only very old computers wouldn't be able to handle 1024x1024 textures anyway.

Maybe all the other games are using Direct3D and not OpenGL, and your OpenGL drivers are outdated? You could try the fix here:
Parent - - By Nanaya Date 2013-03-09 03:04
Maybe so.
I don't know why, but image bigger than 1024 (width), BMP (with "invisible" color, the pink one), make it bug.
I'll work with png, lighter, and easy to make with GIMP.

And the solution on the site was a very bad idea. Thus, opengl exemple files works without problem. Only those with Gosu (what a pain).
Parent - - By BlueScope Date 2013-03-09 11:57
For clarification on your question why games work on 1024x768: That's your output screen size, not your texture size. an output of the dimensions 1024x768 can consist of a single 32x32 texture, scaled up by 32 to fill the viewport entirely. It could also simply show a 32x32 texture somewhere, and show nothing (rgb 0-0-0) for all pixels not filled with a texture.
So, maybe your scenario is that your graphics chip (and monitor, for that matter) support a resolution of up to 1024x768, but a maximum texture size of 512x512... (though jlnr's explanation below would counter-prove this theory...)
Maybe there's a software or configuration issue that doesn't allow bigger textures?

Also, 'pink' is not a transparent color - your program might use it as a placeholder to save transparent on output, because it's impossible to display real transparency on today's monitors. Photoshop, for example, solves this by displaying a pattern 'behind' your workspace.
There's also differences whether you're saving your PNGs as 24bit or 32bit (with an included alpha channel). It's really quite a deep topic and I'm not an expert on it either, all I'm saying is: Make sure you're not using Paint or something to create your images. :D
Parent - By Nanaya Date 2013-03-09 13:17 Edited 2013-03-10 00:42
Indeed, the background image texture size that was the limite, not the game windows one (I mean, from what I could noticed during my tests).

PNG from GIMP works fine. There's no problem with them, "transparency" works (thanks alpha channel).
Guess those are 32bit one.

Thanks a lot everyone.

P.S. : Gosu::Image::load_tiles gives me headaches. If alone, everythings ok, but with other images it doesn't work at all.
P.P.S. : RGSS lib works fine by the way. Just require my computer to be at last at 1024*768.
Up Topic Gosu / Gosu Exchange / [Solved] Strange image look...

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill