Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Window resizing?  (Read 14108 times)

0 Members and 1 Guest are viewing this topic.

Hydra

  • Newbie
  • *
  • Posts: 37
    • View Profile
Window resizing?
« on: August 21, 2015, 12:54:12 pm »
I've recently started using SFML and it's great. I've got one problem with it though. In for example Java when creating a window and resizing it the objects inside the window will stay the same size. But in SFML it automatically resizes to fit the screen. Creating a stretched ugly mess I've looked online yet can't find anywhere that lets you disable the window resizing like this?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Window resizing?
« Reply #1 on: August 21, 2015, 01:00:32 pm »
A sf::View can be used to scale stuff.

Hydra

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Window resizing?
« Reply #2 on: August 21, 2015, 01:05:51 pm »
+Jesper Juhl

So is there no way to disable the resizing? It seems more like an annoyance than a feature of SFML.

Satus

  • Guest
Re: Window resizing?
« Reply #3 on: August 21, 2015, 02:03:07 pm »
+Jesper Juhl

So is there no way to disable the resizing? It seems more like an annoyance than a feature of SFML.

Get sf::View from window.getDefaultView(), call window.setView() and pass it your received view.
Also stackoverflow
Wiki tutorial on View: https://github.com/SFML/SFML/wiki/Tutorial:-Using-View
« Last Edit: August 21, 2015, 02:11:52 pm by Satus »

Verra

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Window resizing?
« Reply #4 on: August 21, 2015, 05:56:59 pm »
If you don't want resizing you can pass the style flag sf::Style::Close.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Laurent Gomila - SFML developer

Mithra

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Window resizing?
« Reply #6 on: November 17, 2015, 01:50:43 am »
Perfect, thank you Laurent!  I was having the same problem.

mkalex777

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: Window resizing?
« Reply #7 on: November 17, 2015, 02:37:10 am »
Just use View and set it's size to window size at beginning of render loop. That's all what you need. So you don't need to handle resize event, because your view size will be always correct, even when resize event will not be raised
« Last Edit: November 17, 2015, 02:39:22 am by mkalex777 »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Window resizing?
« Reply #8 on: November 17, 2015, 08:53:29 am »
Quote
Just use View and set it's size to window size at beginning of render loop
How is that better than doing it only when the Resized event is triggered, ie. only when it makes sense?
Laurent Gomila - SFML developer

mkalex777

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: Window resizing?
« Reply #9 on: November 18, 2015, 09:07:33 am »
Quote
Just use View and set it's size to window size at beginning of render loop
How is that better than doing it only when the Resized event is triggered, ie. only when it makes sense?

I think that it's better because the code will be short and transparent, it will be better to understand, because it means that view size is always the same as window size :)

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Window resizing?
« Reply #10 on: November 18, 2015, 09:18:23 am »
But the view size will always be the same as the window size if you set it to the window size upon a Resized event. It also means that the view isn't being changed constantly, and the code for changing the size of the view is clearly under an if that states that it is the code for coping with the resizing of the window, which means it explicitly states what it does, why it does it and it will have the better performance.