FifeGUI 0.3.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
8// Standard library includes
9#include <memory>
10
11// Platform config include
12#include "fifechan/platform.hpp"
13
14// Third-party library includes
15#include <SDL3/SDL.h>
16
17// Project headers (subdirs before local)
18#include <fifechan/backends/sdl3/graphics.hpp>
19#include <fifechan/backends/sdl3/image.hpp>
20#include <fifechan/backends/sdl3/imageloader.hpp>
21#include <fifechan/backends/sdl3/input.hpp>
22#include <fifechan/backends/sdl3/truetypefont.hpp>
23
24namespace fcn::sdl3
25{
27 using Graphics = fcn::sdl3::Graphics;
28
30 using Image = fcn::sdl3::Image;
31
33 using ImageLoader = fcn::sdl3::ImageLoader;
34
36 using Input = fcn::sdl3::Input;
37
39 using TrueTypeFont = fcn::sdl3::TrueTypeFont;
40
42 inline std::shared_ptr<SDL_Window> makeSDLSharedPtr(SDL_Window* window)
43 {
44 return std::shared_ptr<SDL_Window>{window, [](SDL_Window* value) {
45 if (value != nullptr) {
46 SDL_DestroyWindow(value);
47 }
48 }};
49 }
50
52 inline std::shared_ptr<SDL_Renderer> makeSDLSharedPtr(SDL_Renderer* renderer)
53 {
54 return std::shared_ptr<SDL_Renderer>{renderer, [](SDL_Renderer* value) {
55 if (value != nullptr) {
56 SDL_DestroyRenderer(value);
57 }
58 }};
59 }
60
62 inline std::shared_ptr<SDL_Surface> makeSDLSharedPtr(SDL_Surface* surface)
63 {
64 return std::shared_ptr<SDL_Surface>{surface, [](SDL_Surface* value) {
65 if (value != nullptr) {
66 SDL_DestroySurface(value);
67 }
68 }};
69 }
70
72 inline std::shared_ptr<SDL_Texture> makeSDLSharedPtr(SDL_Texture* texture)
73 {
74 return std::shared_ptr<SDL_Texture>{texture, [](SDL_Texture* value) {
75 if (value != nullptr) {
76 SDL_DestroyTexture(value);
77 }
78 }};
79 }
80} // namespace fcn::sdl3
81
82#endif // INCLUDE_FIFECHAN_BACKENDS_SDL_SDL_HPP_
SDL3 renderer-specific implementation of the Graphics interface.
SDL3-specific implementation of ImageLoader.
SDL3-specific implementation of Image.
SDL3-specific implementation of Input.
SDL3/FreeType implementation for rendering TrueType fonts.