SFML community forums

General => General discussions => Topic started by: Nexus on July 16, 2011, 01:05:57 pm

Title: List of modifications from SFML 1.6 to 2.0
Post by: Nexus on July 16, 2011, 01:05:57 pm
Since many SFML users have already asked this question and it might be useful for people who port projects from SFML 1.6 to Git revisions of SFML 2, I have created a list of API and functionality modifications. Feel free to complete it, I will edit this post. Note that SFML 2 is not finished yet, so the current API is still subject to change.

I only want to mention the most important and not obvious API-breaking changes to keep a good overview. Red are changes which may still compile with old code, but which introduce silent bugs and hence require special attention. Blue are pure additions.

GeneralSystem package
Window package
Graphics package
Network packageAudio package
Title: List of modifications from SFML 1.6 to 2.0
Post by: Jove on July 16, 2011, 03:09:13 pm
Thanks Nexus.
Title: List of modifications from SFML 1.6 to 2.0
Post by: Hiura on July 16, 2011, 09:18:07 pm
Good work there! Thank you!  :)
Title: List of modifications from SFML 1.6 to 2.0
Post by: Contadotempo on July 16, 2011, 10:06:38 pm
On SFML 1.6 sf::Image::SetSmooth() was set to true by default, on SFML 2.0 is set to false, right?
Is it worth adding it to the list?
Title: List of modifications from SFML 1.6 to 2.0
Post by: xazax on July 17, 2011, 09:31:36 am
And there is a new SFML\OpenGL.hpp that needs to be included if somebody do OpenGL stuff. It wasn't there in 1.6.
Title: List of modifications from SFML 1.6 to 2.0
Post by: Laurent on July 17, 2011, 10:51:15 am
Here is my private changelog. It should be almost complete :)

I should rather put it in an official tutorial for SFML 2.0 ("Porting from 1.6 to 2.0"). I'll try to find the time to do it soon.

SYSTEM
- OS-specific implementations (threads, mutexes) no longer appear in the public headers
- Added thread-local storage classes
- Changed the sf::Thread interface
- Improved string handling (added sf::String (high-level) and sf::Utf (low-level))
- Added string conversions between UTF and latin-1 (ISO-5589-1)
- Errors are now written to a SFML specific stream (sf::Err()) rather than std::cerr
- Removed the sf::Randomizer class
- sf::Mutex is now recursive on all platforms (was not on Linux and Mac OS X)

WINDOW
- Changed WindowSettings to ContextSettings, changed default values (24, 8, 0) -> (0, 0, 0)
- Added the context version to ContextSettings (to be able to create OpenGL 3.x context)
- OpenGL headers are no longer included by default in sfml-window, it is now in SFML/OpenGL.hpp
- Added Style::Default
- Improved synchronization between events and corresponding states in sf::Input
- Merged VideoMode::GetModesCount and VideoMode::GetMode into a single function

VideoMode::GetFullscreenModes
- Renamed Window::UseVerticalSync to EnableVerticalSync
- Added a blocking WaitEvent function in sf::Window
- Added Window::GetSystemHandle()
- Added sf::Window::SetTitle
- Added mouse position to the Event::MouseWheelMoved event
- Added support for OpenGL 3 (and above) contexts
- sf::Input -> sf::Joystick, sf::Keyboard, sf::Mouse (directly connected to the OS rather than to sf::Event)
- Removed sf::Window::SetCursorPosition (see sf::Mouse::SetPosition(Window))

GRAPHICS
- Added sf::RenderImage
- View --> slightly changed interface
- Added viewport to sf::View
- Added rotation to sf::View
- Improved rendering performances
- Removed RenderWindow::Capture (use Image::CopyScreen instead)
- Removed RenderTarget::PreserveOpenGLStates, replaced with SaveGLStates/RestoreGLStates
- Added Image::GetMaximumSize()
- Renamed Image::GetValidTextureSize to Image::GetValidSize
- Views are now handled by value (copied), not by reference
- Renamed Shape::GetNbPoints to Shape::GetPointsCount (consistent with other similar functions)
- Glyph : Rectangle --> Bounds, TexCoords --> SubRect
- Renamed Shape::Set/GetOutlineWidth to Set/GetOutlineThickness
- Renamed sf::PostFx to sf::Shader, and made it more flexible (can be applied to individual drawables)
- Inverted angles in drawable classes
- Images are not smooth anymore by default
- Renamed sf::String to sf::Text
- Added Image::UpdatePixels for fast pixel updates
- sf::Rect is now defined as [left, top, width, height]
- Added a parameter to Sprite::SetImage, to allow auto-adjustment of the subrect to the size of the new image
- Fixed tab character not properly rendered in sf::Text
- Renamed the Center property of drawables to Origin
- sf::Font now dynamically adapts to the rendered text, there's no more fixed size and character set

AUDIO
- Removed dependency to stb_vorbis
- Renamed SoundRecorder::CanCapture to SoundRecorder::IsAvailable
- Fixed sf::Listener's target that was a relative direction instead of an absolute position
- Added support for saving audio files as ogg/vorbis
- Added the ability to seek in sound streams and musics

NETWORK
- Reorganized the socket classes, however the features remain the same
- Minor modifications to sf::IpAddress
- Removed dependencies to system specific libraries in the public headers
- Made packet handling with UDP sockets more robust
- Added support for Unicode strings in sf::Packet
- Got rid of whatismyip.org as the default server for public IP retrieval
- Changed sf::Packet::operator bool() to something similar that avoids inappropriate implicit conversions

GENERAL
- Huge improvements to the API documentation, it is now much more detailed
- Changed const char* to const void* in LoadFromMemory functions
- The external libraries used by sfml-graphics are now linked instead of being integrated into the source code
- Removed the Qt and wxWidgets samples
- Switched to CMake, dropped individual support for compilers/IDEs
- New naming conventions for binaries (major version number appears in Windows DLLs -- not import libraries)
- SFML_DYNAMIC -> SFML_STATIC
- Added the SFML_VERSION_MAJOR and SFML_VERSION_MINOR macros
- Added support for 64-bits builds
- Changed all times in SFML to be Uint32 milliseconds instead of float seconds
Title: List of modifications from SFML 1.6 to 2.0
Post by: Nexus on July 17, 2011, 11:39:37 am
Ah nice, yours is slightly more detailed :D

Maybe it is worthwhile to emphasize backwards-incompatible changes and those who still compile but have other semantics. That would make it easier for people who just want to port projects without caring about all the new features. What do you think? I can colorize the points if you want ;)
Title: List of modifications from SFML 1.6 to 2.0
Post by: Groogy on July 17, 2011, 11:41:37 am
Well The time is one on that. Because I could compile rbSFML after it was changed from float to sf::Uint32 which kind of scared me.
Title: List of modifications from SFML 1.6 to 2.0
Post by: Laurent on July 17, 2011, 12:10:25 pm
Quote
Maybe it is worthwhile to emphasize backwards-incompatible changes and those who still compile but have other semantics. That would make it easier for people who just want to port projects without caring about all the new features. What do you think? I can colorize the points if you want

Like I said, I'll rather try to write the corresponding porting tutorial ;)
Title: List of modifications from SFML 1.6 to 2.0
Post by: TheMiss on July 17, 2011, 01:40:41 pm
Why inverted angles of the sf::Drawable  :?:
Title: List of modifications from SFML 1.6 to 2.0
Post by: Nexus on July 17, 2011, 01:50:33 pm
Quote from: "Laurent"
Like I said, I'll rather try to write the corresponding porting tutorial ;)
That's a good idea, then you can mainly focus on the API breakers. But a complete list of changes in addition is useful, too.

Quote from: "TheMiss"
Why inverted angles of the sf::Drawable :?:
Because they were mathematically incorrect, see here (http://www.sfml-dev.org/forum/viewtopic.php?t=4467).
Title: List of modifications from SFML 1.6 to 2.0
Post by: malandrin on July 20, 2011, 10:15:37 am
I can't find Socket::isValid anymore in 2.0.
Should I forget it ?
Title: List of modifications from SFML 1.6 to 2.0
Post by: Laurent on July 20, 2011, 10:34:42 am
Quote
I can't find Socket::isValid anymore in 2.0
Should I forget it ?

Yes.
* this is useless for UDP sockets
* for TCP sockets, you want to check if the socket is connected with GetRemoteAddress()
Title: List of modifications from SFML 1.6 to 2.0
Post by: AngelHoof on July 22, 2011, 01:30:42 pm
Quote
sf::Input -> sf::Joystick, sf::Keyboard, sf::Mouse (directly connected to the OS rather than to sf::Event)


I thought I was using SFML 2.0, or are these simply not implemented in the build I am using?
Title: List of modifications from SFML 1.6 to 2.0
Post by: Laurent on July 22, 2011, 01:47:59 pm
Quote
I thought I was using SFML 2.0, or are these simply not implemented in the build I am using?

It was implemented two weeks ago.
Title: List of modifications from SFML 1.6 to 2.0
Post by: Klaim on July 25, 2011, 02:29:02 pm
Laurent, when the time comes, could you add a tag in the repository to mark the last changeset that have the current drawing API?

As said in another thread I'll work in August on a game that requires to heavily manipulate this API, but I still want to use SFML2.0.
It would be easier to know which version to use that is not a WIP implementation, so maybe a tag is an easy way to do make people use a fixed api?

Or maybe you'll work on it on another branch or clone repository? If it's the case, then ignore my request. :)
Title: Re: List of modifications from SFML 1.6 to 2.0
Post by: hagel on August 03, 2011, 04:14:30 pm
Quote from: "Nexus"

System package
  • sf::Thread works now with function objects, no more inheritance

So no more of this?
Code: [Select]

class MyClass : public sf::Thread{
private :
    virtual void Run(){
        for (int i = 0; i < 10; ++i)
            std::cout << "I'm the thread number 2" << std::endl;
    }
};
myClass.Launch();

Oh man. That will mess up my code.
What will the alternatives be? For someone trying to program as object oriented as possible?
Title: Re: List of modifications from SFML 1.6 to 2.0
Post by: Nexus on August 03, 2011, 04:32:40 pm
Quote from: "hagel"
What will the alternatives be?
Any callables (functors, functions, member functions). It is a good decision to use them since they are far more powerful while reducing boilerplate code. For the full flexibility, you might want to take a look at Boost.Function and Boost.Bind, their functionality is part of the coming C++ standard.

What probably shows best their power is the fact that you can nearly keep your code: Just remove the inheritance and initialize the sf::Thread object with a member function pointer to the non-virtual MyClass::Run().

Quote from: "hagel"
For someone trying to program as object oriented as possible?
Code doesn't automatically become more object oriented the more classes it uses. Inheritance to extend functionality is the Java approach, C++ additionally provides many (often better) alternatives. There is no reason why a thread cannot be a global function.
Title: List of modifications from SFML 1.6 to 2.0
Post by: MorleyDev on August 03, 2011, 08:35:30 pm
boost::thread is being implemented to in C++(0/1)x as std::thread. I prefer using boost::thread anyway since it gives me access to the rest of boost's thready goodness :P
Title: Re: List of modifications from SFML 1.6 to 2.0
Post by: hagel on August 04, 2011, 11:53:48 am
Quote from: "Nexus"
Quote from: "hagel"
For someone trying to program as object oriented as possible?
Code doesn't automatically become more object oriented the more classes it uses. Inheritance to extend functionality is the Java approach, C++ additionally provides many (often better) alternatives. There is no reason why a thread cannot be a global function.

Of couse more classes aren't always more OOP but in my case, the code was for a server thread. The class will exist.

After finding the 2.0 documentation and looking at the examples I found that all three of them use an instance of sf::Thread.
Before I had a server object in my game class. Now I need a server object and a thread object. I know, not a big deal, but still.

Also, why remove the functionality of inheritance? Because of clashing with the other new functionality?

I'll have to experiment a bit with this.
Title: List of modifications from SFML 1.6 to 2.0
Post by: Laurent on August 04, 2011, 12:00:19 pm
Quote
Before I had a server object in my game class. Now I need a server object and a thread object. I know, not a big deal, but still.

Also, why remove the functionality of inheritance? Because of clashing with the other new functionality?

It seems like you don't fully understand the new way of using threads.
There's no removed functionality (only more flexibility), and your server can remain as it is, you just need to change 2 lines of code in its implementation.

Code: [Select]
class Server
{
public:

    Server() : myThread(&Server::Run, this)
    {
    }

private:

    void Run()
    {
        ...
    }

    sf::Thread myThread;
};


The old way of using threads, with inheritance, was only a special case of what the new implementation allows.
Title: List of modifications from SFML 1.6 to 2.0
Post by: hagel on August 04, 2011, 12:10:15 pm
Quote from: "Laurent"
...Excellent information...

Wow, I'm an idiot. I understand now. I learned threads from Java, and it was a few years ago.
Thanks
Title: List of modifications from SFML 1.6 to 2.0
Post by: Nexus on August 04, 2011, 12:44:59 pm
That's what I wanted to say with that statement ;)
Quote from: "Nexus"
What probably shows best their power is the fact that you can nearly keep your code: Just remove the inheritance and initialize the sf::Thread object with a member function pointer to the non-virtual MyClass::Run().

Additionally, sf::Thread now offers many alternatives, such as functors (especially created with std::bind) or global functions. In the end, you have many more possibilities with the new approach. By the way, std::thread also works with callables.
Title: great job!
Post by: prchakal on August 05, 2011, 09:34:17 pm
great job sfml team!

do you know where the version will be avaliable?

for linux and mac too?
Title: List of modifications from SFML 1.6 to 2.0
Post by: LightWolf on August 08, 2011, 03:42:45 pm
Should note the very recent splitting of sf::Image in sf::Texture and sf::Image  8)
Title: Re: great job!
Post by: OniLinkPlus on August 08, 2011, 10:39:18 pm
Quote from: "prchakal"
great job sfml team!

do you know where the version will be avaliable?

for linux and mac too?
There's no "SFML Team," it's just Laurent.
It's available on the github repository, accessible from the mainsite. If you meant when, it's available now, for every platform.
Title: Re: great job!
Post by: Nexus on August 09, 2011, 08:33:02 am
Quote from: "LightWolf"
Should note the very recent splitting of sf::Image in sf::Texture and sf::Image
I don't know, does it make sense if I keep the list here up-to-date?

Quote from: "OniLink10"
There's no "SFML Team," it's just Laurent.
Don't forget Hiura for the Mac port and the language binding developers. But Laurent is the one designing the library ;)
Title: Re: great job!
Post by: LightWolf on August 09, 2011, 11:59:33 am
Quote from: "Nexus"
Quote from: "LightWolf"
Should note the very recent splitting of sf::Image in sf::Texture and sf::Image
I don't know, does it make sense if I keep the list here up-to-date?

Why not?
Title: List of modifications from SFML 1.6 to 2.0
Post by: Nexus on August 09, 2011, 01:45:27 pm
Since Laurent has the better list and announced to write a complete tutorial ;)

But if you like, I can still keep the list in the initial post up-to-date, referring only to the most important changes.
Title: List of modifications from SFML 1.6 to 2.0
Post by: Jasmine on August 12, 2011, 08:29:52 am
Please do, it is very useful for people in the mean time :)
Title: where is sf::RenderImage ?
Post by: vanisher on August 20, 2011, 02:57:26 am
Where is sf::RenderImage?

Just downloaded a project that uses it, but the 2.0 snapshot doesn't mention it anywhere... then i read in this thread that sf::RenderImage was a new addition but i can't find it anywhere in the snapshot or the docs, now i got no clue how to compile the project..

Also, is it possible to download win32 DLLs from recent 2.0 snapshots anywhere?

And... do you have any idea when v2.0 might become official?
Title: List of modifications from SFML 1.6 to 2.0
Post by: Laurent on August 20, 2011, 09:19:21 am
Quote
Where is sf::RenderImage?

It was renamed to sf::RenderTexture.

Quote
Also, is it possible to download win32 DLLs from recent 2.0 snapshots anywhere

No. But compiling it is really easy if you follow the detailed tutorial.

Quote
And... do you have any idea when v2.0 might become official?

No, sorry.
Title: List of modifications from SFML 1.6 to 2.0
Post by: Dragnalith on October 24, 2011, 04:45:28 am
Hi,
I have just saw the topic about the graphical API refactoring. Does it mean it's a bad idea to use unstable SFML 2.0 today because a lot of thing will change soon ?
Title: List of modifications from SFML 1.6 to 2.0
Post by: Laurent on October 24, 2011, 07:33:19 am
No, because the current classes will not change so much. Only sf::Shape will be significantly modified.
Title: Re: List of modifications from SFML 1.6 to 2.0
Post by: Nexus on April 21, 2013, 12:35:45 pm
Time passes so fast...

I have updated the list with some important points. It's still largely incomplete, even if we focus only on the crucial API parts. Don't hesitate to post suggestions here :)