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

Author Topic: float, float for ctors or setSize  (Read 3385 times)

0 Members and 1 Guest are viewing this topic.

chessguy

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
float, float for ctors or setSize
« on: January 06, 2014, 08:40:46 pm »
Greetings. This isn't so much a feature request as an idea for slight convenience.

Let's take RectangleShape as an example, though it isn't the only thing. The ctor takes sf::Vector2f, as does setSize. However, others - position, origin, scale, etc - also take two floats. For lazy people like myself, such methods are nice. Is there a reason the setSize* don't have it?

On another note, I recently added a fullscreen option for something. To check if it was, I had to get the fullscreen modes from VideoMode, then compare it. I feel there must be a better way. Should Window have a getStyle?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: float, float for ctors or setSize
« Reply #1 on: January 06, 2014, 08:51:30 pm »
These questions have already been discussed. I recommend to use the forum search, especially if you like to hear the opinion of Laurent himself.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

chessguy

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: float, float for ctors or setSize
« Reply #2 on: January 06, 2014, 09:08:02 pm »
Hrm. Apparently it is easier to find things using google search than the forum search. Now I came up with something.

The reason I found stated was to not have duplicate code, essentially. This is logical. However, I don't see the problem here. setSize(float, float) can call setSize(sf::Vector2f), can it not? I myself did this for something, and have not seen any problems.

ctors can work similarly if using C++11. I don't know when SFML will reach that point, though.

Not sure on the window thing. One place I found said that the window needs to be recreated anyway for such a thing. Another (this by Laurent) said it was a planned feature. I don't think it would be hard to store the flags of the last set, though. Quite possible I am overlooking something obvious.

thomas9459

  • Newbie
  • *
  • Posts: 49
    • View Profile
    • Email
Re: float, float for ctors or setSize
« Reply #3 on: January 11, 2014, 07:45:40 pm »
It is possible (at least in c++11) to use this:
sprite.setSize({200,200});
instead of this:
sprite.setSize(sf::Vector2f(200.f, 200.f));
This technique can also be applied elsewhere, such as for sf::Color. It's not very clean, but if your lazy, what do you expect? :P

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: Re: float, float for ctors or setSize
« Reply #4 on: January 11, 2014, 08:14:17 pm »
This technique can also be applied elsewhere, such as for sf::Color. It's not very clean, but if your lazy, what do you expect? :P
I consider it clean enough. The signature of functions are clearly defined, there's no need to reapt the type explicitly again. It might lose some verbosity, but I don't see that as an issue. The code will for sure start to look cleaner.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/