Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Image Wont Draw!
- By ell Date 2010-04-15 10:08
For some reason, none of my Gosu::Image(s) will draw under certain circumstances and I have no idea why. I beleive it is something to do with my loading function. Here are my ResourceBatch(http://pastebin.com/KqjB2fVA) and Resource(http://pastebin.com/vFiNM9xf) classes. To get a resource one simply needs to $game.resources[name_of_resource].

In my test scenes, drawing will work fine if the image is used on the first scene, for example:

class FirstScene < Blocks::SceneBase
  def draw
    $game.resources["Media/TestImage.png"].draw(0,0,0) #this will always work
  end
end
class NextScene < Blocks::SceneBase
  def draw
    $game.resources["Media/TestImage.png"].draw(0,0,0) #this will only work if the image has been used on FirstScene
  end
end

Sorry if I haven't provided enough information and thanks in advance! ell.
- By banister Date 2010-04-15 13:23
sounds like you have a bug ;)
- By ell Date 2010-04-15 16:42
Having just read the thread on drawing on another window that says that all drawing calls must be on the main thread, maybe this is the issue for the ResourceBatch.load_all is run on a seperate thread. And any ideas on how to fix the bug?
- By jlnr (dev) Date 2010-04-18 10:41
I don't see the threading part. Where does it happen? It might indeed be related :)

Also, are you sure that this is not overengineering going on here? :) I have never seen such a large resource class.
- By ell Date 2010-04-18 15:47 Edited 2010-04-18 15:51
I'l show you, and yes, there probably is a very large amount of over-engineering but I'm just trying to do cool things with Gosu and Ruby at the moment, then maybe after I have learn't all of their ways I might make something serious!, and here's the threading link:
http://pastebin.com/0eeU86xz

And although this bug (if it is one) may be obsolete because I might not use this since it is heavily over-engineered, I may use it anyway :D. Thanks in advance, ell

[edit]: When I said trying to do cool things, that sounded rather casual and care-free, what I meant was, learn about different concepts. For example, the resource class(if you didnt catch this) will load in the background, and when a file is requested it is given, if it hasn't loaded it will be loaded, if you did catch that, paron me if I insulted your intelligence!
- By jlnr (dev) Date 2010-04-18 23:31
Well now I saw it! ;) It's not legally possible though, because I commented out any thread synchronisation between Image.new and Window's internal management, so it might do even worse things than not draw an image :(

In fact, Gosu has a commented-out "Image.async_new(...)" function that will return a placeholder that can be polled for completion, but since nobody ever requested it outside of highly secret contexts, it never made it to the official side of things.
- By erisdiscord Date 2010-04-19 03:35
Hey, that async_new actually sounds pretty genius. Consider this a formal request? :)

It would be useful for loading non-vital network resources—say, custom character graphics that could be represented by a placeholder until they are loaded. In fact, I have tried to implement something similar using a proxy object.
- By jlnr (dev) Date 2010-04-19 04:17
Hah, not sure when to schedule it, but I consider it requested. ;)
- By ell Date 2010-04-19 18:10
So what I'm doing can't be done? Also can you give me some examples of some basic game classes (or should I just look at the showcase?) Ell
- By jlnr (dev) Date 2010-04-20 07:18
Nope, can't be done without help from Gosu's side.

You can look at the showcase, Ludum Dare entries pretty much all have a simple to understand object model. Actually the RMagickIntegration.rb example also has the object system like I usually use it for games, but you will need RMagick to run it.

For game state management, you can also look at Ludum Dare entries or at the Chingu library from the showcase which just extracts what most people do anyway (the State part of Chingu, the rest of Chingu is an alternative object system).
Up Topic Gosu / Gosu Exchange / Image Wont Draw!

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill