Simple and Fast Multimedia Library

Overview

SFML logo

SFML — Simple and Fast Multimedia Library

SFML is a simple, fast, cross-platform and object-oriented multimedia API. It provides access to windowing, graphics, audio and network. It is written in C++, and has bindings for various languages such as C, .Net, Ruby, Python.

Authors

Download

You can get the latest official release on SFML's website. You can also get the current development version from the Git repository.

Install

Follow the instructions of the tutorials, there is one for each platform/compiler that SFML supports.

Learn

There are several places to learn SFML:

Contribute

SFML is an open-source project, and it needs your help to go on growing and improving. If you want to get involved and suggest some additional features, file a bug report or submit a patch, please have a look at the contribution guidelines.

Issues
  • Remove dependecy toward libsndfile on all OS

    Remove dependecy toward libsndfile on all OS

    This implements #604. It's a rebase of feature/no_libsndfile_osx onto master (which includes feature/no_libsndfile) so be extra careful when proofreading it. Hopefully I haven't made any mistake but there were a lot of conflicts so...

    What's done & what's to be done:

    • [x] Android (all libs included)
    • [x] Android – make loading sound compatible with APK
    • [x] iOS (all libs included)
    • [x] Linux (no binary to be provided)
    • [x] OS X (all libs included)
    • [x] Window (all libs included)

    It also includes the base step toward #620.

    feature m:sfml-audio m:config 
    opened by mantognini 141
  • Replace FindSFML.cmake with SFMLConfig.cmake

    Replace FindSFML.cmake with SFMLConfig.cmake

    TODO list:

    • [x] Have config file generated on all platforms
    • [x] Support debug/release config
    • [x] Have no absolute path in generated config files on Linux / Windows / macOS / iOS? / Android?
    • [x] Export internal dependencies in case of static build (ie. remove the need for SFML_DEPENDENCIES)
    • [x] Support for REQUIRED/QUIET options of find_package()
    • [x] Framework install path
    • [x] SFML_DOC_DIR
    • [x] Remove FindSFML.cmake once SFMLConfig supports everything from it
    • [x] Exhaustive testing! ==> see https://en.sfml-dev.org/forums/index.php?topic=23676.msg161479#msg161479

    Out of scope:

    • Compatibility with split Linux packages
    • Support for components

    =============

    I've started doing the changes to support config file generation. At the moment this is working at least for me on macOS with frameworks. I expect it to work on other platforms too because it reuses the definitions of current SFML targets. This implies a LOT of changes though so I would like your feedback before going on.

    Especially I have replaced all the listing of dependencies with calls to target_link_libraries() and target_include_directories() for 3 reasons:

    • this avoids redoing what CMake already does (target_link_libraries() and target_include_directories() already handle lists)
    • this makes it easier to group the full setup (include+link) of each dependency
    • this will allow specifying which dependencies must be public in case of static linking (what SFML_DEPENDENCIES currently does in FindSFML.cmake), same eventually if compile definitions or include dirs must be exported (currently only the root include dir of SFML is exported)

    In terms of usage right now (example from sfeMovie) of course without any FindSFML.cmake:

    find_package (SFML 2.3 COMPONENTS graphics window system audio REQUIRED)
    target_link_libraries(sfeMovie PRIVATE sfml-graphics sfml-window sfml-system sfml-audio)
    

    I didn't expose yet the fact that sfml-graphics depends on sfml-window and sfml-system. Could be done and would allow writing only target_link_libraries(sfeMovie PRIVATE sfml-graphics sfml-audio) Dunno yet if we want that though.

    If you want to look at what the generated config looks like for now: http://yalir.org/files/SFML/ It gets installed in /usr/local/lib/cmake/SFML by default.

    References

    https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-packages https://cmake.org/cmake/help/latest/command/find_package.html https://cmake.org/cmake/help/latest/command/export.html https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html https://github.com/SFML/SFML/compare/master...SrTobi:support-config-file-packages

    Related issues

    https://github.com/SFML/SFML/issues/758 https://github.com/SFML/SFML/issues/937

    feature s:accepted m:config 
    opened by Ceylo 131
  • Added methods to set the cursor type/image

    Added methods to set the cursor type/image

    Supersedes #784.

    Thanks to @fundies for the initial draft implementation. I originally wanted to attribute the commit to him, but there were simply too many changes in the end.

    Resource leaks should be gone now, and general code style is fixed up. Like #784, this is still missing the OS X implementation. Hopefully @mantognini or someone else can fill in the gaps here and here. It can't be nearly as horrible as the Windows or Unix implementations. :stuck_out_tongue: This might help a bit.

    This implements #269.

    feature m:sfml-window s:accepted 
    opened by binary1248 131
  • Added a method to set and get additional spacing between characters.

    Added a method to set and get additional spacing between characters.

    SFML Tasks

    • [x] Check for forgotten discussion points
    • [x] Review code

    This is my code, that I promised in this forum thread. It is pretty straight forward. Here is some example code to test with:

    #include <SFML/Graphics.hpp>
    #include <iostream>
    
    int main()
    {
        sf::RenderWindow window(sf::VideoMode(800, 600), "Character Spacing Example");
        window.setFramerateLimit(60);
    
        // load font
        sf::Font font;
        if(!font.loadFromFile("BilboSwashCaps-Regular.otf"))
        {
            std::cerr << "Failed to load font!" << std::endl;
            return 1;
        }
    
        // setup the texts
        sf::Text normalText("SFML rocks! 123", font);
        normalText.setCharacterSize(100);
        normalText.setPosition(30, 10);
        normalText.setStyle(sf::Text::Style::Bold);
    
        sf::Text smallText("SFML rocks! 123", font);
        smallText.setCharacterSize(30);
        smallText.setPosition(30, 150);
        smallText.setStyle(sf::Text::Style::Bold);
    
        sf::Text stretchedText("SFML rocks! 123", font);
        stretchedText.setCharacterSize(100);
        stretchedText.setPosition(30, 200);
        stretchedText.setStyle(sf::Text::Style::Bold);
        stretchedText.setLetterSpacing(6.f);
    
        sf::Text smallStretchedText("SFML rocks! 123", font);
        smallStretchedText.setCharacterSize(30);
        smallStretchedText.setPosition(30, 350);
        smallStretchedText.setStyle(sf::Text::Style::Bold);
        smallStretchedText.setLetterSpacing(1.f);
    
    
        // run the program as long as the window is open
        while (window.isOpen())
        {
            // check all the windows events
            sf::Event event;
            while (window.pollEvent(event))
            {
                // "close requested" event: we close the window
                if (event.type == sf::Event::Closed)
                    window.close();
    
                else if (event.type == sf::Event::KeyReleased) {
                    // close if escape key was pressed
                    if (event.key.code == sf::Keyboard::Escape) {
                        window.close();
                    }
                }
            }
    
            // clear the window to black
            window.clear();
    
            // draw text
            window.draw(normalText);
            window.draw(smallText);
            window.draw(stretchedText);
            window.draw(smallStretchedText);
    
            // display the windows content
            window.display();
        }
        return 0;
    }
    

    letter-spacing The font Bilbo Swash Caps Regular is taken from here.

    feature m:sfml-graphics s:accepted 
    opened by Foaly 113
  • Methods to request and check window focus

    Methods to request and check window focus

    This pull request is based on https://github.com/LaurentGomila/SFML/pull/525 by @Foaly.

    It extends the sf::Window public interface with two methods:

    • void requestFocus() to give the window the focus
    • bool hasFocus() const to check whether the window is currently focused

    I tested the functionality on Windows 8.1 and Ubuntu 12.04. Here's a simple test program, based on Foaly's:

    #include <SFML/Graphics.hpp>
    
    int main()
    {
        sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
        window.setFramerateLimit(60);
    
        sf::Clock clock;
        while (window.isOpen())
        {
            sf::Event event;
            while (window.pollEvent(event))
            {
                if (event.type == sf::Event::Closed)
                    window.close();
                if (event.type == sf::Event::KeyReleased && event.key.code == sf::Keyboard::Escape)
                    window.close();
            }
    
            if (clock.getElapsedTime() > sf::seconds(2))
            {
                window.requestFocus();
                clock.restart();
            }
    
            window.setTitle(window.hasFocus() ? "Focused" : "Lost");
            window.clear(window.hasFocus() ? sf::Color::White : sf::Color::Black);
            window.display();
        }
    }
    

    I haven't gotten feedback concerning the X11 check as suggested by @FRex, it would be nice if somebody could have a look at commit 2df07b2eb61a9603bedb095dff73a042c4f26453.

    feature m:sfml-window s:accepted 
    opened by Bromeon 107
  • Feature/grab mouse

    Feature/grab mouse

    Related to #394.

    Adds sf::Window::setCursorGrabbed implementations for Linux, Windows and Mac OS X. Android and iOS devices have a «not applicable» implementation.

    Requires testing on:

    • [x] Linux
    • [x] Windows
    • [ ] OS X
    • [ ] iOS (build check only)
    • [x] Android (build check only)

    Here are a few scenarios to be tested:

    1. Grabbing the cursor works when the window has the focus.
    2. When grabbed, the cursor should not be able to leave the window.
    3. Closing the window should release the cursor.
    4. When grabbed, the window should not be resizable by dragging one of its sides.
    5. When switching to another app, the cursor should be released and re-grabbed when reactivating the SFML app.
    6. If the cursor is outside the view when it is grabbed the cursor should be projected into the window (and thus generate a mouse in event).
    7. The user should not be able to move fast the cursor and click outside the window to activate another application.
    8. The user should not be able to use the window bar to move, minimize, maximize or close the window.
    9. Fullscreen windows should grab the cursor correctly with 2+ monitors.
    10. Programmatically moving the window should keep the cursor inside the rendering area in case the cursor was grabbed and properly update the "grab area" to match the new window position.
    11. Like 10. but when programmatically resizing the window.

    This code can be useful for testing.

    Below is the list of issue from the above list that need to be fixed before merging this PR:

    • Linux: 5 (should be fixed, confirmation needed)
    • OS X: N/A
    • Window: N/A
    • iOS: N/A
    • Android: N/A

    Regarding OS X: [Updated on 25/4/2016] ~~The current impl is not bad but still an approximation of the feature (test n° 7 is somewhat supported and n° 8 is not supported at all) . It seems really hard to do it on Mac. Other libs (e.g. SDL) have even more bugs or undesired behaviour than this implementation. However, a lot of tricks are used which is not nice at all for future modifications of SFOpenGLView (among other things).~~

    ~~Commit d16d38e contains a more detailed explanation of the known issues (in commit message and comments in the code itself). I'm reluctant to include this commit in SFML codebase because it will considerably increase the complexity of the code and make it really hard to maintain. All that to "only" workaround a stupid corner case... Please let me know what you think.~~

    ~~An alternative for games that need grabbing would be to hide the cursor and use relative motion, preventing the cursor to actually move. This would involve much fewer corner cases in the implementations. Actually, SDL also provides this alternative.~~

    Please refer to commit 4f5baa53ece0f8777c23d1027098ceff7c2cea3c for detailed description of the workarounds involved.

    feature m:sfml-window s:accepted 
    opened by mantognini 90
  • Added loop point support to sf::Music

    Added loop point support to sf::Music

    After working a bit with SFML, I noticed that I couldn't set any custom loop points for sounds, and I need them for a game I'm working on. I spotted issue #177 sitting around, so I figured I would try implementing myself.

    For sf::Music / sf::SoundStream, I added a feature to detect a loop point and cut off the streaming of the buffer, and a pair of virtual functions that can allow sf::SoundStream to let its derived class decide where to seek upon looping. It's accomplished entirely within those two classes without doing anything too funny with OpenAL, and I'm happy with what I managed to accomplish with it.

    ~~For sf::SoundBuffer / sf::Sound, I ran into some more constraints. OpenAL-Soft has a way to set loop points, but it's not a well-documented feature, and it is also a buffer trait, rather than a source trait. It has a few more restrictions on the allowable values compared to the Music version because of this. It uses an "enum" value called AL_LOOP_POINTS_SOFT defined in "alext.h", which was present in SFML but not included, and I figured it was fair game to use. If not, then I can take the SoundBuffer implementation out.~~

    The inline documentation will explain any interface differences, but they're roughly the same, with getLoopStart(), getLoopEnd(), setLoopPointsFromTime(), and setLoopPointsFromSamples(). Three of those work with sf::Time, to keep everything consistent, the fourth is if you have an exact sample position you want to use.

    I hope this isn't frowned upon, but for testing, I augmented the SFML Sound Example to include some additional playings of the resource sounds, and demonstrating some of the extra features of the Music implementations. At least it should be easy to build and test. If any modification or more proof-of-functionality is needed, please let me know!

    feature m:sfml-audio s:accepted 
    opened by Cobaltergeist 78
  • Text rendering is ugly at small font sizes

    Text rendering is ugly at small font sizes

    It seems the text rendering APIs available in SFML 2.0 currently aren't able to render text with enough hinting to be legible at lower resolutions. Having text < 20pt is a must for some areas of my interface elements I'm making with SFML, so this is a large issue at the moment.

    Here's an example of what I'm talking about: Example of bad text rendering

    It seems SFML does have some kind of support for bitmap fonts, it's stated on the website as a feature: "Easy manipulation of graphical text through bitmap fonts". I can't seem to find anything in the documentation about this though, does this feature really exist?

    It'd be nice if one of the solutions was approached, either the inbuilt font rendering being worked on to be more capable, or bitmap font support being added so those that do wish to use small fonts can do so without rendering issues.

    Ironically it seems that even at 40pt the rendering engine can't handle some of the more fine hinting required by the current font I'm using, this can be seen in the 'i' of Exception, and various rounded edges of the 'rounder' letters like 'p' and 'o'.

    bug m:sfml-graphics s:accepted 
    opened by lyptt 65
  • Access Violation error in the destructor of sf::AudioDevice

    Access Violation error in the destructor of sf::AudioDevice

    Access Violation error occurs int the destructor of sf::AudioDevice on Windows XP SP3. It doesn't occur on Windows 7 and Windows Vista.

    Here is the instruction pointed by the visual C++ 2008 debugger:

    Code:

    AudioDevice::~AudioDevice() 
    { 
        // Destroy the context 
        alcMakeContextCurrent(NULL); 
        if (audioContext) 
    =>           alcDestroyContext(audioContext); 
    
        // Destroy the device 
        if (audioDevice) 
            alcCloseDevice(audioDevice); 
    } 
    

    The error can be reproduced with this simple code :

    #include <SFML/Audio.hpp> 
    
    int main() 
    { 
        sf::Sound Sound; 
    
        return EXIT_SUCCESS; 
    } 
    

    This problem was first discussed in this post of the french forum : http://www.sfml-dev.org/forum-fr/viewtopic.php?t=3443

    bug m:sfml-audio s:accepted 
    opened by fpoisson 60
  • Added support for outlined text

    Added support for outlined text

    Considering all the requests over the years for outlined text (and the totally hackish workarounds) and also that my current project will definitely need this at some point, I went ahead and implemented it. I made the PR for code review.

    Some key points are the following.

    • Outlined glyphs are stored in the same page as normal glyphs (can be changed if this is deemed that it will fill up the page texture too fast).
    • Text::[set|get]Color(...) is now marked as deprecated, instead everyone should use Text::[set|get]FillColor(...)
    • Font::getGlyph(...) has a new parameter, outline thickness which is defaulted to 0 (to avoid API breakage). The parameter determines how thick the outline will be in pixels.
    • Since outlined glyphs are stored in the same page/texture the key type has been changed to Int64 to continue being unique now that the outline thickness is part of the key.
    • I refactored Text::ensureGeometryUpdate() and split the duplicated code to append vertices to separate functions ::addLine(...) and ::addGlyphQuad(...). These can be renamed if someone could think of more appropriate names.
    • ~~Outline thickness is unsigned, I don't see any easy ways with freetype to make the outline protrude inwards with a negative thickness.~~ It is a float, but a negative value causes distorted rendering.
    • Nothing should change with the current rendering of text if the user decides not to use outlines.

    As stated before, please review this and give some feedback.

    #include <SFML/Graphics.hpp>
    
    int main()
    {
        sf::RenderWindow window({ 700, 400 }, "Outline test");
        window.setVerticalSyncEnabled(true);
    
        sf::Font font;
        font.loadFromFile("C:/Windows/Fonts/arial.ttf");
    
        sf::Text text(L"\u0476ZyG\noLPfkdf", font, 140);
        text.setPosition({ 20, 20 });
    
        text.setFillColor(sf::Color::Red);
    
        text.setOutlineThickness(5);
        text.setOutlineColor(sf::Color::White);
    
        text.setStyle(sf::Text::Underlined | sf::Text::Italic | sf::Text::StrikeThrough);
    
        while (window.isOpen())
        {
            sf::Event e;
            while (window.pollEvent(e))
            {
                if (e.type == sf::Event::Closed)
                    window.close();
            }
    
            window.clear();
    
            window.draw(text);
    
            window.display();
        }
    }
    

    Example Image

    feature m:sfml-graphics s:accepted 
    opened by zsbzsb 52
  • Added optional argument on which address to bind (socket).

    Added optional argument on which address to bind (socket).

    Before, SFML bound sf::TcpListener to all available addresses internally. This change lets you specify to which address you'd like to bind (listen).

    Only been tested on Ubuntu 14.04 (clean rebuild).

    feature m:sfml-network s:superseded 
    opened by bumbar1 49
  • Automate formatting with clang-format

    Automate formatting with clang-format

    Description

    Supersedes #1861 with the permission of its author @metaquarx.

    This PR is big so I'll try to break down my rationale before anyone spends quite literally hours reviewing every line of code that got changed.

    #1861 established that there is broad consensus behind adopting automated formatting and clang-format is the obvious tool to solve that. While #1861 didn't reach a consensus on how many PRs this might require, I advocate for 1 PR that both adds the .clang-format file and all the infrastructure to reformat the codebase and performs said refactoring. By reformatting the code in this PR, it's easy for everyone to see the impact of the style rules chosen.

    Because SFML does not already have perfectly consistent formatting, some amount of formatting changes are going to happen no matter how perfectly we configure the formatting rules. Fixing inconsistencies necessary generates a non-zero diff. Certainly though the goal is for this initial formatting pass to generate the most minimal diff possible. I tweaked as many settings as I could to ensure our .clang-format file best represents existing SFML style.

    #1861 left off with discussions about what minimum clang-format version to require. Because newer clang-format versions add new settings incompatible with older versions, we must specific a minimum version. At the time of authoring that PR, at least clang-format-12 was widely available. On the latest LTS Ubuntu and macOS, clang-format-14 is shipping. Unsure what the situation is on Windows. We were previously experiencing issues with clang-format-12 and clang-format-14 not producing identical results so were considering upgrading the minimum version to clang-format-14 but luckily only minimal changes were required to get the two programs to produce identical results.

    Now that I was able to get multiple versions of clang-format to produce identical results, I wanted CI to verify that. There was already a CI job for running clang-format on ubuntu-latest (Ubuntu 22.04 at the time of this PR) from #1861 so I added a second macOS formatting job which is using clang-format-14. These two formatting jobs make it even less likely that we end up in a situation where a PR submits code that provides different formatting across the two versions. I expect we may add more formatting jobs as more versions of clang-format get released and become usable in CI. Over time I also expect we periodically increase our clang-format version since newer version do provide features and bug fixes we may find useful.

    So that leads us to the last commit of this PR which runs clang-format, touching 373 files with 8,214 additions and 7,743 deletions. It's a doozy to review this all but the good news is that we'll never have to review such a gigantic reformatting PR ever again!

    There are certain aspects of SFML style which cannot be captured by clang-format including the empty newline after access specifiers and the extra space after operator. Otherwise please let me know if there are ways we can tweak the .clang-format to better capture SFML style. There are also certain code blocks where formatting was explicitly disabled via // clang-format off and // clang-format on. I suspect we may add or remove some of those depending on where we think manual formatting is worthwhile.

    https://releases.llvm.org/12.0.0/tools/clang/docs/ClangFormatStyleOptions.html

    Here are the docs for clang-format-12's formatting options.

    Tasks

    • [x] Tested on Linux
    • [x] Tested on Windows
    • [x] Tested on macOS
    • [x] Tested on iOS
    • [x] Tested on Android
    feature s:accepted m:config 
    opened by ChrisThrasher 17
  • Use in-class member initializers

    Use in-class member initializers

    Description

    This PR uses in-class member initializers in the System module. The plan is that if this PR is accepted 1 or more subsequent PRs will employ this pattern in the other 5 modules as well as the tests and examples.

    See C++ Core Guidelines item C.45 for more information.

    https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c45-dont-define-a-default-constructor-that-only-initializes-data-members-use-in-class-member-initializers-instead

    "Why use braced initializers?"

    There are some technical advantages to braced initializers including how lossy conversions are not possible. That advantage is nice but I also appreciate how initializing with {} makes it more obvious to the reader how they're not reading stack variables which by SFML convention are typically initialized with () or =. If a reader sees {} initializers it is more apparent that they're reading a class declaration and not procedural code.

    Tasks

    • [x] Tested on Linux
    • [x] Tested on Windows
    • [x] Tested on macOS
    • [x] Tested on iOS
    • [x] Tested on Android
    opened by ChrisThrasher 5
  • Issue when installing with apt-get: libudev.so.0 missing

    Issue when installing with apt-get: libudev.so.0 missing

    Subject of the issue

    When installing SFML from apt-get, and then trying to import SFML/Window.hpp, we get the following error:

    /usr/bin/ld: warning: libudev.so.0, needed by /home/nathan/miniconda3/envs/nocturne/lib/libsfml-window.so.2.5.1, not found (try using -rpath or -rpath-link)
    # or
    ImportError: libudev.so.0: cannot open shared object file
    

    This has occurred on several independent machines. We usually fix it by creating a symbolic link from the libudev.so.1 (which does exist) to the missing libudev.so.0:

    ln -s /usr/lib/x86_64-linux-gnu/libudev.so.1 /usr/lib/x86_64-linux-gnu/libudev.so.0
    

    We were wondering whether the dependencies could be upgraded to support libudev.so.1 (which seems to work equally well with the symbolic link) or whether we did something wrong?

    Thanks!

    Your environment

    • Ubuntu 20.04
    • SFML 2.5.1

    Steps to reproduce

    Installed SFML using

    sudo apt-get install libsfml-dev
    

    Error happens when compiling:

    #include <SFML/Window.hpp>
    
    bug m:sfml-window s:undecided p:linux 
    opened by nathanlct 5
  • Error handling in SFML 3

    Error handling in SFML 3

    Back in 2015, I created several forum threads around the topic of error handling/reporting:

    Some discussions around the topic date back to 2011 and 2013:

    These are quite interesting, already to understand historic context and how SFML 1 and 2 evolved to be without exceptions.


    Error handling in SFML 3

    Now the year is 2022, a lot has changed, and at last we have the option to introduce breaking changes and redesign the API for better userfriendlyness. Handling errors is an important topic, and there are different options to tackle them in SFML 3. I'll jump right into them:

    1. Boolean return types E.g. SFML 2 sf::Image::loadFromFile()

      • ✔️ Simple.
      • ✔️ Easy to port to bindings.
      • :x: Can be forgotten ([[nodiscard]] is needed on every single method).
      • ❌ Needs separate output parameters.
      • ❌ No way to transport error messages, needs sf::err() side channel.
    2. Optionals Basically all the disadvantages of bool except no need for output parameters.

      • ✔️ Simple to understand and document.
      • ✔️ Easy to port to bindings.
      • :x: Can be forgotten ([[nodiscard]] is needed on every single method).
      • ❌ No way to transport error messages.
    3. Assertions Listed for completeness, but they are not really a solution for runtime errors. But we might want to use them more often to complement other error mechanisms in the case of logic errors.

      • ✔️ Immediate breakpoint, must be fixed.
      • ✔️ No runtime overhead in release.
      • :x: Only useful for errors that are bugs (not loading files etc).
      • ❌ Do not allow the user to be lenient about certain errors.
    4. Exceptions

      • ✔️ User cannot ignore them.
      • ✔️ Automatically propagate upward.
      • ✔️ Can be polymorphic, allowing automatic fallbacks and higher-level handling.
      • ✔️ Can theoretically transport extra data beyond message, although rarely done in practice.
      • ✔️ Can be used in constructors.
      • ❌ Hard to document and follow, especially once multiple layers/callbacks/virtual functions are involved.
      • ❌ Exception safety can be hard to achieve, and we need to enter the whole noexcept rabbit hole.
      • ❌ Need verbose try/catch block even in situations where the user explicitly wants to ignore them.
      • ❌ Not easy to map to bindings, especially due to polymorphism.
      • ❌ Small runtime overhead (more or less depending on exception mechanism).
    5. Result type Inspired by std::expected proposal or Rust's Result type. Basically std::variant<T, E> but with a highly specialized API.

      • ✔️ User cannot forget them ([[nodiscard]] can be declared directly on the type).
      • ✔️ User can however explicitly and concisely ignore them (e.g. with (void) or an ignore() method).
      • ✔️ Allow to transport arbitrary data as part of the error (e.g. an enum, message, context info).
      • ✔️ Function signature makes immediately obvious which methods can fail, and how they can do so -- users are not surprised by unexpected errors and cannot miss any documentation.
      • ❌ No automatic propagation (could probably be made somewhat ergonomic as a library solution).
      • ❌ Require static factory functions such as Image::fromFile(), no constructor support (if this is truly a disadvantage).
      • ❌ Non-polymorphic unless explicitly designed.
      • ❌ Requires either custom-built type for SFML or use of an established library.
    feature 
    opened by Bromeon 2
  • Overhaul `sf::IpAddress`

    Overhaul `sf::IpAddress`

    So apparently these tests pass:

    const sf::IpAddress ipAddress;
    CHECK(ipAddress.toString() == "0.0.0.0"s);
    CHECK(ipAddress.toInteger() == 0);
    CHECK(ipAddress != sf::IpAddress::Any);
    
    const sf::IpAddress any("0.0.0.0"s);
    CHECK(any.toString() == "0.0.0.0"s);
    CHECK(any.toInteger() == 0x00000000);
    CHECK(any == sf::IpAddress::Any);
    

    This is extremely worrisome to me -- because there's a hidden "invalid" state that cannot be distinguished from toString and toInteger.

    So here's my proposal:

    1. Rename sf::IpAddress to sf::IpV4Address. This can be done as a pure renaming refactoring PR.
    2. sf::IpV4Address is an always-valid value semantic class. It's just a wrapper around a single sf::Uint32.
    3. To create sf::IpV4Address instances, a factory function returning std::optional<sf::IpV4Address> must be used. The constructor of sf::IpV4Address is private.

    Thoughts? @ChrisThrasher @eXpl0it3r @Bromeon

    feature m:sfml-network s:accepted 
    opened by vittorioromeo 8
  • Add API to get monitor/screen information

    Add API to get monitor/screen information

    Inspired by https://github.com/eliasdaler/imgui-sfml/pull/213. It would be nice if SFML provided an API to get information about all the available monitors (e.g. x/y/width/height, refresh rate, rotation, etc.).

    There was some work done here, see forum thread that gives an idea on how to do this on Win32.

    Mockup:

    int main()
    {
        const std::vector<sf::MonitorInfo> mInfos = sf::getMonitorInfos();
        assert(mInfos.size() > 0);
        
        const sf::MonitorInfo& mi = mInfos[0];
        
        std::cout << mi.x << '\n'
                  << mi.y << '\n'
                  << mi.width << '\n'
                  << mi.height << '\n' 
                  << mi.name << '\n'
                  << mi.refreshRate << '\n'
                  << mi.rotation << '\n';
    }
    

    Is this something we'd like to target for 3.x?

    Other multi-monitor support ideas:

    • API to switch from one monitor to the other when in fullscreen mode
    feature m:sfml-window s:accepted 
    opened by vittorioromeo 1
Releases(2.5.1)
  • 2.5.1(Oct 15, 2018)

    Changelog

    SFML 2.5.1

    Also available on the website: https://www.sfml-dev.org/changelog.php#sfml-2.5.1

    General

    • Various CMake fixes (#1414, #1416, #1436, #1439, #1467, #1470)
    • Fixed the installation of pkg-config files (#1466)
    • Fixed two conversion warnings (#1454)
    • [Android] Fixes all symbols in sfml-main are hidden (#1457, #1460)
    • [Android] Fixed some #define flag problem (#1458)
    • [Android] Fix deadlock in main cleanup (#1265)
    • [iOS] Modernized toolchain file (#1411)
    • [iOS] Check that <SFML/Main.hpp> is used (#1412)
    • [macOS] Add -ObjC flag to fix static linking on macOS (#1485)

    Window

    Bugfixes

    • [iOS] Use default supported rotations when none are specified (#1417)
    • [iOS] Fixed autocomplete window overlaps keyboard (#1473, #1482)
    • [Linux] Fixed dual monitor issue (#1226, #1238)
    • [Linux] Fixed issue where fullscreen window didn't go over task bars on top and left on in Ubuntu (#1224)
    • [Linux] Fixed the Unix clipboard implementation causing an abort due to internal data races in Xlib (#1437)
    • [macOS] Added additional system cursors (#1401, #1413, #1425)
    • [Windows] Fixed swapped colors for custom cursors (#1464, #1465, #1491)

    Graphics

    Bugfixes

    • Fixed a bug in which a sf::RenderTexture would not be re-activated after being re-created (#1438)
    • Fixed sf::RenderTextureImplFBO's destructor incorrectly triggering deletion of other sf::RenderTextureImplFBO's active FBOs (#1440)
    • Fix sf::RenderWindow::setActive incorrectly trying to unbind an FBO during deactivation (#1442)
    • Fixed sf::RenderTexture::display() dereferencing a NULL pointer when being called before sf::RenderTexture::create() (#1446)
    • Fixed bug in sf::Text when applying an outline color/thickness (#1176)
    • Squash duplicated sf::Font glyphs to single chars (#1461)
    • Fixed two issues with glyph sub-pixel positioning (#1452)
    • Reduced context locking & unlocking while creating textures (#1459)
    • Fixed the error message when the wrong bitmap font size is selected (#1456, #1474, #1492)

    Audio

    Bugfixes

    • Fixed performance issue with reading WAV files (#1450)
    Source code(tar.gz)
    Source code(zip)
    SFML-2.5.1-doc.zip(1.42 MB)
    SFML-2.5.1-linux-gcc-64-bit.tar.gz(2.21 MB)
    SFML-2.5.1-macOS-clang.tar.gz(5.50 MB)
    SFML-2.5.1-sources.zip(22.20 MB)
    SFML-2.5.1-windows-gcc-5.1.0-tdm-32-bit.zip(14.11 MB)
    SFML-2.5.1-windows-gcc-7.3.0-mingw-32-bit.zip(15.58 MB)
    SFML-2.5.1-windows-gcc-7.3.0-mingw-64-bit.zip(16.54 MB)
    SFML-2.5.1-windows-vc12-32-bit.zip(18.35 MB)
    SFML-2.5.1-windows-vc12-64-bit.zip(20.30 MB)
    SFML-2.5.1-windows-vc14-32-bit.zip(18.04 MB)
    SFML-2.5.1-windows-vc14-64-bit.zip(19.97 MB)
    SFML-2.5.1-windows-vc15-32-bit.zip(16.32 MB)
    SFML-2.5.1-windows-vc15-64-bit.zip(18.05 MB)
  • 2.5.0(May 7, 2018)

    Changelog

    SFML 2.5.0

    Also available on the website: https://www.sfml-dev.org/changelog.php#sfml-2.5.0

    General

    • Replaced FindSFML.cmake with SFMLConfig.cmake (#1335)
    • Markdown'd and updated readme, changelog, contributing and license files (#1196, #1368, #1317)
    • Improve packaging support (#1173)
    • Added Tagfile generation and search (#1327)
    • Added CMake variables to select the modules to be built (#798, #800)
    • Do not install extlibs if SFML_USE_SYSTEM_DEPS is true (#1236, #1237)
    • Fixed various type conversion/comparison warnings (#1325)
    • [Android] Increased minimum API version to 14 (#1362)
    • [Android] Removed custom toolchain and added support for the newest NDK version and Gradle (#1350, #1393)
    • [iOS] Updated the binary libs from exlibs/libs-ios (#1207, #1209)
    • [iOS] Use a CMake toolchain file for iOS build (#1268, #1269)
    • [iOS] Install extlibs if needed (#1348)
    • [iOS] Drop 32 bit support (#1374)
    • [iOS] Force correct iOS architecture for cmake (#1373, #1377)
    • [iOS] Added iOS example (#1378)
    • [macOS] Fixed launch of cocoa examples (#1334)
    • [macOS] Improved application signing process (#1020, #1036, #1194)
    • [macOS] Improved CMake script (#1215, #1371)
    • [macOS] Use -stdlib=libc++ (#1361)
    • [OpenBSD] Added support for OpenBSD (#1330)

    System

    Bugfixes

    • Added protected destructor to sf::NonCopyable to prevent possible resource leaks (#1125, #1161)
    • Fixed crash when sf::Clock is constructed in a global scope (#1258)

    Window

    Features

    • Implemented Cursor API (#269, #784, #827)
    • Implemented Clipboard API (#715, #1204, #1221)
    • Renamed a few key codes (#1395)
    • Added joystick example (#1363)
    • [Windows] Added support for interfacing with joysticks via DirectInput when it is available (#1251, #1326)
    • [Windows] Fix discrete GPU preference symbols being exported from the wrong place (#1192, #1406)

    Bugfixes

    • [Android] Return correct key code for delete/backspace (#1309, #1362)
    • [iOS] Don't need to find vorbisfile or vorbisenc (#1347)
    • [Linux] Fixed sf::Window::getPosition() returning incorrect position because of differences in window managers (#1228, #1266)
    • [Linux] Fix X11 key repeat handling not filtering out events from other windows (#1223, #1230, #1291)
    • [Linux] Restore fullscreen of a non-visible window (#1339)
    • [macOS] Fixed window menu not working (#1091, #1180, #1193)
    • [macOS] Fixed crash with application messing hardware detection e.g. TeamViewer (#1323)
    • [macOS] Added support for (some) Hat/POV axis (#1248)
    • [Windows] Prevent uninitialized read by zeroing memory (#1264)
    • [Windows] Fixed modifier keys handling (#1357)

    Graphics

    Features

    • Implemented additional line spacing and letter spacing in sf::Text (#928, #1366)
    • Added sf::VertexBuffer class (#1308)
    • Added GPU local texture copying support, allowing performance optimizations and texture swapping (#1119, #1319, #1320)
    • Optimize performance by skipping glTexCoordPointer() call if not needed (#1015)
    • Generate shape outline vertices only if necessary (#925, #1356)
    • Removed dependency to libjpeg, stb_image_write now supports writing JPEG files (#1278, #1279)
    • Enable comparing sf::Transform and optimize resetting OpenGL back to the identity matrix (#1298)
    • Added missing setActive() virtual method to sf::RenderTarget (#1157)
    • Updated stb_image to v2.16 and stb_image_write to v1.07 (#1270)
    • Added sf::RenderTexture stencil and multisampling support (#1274, #1285)
    • Added example demonstrating sf::VertexBuffer, sf::Shader and sf::Thread usage (#1352)
    • Optimized sf::RenderTexture performance (#1379)

    Bugfixes

    • Properly free memory in sf::Font::cleanup() (#1119)
    • Fixed memory leak in sf::Font (#1216)
    • Fix OpenGL texture coordinate pointer not being updated correctly under certain conditions (#1297)
    • Fix for broken text when the font is reloaded (#1345)
    • Fix memory leak in sf::Text (#1233, #1360)
    • Fixed strict aliasing punning warning when generating the key of a glyph in Font.cpp (#1187, #1396)
    • Fixed OpenGL version string being parsed incorrectly on some platforms (#1249, #1390)
    • [macOS] Worked around render target bug (#1132, #1342)
    • [Windows] Replaced time-based joystick poll with a hardware event handler (#1179, #1195, #1198, #1199, #1421)

    Audio

    Features

    • Added loop point support to sf::Music (#177, #629)
    • Added support for the extensible PCM wave file format (#1296)
    • [iOS] Enable audio module (#1338)

    Bugfixes

    • Fixed inconsistent seek behavior in sf::SoundStream (#1118)
    • Fixed stack overflow in sf::SoundStream::fillAndPushBuffer() (#1154)
    • Fixed seeking quirks in the FLAC reader (#966, #1162)
    • Allow polymorphism with sf::SoundSource (#1185)
    • Fixed WAV file writer writing wrong header values (#1280, #1281)
    • Small bugfix to argument of alcCaptureOpenDevice() (#1304, #1305)
    • [iOS] Find OpenAL correctly (#1263, #1376)
    • [Windows] Updated OpenAL Soft to 1.18.1 fixing crashes (#1247, #1260)

    Network

    Features

    • Add append/overwrite parameter to Ftp::upload (#1072, #1399)

    Bugfixes

    • Fixed wrong condition for building network support (#1253)
    • Changed TCP listen backlog from 0 to SOMAXCONN (#1369, #1407)
    • Fixed socket reuse not conforming to documentation (#1346, #1408)
    Source code(tar.gz)
    Source code(zip)
Owner
Simple and Fast Multimedia Library
SFML provides a simple interface to the various components of your PC, to ease the development of games and multimedia applications.
Simple and Fast Multimedia Library
WangBin 3.2k Jun 27, 2022
fast MP4 mux / demux using WASM

mp4-wasm This module is still under development and may change. ✨ Fast MP4 mux / demux using WASM, for modern browsers and Node.js. What's supported:

Matt DesLauriers 202 Jun 24, 2022
a library for audio and music analysis

aubio aubio is a library to label music and sounds. It listens to audio signals and attempts to detect events. For instance, when a drum is hit, at wh

aubio 2.7k Jun 27, 2022
TagLib Audio Meta-Data Library

TagLib TagLib Audio Metadata Library https://taglib.org/ TagLib is a library for reading and editing the metadata of several popular audio formats. Cu

TagLib 921 Jun 29, 2022
Minimalistic MP3 decoder single header library

minimp3 Minimalistic, single-header library for decoding MP3. minimp3 is designed to be small, fast (with SSE and NEON support), and accurate (ISO con

Lion 1.1k Jun 25, 2022
Convenient unified display of the most relevant technical and tag data for video and audio files.

MediaInfoLib README MediaInfo(Lib) is a convenient unified display of the most relevant technical and tag data for video and audio files. MediaInfoLib

MediaArea 445 Jun 28, 2022
PML is a simple, lightweight, easy to use multimedia library written in C.

PML is a simple, lightweight, easy to use multimedia library written in C. PML also works natively with C++, and bindings can be used/made to the native C code for other languages.

Fossbay 12 May 6, 2021
A simple but powerful multimedia player library designed for Qt Quick.

QtMediaPlayer A simple but powerful multimedia player library designed for Qt Quick. Features Full-featured multimedia player Cross-platform: support

Yuhang Zhao 13 Jun 23, 2022
WangBin 3.2k Jun 27, 2022
A multimedia framework developed from scratch in C/C++, bundled with test programs and a neat media analyzer.

MiniVideo framework MiniVideo is a multimedia framework developed from scratch in C/C++, bundled with small testing programs and a neat media analyser

Emeric 79 Mar 21, 2022
TengineGst is a streaming media analytics framework, based on GStreamer multimedia framework, for creating varied complex media analytics pipelines.

TengineGst is a streaming media analytics framework, based on GStreamer multimedia framework, for creating varied complex media analytics pipelines. It ensures pipeline interoperability and provides optimized media, and inference operations using Tengine Toolkit Inference Engine backend, across varied architecture - CPU, iGPU and VPU.

OAID 64 May 30, 2022
GStreamer open-source multimedia framework

GStreamer open-source multimedia framework

GStreamer GitHub mirrors 1.3k Jun 23, 2022
Ole Christian Eidheim 735 Jun 24, 2022
A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio.

A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.

Ole Christian Eidheim 2.3k Jul 2, 2022
Simple and fast C library implementing a thread-safe API to manage hash-tables, linked lists, lock-free ring buffers and queues

libhl C library implementing a set of APIs to efficiently manage some basic data structures such as : hashtables, linked lists, queues, trees, ringbuf

Andrea Guzzo 383 Jul 1, 2022
Fast Binary Encoding is ultra fast and universal serialization solution for C++, C#, Go, Java, JavaScript, Kotlin, Python, Ruby, Swift

Fast Binary Encoding (FBE) Fast Binary Encoding allows to describe any domain models, business objects, complex data structures, client/server request

Ivan Shynkarenka 570 Jun 24, 2022
Simple and fast configuration file library (written in C99)

Features Configuration file reading Supported operating systems Ubuntu MacOS Windows Build requirements C99 compiler CMake 3.10+ Cloning git clone htt

Nikita Fediuchin 3 May 26, 2022
Simple and Fast Network Utility Library

SFNUL Simple and Fast Network Utility library © binary1248 SFNUL is provided under the Mozilla Public License Version 2.0 (see LICENSE for details)

null 49 Feb 17, 2022
Peregrine - A blazing fast language for the blazing fast world(WIP)

A Blazing-Fast Language for the Blazing-Fast world. The Peregrine Programming Language Peregrine is a Compiled, Systems Programming Language, currentl

Peregrine 1.5k Jun 27, 2022
A simple/fast stacking box layout library. It's useful for calculating layouts for things like 2D user interfaces.

A simple/fast stacking box layout library. It's useful for calculating layouts for things like 2D user interfaces. It compiles as C99 or C++. It's tested with gcc (mingw64), VS2015, and clang/LLVM. You only need one file to use it in your own project: layout.h.

Andrew Richards 670 Jun 27, 2022
pugixml is a Light-weight, simple and fast XML parser for C++ with XPath support

pugixml is a C++ XML processing library, which consists of a DOM-like interface with rich traversal/modification capabilities, an extremely fast XML parser which constructs the DOM tree from an XML file/buffer, and an XPath 1.0 implementation for complex data-driven tree queries. Full Unicode support is also available, with Unicode interface variants and conversions between different Unicode encodings (which happen automatically during parsing/saving).

Arseny Kapoulkine 3k Jun 28, 2022
A fast, portable, simple, and free C/C++ IDE

A fast, portable, simple, and free C/C++ IDE. Dev C++ has been downloaded over 67,796,885 times since 2000.

Embarcadero Technologies 1.7k Jun 26, 2022
simple and fast scripting language

The Aument Language The Aument language is a work-in-progress dynamically-typed scripting language with performance first: this scripting language is

The Aument Project 35 Mar 21, 2022
WMBar is a window manager agnostic status bar that aims to be lightweight, simple, extensible/modular and fast.

WMBar is a window manager agnostic status bar that aims to be lightweight, simple, extensible/modular and fast.

WMBar 1 Nov 27, 2021
Solve 20 simple math questions and see how accurate/fast you are!

Math-Quiz Solve 20 simple math questions and see how accurate/fast you are! Want to try? Clone this repository $ git clone https://github.com/Mini-War

Mini Ware 8 Apr 10, 2022
A fast and simple 6502 emulator in plain C.

6502js But C A hobby project that replicates the 6502js emulator, but with the speed of C. Why? For fun and learning :D Simple on the outside: Replica

Lim Ding Wen 2 Nov 25, 2021
Blade - A simple, fast, clean, and dynamic language that allows you to develop complex applications quickly.

The Blade Programming Language Quick links: BUILDING | CONTRIBUTING | DOCS | LICENSE | tl;dr Blade is a simple, fast, clean and dynamic language that

Blade Programming Language 66 Jun 2, 2022
Fast, flexible and simple GUI.

MyGUI is a cross-platform library for creating graphical user interfaces (GUIs) for games and 3D applications. Website: http://mygui.info/ There you c

null 606 Jun 21, 2022
A family of small, fast, and simple bitmap fonts in single-file C headers

Blit A family of small, fast, and simple bitmap fonts in single-file C headers [go to repository] These are not intended as a replacement for fancy us

Andrew Reece 49 May 18, 2022