#pragma once /** @file Surface.hpp * @brief Defines the Surface class for handling SDL surfaces. */ #include #include /** Surfaces hold bitmap data **/ namespace hdk::sdl { class Surface : public hdk::grid::SharedPtrWrapper { public: /** Inherit constructors from SharedPtrWrapper */ using hdk::grid::SharedPtrWrapper::SharedPtrWrapper; /** @see https://wiki.libsdl.org/SDL3/SDL_AddSurfaceAlternateImage * @brief Add an alternate image to a surface. * @param surface The surface to add the alternate image to. * @return bool true on success */ bool AddAlternateImage(SDL_Surface* surface) const { return SDL_AddSurfaceAlternateImage(*this, surface); } /** @see https://wiki.libsdl.org/SDL3/SDL_BlitSurface * @brief Perform a fast blit from `this` surface to the destination surface. * @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. * @return bool true on success */ 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); } /** @see https://wiki.libsdl.org/SDL3/SDL_BlitSurface * @brief Perform a fast blit to `this` surface from a source surface. * @param src_surface The source surface to blit from. * @param src_rect A pointer to an SDL_Rect structure representing the area on the source surface to blit * from, or NULL to blit the entire surface. * @param dst_rect A pointer to an SDL_Rect structure representing the area of the destination surface to blit, * or NULL to blit the entire surface. * @return bool true on success */ 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); } /** @see https://wiki.libsdl.org/SDL3/SDL_BlitSurface9Grid * @brief Perform a blit with 9-grid scaling from `this` surface to the destination surface. * @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 * @param left_width The width of the left columns of the 9-grid * @param right_width The width of the right columns of the 9-grid * @param top_height The height of the top rows of the 9-grid * @param bottom_height The height of the bottom rows of the 9-grid * @param scale The scale factor to apply to the center of the 9-grid * @param scale_mode * @param src_rect * @return bool true on success */ 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); } /** @see https://wiki.libsdl.org/SDL3/SDL_BlitSurface9Grid * @brief Perform a blit with 9-grid scaling to `this` surface from a source surface. * @param src_surface The source surface to blit from. * @param src_rect * @param left_width The width of the left columns of the 9-grid * @param right_width The width of the right columns of the 9-grid * @param top_height The height of the top rows of the 9-grid * @param bottom_height The height of the bottom rows of the 9-grid * @param scale The scale factor to apply to the center of the 9-grid * @param scale_mode * @param dst_rect A pointer to an SDL_Rect structure representing the area on the destination surface to blit, or NULL to blit the entire surface. * @return bool true on success */ 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); } /** @see https://wiki.libsdl.org/SDL3/SDL_BlitSurfaceScaled * @brief Perform a scaled blit from `this` surface to the destination surface. * @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 * @param scale_mode The scale mode to use for scaling the 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. * @return bool true on success */ 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); } /** @see https://wiki.libsdl.org/SDL3/SDL_BlitSurfaceScaled * @brief Perform a scaled blit to `this` surface from a source surface. * @param src_surface The source surface to blit from. * @param src_rect A pointer to an SDL_Rect structure representing the area on the source * @param scale_mode The scale mode to use for scaling the surface * @param dst_rect A pointer to an SDL_Rect structure representing the area on the destination surface to blit, or * NULL to blit the entire surface. * @return bool true */ 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); } /** @see https://wiki.libsdl.org/SDL3/SDL_BlitSurfaceTiled * @brief Perform a tiled blit from `this` surface to the destination surface. * @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. * @return bool true on success */ 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); } /** @see https://wiki.libsdl.org/SDL3/SDL_BlitSurfaceTiled * @brief Perform a tiled blit to `this` surface from a source surface. * @param src_surface The source surface to blit from. * @param src_rect A pointer to an SDL_Rect structure representing the area on the source surface to blit, or NULL * to blit the entire surface. * @param dst_rect A pointer to an SDL_Rect structure representing the area of the destination surface to blit, or * NULL to blit the entire surface. * @return bool true on success */ 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); } /** @see https://wiki.libsdl.org/SDL3/SDL_BlitSurfaceTiledWithScale * @brief Perform a tiled blit with scale from `this` surface to the destination surface. * @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 scale The scale factor to apply to the source surface when blitting. * @param scale_mode The scale mode to use for scaling the surface * @param src_rect A pointer to an SDL_Rect structure representing the area of the source */ 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); } /** @see https://wiki.libsdl.org/SDL3/SDL_BlitSurfaceTiledWithScale * @brief Perform a tiled blit with scale to `this` surface from a source surface. * @param src_surface The source surface to blit from. * @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 The scale factor to apply to the source surface when blitting. * @param scale_mode The scale mode to use for scaling the surface * @param dst_rect A pointer to an SDL_Rect structure representing the area of the destination surface to blit, or * NULL to blit the entire surface. * @return bool true on success */ 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); } /** @todo https://wiki.libsdl.org/SDL3/SDL_BlitSurfaceUnchecked */ /** @todo https://wiki.libsdl.org/SDL3/SDL_BlitSurfaceUncheckedScaled */ /** @see https://wiki.libsdl.org/SDL3/SDL_ClearSurface * @brief Clear the surface to the specified color. * @param r * @param g * @param b * @param a */ 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 */ /** @see https://wiki.libsdl.org/SDL3/SDL_ConvertSurface * @brief Convert surface to specified pixel format. * @param format The pixel format to convert to. * @return A new Surface instance with the converted surface, or nullptr on failure. */ Surface Convert(SDL_PixelFormat format) const { return get_or_cache(SDL_ConvertSurface(*this, format), SDL_DestroySurface); } /** @see https://wiki.libsdl.org/SDL3/SDL_ConvertSurfaceAndColorspace * @brief Convert surface to specified pixel format and colorspace. * @param format * @param palette (optional) The palette to use for the converted surface, or NULL to use the palette from the * original surface. * @param colorspace * @param properties (optional) can be 0. * @return A new Surface instance with the converted surface, or nullptr on failure. */ 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); } /** @todo https://wiki.libsdl.org/SDL3/SDL_CreateSurfacePalette */ /** @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); } /** @todo https://wiki.libsdl.org/SDL3/SDL_GetSurfaceImages */ /** @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); } }; }