FifeGUI 0.2.0
A C++ GUI library designed for games.
backends/sdl2/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#include <SDL2/SDL.h>
9
10#include <string>
11
12#include "fifechan/imageloader.hpp"
13#include "fifechan/platform.hpp"
14
15namespace fcn
16{
17 class Image;
18}
19
20namespace fcn::sdl2
21{
22
28 class FIFEGUI_EXT_API ImageLoader : public fcn::ImageLoader
29 {
30 public:
32
34 fcn::Image* load(std::string const & filename, bool convertToDisplayFormat) override;
35
37 SDL_PixelFormat const & getSDLPixelFormat();
38
40 void setSDLPixelFormat(SDL_PixelFormat const & format);
41
43 void setRenderer(SDL_Renderer* renderer);
44
45 protected:
47 virtual SDL_Surface* loadSDLSurface(std::string const & filename);
48
50 virtual SDL_Texture* loadSDLTexture(std::string const & filename);
51
53 virtual SDL_Surface* convertToStandardFormat(SDL_Surface* surface);
54
55 private:
57 SDL_PixelFormat mPixelFormat;
58
60 SDL_Renderer* mRenderer;
61 };
62} // namespace fcn::sdl2
63
64#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:32
virtual SDL_Texture * loadSDLTexture(std::string const &filename)
Load an SDL_Texture from disk (internal).
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).
void setRenderer(SDL_Renderer *renderer)
Set the SDL renderer used when creating textures.
SDL_PixelFormat const & getSDLPixelFormat()
Return the current SDL pixel format used for conversions.
void setSDLPixelFormat(SDL_PixelFormat const &format)
Set the SDL pixel format used for conversions.
Unified header for the SDL backend.