Questions tagged [sfml]

SFML (Simple Fast Multimedia Library) is a portable and easy to use multimedia API written in C++. You can see it as a modern, object-oriented alternative to SDL. SFML is composed of several packages to perfectly suit your needs. You can use SFML as a minimal windowing system to interface with OpenGL, or as a fully-featured multimedia library for building games or interactive programs.

Official resources

Main features

  • Portable: SFML compiles on standard platforms like Windows (98, 2000, XP, Vista, 7, 8 and 10) and Unix systems (Linux, and Mac OS X). As the library grows up, support for more operating systems will be added.
  • Object-oriented: SFML is written in C++ and provides an efficient, object-oriented design. It relies on standard patterns and idioms to provide a simple and robust framework.
  • Easy to use: SFML aims at being easy to manipulate. The effort is put on the internal code to provide the simplest public interface.
  • Flexible: Instead of being one big API, SFML rather contains a lot of small packages, that can be chosen and combined according to the intended usage. You can use only the base package to get input and windowing, as well as the full graphics package with sprites and post-effects.
  • Easily integrable: SFML can be used in one or more windows, and/or can be integrated with existing interface components. Integration with existing graphical user interface (GUI) libraries is easy so that you can add SFML views into complex interfaces built with Qt, wxWidgets, MFC or whatever.

Languages

SFML is implemented in C++. That said, several bindings have been created for other languages that allow SFML to be used from C, C#, C++/CLI, D, Ruby, OCaml, Java, Python and VB.NET.

System

  • Portable and accurate time measurement
  • Simple and object-oriented threads and mutexes
  • Unicode module for proper conversions between UTF and locale-dependent encodings

Window

  • Can be used as a minimal, portable package to replace GLUT or SDL for windowing and input with OpenGL
  • Can create several rendering windows
  • Can be integrated into components of existing Qt, MFC, wxWidgets, Win32, X11, etc. interfaces
  • Provides both a message-based and a real-time interface for handling input
  • Can handle mouses with up to five buttons
  • Can handle four joysticks with up to seven axes and 32 buttons

Graphics

  • Interfaces very easily with OpenGL
  • Modern effects available and hardware-accelerated: alpha-blending, rotations, shaders, ...
  • Manages memory efficiently, so that you don't have to worry about resources lifetime or storage; you can even load your graphical resources before any window is created
  • Can load and save standard image formats: BMP, DDS, JPEG, PNG, TGA, and PSD
  • Can load all graphics resources directly from files in memory
  • Can use views like in a 3D scene, to zoom / translate / rotate the whole world
  • Uses a simplified shader language for adding real-time post-effects
  • Easy manipulation of graphical text through bitmap fonts
  • Supports unicode characters
  • Can load standard font file formats: TTF, CFF, PCF, FNT, BDF, PFR, SFNT, PostScript Type 1, Type 42

Audio

  • Uses hardware acceleration whenever possible
  • Can load and save standard sound formats: Ogg, WAV, FLAC, AIFF, Au, RAW, paf, 8SVX, NIST, VOC, IRCAM, W64, MAT4, MAT5 PVF, HTK, SDS, AVR, SD2, Core Audio Format, WVE, MPC2K, RF64
  • Can load all audio resources directly from files in memory
  • 3D sound spacialization
  • Easy interface for capturing audio
  • Manages memory efficiently, so that you don't have to worry about resources lifetime or storage
  • Supports streaming for big files ; you can even write your custom streaming class for any source (network, ...)
  • Supports multi-channels formats (mono, stereo, 4.0, 5.1, 6.1, 7.1)

Network

  • Implements a portable layer over TCP and UDP sockets
  • Easy data transfers through stream-based extensible packets
  • Classes to use the HTTP and FTP internet protocols

License

3542 questions
6
votes
2 answers

SFML Library not loaded error, image not found

I am trying to get started with SFML on my OS Mac without using Xcode and have gone through the non-IDE installation. I am following this tutorial: https://www.sfml-dev.org/tutorials/2.0/start-linux.php It is the linux install page but it seems…
hundred_dolla_tea
  • 523
  • 1
  • 5
  • 14
6
votes
4 answers

How do i link the SFML libraries in Visual Studio Code?

I've been trying for hours and I can't seem to do it I've downloaded extensions and asked for help around but everything is just confusing me at this point. I want to include the SFML libs in my project and I'm trying to use the the Visual Studio…
Jason
  • 61
  • 1
  • 1
  • 3
6
votes
1 answer

Qt Creator / QMake Linker Libraries

I'm using SFML, and I want to use Qt Creator in conjunction with it. When I'm compiling manually, I supply the following arguments to the linker -lsfmlsystem -lsfmlwindow. How do I do this if I'm using Qt Creator and (I think) QMake?
Matthew H
  • 5,831
  • 8
  • 47
  • 82
6
votes
1 answer

Shapes proportionally resize with window in SFML 2.X

The code is off the tutorial on the SFML site. When I compile and run it the circle scales proportionally as the window is scaled by the user. I want the circle to stay a constant shape. When the screen is re-sized, both the correct screen…
Morgoth
  • 4,935
  • 8
  • 40
  • 66
6
votes
1 answer

Repeating texture to fit certain size in SFML

I have a file that contains textures. I load it to sf::Texture and split into sprites with setTextureRect. Now lets say one sprite contains part of texture that is 20 pixels wide. How can I render it to fit width of e.g. 213 pixels. The only way I…
TPlant
  • 463
  • 5
  • 15
6
votes
3 answers

Cannot call XInitThreads

I have written an SFML C++ game, and tried to start using threads, but after a while everything crashes. After searching I found out the fix seems to be to call XInitThreads(); but this does not work somehow. simplified code: #include…
user3554800
  • 73
  • 1
  • 1
  • 5
6
votes
2 answers

Resizing in SFML 2.0

This may be a simple question but I'm having a hard time finding a straight answer to it: is there a way to resize a loaded Texture in SFML 2.0? For instance, if I have a 3264x2448 png and I want to scale it down to fit a 900x1200 rendered window…
user3113547
6
votes
1 answer

SFML error loadFromFile()

I have the following code: #include #include int main(int argc, char* argv[]) { sf::RenderWindow window(sf::VideoMode(640, 480), "SFML Render"); sf::Image image; sf::Texture texture; sf::Sprite…
Ivan
  • 992
  • 1
  • 10
  • 22
6
votes
1 answer

Open a fullscreen window on 2nd monitor with SFML?

Is there a way to open a full screen window with SFML on a 2nd monitor?
Prof. Falken
  • 24,226
  • 19
  • 100
  • 173
6
votes
1 answer

Keyboard Event SFML 2.0

Im trying to get the key input in SFML 2, in the SFML 1.6 im using while (App.GetEvent(Event)) { if (App.GetInput().IsKeyDown(sf::Key::Down)) { dir='d'; } } But i have no idea how to do this in SFML 2.
Mete
  • 293
  • 1
  • 4
  • 16
6
votes
4 answers

C++ Vector iterate over abstract class

Background info: Me and a couple of friends are building this platform game in C++ with the help och sfml and box2d for a school assignment. One of the requirements is that we follow the "MVC pattern". We have created classes like Bullet and…
5
votes
0 answers

Need some help to choose beetween Allegro 5, SDL 1.2, SDL 1.3 or SFML

I won't start a debate about which library is better, it would be against the rule, but more ask a series of technical question. When i ask if there is special technique, just say the name of the technique, or a link. Don't forget, im comparing also…
user1115057
  • 1,815
  • 2
  • 18
  • 20
5
votes
2 answers

SFML 1.6 without admin priviliges

So I have this SFML 1.6 application that works well on Mac OS X Lion. Currently the way I have it is that the SFML frameworks are in /Library/Frameworks and it works well, however to install on other machines it requires admin privileges. So I want…
slartibartfast
  • 4,348
  • 5
  • 31
  • 46
5
votes
3 answers

Learning to use VBOs properly

So I've been trying to teach myself to use VBOs, in order to boost the performance of my OpenGL project and learn more advanced stuff than fixed-function rendering. But I haven't found much in the way of a decent tutorial; the best ones I've found…
GarrickW
  • 2,181
  • 5
  • 31
  • 38
5
votes
1 answer

How to pass center of each primitive to fragment shader?

In the following example I would like to manually create points (x, y, angle) from SFML then fill a circle around each point. The angle will be used later, for now I use it for debugging. SFML draws 2 points Vertex shader convert points to -1..1…
nowox
  • 25,978
  • 39
  • 143
  • 293