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
10
votes
2 answers

#error gl.h included before glew.h

So I'm trying to move my OpenGL code from Main() into a specific class that will handle the 3D graphics only when necessary. Previously, the top of my main.cpp file looked like this: #define GLEW_STATIC #include #include…
GarrickW
  • 2,181
  • 5
  • 31
  • 38
10
votes
2 answers

Getting dimensions of text in SFML

I was wondering how i get the dimensions of my text in SFML? I tried to do it like this: sf::Text text("Hello SFML", font, 50); // using text.getRect() // i also tried getScale() & getSize() // neither are correct text.setPosition(…
Sir
  • 8,135
  • 17
  • 83
  • 146
10
votes
3 answers

Writing a console within an application

My application requires a console to be embeded within the application window, an example would be in a program like autoCAD where the console is at the bottom of the window waiting for commands. I need the console within my application so that I…
Elgoog
  • 2,205
  • 7
  • 36
  • 48
9
votes
2 answers

Is it possible to draw a Drawable and get a bitmap from it?

Is it possible to get a drawn Drawable as a Texture (a bitmap)? How could I do that, please? My try I've modified the green circle example. Now it's really drawn as a bitmap... But it's drawn just like that: I'd like to have anti-aliasing. With…
user5066707
9
votes
1 answer

SFML not linking statically to openal32 (links statically to all other dependencies)

I compiled SFML using CMake for MinGW. After running "mingw32-make install" everything is built and installed with no errors. But when running the examples - pong.exe, sound.exe, sound-capture.exe and voip.exe all depend upon openal32.dll. I…
Kvothe
  • 1,819
  • 2
  • 23
  • 37
9
votes
1 answer

Mingw 'std::function' has not been declared?

First of all, I'm using code blocks on windows with the latest mingw release. I am using the sfml library to start a game, but unfortunately I came across this problem. I need to use std::function for my state manager, but it keeps showing the same…
user3452725
  • 603
  • 1
  • 6
  • 14
9
votes
2 answers

Simple C++ SFML program high CPU usage

I'm currently working on a platformer and trying to implement a timestep, but for framerate limits greater than 60 the CPU usage goes up from 1% to 25% and more. I made this minimal program to demonstrate the issue. There are two comments (lines…
A. D.
  • 728
  • 1
  • 9
  • 27
8
votes
2 answers

Can't get depth testing to work in OpenGL

I use SFML to create the window. In this screenshot the cube should be behind the pyramid but it just doesn't work. Here is the minimal code I used: #include #include #include #include…
RadicalRaid
  • 996
  • 9
  • 17
8
votes
1 answer

Warning C26812: Enum type is unscoped. Prefer enum class over enum

It is puzzling me as to why am I getting this warning at all. I do not even have enumerations in my entire code? #include #include using sf::RenderWindow; using sf::VideoMode; using sf::Event; using std::vector; using…
Programming Rage
  • 403
  • 1
  • 4
  • 18
8
votes
3 answers

Make SFML Snake game more responsive to key presses?

I found a SFML C++ snake game and I've been messing around with it and changing a few things, but one of the things I can't figure out is how to make it more smooth/responsive with the arrow key presses. Right now it's using enum Direction {Up,…
Austin
  • 6,921
  • 12
  • 73
  • 138
8
votes
3 answers

The procedure entry point _ZSt24__throw_out_of_range_fmtPKcz could not be located in the dynamic link library sfml-graphics-2.dll

Today I decided to download, install, and attempt to use SFML 2.2. I also downloaded Code::Blocks with the MinGW compiler. I set up everything and installed everything correctly (or so I thought) and tried to run a sample code to see if it would…
user4500878
8
votes
4 answers

Linux mingw32 sfml cross compile for windows - missing dll files

I am compiling my C++ project in the following way: /usr/bin/i686-w64-mingw32-g++ -g -std=c++0x -Wall -I /home/bluszcz/dev/win64/SFML-2.1/include -L /home/bluszcz/dev/win64/SFML-2.1/lib -static-libgcc -static-libstdc++ -static -O4 -c src/game.cpp -o…
bluszcz
  • 4,054
  • 4
  • 33
  • 52
8
votes
3 answers

OpenCV 2.3: Convert Mat to RGBA pixel array

I am attempting to use OpenCV to grab frames from a webcam and display them in a window using SFML. VideoCapture returns frames in OpenCV's Mat format. To display the frames, SFML requires a 1D array of pixels in its uint8 format, which (as far as I…
Thew
  • 83
  • 1
  • 1
  • 3
7
votes
2 answers

How can I compile sfml project via command line on mac?

I am trying to compile a sfml project via command line under mac osx. Currently, I'm not able to get it to compile. Any help guys?
dchhetri
  • 6,926
  • 4
  • 43
  • 56
7
votes
5 answers

How is this private variable "not declared in this scope"?

I'm currently trying to learn more about object oriented design in C++ (familiar with Java) and am running into some walls. The project I am trying to put together to learn these principles in a game built using SFML for the graphics and audio. I…
XBigTK13X
  • 2,655
  • 8
  • 30
  • 39