Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Window.record can't store Window.draw_triangle ?
- - By dunric Date 2015-02-25 01:02
I'm trying to speed-up drawing proces by moving static content into Gosu::Window.initialize method and store it in Gosu::Image, to be drawn once.

I'm surprised even the following simple gradient triangle is stored improperly. When stored bitmap is drawn it has distorted top-left corner and is half-transparent.


class GameWindow < Gosu::Window
  def initialize
     …
     @triangle = record(width, height) do
      draw_triangle(width/10, height/10, Gosu::Color::RED,
                    width*9/10, height/2, Gosu::Color::GREEN,
                    width/2, height*9/10, Gosu::Color::BLUE)
    end
     …
  end

  def draw
    @triangle.draw(0, 0, 10)
     …
  end
end


Any idea why Gosu::Window.record stores the triangle garbled ?

Thanks
Parent - - By jlnr (dev) Date 2015-02-25 03:00
Hey, that seems to be a bug in how triangles are handled inside record (which does not render to a bitmap, but into an OpenGL vertex array). I've created a github issue:

https://github.com/jlnr/gosu/issues/267

As a workaround, you can use draw_quad instead of draw_triangle and repeat the third coordinate/colour:

      draw_quad(width/10, height/10, Gosu::Color::RED,
                width*9/10, height/2, Gosu::Color::GREEN,
                width/2, height*9/10, Gosu::Color::BLUE,
                width/2, height*9/10, Gosu::Color::BLUE)


This is what Gosu will probably do internally soon, GL_TRIANGLES and GL_LINES are not worth all the special cases in the rendering backend.
Parent - By dunric Date 2015-02-25 03:22
Oh, thanks very much even for the filled bugreport !

Regards

David
Up Topic Gosu / Gosu Exchange / Window.record can't store Window.draw_triangle ?

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill