17#ifndef _FGE_GRAPHIC_C_SURFACE_HPP_INCLUDED
18#define _FGE_GRAPHIC_C_SURFACE_HPP_INCLUDED
20#include "FastEngine/fge_extern.hpp"
21#include "FastEngine/C_rect.hpp"
22#include "FastEngine/C_vector.hpp"
23#include "FastEngine/graphic/C_color.hpp"
24#include "SDL_render.h"
70 explicit Surface(SDL_Surface* newSurface);
81 bool create(
int width,
int height,
fge::Color const& color = {0, 0, 0, 255});
82 bool loadFromFile(std::filesystem::path
const& filePath);
83 bool loadFromMemory(
void const* data, std::size_t size);
91 bool saveToFile(std::filesystem::path
const& filePath)
const;
93 [[nodiscard]] fge::Vector2i getSize()
const;
103 bool setPixel(
int x,
int y,
fge::Color const& color);
104 [[nodiscard]] std::optional<fge::Color> getPixel(
int x,
int y)
const;
106 void setCircle(
int x,
int y,
unsigned int radius,
fge::Color const& color);
108 void flipHorizontally();
109 void flipVertically();
121 bool blitSurface(
Surface const& src, std::optional<SDL_Rect>
const& srcRect, std::optional<SDL_Rect>& dstRect);
153 void set(SDL_Surface* surface);
159 [[nodiscard]] SDL_Surface*
get()
const;
177 SDL_Surface* g_surface;
Definition C_color.hpp:35
Abstraction of SDL_Surface.
Definition graphic/C_surface.hpp:55
bool saveToFile(std::filesystem::path const &filePath) const
Save the surface to a PNG format file.
SDL_Surface * get() const
Get the SDL_Surface pointer.
bool blitSurface(Surface const &src, std::optional< SDL_Rect > const &srcRect, std::optional< SDL_Rect > &dstRect)
Blit a surface on this surface.
bool fillRect(std::optional< SDL_Rect > const &rect, fge::Color const &color)
Fill a rectangle section of the surface with a color.
void createMaskFromColor(fge::Color const &color, uint8_t alpha=0)
Create a transparent mask from a color.
fge::RectFloat normalizeTextureRect(fge::RectInt const &rect) const
Convert a pixel rectangle to a texture rectangle (0.0f to 1.0f)
void clear()
Destroy the surface.
fge::Vector2f normalizeTextureCoords(fge::Vector2i const &coords) const
Convert some pixel coordinates to texture coordinates (0.0f to 1.0f)
bool addBorder(int borderSize, fge::Color const &color)
Add a border to the surface with a specific color.
void set(SDL_Surface *surface)
Set a new surface.
Vulkan context.
Definition C_context.hpp:70