ohai / ruby-sdl2

A Ruby wrapper for SDL 2.x
GNU Lesser General Public License v3.0
72 stars 16 forks source link

Viewports not working? #16

Closed ryu-sxp closed 6 years ago

ryu-sxp commented 6 years ago

When I set a custom rectangle as a viewport Renderer.viewport returns the parameters of the default viewport (whole window). Furthermore updating the viewport works only once. Normally SDL allows for drawing on multiple viewports in one frame

ryu-sxp commented 6 years ago

Here's an example program:

require "sdl2"

SDL2.init(SDL2::INIT_TIMER|SDL2::INIT_AUDIO|SDL2::INIT_VIDEO| SDL2::INIT_EVENTS)

window = SDL2::Window.create("viewport test", SDL2::Window::POS_CENTERED, SDL2::Window::POS_CENTERED, 640, 480, 0)

renderer = window.create_renderer(-1, 0)

view1 = SDL2::Rect[0, 0, 320, 400] view2 = SDL2::Rect[320, 0, 320, 400] view3 = SDL2::Rect[0, 400, 640, 80]

renderer.viewport = view1 renderer.draw_color = [255, 0, 0] renderer.fill_rect SDL2::Rect[0, 0, 320, 400]

renderer.viewport = view2 renderer.draw_color = [0, 255, 0] renderer.fill_rect SDL2::Rect[0, 0, 320, 400]

renderer.viewport = view3 renderer.draw_color = [0, 0, 255] renderer.fill_rect SDL2::Rect[0, 0, 640, 80]

renderer.present

SDL2.delay 2000

ohai commented 6 years ago

Thank you for your report. Probably I have found a bug in Ruby/SDL2, and I will fix it soon.

ohai commented 6 years ago

Now I fix the problem and release ver 0.3.4 on rubygems. Please try it.

ryu-sxp commented 6 years ago

Thank you very much for fixing this so quickly! As far as I tested it works correctly now.

smortex commented 5 years ago

@ohai No tag for 0.3.4 in this repo :wink:

ohai commented 5 years ago

Thanks for the comment, @smortex. I pushed 0.3.4.