436 lines
24 KiB
C++
436 lines
24 KiB
C++
#pragma once
|
|
/// @file Surface.hpp
|
|
/// For complete documentation, see src/video/Surface.cpp
|
|
#include <SDL3/SDL.h>
|
|
#include <hdk/grid/SharedPtrWrapper.hpp>
|
|
#include <list>
|
|
namespace hdk::sdl {
|
|
class Palette;
|
|
|
|
class Surface : public hdk::grid::SharedPtrWrapper<SDL_Surface> {
|
|
public:
|
|
friend class Renderer;
|
|
using hdk::grid::SharedPtrWrapper<SDL_Surface>::SharedPtrWrapper;
|
|
bool AddAlternateImage(SDL_Surface* surface) const { return SDL_AddSurfaceAlternateImage(*this, surface); }
|
|
bool BlitTo(
|
|
SDL_Surface* dst_surface, const SDL_Rect* dst_rect = nullptr, const SDL_Rect* src_rect = nullptr) const {
|
|
return SDL_BlitSurface(*this, src_rect, dst_surface, dst_rect);
|
|
}
|
|
bool BlitFrom(
|
|
SDL_Surface* src_surface, const SDL_Rect* src_rect = nullptr, const SDL_Rect* dst_rect = nullptr) const {
|
|
return SDL_BlitSurface(src_surface, src_rect, *this, dst_rect);
|
|
}
|
|
bool Blit9GridTo(SDL_Surface* dst_surface, const SDL_Rect* dst_rect, int left_width, int right_width,
|
|
int top_height, int bottom_height, float scale, SDL_ScaleMode scale_mode,
|
|
const SDL_Rect* src_rect = nullptr) const {
|
|
return SDL_BlitSurface9Grid(*this, src_rect, left_width, right_width, top_height, bottom_height, scale,
|
|
scale_mode, dst_surface, dst_rect);
|
|
}
|
|
bool Blit9GridFrom(SDL_Surface* src_surface, const SDL_Rect* src_rect, int left_width, int right_width,
|
|
int top_height, int bottom_height, float scale, SDL_ScaleMode scale_mode,
|
|
const SDL_Rect* dst_rect = nullptr) const {
|
|
return SDL_BlitSurface9Grid(src_surface, src_rect, left_width, right_width, top_height, bottom_height, scale,
|
|
scale_mode, *this, dst_rect);
|
|
}
|
|
bool BlitScaledTo(SDL_Surface* dst_surface, const SDL_Rect* dst_rect, SDL_ScaleMode scale_mode,
|
|
const SDL_Rect* src_rect = nullptr) const {
|
|
return SDL_BlitSurfaceScaled(*this, src_rect, dst_surface, dst_rect, scale_mode);
|
|
}
|
|
bool BlitScaledFrom(SDL_Surface* src_surface, const SDL_Rect* src_rect, SDL_ScaleMode scale_mode,
|
|
const SDL_Rect* dst_rect = nullptr) const {
|
|
return SDL_BlitSurfaceScaled(src_surface, src_rect, *this, dst_rect, scale_mode);
|
|
}
|
|
bool BlitTiledTo(
|
|
SDL_Surface* dst_surface, const SDL_Rect* dst_rect = nullptr, const SDL_Rect* src_rect = nullptr) const {
|
|
return SDL_BlitSurfaceTiled(*this, src_rect, dst_surface, dst_rect);
|
|
}
|
|
bool BlitTiledFrom(
|
|
SDL_Surface* src_surface, const SDL_Rect* src_rect = nullptr, const SDL_Rect* dst_rect = nullptr) const {
|
|
return SDL_BlitSurfaceTiled(src_surface, src_rect, *this, dst_rect);
|
|
}
|
|
bool BlitTiledWithScaleTo(SDL_Surface* dst_surface, const SDL_Rect* dst_rect, float scale,
|
|
SDL_ScaleMode scale_mode, const SDL_Rect* src_rect = nullptr) const {
|
|
return SDL_BlitSurfaceTiledWithScale(*this, src_rect, scale, scale_mode, dst_surface, dst_rect);
|
|
}
|
|
bool BlitTiledWithScaleFrom(SDL_Surface* src_surface, const SDL_Rect* src_rect, float scale,
|
|
SDL_ScaleMode scale_mode, const SDL_Rect* dst_rect = nullptr) const {
|
|
return SDL_BlitSurfaceTiledWithScale(src_surface, src_rect, scale, scale_mode, *this, dst_rect);
|
|
}
|
|
bool BlitUncheckedTo(SDL_Surface* dst_surface, const SDL_Rect* dst_rect = nullptr, const SDL_Rect* src_rect = nullptr) const {
|
|
return SDL_BlitSurfaceUnchecked(*this, src_rect, dst_surface, dst_rect);
|
|
}
|
|
bool BlitUncheckedFrom(SDL_Surface* src_surface, const SDL_Rect* src_rect = nullptr, const SDL_Rect* dst_rect = nullptr) const {
|
|
return SDL_BlitSurfaceUnchecked(src_surface, src_rect, *this, dst_rect);
|
|
}
|
|
bool BlitUncheckedScaledTo(SDL_Surface* dst_surface, const SDL_Rect* dst_rect, SDL_ScaleMode scale_mode,
|
|
const SDL_Rect* src_rect = nullptr) const {
|
|
return SDL_BlitSurfaceUncheckedScaled(*this, src_rect, dst_surface, dst_rect, scale_mode);
|
|
}
|
|
bool BlitUncheckedScaledFrom(SDL_Surface* src_surface, const SDL_Rect* src_rect, SDL_ScaleMode scale_mode,
|
|
const SDL_Rect* dst_rect = nullptr) const {
|
|
return SDL_BlitSurfaceUncheckedScaled(src_surface, src_rect, *this, dst_rect, scale_mode);
|
|
}
|
|
void Clear(float r, float g, float b, float a) const { SDL_ClearSurface(*this, r, g, b, a); }
|
|
/** @todo https://wiki.libsdl.org/SDL3/SDL_ConvertPixels
|
|
*/
|
|
/** @todo https://wiki.libsdl.org/SDL3/SDL_ConvertPixelsAndColorspace
|
|
*/
|
|
Surface Convert(SDL_PixelFormat format) const {
|
|
return get_or_cache(SDL_ConvertSurface(*this, format), SDL_DestroySurface);
|
|
}
|
|
Surface ConvertAndColorspace(SDL_PixelFormat format, SDL_Palette* palette, SDL_Colorspace colorspace,
|
|
SDL_PropertiesID properties = 0) const {
|
|
return get_or_cache(
|
|
SDL_ConvertSurfaceAndColorspace(*this, format, palette, colorspace, properties), SDL_DestroySurface);
|
|
}
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_CreateSurface
|
|
* @brief Create a new surface
|
|
* @param w
|
|
* @param h
|
|
* @param format
|
|
* @return A new Surface instance with the created surface, or nullptr on failure.
|
|
*/
|
|
static Surface Create(int w, int h, SDL_PixelFormat format) {
|
|
return get_or_cache(SDL_CreateSurface(w, h, format), SDL_DestroySurface);
|
|
}
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_CreateSurfaceFrom
|
|
* @brief Create a new surface from existing pixel data.
|
|
* @param w
|
|
* @param h
|
|
* @param format
|
|
* @param pixels
|
|
* @param pitch
|
|
* @return A new Surface instance with the created surface, or nullptr on failure.
|
|
*/
|
|
static Surface CreateFrom(int w, int h, SDL_PixelFormat format, void* pixels, int pitch) {
|
|
return get_or_cache(SDL_CreateSurfaceFrom(w, h, format, pixels, pitch), SDL_DestroySurface);
|
|
}
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_CreateSurfacePalette
|
|
* @brief Create a new surface with a palette.
|
|
* @returns a new pallet on success or nullptr on failure
|
|
*/
|
|
Palette CreatePalette() const;
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_DestroySurface
|
|
*/
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_DuplicateSurface
|
|
* @brief Create a new surface that is a duplicate of the original surface.
|
|
* @return A new Surface instance with the duplicated surface, or nullptr on failure.
|
|
*/
|
|
Surface Duplicate() const { return get_or_cache(SDL_DuplicateSurface(*this), SDL_DestroySurface); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_FillSurfaceRect
|
|
* @brief Fill a rectangle on the surface with a color.
|
|
* @param rect A pointer to an SDL_Rect structure representing the rectangle to fill, or NULL to fill the entire
|
|
* surface.
|
|
* @param color
|
|
*/
|
|
void FillRect(const SDL_Rect* rect, Uint32 color) const { SDL_FillSurfaceRect(*this, rect, color); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_FillSurfaceRects
|
|
* @brief Fill multiple rectangles on the surface with a color.
|
|
* @param rects An array of SDL_Rect structures representing the rectangles to fill.
|
|
* @param count The number of rectangles in the rects array.
|
|
* @param color
|
|
* @return bool true on success
|
|
*/
|
|
bool FillRects(const SDL_Rect* rects, int count, Uint32 color) const {
|
|
return SDL_FillSurfaceRects(*this, rects, count, color);
|
|
}
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_FlipSurface
|
|
* @brief Flip the surface.
|
|
* @param flip_mode SDL_FlipMode enum to control horizontal, vertical, or both flipping.
|
|
* @return bool true on success
|
|
*/
|
|
bool Flip(SDL_FlipMode flip_mode) const { return SDL_FlipSurface(*this, flip_mode); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_GetSurfaceAlphaMod
|
|
* @brief Get the surface's alpha modulation value.
|
|
* @param alpha pointer to 8bit to receive the alpha modulation value (0-255).
|
|
* @return bool true on success
|
|
*/
|
|
bool GetAlphaMod(Uint8* alpha) const { return SDL_GetSurfaceAlphaMod(*this, alpha); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_GetSurfaceBlendMode
|
|
* @brief Get the surface's blend mode.
|
|
* @param blend_mode pointer to an SDL_BlendMode variable to receive the blend mode
|
|
* @return bool true on success
|
|
*/
|
|
bool GetBlendMode(SDL_BlendMode* blend_mode) const { return SDL_GetSurfaceBlendMode(*this, blend_mode); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_GetSurfaceClipRect
|
|
* @brief Get the surface's clipping rectangle.
|
|
* @param rect pointer to an SDL_Rect structure to receive the clipping rectangle
|
|
* @return bool true on success
|
|
*/
|
|
bool GetClipRect(SDL_Rect* rect) const { return SDL_GetSurfaceClipRect(*this, rect); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_GetSurfaceColorKey
|
|
* @brief Get the surface's color key.
|
|
* @param color_key pointer to a Uint32 variable to receive the color key value
|
|
* @return bool true on success
|
|
*/
|
|
bool GetColorKey(Uint32* color_key) const { return SDL_GetSurfaceColorKey(*this, color_key); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_GetSurfaceColorMod
|
|
* @brief Get the surface's color modulation values.
|
|
* @param r pointer to Uint8 variable to receive the red color modulation value
|
|
* @param g pointer to Uint8 variable to receive the green color modulation value
|
|
* @param b pointer to Uint8 variable to receive the blue color modulation value
|
|
* @return bool true on success
|
|
*/
|
|
bool GetColorMod(Uint8* r, Uint8* g, Uint8* b) const { return SDL_GetSurfaceColorMod(*this, r, g, b); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_GetSurfaceColorspace
|
|
* @brief Get the surface's colorspace.
|
|
* @return The colorspace of the surface.
|
|
*/
|
|
SDL_Colorspace GetColorspace() const { return SDL_GetSurfaceColorspace(*this); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_GetSurfaceImages
|
|
* @brief Get the surface's alternative images.
|
|
* @param count pointer to an int variable to receive the number of alternative images
|
|
* @return An array of Surface instances representing the surface's alternative images, or nullptr
|
|
*/
|
|
SDL_Surface** GetImages(int* count) const { return SDL_GetSurfaceImages(*this, count); }
|
|
/**
|
|
* @brief Get the surface's alternative images as a list.
|
|
* @return A list of Surface instances representing the surface's alternative images.
|
|
*/
|
|
std::list<Surface> GetImages() const {
|
|
int count = 0;
|
|
SDL_Surface** images = GetImages(&count);
|
|
std::list<Surface> image_list;
|
|
for (int i = 0; i < count; ++i) {
|
|
image_list.emplace_back(get_or_cache(images[i], SDL_DestroySurface));
|
|
}
|
|
SDL_free(images);
|
|
return image_list;
|
|
}
|
|
|
|
/** @todo https://wiki.libsdl.org/SDL3/SDL_GetSurfacePalette
|
|
*/
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_GetSurfaceProperties
|
|
* @brief Get the surface's properties.
|
|
* @return The properties set associated with the surface.
|
|
*/
|
|
SDL_PropertiesID GetProperties() const { return SDL_GetSurfaceProperties(*this); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_LoadBMP
|
|
* @brief Load a BMP image from a file and return a new surface containing the image.
|
|
* @param file The file path of the BMP image to load.
|
|
* @return A new Surface instance with the loaded surface, or nullptr on failure.
|
|
*/
|
|
static Surface LoadBMP(const char* file) { return get_or_cache(SDL_LoadBMP(file), SDL_DestroySurface); }
|
|
/** @todo https://wiki.libsdl.org/SDL3/SDL_LoadBMP_IO
|
|
*/
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_LoadPNG
|
|
* @brief Load a PNG image from a file and return a new surface containing the image.
|
|
* @param file The file path of the PNG image to load.
|
|
* @return A new Surface instance with the loaded surface, or nullptr on failure.
|
|
*/
|
|
static Surface LoadPNG(const char* file) { return get_or_cache(SDL_LoadPNG(file), SDL_DestroySurface); }
|
|
/** @todo https://wiki.libsdl.org/SDL3/SDL_LoadPNG_IO
|
|
*/
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_LoadSurface
|
|
* @brief Load a surface from a file. PNG or BMP image formats are supported.
|
|
* @param file The file path of the image to load.
|
|
* @return A new Surface instance with the loaded surface, or nullptr on failure.
|
|
*/
|
|
static Surface LoadSurface(const char* file) { return get_or_cache(SDL_LoadSurface(file), SDL_DestroySurface); }
|
|
/** @todo https://wiki.libsdl.org/SDL3/SDL_LoadSurface_IO
|
|
*/
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_LockSurface
|
|
* @brief Lock the surface for direct pixel access.
|
|
* @return bool true on success
|
|
*/
|
|
bool Lock() const { return SDL_LockSurface(*this); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_MapSurfaceRGB
|
|
* @brief Map RGB values to a pixel format and return the mapped color value.
|
|
* @param r The red component of the color
|
|
* @param g The green component of the color
|
|
* @param b The blue component of the color
|
|
* @return The mapped color value in the surface's pixel format.
|
|
*/
|
|
Uint32 MapRGB(Uint8 r, Uint8 g, Uint8 b) const { return SDL_MapSurfaceRGB(*this, r, g, b); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_MapSurfaceRGBA
|
|
* @brief Map RGBA values to a pixel format and return the mapped color value.
|
|
* @param r The red component of the color
|
|
* @param g The green component of the color
|
|
* @param b The blue component of the color
|
|
* @param a The alpha component of the color
|
|
* @return The mapped color value in the surface's pixel format.
|
|
*/
|
|
Uint32 MapRGBA(Uint8 r, Uint8 g, Uint8 b, Uint8 a) const { return SDL_MapSurfaceRGBA(*this, r, g, b, a); }
|
|
/** @todo https://wiki.libsdl.org/SDL3/SDL_PremultiplyAlpha
|
|
*/
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_PremultiplySurfaceAlpha
|
|
* @brief Premultiply the surface's alpha values into its color values.
|
|
* @param linear
|
|
* @return bool true on success
|
|
*/
|
|
bool PremultiplyAlpha(bool linear) const { return SDL_PremultiplySurfaceAlpha(*this, linear); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_ReadSurfacePixel
|
|
* @brief Read a pixel from the surface at the specified coordinates and return its color value.
|
|
* @param x
|
|
* @param y
|
|
* @param r pointer to Uint8 variable to receive the red component of the pixel's color
|
|
* @param g pointer to Uint8 variable to receive the green component of the pixel's color
|
|
* @param b pointer to Uint8 variable to receive the blue component of the pixel's color
|
|
* @param a pointer to Uint8 variable to receive the alpha component of the pixel's color
|
|
* @return bool true on success
|
|
*/
|
|
bool ReadPixel(int x, int y, Uint8* r, Uint8* g, Uint8* b, Uint8* a) const {
|
|
return SDL_ReadSurfacePixel(*this, x, y, r, g, b, a);
|
|
}
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_ReadSurfacePixelFloat
|
|
* @brief Read a pixel from the surface at the specified coordinates and return its color value as floats.
|
|
* @param x
|
|
* @param y
|
|
* @param r pointer to float variable to receive the red component of the pixel's color
|
|
* @param g pointer to float variable to receive the green component of the pixel's color
|
|
* @param b pointer to float variable to receive the blue component of the pixel's color
|
|
* @param a pointer to float variable to receive the alpha component of the pixel's color
|
|
* @return bool true on success
|
|
*/
|
|
bool ReadPixelFloat(int x, int y, float* r, float* g, float* b, float* a) const {
|
|
return SDL_ReadSurfacePixelFloat(*this, x, y, r, g, b, a);
|
|
}
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_RemoveSurfaceAlternateImages
|
|
* @brief Remove all alternate images from the surface.
|
|
*/
|
|
void RemoveAlternateImages() const { SDL_RemoveSurfaceAlternateImages(*this); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_RotateSurface
|
|
* @brief Rotate the surface by a specified angle returning a new surface with the rotated image.
|
|
* @param angle The angle to rotate the surface, in degrees.
|
|
*/
|
|
Surface Rotate(float angle) const { return get_or_cache(SDL_RotateSurface(*this, angle), SDL_DestroySurface); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_SaveBMP
|
|
* @brief Save the surface as a BMP image to a file.
|
|
* @param file The file path to save the BMP image to.
|
|
* @return bool true on success
|
|
*/
|
|
bool SaveBMP(const char* file) const { return SDL_SaveBMP(*this, file); }
|
|
/** @todo https://wiki.libsdl.org/SDL3/SDL_SaveBMP_IO
|
|
*/
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_SavePNG
|
|
* @brief Save the surface as a PNG image to a file.
|
|
* @param file The file path to save the PNG image to.
|
|
* @return bool true on success
|
|
*/
|
|
bool SavePNG(const char* file) const { return SDL_SavePNG(*this, file); }
|
|
/** @todo https://wiki.libsdl.org/SDL3/SDL_SavePNG_IO
|
|
*/
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_ScaleSurface
|
|
* @brief Scale the surface to a new width and height, returning a new surface with the scaled image.
|
|
* @param w The new width of the surface.
|
|
* @param h The new height of the surface.
|
|
* @param scale_mode The scale mode to use for scaling the surface
|
|
* @return A new Surface instance with the scaled surface, or nullptr on failure.
|
|
*/
|
|
Surface Scale(int w, int h, SDL_ScaleMode scale_mode) const {
|
|
return get_or_cache(SDL_ScaleSurface(*this, w, h, scale_mode), SDL_DestroySurface);
|
|
}
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_SetSurfaceAlphaMod
|
|
* @brief Set the surface's alpha modulation value.
|
|
* @param alpha The alpha modulation value to set (0-255).
|
|
* @return bool true on success
|
|
*/
|
|
bool SetAlphaMod(Uint8 alpha) const { return SDL_SetSurfaceAlphaMod(*this, alpha); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_SetSurfaceBlendMode
|
|
* @brief Set the surface's blend mode.
|
|
* @param blend_mode The blend mode to set for the surface.
|
|
* @return bool true on success
|
|
*/
|
|
bool SetBlendMode(SDL_BlendMode blend_mode) const { return SDL_SetSurfaceBlendMode(*this, blend_mode); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_SetSurfaceClipRect
|
|
* @brief Set the surface's clipping rectangle.
|
|
* @param rect A pointer to an SDL_Rect structure representing the clipping rectangle to set,
|
|
* or NULL to disable clipping.
|
|
* @return bool true on success
|
|
*/
|
|
bool SetClipRect(const SDL_Rect* rect) const { return SDL_SetSurfaceClipRect(*this, rect); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_SetSurfaceColorKey
|
|
* @brief Set the surface's color key.
|
|
* @param enable Whether to enable or disable the color key for the surface.
|
|
* @param color_key The color key value to set for the surface.
|
|
* @return bool true on success
|
|
*/
|
|
bool SetColorKey(bool enable, Uint32 color_key) const { return SDL_SetSurfaceColorKey(*this, enable, color_key); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_SetSurfaceColorMod
|
|
* @brief Set the surface's color modulation values.
|
|
* @param r The red color modulation value to set.
|
|
* @param g The green color modulation value to set.
|
|
* @param b The blue color modulation value to set.
|
|
* @return bool true on success
|
|
*/
|
|
bool SetColorMod(Uint8 r, Uint8 g, Uint8 b) const { return SDL_SetSurfaceColorMod(*this, r, g, b); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_SetSurfaceColorspace
|
|
* @brief Set the surface's colorspace.
|
|
* @param colorspace The colorspace to set for the surface.
|
|
* @return bool true on success
|
|
*/
|
|
bool SetColorspace(SDL_Colorspace colorspace) const { return SDL_SetSurfaceColorspace(*this, colorspace); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_SetSurfacePalette
|
|
* @brief Set the surface's palette.
|
|
* @param palette A pointer to an SDL_Palette structure representing the palette to set for the surface.
|
|
* @return bool true on success
|
|
*/
|
|
bool SetPalette(SDL_Palette* palette) const { return SDL_SetSurfacePalette(*this, palette); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_SetSurfaceRLE
|
|
* @brief Set the surface's RLE acceleration hint.
|
|
* @param rle The RLE acceleration hint to set for the surface.
|
|
* @return bool true on success
|
|
*/
|
|
bool SetRLE(bool rle) const { return SDL_SetSurfaceRLE(*this, rle); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_StretchSurface
|
|
* @brief Blits this surface onto a destination rectangle stretching/smooshing the image to fit the destination
|
|
* rectangle.
|
|
* @param dst_surface The destination surface to blit on to.
|
|
* @param dst_rect A pointer to an SDL_Rect structure representing the area on the destination surface to blit
|
|
* onto, or NULL to blit onto the entire surface.
|
|
* @param src_rect A pointer to an SDL_Rect structure representing the area of the source surface to blit, or NULL
|
|
* to blit the entire surface.
|
|
* @param scale_mode The scale mode to use for scaling the surface when stretching.
|
|
* @return bool true on success
|
|
*/
|
|
bool StretchTo(
|
|
SDL_Surface* dst_surface, const SDL_Rect* dst_rect, const SDL_Rect* src_rect, SDL_ScaleMode scale_mode) const {
|
|
return SDL_StretchSurface(*this, src_rect, dst_surface, dst_rect, scale_mode);
|
|
}
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_SurfaceHasAlternateImages
|
|
* @brief Check if the surface has any alternate images.
|
|
* @return bool true if the surface has alternate images, false otherwise.
|
|
*/
|
|
bool HasAlternateImages() const { return SDL_SurfaceHasAlternateImages(*this); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_SurfaceHasColorKey
|
|
* @brief Check if the surface has a color key.
|
|
* @return bool true if the surface has a color key, false otherwise.
|
|
*/
|
|
bool HasColorKey() const { return SDL_SurfaceHasColorKey(*this); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_SurfaceHasRLE
|
|
* @brief Check if the surface has RLE acceleration enabled.
|
|
* @return bool true if the surface has RLE acceleration enabled, false otherwise.
|
|
*/
|
|
bool HasRLE() const { return SDL_SurfaceHasRLE(*this); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_UnlockSurface
|
|
* @brief Unlock the surface after direct pixel access.
|
|
*/
|
|
void Unlock() const { SDL_UnlockSurface(*this); }
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_WriteSurfacePixel
|
|
* @brief Write a pixel to the surface at the specified coordinates with the given color value.
|
|
* @param x
|
|
* @param y
|
|
* @param r
|
|
* @param g
|
|
* @param b
|
|
* @param a
|
|
* @return bool true on success
|
|
*/
|
|
bool WritePixel(int x, int y, Uint8 r, Uint8 g, Uint8 b, Uint8 a) const {
|
|
return SDL_WriteSurfacePixel(*this, x, y, r, g, b, a);
|
|
}
|
|
/** @see https://wiki.libsdl.org/SDL3/SDL_WriteSurfacePixelFloat
|
|
* @brief Write a pixel to the surface at the specified coordinates with the given color value as floats.
|
|
* @param x
|
|
* @param y
|
|
* @param r
|
|
* @param g
|
|
* @param b
|
|
* @param a
|
|
* @return bool true on success
|
|
*/
|
|
bool WritePixelFloat(int x, int y, float r, float g, float b, float a) const {
|
|
return SDL_WriteSurfacePixelFloat(*this, x, y, r, g, b, a);
|
|
}
|
|
};
|
|
} |