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. It is composed of five modules: system, window, graphics, audio and network.
개요
SFML(Simple and Fast Multimedia Library)은 프랑스의 Laurent Gomila사가 만든 멀티미디어 API이다. 기존의 크로스 플랫폼 멀티미디어 API인 Simple DirectMedia Layer (SDL)을 대체하려는 목적으로 만들어 졌으며, 처음에는 C++에 기반헀으나 버전업을 계속하면서 C#이나 JAVA, 심지어는 파이썬, 루비와 같은 다양한 언어를 지원하게 되었다. 멀티미디어 답게 그래픽, 사운드, 입출력, 네트워크등의 라이브러리를 지원한다.
상세
SFML의 장점은 빠르고 사용하기 쉽고 객체지향적이라는 것에 있다. SDL이 C언어를 바탕으로 만들어져 객체지향적인 고려가 되어있지 않은데 비해, 처음부터 객체지향적인 개발을 염두에 두고 만든 API라서 현대의 다른 객체지향 언어(C#, JAVA)에서도 대응하기가 쉽다. 또한 인터페이스가 직관적이고 객체지향에 익숙해있다면 라이브러리를 사용하는데 어려움이 적다. 다시말해 편하고 쉽다. 그래픽 API 중 쉽다고 소문난 SDL보다 더 쉽다. 사용편의성만 치면 과거 볼랜드사에서 개발한 winbgi와 맞먹을 정도다. 그런데 이건 그래픽 뿐만 아니라 사운드, 입출력, 네트워크 라이브러리까지 된다. 그러면서도 빠르기까지 하다.
그러나 단점도 꽤 많다. 우선 마이너하다. SDL은 개발된지 꽤 된 물건이라서 많이 사용되어왔고 상용 프로그램에서도 널리 사용되고 있다.1 반면에 SFML은 그럭저럭 쓸만하다고 평가받는 1.6 버전이 나온게 2010년. 관록의 차이는 관련 커뮤니티의 규모, 관련 개발 도서, 레퍼런스, 소스 등등의 차이로 나타나서 개발에 어려움을 겪게 한다. 일례로 SDL은 관련 서적이 10종 이상 출간되었으나 SFML은 첫 개발 도서인 SFML Game Development가 2013년 6월 24일 출간되었다.
SFML의 미래는 아직은 불투명하지만, 장기적으로 SDL의 위치를 위협할 수 있을거라 전망된다. 일단 객체지향 라이브러리인 점이 개발에 굉장한 메리트를 갖고 있기 때문에 이거 하나만으로 SFML을 쓸 이유는 충분하다.
Dependencies
libogg, flac, freetype, libvorbis
Ducumentation
Getting started
- SFML and Linux
- Compiling SFML with CMake
How to install in Ubuntu
System module
- Handling time
- Threads
- User data streams
Window module
- Opening and managing an SFML window
- Events explained
- Keyboard, mouse and joysticks
- Using OpenGL in a SFML window
Graphics module
- Drawing 2D stuff
- Sprites and textures
- Text and fonts
- Shapes
- Designing your own entities with vertex arrays
- Position, rotation, scale: transforming entities
- Adding special effects with shaders
- Controlling the 2D camera with views
Audio module
- Playing sounds and music
- Recording audio
- Custom audio streams
- Spatialization: Sounds in 3D
Network module
- Communication using sockets
- Using and extending packets
- Web requests with HTTP
- File transfers with FTP
Simple example
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/CircleShape.hpp>
#include <SFML/System/Clock.hpp>
#include <SFML/Window/Event.hpp>
int runDefaultSfml()
{
sf::RenderWindow window(sf::VideoMode(200, 200), LIBWORLD_MAIN_TITLE);
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
Troubleshooting
Font 정상 출력 버그
sf::Font::loadFromMemory()
를 사용하여 폰트를 읽을 경우 모든 글꼴 데이터를 미리로드 할 수 없기 때문에 sf::Font
객체가 새 글꼴을로드하거나 소멸 될 때까지 데이터가 가리키는 버퍼는 유효해야합니다.
Project
- Sources · SFML/SFML Wiki · GitHub
- Projects · SFML/SFML Wiki · GitHub
- imgui-sfml (imgui)
- SFGUI
- sefMovie
- Thor
- ObEngine
- Github - SelbaWard - A collection of SFML drawables
- Github - Swoosh - SFML Activity and Segue Mini Library
- Tiled Map Editor (tiled)
See also
Favorite site
- SFML website
- Wikipedia (en) SFML에 대한 설명
- 나무위키 - SFML
- [추천] SFML Projects
- Using OpenGL in a SFML window
- HowTo: SFML on Android
SFML on Android(NDK)
SFML on wxWidgets
- Integrating to a wxWidgets interface (SFML 1.6)
References
-
대표적으로 문명 콜 투 파워와 심시티 3000의 리눅스판, 세컨트 라이프, Open TTD 등이 있다. ↩