Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Window#resize? #255

Closed
jlnr opened this issue Oct 22, 2014 · 6 comments
Closed

Window#resize? #255

jlnr opened this issue Oct 22, 2014 · 6 comments

Comments

@jlnr
Copy link
Member

jlnr commented Oct 22, 2014

There is a new forum thread about resizing windows or changing resolutions almost every week. :)

I think a good first addition would be Window#resize(width, height, fullscreen), but the question is, when are you allowed to call it? I think it should raise an exception when called from Window#draw but work everywhere else.

(Live-resizable windows are a related, but different issue.)

@Dahrkael
Copy link

Dahrkael commented Dec 1, 2016

this should be easy making use of https://wiki.libsdl.org/SDL_SetWindowSize

@jlnr
Copy link
Member Author

jlnr commented Dec 5, 2016

@jlnr jlnr closed this as completed in 5d13271 Dec 14, 2016
@jlnr
Copy link
Member Author

jlnr commented Dec 14, 2016

Thanks for you nudging me! It was pretty straightforward. Needs some testing on Windows and Linux, then 0.10.9 is ready to go.

@ghost
Copy link

ghost commented Apr 3, 2018

There's no API for resizing windows from Ruby, however you can resize by recalling initialize with a different resolution.

Example of a Ruby implementation of the resize method:

class Window < Gosu::Window
  def initialize(width, height)
    super
  end

  def resize(width, height, fullscreen=fullscreen?)
    initialize(width, height)
    self.fullscreen = fullscreen
  end
end

window = Window.new(1280, 720)
window.resize(1920, 1080, true)

@Kjarrigan
Copy link
Collaborator

Well, thats not exactly true, although you're right that its a bit hidden and not intuitive at the moment. You can set the width and height of an Window in the Ruby interface which triggers an resize.

%rename("width=") setWidth;
%rename("height=") setHeight;
%rename("fullscreen=") setFullscreen;

   void setWidth(unsigned width) {
        $self->resize(width, $self->height(), $self->fullscreen());
    }
    void setHeight(unsigned height) {
        $self->resize($self->width(), height, $self->fullscreen());
    }
    void setFullscreen(bool fullscreen) {
        $self->resize($self->width(), $self->height(), fullscreen);
    }

Don't know about the reasons for @jlnr to

%ignore Gosu::Window::resize(unsigned, unsigned, bool);

but maybe it can be rethought while we're working on #437

@ghost
Copy link

ghost commented Apr 3, 2018

Ah, I never actually tried setting the width and height that way. It's quite a lot better than my method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants