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

Author Topic: [1.6] How to disable resizing SFML window.  (Read 5642 times)

0 Members and 1 Guest are viewing this topic.

Link

  • Newbie
  • *
  • Posts: 11
    • View Profile
[1.6] How to disable resizing SFML window.
« on: March 31, 2013, 03:43:57 am »
So, I want to be able to disable resizing the SFML window and tried to do it using the following code I found:

gameScreen.Create(sf::VideoMode(800, 600), "Lazeroids!", sf::Style::Resize, 0);
although this doesn't seem to work at all. Am I missing something?

P.S. If I'm making an asteroids game, would it be better to disable resizing, or just change the view, and if the view, how would I do it?

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: [1.6] How to disable resizing SFML window.
« Reply #1 on: March 31, 2013, 04:10:09 pm »
Giving sf::Style::Resize to your window does the opposite of what you want: you're allowing your window to be resized. :D
The style of your window is defined by a combination of different styles. When you use sf::Style::Default, you actually use sf::Style::Resize and sf::Style::Close, which allow resizing and closing.
You can use multiple styles with | bit operator. For example, if you want a window with a titlebar and a close button you create a combination of the 2 corresponding styles:
gameScreen.Create(sf::VideoMode(800, 600), "Lazeroids!", sf::Style::Titlebar | sf::Style::Close, 0);

Here's a tutorial (unrelated to SFML) if you need a better understanding of flags : http://www.codeproject.com/Articles/13740/The-Beginner-s-Guide-to-Using-Enum-Flags

Link

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: [1.6] How to disable resizing SFML window.
« Reply #2 on: March 31, 2013, 05:15:27 pm »
I do that but I get the following error:

app.cpp:5: error: no matching function for call to ‘sf::Window::Create(sf::VideoMode, const char [11], int, int)
/usr/local/include/SFML/Window/Window.hpp:100: note: candidates are: void sf::Window::Create(sf::VideoMode, const std::string&, long unsigned int, const sf::WindowSettings&)
/usr/local/include/SFML/Window/Window.hpp:109: note:                 void sf::Window::Create(sf::WindowHandle, const sf::WindowSettings&)
 

Seems to say that calling the function like that is incorrect?

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: [1.6] How to disable resizing SFML window.
« Reply #3 on: March 31, 2013, 05:26:45 pm »
Try without the 0 at the end. I copied it from your code, it's been a long time since I used 1.6.
gameScreen.Create(sf::VideoMode(800, 600), "Lazeroids!", sf::Style::Titlebar | sf::Style::Close);

BTW it was only an example, the doc says that sf::Style::Close contains sf::Style::Titlebar, so Titlebar is actually useless if you already use the Close style.
gameScreen.Create(sf::VideoMode(800, 600), "Lazeroids!", sf::Style::Close);
« Last Edit: March 31, 2013, 05:28:17 pm by G. »

Link

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: [1.6] How to disable resizing SFML window.
« Reply #4 on: March 31, 2013, 05:39:25 pm »
Wow, thanks! The last/second one worked perfectly. Thanks for the help.