Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Problem with 0.7.29
- - By psadda Date 2011-04-15 19:40 Edited 2011-04-15 19:46
I'm running 0.7.29 on 64 bit Windows with Ruby 1.9.1.

If find that if I subclass Gosu::Window, override the draw method, and include ANY method call in the draw method, Gosu completely brings my system to a crawl. It runs completely fine if you make no method calls from draw. For example, the following code does not work:

class Win < Gosu::Window
   def initialize
     super(640, 480, false)
   end
   def draw
     self.caption = "dsdada"
   end
end

Win.new.show

This code does not work either:

def some_function
end

class Win < Gosu::Window
   def initialize
     super(640, 480, false)
   end
   def draw
     some_function
   end
end

Win.new.show

But this program does run:

class Win < Gosu::Window
   def initialize
     super(640, 480, false)
   end
   def draw
     x = 1
   end
end

Win.new.show

As does this one:

class Win < Gosu::Window
   def initialize
     super(640, 480, false)
   end
   def update
     self.caption = "dsdada"
   end
end

Win.new.show

(I have tested all of the above examples)

This is a pretty serious issue, obviously. Has anyone else been having trouble, or is this a problem with my particular system?
Parent - By psadda Date 2011-04-15 19:53
Also, adding the following:

class Win
  def needs_redraw?
    return false
  end
end

has no effect.
Parent - - By jlnr (dev) Date 2011-04-16 12:11
I have never seen anything like that. Does it also happen if you upgrade to Ruby 1.9.2?

There is another bug that happens on some 64-bit Windows systems, which is that exceptions in draw/update do not propagate correctly out of Window#show. If you throw an exception in draw, what happens?

I actually set up a Win XP 64 VM last week to reproduce the latter bug, but everything works just fine :(
Parent - By psadda Date 2011-04-16 13:08 Edited 2011-04-16 14:17
Strange, I ran the same examples that gave me problems yesterday, and today they are working just fine.

Exceptions do not propogate from draw, though. I am using Windows 7 x64.

The exit method also does not work.

Anyway, it was fairly trivial to put together a temporary patch:

class GosuWindowWrapper < Gosu::Window
  def initialize
    super(640, 480, false)
  end
  def update_callback
    #...
  end
  def draw_callback
    #...
  end
  def update
    begin
      update_callback
    rescue Exception => e
      puts e.message
      puts e.backtrace
      close
    end
    return nil
  end
  def draw
    begin
      draw_callback
    rescue Exception => e
      puts e.message
      puts e.backtrace
      close
    end
    return nil
  end
end
Up Topic Gosu / Gosu Exchange / Problem with 0.7.29

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill