FifeGUI 0.2.0
A C++ GUI library designed for games.
sdl.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later OR BSD-3-Clause
2// SPDX-FileCopyrightText: 2004 - 2008 Olof Naessén and Per Larsson
3// SPDX-FileCopyrightText: 2013 - 2026 Fifengine contributors
4
5#ifndef INCLUDE_FIFECHAN_BACKENDS_SDL_SDL_HPP_
6#define INCLUDE_FIFECHAN_BACKENDS_SDL_SDL_HPP_
7
11#include <SDL2/SDL.h>
12
13#include <fifechan/backends/sdl2/graphics.hpp>
14#include <fifechan/backends/sdl2/image.hpp>
15#include <fifechan/backends/sdl2/imageloader.hpp>
16#include <fifechan/backends/sdl2/input.hpp>
17#include <fifechan/backends/sdl2/truetypefont.hpp>
18#include <fifechan/platform.hpp>
19
20#include <memory>
21
22namespace fcn::sdl2
23{
26
29
32
35
38
40 inline std::shared_ptr<SDL_Window> makeSDLSharedPtr(SDL_Window* window)
41 {
42 return std::shared_ptr<SDL_Window>{window, [](SDL_Window* value) {
43 if (value != nullptr) {
44 SDL_DestroyWindow(value);
45 }
46 }};
47 }
48
50 inline std::shared_ptr<SDL_Renderer> makeSDLSharedPtr(SDL_Renderer* renderer)
51 {
52 return std::shared_ptr<SDL_Renderer>{renderer, [](SDL_Renderer* value) {
53 if (value != nullptr) {
54 SDL_DestroyRenderer(value);
55 }
56 }};
57 }
58
60 inline std::shared_ptr<SDL_Surface> makeSDLSharedPtr(SDL_Surface* surface)
61 {
62 return std::shared_ptr<SDL_Surface>{surface, [](SDL_Surface* value) {
63 if (value != nullptr) {
64 SDL_FreeSurface(value);
65 }
66 }};
67 }
68
70 inline std::shared_ptr<SDL_Texture> makeSDLSharedPtr(SDL_Texture* texture)
71 {
72 return std::shared_ptr<SDL_Texture>{texture, [](SDL_Texture* value) {
73 if (value != nullptr) {
74 SDL_DestroyTexture(value);
75 }
76 }};
77 }
78} // namespace fcn::sdl2
79
80#endif // INCLUDE_FIFECHAN_BACKENDS_SDL_SDL_HPP_
SDL2 renderer-specific implementation of the Graphics interface.
SDL2-specific implementation of ImageLoader.
SDL2-specific implementation of Image.
SDL2-specific implementation of Input.
SDL2/FreeType implementation for rendering TrueType fonts.
Unified header for the SDL backend.
std::shared_ptr< SDL_Window > makeSDLSharedPtr(SDL_Window *window)
Create a shared_ptr that will destroy the SDL_Window when released.
Definition sdl.hpp:40