Pixels, Surfaces, Renderer, oh my...
This commit is contained in:
@@ -1,37 +1,18 @@
|
||||
#pragma once
|
||||
/** @file Palette.hpp
|
||||
* @brief HDK sdl video header only wrapper for SDL_Palette struct & related functions
|
||||
*/
|
||||
/// @file Palette.hpp
|
||||
/// For complete documentation, see src/pixels/Palette.cpp
|
||||
#include <SDL3/SDL_pixels.h>
|
||||
#include <hdk/grid/SharedPtrWrapper.hpp>
|
||||
namespace hdk::sdl {
|
||||
/**
|
||||
* @brief
|
||||
* @note
|
||||
*/
|
||||
class Palette : public hdk::grid::SharedPtrWrapper<SDL_Palette> {
|
||||
public:
|
||||
/** Inherit constructors from SharedPtrWrapper */
|
||||
friend class Texture;
|
||||
friend class Surface;
|
||||
using hdk::grid::SharedPtrWrapper<SDL_Palette>::SharedPtrWrapper;
|
||||
/** @see https://wiki.libsdl.org/SDL3/SDL_CreatePalette
|
||||
* @brief Create a palette with a specified number of colors.
|
||||
* @param ncolors The number of colors in the palette.
|
||||
* @return Palette The created palette. If the creation fails, returns an invalid palette.
|
||||
*/
|
||||
static Palette Create(int ncolors) {
|
||||
return Palette(get_or_cache(SDL_CreatePalette(ncolors), SDL_DestroyPalette));
|
||||
}
|
||||
/** @see https://wiki.libsdl.org/SDL3/SDL_DestroyPalette
|
||||
* @brief Destroy a palette and free its associated memory.
|
||||
*/
|
||||
void Destroy() const { SDL_DestroyPalette(*this); }
|
||||
/** @see https://wiki.libsdl.org/SDL3/SDL_SetPaletteColors
|
||||
* @brief Set a range of colors in a palette.
|
||||
* @param colors An array of SDL_Color structures representing the colors to set in the palette.
|
||||
* @param firstcolor The index of the first color to set in the palette.
|
||||
* @param ncolors The number of colors to set in the palette.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
bool SetColors(const SDL_Color* colors, int firstcolor, int ncolors) const {
|
||||
return SDL_SetPaletteColors(*this, colors, firstcolor, ncolors);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user