FifeGUI 0.3.0
A C++ GUI library designed for games.
backends/sdl3/imageloader.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_SDLIMAGELOADER_HPP_
6#define INCLUDE_FIFECHAN_BACKENDS_SDL_SDLIMAGELOADER_HPP_
7
8// Standard library includes
9#include <string>
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/imageloader.hpp"
19
20namespace fcn
21{
22 class Image;
23}
24
25namespace fcn::sdl3
26{
27
33 class FIFEGUI_EXT_API ImageLoader : public fcn::ImageLoader
34 {
35 public:
36 ImageLoader();
38
40 fcn::Image* load(std::string const & filename, bool convertToDisplayFormat) override;
41
43 SDL_PixelFormat const & getSDLPixelFormat();
44
46 void setSDLPixelFormat(SDL_PixelFormat const & format);
47
49 void setRenderer(SDL_Renderer* renderer);
50
51 protected:
53 virtual SDL_Surface* loadSDLSurface(std::string const & filename);
54
56 virtual SDL_Texture* loadSDLTexture(std::string const & filename);
57
59 virtual SDL_Surface* convertToStandardFormat(SDL_Surface* surface);
60
61 private:
63 SDL_PixelFormat mPixelFormat{};
64
66 SDL_Renderer* mRenderer{nullptr};
67 };
68} // namespace fcn::sdl3
69
70#endif // INCLUDE_FIFECHAN_BACKENDS_SDL_SDLIMAGELOADER_HPP_
Abstract interface for loading image assets.
Image * load(std::string const &filename)
Loads an image.
Abstract holder for image data.
Definition image.hpp:34
SDL_PixelFormat const & getSDLPixelFormat()
Return the current SDL pixel format used for conversions.
virtual SDL_Surface * convertToStandardFormat(SDL_Surface *surface)
Convert a surface to a standard internal format (internal).
fcn::Image * load(std::string const &filename, bool convertToDisplayFormat) override
Load an image from filename.
virtual SDL_Surface * loadSDLSurface(std::string const &filename)
Load an SDL_Surface from disk (internal).
virtual SDL_Texture * loadSDLTexture(std::string const &filename)
Load an SDL_Texture from disk (internal).
void setSDLPixelFormat(SDL_PixelFormat const &format)
Set the SDL pixel format used for conversions.
void setRenderer(SDL_Renderer *renderer)
Set the SDL renderer used when creating textures.
Used replacement tokens by configure_file():