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

A collection of pixels used in software blitting. More...

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

Public Member Functions

PropertiesRef GetProperties () const
 Get the properties associated with a surface.
 
void SetColorspace (Colorspace colorspace)
 Set the colorspace used by a surface.
 
Colorspace GetColorspace () const
 Get the colorspace used by a surface.
 
PaletteRef CreatePalette ()
 Create a palette and associate it with a surface.
 
void SetPalette (PaletteRef palette)
 Set the palette used by a surface.
 
PaletteRef GetPalette () const
 Get the palette used by a surface.
 
void AddAlternateImage (SurfaceRef image)
 Add an alternate version of a surface.
 
bool HasAlternateImages () const
 Return whether a surface has alternate versions available.
 
OwnArray< SurfaceRefGetImages () const
 Get an array including all versions of a surface.
 
void RemoveAlternateImages ()
 Remove all alternate versions of a surface.
 
constexpr bool MustLock () const
 Evaluates to true if the surface needs to be locked before access.
 
SurfaceLock Lock () &
 Set up a surface for directly accessing the pixels.
 
void SetRLE (bool enabled)
 Set the RLE acceleration hint for a surface.
 
bool HasRLE () const
 Returns whether the surface is RLE enabled.
 
void SetColorKey (Color key)
 Set the color key (transparent pixel) in a surface.
 
void SetColorKey (std::optional< Uint32 > key)
 Set the color key (transparent pixel) in a surface.
 
void ClearColorKey ()
 Unset the color key (transparent pixel) in a surface.
 
bool HasColorKey () const
 Returns whether the surface has a color key.
 
Color GetColorKey () const
 Get the color key (transparent pixel) for a surface.
 
void GetColorKey (Color *key) const
 Get the color key (transparent pixel) for a surface.
 
void GetColorKey (Uint32 *key) const
 Get the color key (transparent pixel) for a surface.
 
void SetColorMod (Uint8 r, Uint8 g, Uint8 b)
 Set an additional color value multiplied into blit operations.
 
void GetColorMod (Uint8 *r, Uint8 *g, Uint8 *b) const
 Get the additional color value multiplied into blit operations.
 
void SetAlphaMod (Uint8 alpha)
 Set an additional alpha value used in blit operations.
 
Uint8 GetAlphaMod () const
 Get the additional alpha value used in blit operations.
 
void SetMod (Color color)
 Set an additional color and alpha value multiplied into blit operations.
 
Color GetMod () const
 Get the additional color and alpha value multiplied into blit operations.
 
void SetBlendMode (BlendMode blendMode)
 Set the blend mode used for blit operations.
 
BlendMode GetBlendMode () const
 Get the blend mode used for blit operations.
 
bool SetClipRect (OptionalRef< const SDL_Rect > rect)
 Set the clipping rectangle for a surface.
 
void ResetClipRect ()
 Disable the clipping rectangle for a surface.
 
Rect GetClipRect () const
 Get the clipping rectangle for a surface.
 
void Flip (FlipMode flip)
 Flip a surface vertically or horizontally.
 
Surface Duplicate () const
 Creates a new surface identical to the existing surface.
 
Surface Scale (int width, int height, ScaleMode scaleMode) const
 Creates a new surface identical to the existing surface, scaled to the desired size.
 
Surface Convert (PixelFormat format) const
 Copy an existing surface to a new surface of the specified format.
 
Surface Convert (PixelFormat format, PaletteRef palette, Colorspace colorspace, PropertiesRef props) const
 Copy an existing surface to a new surface of the specified format and colorspace.
 
void PremultiplyAlpha (bool linear)
 Premultiply the alpha in a surface.
 
void Clear (SDL_FColor color)
 Clear a surface with a specific color, with floating point precision.
 
void Fill (SDL_Color color)
 Perform a fast fill of a rectangle with a specific color.
 
void Fill (Uint32 color)
 Perform a fast fill of a rectangle with a specific color.
 
void FillRect (OptionalRef< const SDL_Rect > rect, SDL_Color color)
 Perform a fast fill of a rectangle with a specific color.
 
void FillRect (OptionalRef< const SDL_Rect > rect, Uint32 color)
 Perform a fast fill of a rectangle with a specific color.
 
void FillRects (SpanRef< const SDL_Rect > rects, SDL_Color color)
 Perform a fast fill of a set of rectangles with a specific color.
 
void FillRects (SpanRef< const SDL_Rect > rects, Uint32 color)
 Perform a fast fill of a set of rectangles with a specific color.
 
void Blit (SurfaceRef src, OptionalRef< const SDL_Rect > srcrect, const SDL_Point &dstpos)
 Performs a fast blit from the source surface to the destination surface with clipping.
 
void Blit (SurfaceRef src, OptionalRef< const SDL_Rect > srcrect, OptionalRef< const SDL_Rect > dstrect)
 Performs a fast blit from the source surface to the destination surface with clipping.
 
void BlitUnchecked (SurfaceRef src, const SDL_Rect &srcrect, const SDL_Rect &dstrect)
 Perform low-level surface blitting only.
 
void BlitScaled (SurfaceRef src, OptionalRef< const SDL_Rect > srcrect, OptionalRef< const SDL_Rect > dstrect, ScaleMode scaleMode)
 Perform a scaled blit to a destination surface, which may be of a different format.
 
void BlitUncheckedScaled (SurfaceRef src, const SDL_Rect &srcrect, const SDL_Rect &dstrect, ScaleMode scaleMode)
 Perform low-level surface scaled blitting only.
 
void Stretch (SurfaceRef src, OptionalRef< SDL_Rect > srcrect, OptionalRef< SDL_Rect > dstrect, ScaleMode scaleMode)
 Perform a stretched pixel copy from one surface to another.
 
void BlitTiled (SurfaceRef src, OptionalRef< const SDL_Rect > srcrect, OptionalRef< const SDL_Rect > dstrect)
 Perform a tiled blit to a destination surface, which may be of a different format.
 
void BlitTiledWithScale (SurfaceRef src, OptionalRef< const SDL_Rect > srcrect, float scale, SDL_ScaleMode scaleMode, OptionalRef< const SDL_Rect > dstrect)
 Perform a scaled and tiled blit to a destination surface, which may be of a different format.
 
void Blit9Grid (SurfaceRef src, OptionalRef< const SDL_Rect > srcrect, int left_width, int right_width, int top_height, int bottom_height, OptionalRef< const SDL_Rect > dstrect)
 Perform a scaled blit using the 9-grid algorithm to a destination surface, which may be of a different format.
 
void Blit9GridWithScale (SurfaceRef src, OptionalRef< const SDL_Rect > srcrect, int left_width, int right_width, int top_height, int bottom_height, float scale, SDL_ScaleMode scaleMode, OptionalRef< const SDL_Rect > dstrect)
 Perform a scaled blit using the 9-grid algorithm to a destination surface, which may be of a different format.
 
Uint32 MapColor (SDL_Color color) const
 Map an RGBA quadruple to a pixel value for a surface.
 
Uint32 MapColor (Uint8 r, Uint8 g, Uint8 b) const
 Map an RGB triple to an opaque pixel value for a surface.
 
Uint32 MapColor (Uint8 r, Uint8 g, Uint8 b, Uint8 a) const
 Map an RGBA quadruple to a pixel value for a surface.
 
Color ReadPixel (const SDL_Point &p) const
 This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.
 
void ReadPixel (const SDL_Point &p, SDL_Color *c) const
 This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.
 
void ReadPixel (const SDL_Point &p, SDL_FColor *c) const
 Retrieves a single pixel from a surface.
 
void ReadPixel (const SDL_Point &p, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) const
 Retrieves a single pixel from a surface.
 
void ReadPixel (const SDL_Point &p, float *r, float *g, float *b, float *a) const
 Retrieves a single pixel from a surface.
 
void WritePixel (const SDL_Point &p, SDL_Color c)
 Writes a single pixel to a surface.
 
void WritePixel (const SDL_Point &p, SDL_FColor c)
 Writes a single pixel to a surface.
 
constexpr int GetWidth () const
 Get the width in pixels.
 
constexpr int GetHeight () const
 Get the height in pixels.
 
constexpr Point GetSize () const
 Get the size in pixels.
 
constexpr int GetPitch () const
 Get pitch in bytes.
 
constexpr PixelFormat GetFormat () const
 Get the pixel format.
 
constexpr void * GetPixels () const
 Get the pixels.
 
constexpr Resource (T resource={})
 Constructs from the underlying resource.
 
constexpr Resource (const ResourceHandle< Resource< T > > auto &resource)
 Constructs from pointer like.
 
constexpr Resource (std::nullptr_t)
 Equivalent to default ctor.
 
constexpr Resource (std::nullopt_t)
 Equivalent to default ctor.
 
- Public Member Functions inherited from SDL::Resource< SDL_Surface * >
constexpr Resource (SDL_Surface * resource={})
 Constructs from the underlying resource.
 
constexpr Resource (const ResourceHandle< Resource< SDL_Surface * > > auto &resource)
 Constructs from pointer like.
 
constexpr Resource (std::nullptr_t)
 Equivalent to default ctor.
 
constexpr Resource (std::nullopt_t)
 Equivalent to default ctor.
 
constexpr operator bool () const
 True if contains a valid resource.
 
constexpr operator value_type () const
 Converts back to underlying type.
 
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_Surface * get () const
 Return contained resource;.
 
constexpr const SDL_Surface * operator-> () const
 Access to fields.
 
constexpr SDL_Surface * operator-> ()
 Access to fields.
 

Static Public Member Functions

static void reset (SDL_Surface *resource)
 Free a surface.
 

Additional Inherited Members

- Public Types inherited from SDL::Resource< SDL_Surface * >
using value_type = SDL_Surface *
 The raw resource type.
 

Detailed Description

Pixels are arranged in memory in rows, with the top row first. Each row occupies an amount of memory given by the pitch (sometimes known as the row stride in non-SDL APIs).

Within each row, pixels are arranged from left to right until the width is reached. Each pixel occupies a number of bits appropriate for its format, with most formats representing each pixel as one or more whole bytes (in some indexed formats, instead multiple pixels are packed into each byte), and a byte order given by the format. After encoding all pixels, any remaining bytes to reach the pitch are used as padding to reach a desired alignment, and have undefined contents.

When a surface holds YUV format data, the planes are assumed to be contiguous without padding between them, e.g. a 32x32 surface in NV12 format with a pitch of 32 would consist of 32x32 bytes of Y plane followed by 32x16 bytes of UV plane.

When a surface holds MJPG format data, pixels points at the compressed JPEG image and pitch is the length of that data.

Since
This struct is available since SDL 3.2.0.
Category:
Resource
See also
Surface.Create
Surface.CreateFrom
Surface.Destroy
Surface

Member Function Documentation

◆ AddAlternateImage()

void SDL::SurfaceRef::AddAlternateImage ( SurfaceRef  image)
inline

This function adds an alternate version of this surface, usually used for content with high DPI representations like cursors or icons. The size, format, and content do not need to match the original surface, and these alternate versions will not be updated when the original surface changes.

This function adds a reference to the alternate version, so you should call Surface.Destroy() on the image after this call.

Parameters
imagean alternate SurfaceRef to associate with this surface.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.RemoveAlternateImages
SurfaceRef.GetImages
SurfaceRef.HasAlternateImages

◆ Blit() [1/2]

void SDL::SurfaceRef::Blit ( SurfaceRef  src,
OptionalRef< const SDL_Rect >  srcrect,
const SDL_Point &  dstpos 
)
inline

If either srcrect or dstrect are nullptr, the entire surface (src or dst) is copied while ensuring clipping to dst->clip_rect.

The blit function should not be called on a locked surface.

The blit semantics for surfaces with and without blending and colorkey are defined as follows:

RGBA->RGB:
Source surface blend mode set to BLENDMODE_BLEND:
alpha-blend (using the source alpha-channel and per-surface alpha)
SDL_SRCCOLORKEY ignored.
Source surface blend mode set to BLENDMODE_NONE:
copy RGB.
if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
RGB values of the source color key, ignoring alpha in the
comparison.
RGB->RGBA:
Source surface blend mode set to BLENDMODE_BLEND:
alpha-blend (using the source per-surface alpha)
Source surface blend mode set to BLENDMODE_NONE:
copy RGB, set destination alpha to source per-surface alpha value.
both:
if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
source color key.
RGBA->RGBA:
Source surface blend mode set to BLENDMODE_BLEND:
alpha-blend (using the source alpha-channel and per-surface alpha)
SDL_SRCCOLORKEY ignored.
Source surface blend mode set to BLENDMODE_NONE:
copy all of RGBA to the destination.
if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
RGB values of the source color key, ignoring alpha in the
comparison.
RGB->RGB:
Source surface blend mode set to BLENDMODE_BLEND:
alpha-blend (using the source per-surface alpha)
Source surface blend mode set to BLENDMODE_NONE:
copy RGB.
both:
if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
source color key.
constexpr BlendMode BLENDMODE_NONE
no blending: dstRGBA = srcRGBA
Definition SDL3pp_blendmode.h:37
constexpr BlendMode BLENDMODE_BLEND
alpha blending: dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)), dstA = srcA + (dstA * (1-srcA))
Definition SDL3pp_blendmode.h:44
Parameters
srcthe SDL_Surface structure to be copied from.
srcrectthe SDL_Rect structure representing the rectangle to be copied, or NULL to copy the entire surface.
dstposthe SDL_Point structure representing the x and y position in the destination surface, or NULL for (0,0). The width and height are ignored, and are copied from srcrect. If you want a specific width and height, you should use SurfaceRef.BlitScaled().
Exceptions
Erroron failure.
Thread safety:
Only one thread should be using the src and dst surfaces at any given time.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.BlitScaled

◆ Blit() [2/2]

void SDL::SurfaceRef::Blit ( SurfaceRef  src,
OptionalRef< const SDL_Rect >  srcrect,
OptionalRef< const SDL_Rect >  dstrect 
)
inline

If either srcrect or dstrect are nullptr, the entire surface (src or dst) is copied while ensuring clipping to dst->clip_rect.

The blit function should not be called on a locked surface.

The blit semantics for surfaces with and without blending and colorkey are defined as follows:

RGBA->RGB:
Source surface blend mode set to BLENDMODE_BLEND:
alpha-blend (using the source alpha-channel and per-surface alpha)
SDL_SRCCOLORKEY ignored.
Source surface blend mode set to BLENDMODE_NONE:
copy RGB.
if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
RGB values of the source color key, ignoring alpha in the
comparison.
RGB->RGBA:
Source surface blend mode set to BLENDMODE_BLEND:
alpha-blend (using the source per-surface alpha)
Source surface blend mode set to BLENDMODE_NONE:
copy RGB, set destination alpha to source per-surface alpha value.
both:
if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
source color key.
RGBA->RGBA:
Source surface blend mode set to BLENDMODE_BLEND:
alpha-blend (using the source alpha-channel and per-surface alpha)
SDL_SRCCOLORKEY ignored.
Source surface blend mode set to BLENDMODE_NONE:
copy all of RGBA to the destination.
if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
RGB values of the source color key, ignoring alpha in the
comparison.
RGB->RGB:
Source surface blend mode set to BLENDMODE_BLEND:
alpha-blend (using the source per-surface alpha)
Source surface blend mode set to BLENDMODE_NONE:
copy RGB.
both:
if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
source color key.
Parameters
srcthe SDL_Surface structure to be copied from.
srcrectthe SDL_Rect structure representing the rectangle to be copied, or std::nullopt to copy the entire surface.
dstrectthe SDL_Rect structure representing the x and y position in the destination surface, or std::nullopt for (0,0). The width and height are ignored, and are copied from srcrect. If you want a specific width and height, you should use SurfaceRef.BlitScaled().
Exceptions
Erroron failure.
Thread safety:
Only one thread should be using the src and dst surfaces at any given time.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.BlitScaled

◆ Blit9Grid()

void SDL::SurfaceRef::Blit9Grid ( SurfaceRef  src,
OptionalRef< const SDL_Rect >  srcrect,
int  left_width,
int  right_width,
int  top_height,
int  bottom_height,
OptionalRef< const SDL_Rect >  dstrect 
)
inline

The pixels in the source surface are split into a 3x3 grid, using the different corner sizes for each corner, and the sides and center making up the remaining pixels. The corners are then scaled using scale and fit into the corners of the destination rectangle. The sides and center are then stretched into place to cover the remaining destination rectangle.

Parameters
srcthe SDL_Surface structure to be copied from.
srcrectthe Rect structure representing the rectangle to be used for the 9-grid, or nullptr to use the entire surface.
left_widththe width, in pixels, of the left corners in srcrect.
right_widththe width, in pixels, of the right corners in srcrect.
top_heightthe height, in pixels, of the top corners in srcrect.
bottom_heightthe height, in pixels, of the bottom corners in srcrect.
dstrectthe Rect structure representing the target rectangle in the destination surface, or nullptr to fill the entire surface.
Exceptions
Erroron failure.
Thread safety:
Only one thread should be using the src and dst surfaces at any given time.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.Blit

◆ Blit9GridWithScale()

void SDL::SurfaceRef::Blit9GridWithScale ( SurfaceRef  src,
OptionalRef< const SDL_Rect >  srcrect,
int  left_width,
int  right_width,
int  top_height,
int  bottom_height,
float  scale,
SDL_ScaleMode  scaleMode,
OptionalRef< const SDL_Rect >  dstrect 
)
inline

The pixels in the source surface are split into a 3x3 grid, using the different corner sizes for each corner, and the sides and center making up the remaining pixels. The corners are then scaled using scale and fit into the corners of the destination rectangle. The sides and center are then stretched into place to cover the remaining destination rectangle.

Parameters
srcthe SDL_Surface structure to be copied from.
srcrectthe Rect structure representing the rectangle to be used for the 9-grid, or nullptr to use the entire surface.
left_widththe width, in pixels, of the left corners in srcrect.
right_widththe width, in pixels, of the right corners in srcrect.
top_heightthe height, in pixels, of the top corners in srcrect.
bottom_heightthe height, in pixels, of the bottom corners in srcrect.
scalethe scale used to transform the corner of srcrect into the corner of dstrect, or 0.0f for an unscaled blit.
scaleModescale algorithm to be used.
dstrectthe Rect structure representing the target rectangle in the destination surface, or nullptr to fill the entire surface.
Exceptions
Erroron failure.
Thread safety:
Only one thread should be using the src and dst surfaces at any given time.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.Blit

◆ BlitScaled()

void SDL::SurfaceRef::BlitScaled ( SurfaceRef  src,
OptionalRef< const SDL_Rect >  srcrect,
OptionalRef< const SDL_Rect >  dstrect,
ScaleMode  scaleMode 
)
inline
Parameters
srcthe Surface structure to be copied from.
srcrectthe Rect structure representing the rectangle to be copied, or nullptr to copy the entire surface.
dstrectthe Rect structure representing the target rectangle in the destination surface, or nullptr to fill the entire destination surface.
scaleModethe ScaleMode to be used.
Exceptions
Erroron failure.
Thread safety:
Only one thread should be using the src and dst surfaces at any given time.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.Blit

◆ BlitTiled()

void SDL::SurfaceRef::BlitTiled ( SurfaceRef  src,
OptionalRef< const SDL_Rect >  srcrect,
OptionalRef< const SDL_Rect >  dstrect 
)
inline

The pixels in srcrect will be repeated as many times as needed to completely fill dstrect.

Parameters
srcthe SDL_Surface structure to be copied from.
srcrectthe Rect structure representing the rectangle to be copied, or nullptr to copy the entire surface.
dstrectthe Rect structure representing the target rectangle in the destination surface, or nullptr to fill the entire surface.
Exceptions
Erroron failure.
Thread safety:
Only one thread should be using the src and dst surfaces at any given time.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.Blit

◆ BlitTiledWithScale()

void SDL::SurfaceRef::BlitTiledWithScale ( SurfaceRef  src,
OptionalRef< const SDL_Rect >  srcrect,
float  scale,
SDL_ScaleMode  scaleMode,
OptionalRef< const SDL_Rect >  dstrect 
)
inline

The pixels in srcrect will be scaled and repeated as many times as needed to completely fill dstrect.

Parameters
srcthe SDL_Surface structure to be copied from.
srcrectthe Rect structure representing the rectangle to be copied, or nullptr to copy the entire surface.
scalethe scale used to transform srcrect into the destination rectangle, e.g. a 32x32 texture with a scale of 2 would fill 64x64 tiles.
scaleModescale algorithm to be used.
dstrectthe Rect structure representing the target rectangle in the destination surface, or nullptr to fill the entire surface.
Exceptions
Erroron failure.
Thread safety:
Only one thread should be using the src and dst surfaces at any given time.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.Blit

◆ BlitUnchecked()

void SDL::SurfaceRef::BlitUnchecked ( SurfaceRef  src,
const SDL_Rect &  srcrect,
const SDL_Rect &  dstrect 
)
inline

This is a semi-private blit function and it performs low-level surface blitting, assuming the input rectangles have already been clipped.

Parameters
srcthe SDL_Surface structure to be copied from.
srcrectthe SDL_Rect structure representing the rectangle to be copied, may not be nullptr.
dstrectthe SDL_Rect structure representing the target rectangle in the destination surface, may not be nullptr.
Exceptions
Erroron failure.
Thread safety:
Only one thread should be using the src and dst surfaces at any given time.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.Blit

◆ BlitUncheckedScaled()

void SDL::SurfaceRef::BlitUncheckedScaled ( SurfaceRef  src,
const SDL_Rect &  srcrect,
const SDL_Rect &  dstrect,
ScaleMode  scaleMode 
)
inline

This is a semi-private function and it performs low-level surface blitting, assuming the input rectangles have already been clipped.

Parameters
srcthe Surface structure to be copied from.
srcrectthe Rect structure representing the rectangle to be copied, may not be nullptr.
dstrectthe SDL_Rect structure representing the target rectangle in the destination surface, may not be nullptr.
scaleModethe ScaleMode to be used.
Exceptions
Erroron failure.
Thread safety:
Only one thread should be using the src and dst surfaces at any given time.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.BlitScaled

◆ Clear()

void SDL::SurfaceRef::Clear ( SDL_FColor  color)
inline

This function handles all surface formats, and ignores any clip rectangle.

If the surface is YUV, the color is assumed to be in the sRGB colorspace, otherwise the color is assumed to be in the colorspace of the surface.

Parameters
colorthe color of the pixel, normally in the range 0-1.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.

◆ ClearColorKey()

void SDL::SurfaceRef::ClearColorKey ( )
inline

The color key defines a pixel value that will be treated as transparent in a blit. For example, one can use this to specify that cyan pixels should be considered transparent, and therefore not rendered.

Exceptions
Erroron failure.

◆ CreatePalette()

PaletteRef SDL::SurfaceRef::CreatePalette ( )
inline

This function creates a palette compatible with the provided surface. The palette is then returned for you to modify, and the surface will automatically use the new palette in future operations. You do not need to destroy the returned palette, it will be freed when the reference count reaches 0, usually when the surface is destroyed.

Bitmap surfaces (with format PIXELFORMAT_INDEX1LSB or PIXELFORMAT_INDEX1MSB) will have the palette initialized with 0 as white and 1 as black. Other surfaces will get a palette initialized with white in every entry.

If this function is called for a surface that already has a palette, a new palette will be created to replace it.

Returns
a new PaletteRef structure on success.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
PaletteRef.SetColors

◆ Fill() [1/2]

void SDL::SurfaceRef::Fill ( SDL_Color  color)
inline

If there is a clip rectangle set on the destination (set via SurfaceRef.SetClipRect()), then this function will fill based on the intersection of the clip rectangle and rect.

Parameters
colorthe color to fill with.
Exceptions
Erroron failure.

◆ Fill() [2/2]

void SDL::SurfaceRef::Fill ( Uint32  color)
inline

color should be a pixel of the format used by the surface, and can be generated by MapRGB() or MapRGBA(). If the color value contains an alpha component then the destination is simply filled with that alpha information, no blending takes place.

If there is a clip rectangle set on the destination (set via SurfaceRef.SetClipRect()), then this function will fill based on the intersection of the clip rectangle and rect.

Parameters
colorthe color to fill with.
Exceptions
Erroron failure.

◆ FillRect() [1/2]

void SDL::SurfaceRef::FillRect ( OptionalRef< const SDL_Rect >  rect,
SDL_Color  color 
)
inline

If there is a clip rectangle set on the destination (set via SurfaceRef.SetClipRect()), then this function will fill based on the intersection of the clip rectangle and rect.

Parameters
rectthe SDL_Rect structure representing the rectangle to fill.
colorthe color to fill with.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.FillRects

◆ FillRect() [2/2]

void SDL::SurfaceRef::FillRect ( OptionalRef< const SDL_Rect >  rect,
Uint32  color 
)
inline

color should be a pixel of the format used by the surface, and can be generated by MapRGB() or MapRGBA(). If the color value contains an alpha component then the destination is simply filled with that alpha information, no blending takes place.

If there is a clip rectangle set on the destination (set via SurfaceRef.SetClipRect()), then this function will fill based on the intersection of the clip rectangle and rect.

Parameters
rectthe SDL_Rect structure representing the rectangle to fill.
colorthe color to fill with.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.FillRects

◆ FillRects() [1/2]

void SDL::SurfaceRef::FillRects ( SpanRef< const SDL_Rect >  rects,
SDL_Color  color 
)
inline

If there is a clip rectangle set on the destination (set via SurfaceRef.SetClipRect()), then this function will fill based on the intersection of the clip rectangle and rect.

Parameters
rectsan array of SDL_Rects representing the rectangles to fill.
colorthe color to fill with.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
FillRect()

◆ FillRects() [2/2]

void SDL::SurfaceRef::FillRects ( SpanRef< const SDL_Rect >  rects,
Uint32  color 
)
inline

color should be a pixel of the format used by the surface, and can be generated by MapRGB() or MapRGBA(). If the color value contains an alpha component then the destination is simply filled with that alpha information, no blending takes place.

If there is a clip rectangle set on the destination (set via SurfaceRef.SetClipRect()), then this function will fill based on the intersection of the clip rectangle and rect.

Parameters
rectsan array of SDL_Rects representing the rectangles to fill.
colorthe color to fill with.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.FillRect

◆ Flip()

void SDL::SurfaceRef::Flip ( FlipMode  flip)
inline
Parameters
flipthe direction to flip.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.

◆ GetAlphaMod()

Uint8 SDL::SurfaceRef::GetAlphaMod ( ) const
inline
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
SurfaceRef.GetColorMod
SurfaceRef.SetAlphaMod

◆ GetBlendMode()

BlendMode SDL::SurfaceRef::GetBlendMode ( ) const
inline
Returns
the blendMode on success or BLENDMODE_INVALID on failure; call GetError() for more information.

◆ GetClipRect()

Rect SDL::SurfaceRef::GetClipRect ( ) const
inline

When surface is the destination of a blit, only the area within the clip rectangle is drawn into.

Returns
the Rect structure filled in with the clipping rectangle for the surface on success.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.SetClipRect

◆ GetColorKey() [1/3]

Color SDL::SurfaceRef::GetColorKey ( ) const
inline

The color key is a pixel of the format used by the surface, as generated by MapRGB().

If the surface doesn't have color key enabled this function returns std::nullopt.

Returns
the color key as Color or std::nullopt if it does not have one.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.
See also
SetColorKey()
HasColorKey()

◆ GetColorKey() [2/3]

void SDL::SurfaceRef::GetColorKey ( Color key) const
inline

The color key is a pixel of the format used by the surface, as generated by SDL_MapRGB().

If the surface doesn't have color key enabled this function returns false.

Parameters
keya pointer filled in with the transparent pixel.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
SetColorKey()
HasColorKey()

◆ GetColorKey() [3/3]

void SDL::SurfaceRef::GetColorKey ( Uint32 *  key) const
inline

The color key is a pixel of the format used by the surface, as generated by MapRGB().

If the surface doesn't have color key enabled this function returns false.

Parameters
keya pointer filled in with the transparent pixel.
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
SurfaceRef.SetColorKey
SurfaceRef.HasColorKey

◆ GetColorMod()

void SDL::SurfaceRef::GetColorMod ( Uint8 *  r,
Uint8 *  g,
Uint8 *  b 
) const
inline
Parameters
ra pointer filled in with the current red color value.
ga pointer filled in with the current green color value.
ba pointer filled in with the current blue color value.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.GetAlphaMod
SurfaceRef.SetColorMod

◆ GetColorspace()

Colorspace SDL::SurfaceRef::GetColorspace ( ) const
inline

The colorspace defaults to COLORSPACE_SRGB_LINEAR for floating point formats, COLORSPACE_HDR10 for 10-bit formats, COLORSPACE_SRGB for other RGB surfaces and COLORSPACE_BT709_FULL for YUV textures.

Returns
the colorspace used by the surface, or COLORSPACE_UNKNOWN if the surface is nullptr.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.SetColorspace

◆ GetImages()

OwnArray< SurfaceRef > SDL::SurfaceRef::GetImages ( ) const
inline

This returns all versions of a surface, with the surface being queried as the first element in the returned array.

Returns
a NULL terminated array of SurfaceRef pointers or nullptr on failure; call GetError() for more information.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.AddAlternateImage
SurfaceRef.RemoveAlternateImages
SurfaceRef.HasAlternateImages

◆ GetMod()

Color SDL::SurfaceRef::GetMod ( ) const
inline
Returns
a Color containing RGBA value on success or std::nullopt on failure; call GetError() for more information.

◆ GetPalette()

PaletteRef SDL::SurfaceRef::GetPalette ( ) const
inline
Returns
a pointer to the palette used by the surface, or nullptr if there is no palette used.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.SetPalette

◆ GetProperties()

PropertiesRef SDL::SurfaceRef::GetProperties ( ) const
inline

The following properties are understood by SDL:

  • prop::Surface.SDR_WHITE_POINT_FLOAT: for HDR10 and floating point surfaces, this defines the value of 100% diffuse white, with higher values being displayed in the High Dynamic Range headroom. This defaults to 203 for HDR10 surfaces and 1.0 for floating point surfaces.
  • prop::Surface.HDR_HEADROOM_FLOAT: for HDR10 and floating point surfaces, this defines the maximum dynamic range used by the content, in terms of the SDR white point. This defaults to 0.0, which disables tone mapping.
  • prop::Surface.TONEMAP_OPERATOR_STRING: the tone mapping operator used when compressing from a surface with high dynamic range to another with lower dynamic range. Currently this supports "chrome", which uses the same tone mapping that Chrome uses for HDR content, the form "*=N", where N is a floating point scale factor applied in linear space, and "none", which disables tone mapping. This defaults to "chrome".
  • prop::Surface.HOTSPOT_X_NUMBER: the hotspot pixel offset from the left edge of the image, if this surface is being used as a cursor.
  • prop::Surface.HOTSPOT_Y_NUMBER: the hotspot pixel offset from the top edge of the image, if this surface is being used as a cursor.
Returns
a valid property ID 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.

◆ HasAlternateImages()

bool SDL::SurfaceRef::HasAlternateImages ( ) const
inline
Returns
true if alternate versions are available or false otherwise.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.AddAlternateImage
SurfaceRef.RemoveAlternateImages
SurfaceRef.GetImages

◆ HasColorKey()

bool SDL::SurfaceRef::HasColorKey ( ) const
inline
Returns
true if the surface has a color key, false otherwise.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.SetColorKey
SurfaceRef.GetColorKey

◆ HasRLE()

bool SDL::SurfaceRef::HasRLE ( ) const
inline
Returns
true if the surface is RLE enabled, false otherwise.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.SetRLE

◆ MapColor() [1/3]

Uint32 SDL::SurfaceRef::MapColor ( SDL_Color  color) const
inline

This function maps the RGBA color value to the specified pixel format and returns the pixel value best approximating the given RGBA color value for the given pixel format.

If the surface pixel format has no alpha component the alpha value will be ignored (as it will be in formats with a palette).

If the surface has a palette, the index of the closest matching color in the palette will be returned.

If the pixel format bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored (e.g., with a 16-bpp format the return value can be assigned to a Uint16, and similarly a Uint8 for an 8-bpp format).

Parameters
colorthe color components
Returns
a pixel value.

◆ MapColor() [2/3]

Uint32 SDL::SurfaceRef::MapColor ( Uint8  r,
Uint8  g,
Uint8  b 
) const
inline

This function maps the RGB color value to the specified pixel format and returns the pixel value best approximating the given RGB color value for the given pixel format.

If the surface has a palette, the index of the closest matching color in the palette will be returned.

If the surface pixel format has an alpha component it will be returned as all 1 bits (fully opaque).

If the pixel format bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored (e.g., with a 16-bpp format the return value can be assigned to a Uint16, and similarly a Uint8 for an 8-bpp format).

Parameters
rthe red component of the pixel in the range 0-255.
gthe green component of the pixel in the range 0-255.
bthe blue component of the pixel in the range 0-255.
Returns
a pixel value.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.MapColor

◆ MapColor() [3/3]

Uint32 SDL::SurfaceRef::MapColor ( Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a 
) const
inline

This function maps the RGBA color value to the specified pixel format and returns the pixel value best approximating the given RGBA color value for the given pixel format.

If the surface pixel format has no alpha component the alpha value will be ignored (as it will be in formats with a palette).

If the surface has a palette, the index of the closest matching color in the palette will be returned.

If the pixel format bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored (e.g., with a 16-bpp format the return value can be assigned to a Uint16, and similarly a Uint8 for an 8-bpp format).

Parameters
rthe red component of the pixel in the range 0-255.
gthe green component of the pixel in the range 0-255.
bthe blue component of the pixel in the range 0-255.
athe alpha component of the pixel in the range 0-255.
Returns
a pixel value.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.MapColor

◆ MustLock()

constexpr bool SDL::SurfaceRef::MustLock ( ) const
inlineconstexpr
Since
This macro is available since SDL 3.2.0.

◆ PremultiplyAlpha()

void SDL::SurfaceRef::PremultiplyAlpha ( bool  linear)
inline

This is safe to use with src == dst, but not for other overlapping areas.

Parameters
lineartrue to convert from sRGB to linear space for the alpha multiplication, false to do multiplication in sRGB space.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.

◆ ReadPixel() [1/5]

Color SDL::SurfaceRef::ReadPixel ( const SDL_Point &  p) const
inline

Like SDL_GetRGBA, this uses the entire 0..255 range when converting color components from pixel formats with less than 8 bits per RGB component.

Parameters
pthe coordinates, 0 <= x < width and 0 <= y < height.
Returns
color on success.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.

◆ ReadPixel() [2/5]

void SDL::SurfaceRef::ReadPixel ( const SDL_Point &  p,
float *  r,
float *  g,
float *  b,
float *  a 
) const
inline

This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.

Parameters
pthe coordinates, 0 <= x < width and 0 <= y < height.
ra pointer filled in with the red channel, normally in the range 0-1, or nullptr to ignore this channel.
ga pointer filled in with the green channel, normally in the range 0-1, or nullptr to ignore this channel.
ba pointer filled in with the blue channel, normally in the range 0-1, or nullptr to ignore this channel.
aa pointer filled in with the alpha channel, normally in the range 0-1, or nullptr to ignore this channel.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.

◆ ReadPixel() [3/5]

void SDL::SurfaceRef::ReadPixel ( const SDL_Point &  p,
SDL_Color *  c 
) const
inline

Like SDL_GetRGBA, this uses the entire 0..255 range when converting color components from pixel formats with less than 8 bits per RGB component.

Parameters
pthe coordinates, 0 <= x < width and 0 <= y < height.
ca color pointer to be filled with the color information. Must not be nullptr.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.

◆ ReadPixel() [4/5]

void SDL::SurfaceRef::ReadPixel ( const SDL_Point &  p,
SDL_FColor *  c 
) const
inline

This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.

Parameters
pthe coordinates, 0 <= x < width and 0 <= y < height.
ca color pointer to be filled with the color information. Must not be nullptr.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.

◆ ReadPixel() [5/5]

void SDL::SurfaceRef::ReadPixel ( const SDL_Point &  p,
Uint8 *  r,
Uint8 *  g,
Uint8 *  b,
Uint8 *  a 
) const
inline

This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.

Like GetRGBA, this uses the entire 0..255 range when converting color components from pixel formats with less than 8 bits per RGB component.

Parameters
pthe coordinates, 0 <= x < width and 0 <= y < height.
ra pointer filled in with the red channel, 0-255, or nullptr to ignore this channel.
ga pointer filled in with the green channel, 0-255, or nullptr to ignore this channel.
ba pointer filled in with the blue channel, 0-255, or nullptr to ignore this channel.
aa pointer filled in with the alpha channel, 0-255, or nullptr to ignore this channel.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.

◆ RemoveAlternateImages()

void SDL::SurfaceRef::RemoveAlternateImages ( )
inline

This function removes a reference from all the alternative versions, destroying them if this is the last reference to them.

Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.AddAlternateImage
SurfaceRef.GetImages
SurfaceRef.HasAlternateImages

◆ reset()

static void SDL::SurfaceRef::reset ( SDL_Surface *  resource)
inlinestatic

It is safe to pass nullptr to this function.

Parameters
resourcethe Surface to free.
Thread safety:
No other thread should be using the surface when it is freed.
Since
This function is available since SDL 3.2.0.
See also
Surface.Create
Surface.CreateFrom

◆ ResetClipRect()

void SDL::SurfaceRef::ResetClipRect ( )
inline
See also
SetClipRect()

◆ SetAlphaMod()

void SDL::SurfaceRef::SetAlphaMod ( Uint8  alpha)
inline

When this surface is blitted, during the blit operation the source alpha value is modulated by this alpha value according to the following formula:

srcA = srcA * (alpha / 255)

Parameters
alphathe alpha value multiplied into blit operations.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.GetAlphaMod
SurfaceRef.SetColorMod

◆ SetBlendMode()

void SDL::SurfaceRef::SetBlendMode ( BlendMode  blendMode)
inline

To copy a surface to another surface (or texture) without blending with the existing data, the blendmode of the SOURCE surface should be set to BLENDMODE_NONE.

Parameters
blendModethe BlendMode to use for blit blending.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.GetBlendMode

◆ SetClipRect()

bool SDL::SurfaceRef::SetClipRect ( OptionalRef< const SDL_Rect >  rect)
inline

When surface is the destination of a blit, only the area within the clip rectangle is drawn into.

Note that blits are automatically clipped to the edges of the source and destination surfaces.

Parameters
rectthe Rect structure representing the clipping rectangle, or std::nullopt to disable clipping.
Returns
true if the rectangle intersects the surface, otherwise false and blits will be completely clipped.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.ResetClipRect()
SurfaceRef.GetClipRect

◆ SetColorKey() [1/2]

void SDL::SurfaceRef::SetColorKey ( Color  key)
inline

The color key defines a pixel value that will be treated as transparent in a blit. For example, one can use this to specify that cyan pixels should be considered transparent, and therefore not rendered.

It is a pixel of the format used by the surface, as generated by SDL_MapRGB().

Parameters
keythe transparent pixel color.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.
See also
GetColorKey()
SetRLE()
HasColorKey()

◆ SetColorKey() [2/2]

void SDL::SurfaceRef::SetColorKey ( std::optional< Uint32 >  key)
inline

The color key defines a pixel value that will be treated as transparent in a blit. For example, one can use this to specify that cyan pixels should be considered transparent, and therefore not rendered.

It is a pixel of the format used by the surface, as generated by MapRGB().

Parameters
keythe transparent pixel or std::nullopt to disable it.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.GetColorKey
SurfaceRef.SetRLE
SurfaceRef.HasColorKey

◆ SetColorMod()

void SDL::SurfaceRef::SetColorMod ( Uint8  r,
Uint8  g,
Uint8  b 
)
inline

When this surface is blitted, during the blit operation each source color channel is modulated by the appropriate color value according to the following formula:

srcC = srcC * (color / 255)

Parameters
rthe red color value multiplied into blit operations.
gthe green color value multiplied into blit operations.
bthe blue color value multiplied into blit operations.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.GetColorMod
SurfaceRef.SetAlphaMod

◆ SetColorspace()

void SDL::SurfaceRef::SetColorspace ( Colorspace  colorspace)
inline

Setting the colorspace doesn't change the pixels, only how they are interpreted in color operations.

Parameters
colorspacea Colorspace value describing the surface colorspace.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.GetColorspace

◆ SetMod()

void SDL::SurfaceRef::SetMod ( Color  color)
inline

When this surface is blitted, during the blit operation each source color channel is modulated by the appropriate color value according to the following formula:

srcC = srcC * (color / 255) srcA = srcA * (alpha / 255)

Parameters
colorthe color to be multiplied in blit operations
Exceptions
Erroron failure.

◆ SetPalette()

void SDL::SurfaceRef::SetPalette ( PaletteRef  palette)
inline

A single palette can be shared with many surfaces.

Parameters
palettethe PaletteRef structure to use.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
Palette.Create
SurfaceRef.GetPalette

◆ SetRLE()

void SDL::SurfaceRef::SetRLE ( bool  enabled)
inline

If RLE is enabled, color key and alpha blending blits are much faster, but the surface must be locked before directly accessing the pixels.

Parameters
enabledtrue to enable RLE acceleration, false to disable it.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.Blit
SurfaceRef.Lock
SurfaceLock.Unlock

◆ Stretch()

void SDL::SurfaceRef::Stretch ( SurfaceRef  src,
OptionalRef< SDL_Rect >  srcrect,
OptionalRef< SDL_Rect >  dstrect,
ScaleMode  scaleMode 
)
inline
Parameters
srcthe Surface structure to be copied from.
srcrectthe Rect structure representing the rectangle to be copied.
dstrectthe Rect structure representing the target rectangle in the destination surface, may not be nullptr.
scaleModethe ScaleMode to be used.
Exceptions
Erroron failure.
Thread safety:
Only one thread should be using the src and dst surfaces at any given time.
Since
This function is available since SDL 3.2.4.
See also
SurfaceRef.BlitScaled

◆ WritePixel() [1/2]

void SDL::SurfaceRef::WritePixel ( const SDL_Point &  p,
SDL_Color  c 
)
inline

This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.

Like MapRGBA, this uses the entire 0..255 range when converting color components from pixel formats with less than 8 bits per RGB component.

Parameters
pthe coordinates, 0 <= x < width and 0 <= y < height.
cthe color values, 0-255.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.

◆ WritePixel() [2/2]

void SDL::SurfaceRef::WritePixel ( const SDL_Point &  p,
SDL_FColor  c 
)
inline

This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.

Parameters
pthe coordinates, 0 <= x < width and 0 <= y < height.
cthe color values, normally in the range 0-1.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.

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