Closed ryu-sxp closed 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
Thank you for your report. Probably I have found a bug in Ruby/SDL2, and I will fix it soon.
Now I fix the problem and release ver 0.3.4 on rubygems. Please try it.
Thank you very much for fixing this so quickly! As far as I tested it works correctly now.
@ohai No tag for 0.3.4 in this repo :wink:
Thanks for the comment, @smortex. I pushed 0.3.4.
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