Comments (10)
I like this idea.
from sfml.
It makes sense... I'll have to think about it, and see if it would fit everywhere.
from sfml.
I have added some other examples to the ticket.
from sfml.
Note that sf::Vector2i stores signed ints, whereas most of the listed members are unsigned ints. You should probably think about the definition of sf::Vector2ui instead of having signed/unsigned conflicts all over the place.
from sfml.
Or delete the typedefs for sf::Vector2f and sf::Vector2i and write sf::Vector2< float> etc. all the time. Then there will be never again the problem, that there is a typedef for sf::Vector2< a> but not for sf::Vector2< b>. Thats a cleaner solution in my opinion.
from sfml.
No, that would just introduce unnecessarily long type names without real advantages. In my opinion, it is okay to abbreviate the most common types, especially when they are used by SFML itself. Namely, this concerns float, int, unsigned int.
from sfml.
In fact, none of these solutions satisfy me. It's true that sf::Vector is too long to type, but I don't like sf::Vector2x typedefs.
I'm thinking more and more about doing it the same as Qt does:
- sf::SizeI and sf::SizeF for sizes
- sf::PointI and sf::PointF for positions
- sf::RectI and sf::RectF for rectangles
- signed int everywhere, I think it's not a big deal to use int when negative values don't make sense. People are smart enough to figure out themselves if a negative value would be relevant or not; and it has the additional benefit of allowing -1 for invalid/uninitialized values
This is of course open to discussion.
from sfml.
I am not sure whether the division of vectors into size and position/point is the right decision.
- First, there are too many cases where a vector is neither of them (e.g. scale, velocity or acceleration). Sometimes, it is also difficult to draw the border, since a position is basically a size, namely the vector from the coordinate system origin to the object.
- That is also why I believe this leads to many unnecessary conversions, complicating harmless code.
- Vector operations are more difficult to formulate (does a position have a length/origin distance?) and separate overloads for sf::Point and sf::Size become necessary.
- The change breaks a huge amount of existing code.
- The resulting type safety is of limited advantage. I don't think it can prevent a lot of mistakes, since confusing size and position occurs rarely.
In my opinion, the idea behind the separation is a good one, however I fear that the cons outweigh the pros. The functionality becomes more complex, but at the same time it can cover less use cases. I think SFML as a basic multimedia framework should continue to provide the generally usable vectors.
from sfml.
First of all, I do not think that sf::Vector2< float> is too long. Most containers and types in the STL have long names as well. The long word "unsigned" can be avoided when C++0x is released, because it contains the header cstdint that defines a uint32_t. Avoiding typedefs has the advantage, that the code becomes more understandable. With a typedef it is not obvious that the class behind it is a template. Another problem is, that most naming conventions like Vector2i, Vector2ui, Vector2f, ... create problems and conflicts if you define too much of them (for example, if you define a Vector2si... Is it Vector2< signed int>, Vector2< short int> or Vector2< someotherstrangetype>?).
I agree to TheNexus, that a division into Size and Point is not a good solution. The reasons are already mentioned by him(although I do not think that "The change breaks a huge amount of existing code" is a good reason to keep the old names).
from sfml.
First of all, I do not think that sf::Vector2< float> is too long. Most containers and types in the STL have long names as well.
The difference is, at the STL there are no instantiations which are especially often used, so there is nothing to typedef. In SFML, some types like float clearly have a special status in combination with sf::Vector2. And std::uint32_t is not necessarily the same as unsigned int, apart from that it is even longer.
With a typedef it is not obvious that the class behind it is a template.
Yes, but that is not important. You can use sf::Vector2f as if it were a "raw" class. Very similar to std::string, a lot of C++ programmers don't even know that std::string is a typedef. It just doesn't matter. In fact, class template instantiations are classes.
Anyway, the vectors of the C binding must exist as explicit structure for each type, therefore the removal of the equivalent types from the C++ code is only a step towards inconsistence.
Another problem is, that most naming conventions like Vector2i, Vector2ui, Vector2f, ... create problems and conflicts if you define too much of them
Which is not a problem here since we have at most three different types that also have common abbreviations.
although I do not think that "The change breaks a huge amount of existing code" is a good reason to keep the old names
It is a point to take into account when making such decisions, although not the most important one.
from sfml.
Related Issues (20)
- WebGL Support HOT 1
- `sf::Keyboard::getDescription` returns "Unknown" for F13+ keys on Win32 HOT 4
- choco package HOT 3
- Android CI jobs have broken HOT 2
- Conflict between SRP and OCP HOT 2
- [2.6.1] segfault in waitEvent on close (Ubuntu/X11/Multithreading) HOT 7
- [2.6.1] Drawing to RenderTexture "fails" after Texture copied from (Windows) HOT 3
- Add a CMake guide for static linking the library in MacOS/Linux HOT 1
- `sf::VideoMode::getDesktopMode()` returning the monitor resolution on macOS HOT 2
- Install prefix not honored HOT 3
- Consider changing `sf::Texture::invalidateMipmap()` from private to public HOT 4
- Creating a window when statically linking on macOS causes a crash HOT 2
- MacOS static release HOT 1
- Cannot disable SFML installation targets when installing a game which includes SFML with fetch content HOT 4
- Revert change to `sf::Drawable::draw` signature which made `sf::RenderStates` a const reference, and make it a copy again HOT 10
- (Linux) Window Close Event not triggered with sf::Style None, Titlebar, Resize
- Cannot create DRM context without X server running. HOT 2
- sfml window example crashes due to acess violation on joystick driver ezfrd64.dll HOT 3
- Add support for QOI (Quite OK Image) and QOA (Quite OK Audio) formats HOT 2
- Store angles internally as radians HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sfml.