20 lines
758 B
C++
20 lines
758 B
C++
#pragma once
|
|
/// @file Palette.hpp
|
|
/// For complete documentation, see src/pixels/Palette.cpp
|
|
#include <SDL3/SDL_pixels.h>
|
|
#include <hdk/grid/SharedPtrWrapper.hpp>
|
|
namespace hdk::sdl {
|
|
class Palette : public hdk::grid::SharedPtrWrapper<SDL_Palette> {
|
|
public:
|
|
friend class Texture;
|
|
friend class Surface;
|
|
using hdk::grid::SharedPtrWrapper<SDL_Palette>::SharedPtrWrapper;
|
|
static Palette Create(int ncolors) {
|
|
return Palette(get_or_cache(SDL_CreatePalette(ncolors), SDL_DestroyPalette));
|
|
}
|
|
void Destroy() const { SDL_DestroyPalette(*this); }
|
|
bool SetColors(const SDL_Color* colors, int firstcolor, int ncolors) const {
|
|
return SDL_SetPaletteColors(*this, colors, firstcolor, ncolors);
|
|
}
|
|
};
|
|
} |