SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SDL::PaletteBase Struct Reference

A set of indexed colors representing a palette. More...

Inheritance diagram for SDL::PaletteBase:
Inheritance graph
[legend]

Public Member Functions

 PaletteBase (int ncolors)
 Create a palette structure with the specified number of color entries.
 
constexpr int GetSize () const
 Return the number of colors.
 
constexpr Color operator[] (int index) const
 Get the index color.
 
void SetColors (std::span< const SDL_Color > colors, int firstcolor=0)
 Set a range of colors in a palette.
 
bool SetColors (SpanRef< const SDL_Color > colors, int firstcolor=0)
 Set a range of colors in a palette.
 
constexpr Resource (T resource={})
 Constructs the underlying resource.
 
constexpr Resource (std::nullptr_t)
 Equivalent to default ctor.
 
constexpr Resource (std::nullopt_t)
 Equivalent to default ctor.
 
 Resource (const Resource &other)=delete
 
 Resource (Resource &&other)=delete
 
- Public Member Functions inherited from SDL::Resource< SDL_Palette * >
constexpr Resource (SDL_Palette * resource={})
 Constructs the underlying resource.
 
constexpr Resource (std::nullptr_t)
 Equivalent to default ctor.
 
constexpr Resource (std::nullopt_t)
 Equivalent to default ctor.
 
 Resource (const Resource &other)=delete
 
 Resource (Resource &&other)=delete
 
Resourceoperator= (const Resource &other)=delete
 
Resourceoperator= (Resource &&other)=delete
 
constexpr operator bool () const
 True if contains a valid resource.
 
constexpr bool operator== (const Resource &other) const=default
 Comparison.
 
constexpr bool operator== (std::nullopt_t) const
 Comparison.
 
constexpr bool operator== (std::nullptr_t) const
 Comparison.
 
constexpr SDL_Palette * get () const
 Return contained resource;.
 
constexpr SDL_Palette * release (SDL_Palette * newResource={})
 Return contained resource and empties or replace value.
 
constexpr const SDL_Palette * operator-> () const
 Access to fields.
 
constexpr SDL_Palette * operator-> ()
 Access to fields.
 

Detailed Description

Since
This struct is available since SDL 3.2.0.
Category:
Resource
See also
PaletteBase.SetColors
Palette
PaletteRef

Constructor & Destructor Documentation

◆ PaletteBase()

SDL::PaletteBase::PaletteBase ( int  ncolors)
inline

The palette entries are initialized to white.

Parameters
ncolorsrepresents the number of color entries in the color palette.
Postcondition
a new Palette structure on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
PaletteBase.SetColors
SurfaceBase.SetPalette

Member Function Documentation

◆ SetColors() [1/2]

bool SDL::PaletteBase::SetColors ( SpanRef< const SDL_Color >  colors,
int  firstcolor = 0 
)
inline
Parameters
colorsa span of SDL_Color structures to copy into the palette.
firstcolorthe index of the first palette entry to modify.
Returns
true on success or false on failure; call GetError() for more information.
Thread safety:
It is safe to call this function from any thread, as long as the palette is not modified or destroyed in another thread.

◆ SetColors() [2/2]

void SDL::PaletteBase::SetColors ( std::span< const SDL_Color >  colors,
int  firstcolor = 0 
)
inline
Parameters
colorsan array of Color structures to copy into the palette.
firstcolorthe index of the first palette entry to modify.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread, as long as the palette is not modified or destroyed in another thread.
Since
This function is available since SDL 3.2.0.

The documentation for this struct was generated from the following file: