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
7
votes
4 answers

SFML "failed to create the font face" issue

I'm using SFML in Visual Studio 2015 to make a game that requires me to print text. I try to load fonts and keep getting an error that says "failed to create the font face". I've tried loading several different fonts and none of them work, and they…
SBE
  • 71
  • 1
  • 2
  • 3
7
votes
5 answers

How to run SFML in CLion, Error undefined reference to?

I'm new to C++ and try to learn game programming, I choose SFML and run on CLion by Jetbrain and using Ubuntu machine. I following this tutorial SFML and Linux here my code : #include using namespace sf; int main()…
Phonbopit
  • 3,393
  • 3
  • 21
  • 29
7
votes
2 answers

How to use a custom cursor?

I'm trying to change the default OS cursor to a custom one. As of now, I'm only dealing with Windows. I got an image file with the cursor I want (.png, should I change format?). All in all, I've been searching and trying to simply change the cursor,…
VLV
  • 167
  • 1
  • 12
7
votes
3 answers

How to compile SFML with MinGW?

I have a simple file "main.cpp" seen below. I also have all the sfml 2.1 libraries under "C:\SFML-2.1\". My question is: What are the commands to compile, link, and run this project? I'm very comfortable using g++ to compile projects from the…
Quinn McHugh
  • 1,577
  • 2
  • 17
  • 23
7
votes
1 answer

Inheriting from Transformable and Drawable in SFML

I'm trying to inherit from Transformable and Drawable in SFML in order to make my objects... well, transformable and drawable. I'm making a simple breakout game, but perhaps I'm going about this the wrong way. Here's my code: #include…
mrobinson7627
  • 298
  • 1
  • 4
  • 13
7
votes
1 answer

C++ Box2D - Dynamic bodies not affected by gravity if left alone

I was playing around with Box2D in SFML2 and realized; when I change the gravity of the world, the dynamic bodies that have been untouched for a little while aren't affected by the gravity change. I prepared a video to make this explanation more…
user569322
7
votes
2 answers

C++/OOP game design

I'm practicing my newbie c++ skills by making a small game using SFML and OpenGL. The programming part has been going fine for the most part, but I've questions regarding actual code/class design. I've one class, MainLoop, which contains the game…
7
votes
1 answer

OpenGL being very machine specific

Recently I started using OpenGL in C++ for some 3D rendering, but oddly enough it seems to only work on a few machines. I'm using OpenGL 3.0 or higher (at the moment it is set to 3.0) using vertex array objects (not sure how its called, but the API…
Invalid
  • 1,870
  • 1
  • 16
  • 22
7
votes
1 answer

Building library with cmake

I apologize for bothering you all, but I have a little compilation problem with cmake. I have a CMakeLists.txt file I'm using to build a test executable, and a shared library. They both have dependency to another library (SFML). I'm using cmake on…
Cuthalion
  • 73
  • 1
  • 1
  • 3
6
votes
2 answers

Linker Errors on OS X due to SFML framework

This may seem like quite a 'noob' question: I've downloaded SFML-1.6 for Mac and I have placed the frameworks into my /Library/Frameworks folder. After trying to compile an example SFML application I get linker errors for pretty much every call I…
chrisburke.io
  • 1,497
  • 2
  • 17
  • 26
6
votes
1 answer

What is the correct usage of CMake EXTERNALPROJECT_ADD with a Git repository?

I would like to learn how to download and compile external libraries using the cmake external project module. For example, lets say that I wanted to download the source from the SFML library https://github.com/LaurentGomila/SFML.git and compile it.…
Murtakie
  • 63
  • 1
  • 1
  • 3
6
votes
5 answers

How to form a Concave shape out of Convex shapes?

i'm trying to get around the rule of only being able to form convex shapes in the SFML c++ library. To do this I'm planning on testing given vertices, and if concave, splitting the vertices into groups, testing each groups' concaveness, and…
Griffin
  • 2,399
  • 7
  • 48
  • 83
6
votes
1 answer

Different output with different optimization levels in GCC

I am working on a rewrite of a raytracer that I developed for university last semester and I am running into the following problem: When I compile and run my code in Debug the output is as expected But when I enable higher optimization levels e.g.…
Yamahari
  • 1,926
  • 9
  • 25
6
votes
1 answer

Can't get real path for source - Xcode, SFML, C++

I am new to SFML, and followed SFML & Xcode tutorials for SFML 2.5 to try to get a basic program build and run. After copying the content of Frameworks to /Library/Frameworks and content of extlibs to /Library/Frameworks, and the Xcode templates, I…
S.Hua
  • 69
  • 4
6
votes
3 answers

Xcode, SFML error dyld: Library not loaded

I am trying to start a basic C++ project with link to SFML library. I have unzipped the SFML library to folder /Users/mulperi/cpplib/sfml and I have added that to Include Search Path and Library Search Path. My code is simple, I followed a…
Mulperi
  • 1,450
  • 1
  • 14
  • 24