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

Poll

Which names do you like the most?

Vector2f / Rectf / Vector2i / Recti
24 (58.5%)
Vector2F / RectF / Vector2I / RectI
2 (4.9%)
Vector2F / RectangleF / Vector2I / RectangleI
1 (2.4%)
FloatVector2 / FloatRect / IntVector2 / IntRect
2 (4.9%)
Don't change it please!
9 (22%)
I have something else to suggest
3 (7.3%)

Total Members Voted: 40

Voting closed: June 24, 2009, 06:22:05 pm

Author Topic: Vector2f vs FloatRect  (Read 20789 times)

0 Members and 2 Guests are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Vector2f vs FloatRect
« Reply #15 on: June 25, 2009, 03:25:37 pm »
Quote
Because I think there should be a distinction between points and sizes. A size should never be negative, whereas the members of a point could (and because to me "vector" is not enough explicit). I know explanations have been given about negative size (allows inverted object drawing) but I think this is short and simple solution, but absolutely not an intuitiv one.

There no use of negative sizes to mirror objects in SFML. All integer sizes already use unsigned integers (whether they use sf::Vector2 or not), and float ones well... I can't do anything ;)

Quote
I prefer OpenGL naming convention, thus if I was the only one to be asked, SFML would already follow this convention

What "OpenGL naming conventions" are you talking about, apart from the name{dim}{type} one?
Laurent Gomila - SFML developer

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Vector2f vs FloatRect
« Reply #16 on: June 25, 2009, 07:27:44 pm »
Quote from: "Laurent"
There no use of negative sizes to mirror objects in SFML. All integer sizes already use unsigned integers (whether they use sf::Vector2 or not), and float ones well... I can't do anything ;)

I'm not sure we're talking of the same thing, Rect is defined by Left, Top Right and Bottom, thus Left can be greater than Right, same thing for Top and Bottom. What's the behaviour in these cases ?

Quote from: "Laurent"
Quote
I prefer OpenGL naming convention, thus if I was the only one to be asked, SFML would already follow this convention

What "OpenGL naming conventions" are you talking about, apart from the name{dim}{type} one?

Lowercase for the first letter of methods (yeah I know a lot of people do not like this) and variables, short names rather than fully explicit names (ie Rect instead of Rectangle, and not only for this case!) without using hungrian naming though. I need to have a closer look at SFML interface to tell you more, but that's already part of the thing.

I agree using short naming is discussable, but until it involves confusion, it's quicker to type and use (to my mind).
Want to play movies in your SFML application? Check out sfeMovie!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Vector2f vs FloatRect
« Reply #17 on: June 25, 2009, 07:37:40 pm »
Quote
What's the behaviour in these cases ?

For what usage of rectangles?

Quote
Lowercase for the first letter of methods

Well, it's mainly because every function has the "gl" prefix.

Quote
yeah I know a lot of people do not like this

I like it (if I could change the whole naming convention for SFML I'd do it this way) :lol:

Quote
short names rather than fully explicit

I'll never use short names. There's just no reason to use short names (with auto-completion nobody ever writes full names), and many good reasons to use long ones ;)
Laurent Gomila - SFML developer

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Vector2f vs FloatRect
« Reply #18 on: June 25, 2009, 08:35:22 pm »
Quote from: "Laurent"
Quote
What's the behaviour in these cases ?

For what usage of rectangles?

For example with sf::Sprite::SetSubRect() ? Will the image appear inverted ?

Quote from: "Laurent"
Quote
Lowercase for the first letter of methods

Well, it's mainly because every function has the "gl" prefix.

I think it'd be the same kind of typo even without this prefix.

Quote from: "Laurent"
Quote
yeah I know a lot of people do not like this

I like it (if I could change the whole naming convention for SFML I'd do it this way) :lol:

Does it mean you can't ?

Quote from: "Laurent"
Quote
short names rather than fully explicit

I'll never use short names. There's just no reason to use short names (with auto-completion nobody ever writes full names), and many good reasons to use long ones ;)

Okkay :) .
Want to play movies in your SFML application? Check out sfeMovie!

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Vector2f vs FloatRect
« Reply #19 on: June 25, 2009, 08:47:14 pm »
Quote from: "Ceylo"
Quote from: "Laurent"
Quote
Lowercase for the first letter of methods

Well, it's mainly because every function has the "gl" prefix.

I think it'd be the same kind of typo even without this prefix.
We can assume sf:: as a prefix.
SFML / OS X developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Vector2f vs FloatRect
« Reply #20 on: June 25, 2009, 08:57:24 pm »
Quote
We can assume sf:: as a prefix.

Absolutely :)
I think prefixes / namespaces are a different naming convention than function and variable names.

Quote
For example with sf::Sprite::SetSubRect() ? Will the image appear inverted ?

No, such a rectangle is not valid. But it's impossible to ensure with a structure storing left/right/top/bottom. It would be possible only with width/height, and only for integer based rectangles.

Quote
Does it mean you can't ?

I think so. But I'm tempted :D
Laurent Gomila - SFML developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Vector2f vs FloatRect
« Reply #21 on: June 25, 2009, 09:14:29 pm »
Quote from: "Laurent"
Quote
Does it mean you can't ?

I think so. But I'm tempted :D
IMO you should do it. S(T)L do it that way. So why not SFML ?
SFML / OS X developer

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Vector2f vs FloatRect
« Reply #22 on: June 25, 2009, 10:26:55 pm »
Nothing to do with this topic but, I think sf::String should be called sf::Text.

Classes named "string" are usually meant to handle character arrays in software, and have nothing to do with rendering and viewing.

"Text" or "Label" are usually used for viewable GUI elements.

It's funny because the way of setting a string to sf::String is SetText.
I think it should be the other way around (sf::Text::SetString())


What do you think?

-Martín

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Vector2f vs FloatRect
« Reply #23 on: June 25, 2009, 10:45:49 pm »
Quote
IMO you should do it. S(T)L do it that way. So why not SFML ?

It would be more the Qt style rather than STL/boost one.

Quote
Nothing to do with this topic but, I think sf::String should be called sf::Text.

Probably ;)

Well, it seems that the discussion is sliding towards "global naming conventions in SFML" :D

Unless someone has a good argument for keeping everything like it is (that I could understand), I'm opened to any suggestion. Enjoy it, I won't do this again in the future :lol:
Laurent Gomila - SFML developer

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Vector2f vs FloatRect
« Reply #24 on: June 26, 2009, 12:43:34 pm »
Quote from: "Laurent"
Quote
For example with sf::Sprite::SetSubRect() ? Will the image appear inverted ?

No, such a rectangle is not valid. But it's impossible to ensure with a structure storing left/right/top/bottom. It would be possible only with width/height, and only for integer based rectangles.

So why isn't a Rect composed of these two members ?

Quote from: "Laurent"
Quote
Does it mean you can't ?

I think so. But I'm tempted :D

Reminds me something :roll:

Quote from: "Laurent"
Well, it seems that the discussion is sliding towards "global naming conventions in SFML" :D

Unless someone has a good argument for keeping everything like it is (that I could understand), I'm opened to any suggestion. Enjoy it, I won't do this again in the future :lol:

Woooot ! *goes have a look at the whole SFML interface*
Want to play movies in your SFML application? Check out sfeMovie!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Vector2f vs FloatRect
« Reply #25 on: June 26, 2009, 01:01:24 pm »
Quote
So why isn't a Rect composed of these two members ?

Because I wouldn't be able to use unsigned int size + int position, unless IntRect is a separate class from FloatRect rather than an instanciation of the same template.

Quote
Reminds me something

What?
Laurent Gomila - SFML developer

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Vector2f vs FloatRect
« Reply #26 on: June 26, 2009, 04:46:26 pm »
I like the current Vector/Rect notation because is verbose as the rest of the library functions (But not in an extreme way).

I always liked the Open*L notation, so 2f is the clearest way to tell me that it has 2 floats. As the basic types are lower case, the letter should be to. Also, the capital D is used for other meanings, like glTexImage2D (2 dimensions, not 2 floats :)).

FloatVector2 seems to long to me. But you can always typedef to whatever makes you happy. An umbrella header is the easiest approach.

I'm more ok with the verbose versions that "Rectf/Recti" that sounds (in the later) like a latin conjugation for ASS :lol:

For these almost-basic algebraic types I like verbosity but when It doesn't exceed a length of about 10 characters. After that it starts bloating the source code and looks like crap.

Well, happy ranting to the rest xD

Regards
-Martín

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Vector2f vs FloatRect
« Reply #27 on: June 26, 2009, 04:53:38 pm »
Quote from: "Laurent"
Quote
So why isn't a Rect composed of these two members ?

Because I wouldn't be able to use unsigned int size + int position, unless IntRect is a separate class from FloatRect rather than an instanciation of the same template.


You could having a signed/unsigned typenames in the template and then using uint/int & float/float.

But anyway, it's totally impractical. The subtraction between two int/float numbers is extremely fast (them being cached in the CPU).

If it really makes a difference for a user, then he/she should keep the data duplicated within his own structure.

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Vector2f vs FloatRect
« Reply #28 on: June 27, 2009, 02:56:58 pm »
Quote from: "Laurent"
Quote
So why isn't a Rect composed of these two members ?

Because I wouldn't be able to use unsigned int size + int position, unless IntRect is a separate class from FloatRect rather than an instanciation of the same template.

It's rather annoying, because I would have like to access to the size and position members like I do for x and y. Hmm.. we have GetWidth() and GetHeight() that should be replaced with GetSize() as you mentionned on the previous page. It would be fine to also have something like GetOrigin() returning the top left point.

Quote from: "Laurent"
Quote
Reminds me something

What?

What you know about the packages :P .

Quote from: "nitram_cero "
I like the current Vector/Rect notation because is verbose as the rest of the library functions (But not in an extreme way).

So don't you think it should be Vector/Rectangle (or Frame ?) ? It does look more logical to me.
Want to play movies in your SFML application? Check out sfeMovie!

heishe

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Vector2f vs FloatRect
« Reply #29 on: June 27, 2009, 06:06:54 pm »
vector2f + rectf; you can write these names in a continous flow as you type in the characters on your keyboard. if you do something like vector2F, it puts a shift in the name which makes it kinda more uncomfortable to write.

 

anything