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

Handle to a non owned palette. More...

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

Public Member Functions

constexpr PaletteRef (const PaletteRef &other)
 Copy constructor.
 
constexpr PaletteRef (PaletteRef &&other)
 Move constructor.
 
constexpr ~PaletteRef ()=default
 Default constructor.
 
PaletteRefoperator= (PaletteRef other)
 Assignment operator.
 
void reset (SDL_Palette *newResource={})
 Free a palette created with PaletteBase.PaletteBase().
 
 PaletteBase (int ncolors)
 Create a palette structure with the specified number of color entries.
 
- Public Member Functions inherited from SDL::PaletteBase
 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

Category:
Resource
See also
PaletteBase
Palette

Member Function 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

◆ reset()

void SDL::PaletteRef::reset ( SDL_Palette *  newResource = {})
inline

After calling, this object becomes empty.

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.
See also
PaletteBase.PaletteBase

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