Rose
Classes | Typedefs | Functions
rose::sdl Namespace Reference

Class and functions that are used to access the SDL2 api. More...

Classes

class  ClipRectangleGuard
 Store the current clip rectangle replacing it with a new clip rectangle. More...
 
class  DrawColorGuard
 Store the current draw color replacing it with a new draw color. More...
 
class  DrawColorGuardException
 Thrown by DrawColorGuard on errors. More...
 
class  GradientScale
 A type of texture that if stretch across a destination Rectangle in rendering, will create a gradient coloring. More...
 
class  GradientTexture
 A gradient rendering kernel. More...
 
class  PixelFormat
 An encapsulation of an SDL_PixelFormat. More...
 
class  PixelFormatDestroy
 A functor to destroy an SDL_PixelFormat in a std::unique_ptr (rose::sdl::PixelFormat) More...
 
class  Renderer
 Written as a workaround for an issue in the SDL2 Library. More...
 
struct  RenderFlip
 A Widget manipulator to indicate if and how rendering a texture should be flipped. More...
 
class  RenderTargetGuard
 Store the current render target replacing it with a new render target. More...
 
class  RenderTargetGuardException
 Thrown by RenderTargetGuard on errors. More...
 
class  Texture
 An encapsulation of the SDL_Texture structure. More...
 
class  TextureData
 A Texture with associated meta data. More...
 
class  TextureDestroy
 A functor to destroy an SDL_Texture in a std::unique_ptr (rose::sdl::Texture) More...
 
class  WindowDestroy
 A functor to destroy an SDL_Window in a std::unique_ptr (rose::sdl::Window). More...
 

Typedefs

using Window = std::unique_ptr< SDL_Window, WindowDestroy >
 An SDL_Window unique pointer.
 

Functions

uint32_t mapRGBA (SDL_PixelFormatEnum pixelFormat, const color::RGBA &color)
 Map a color::RGBA to a uint32_t. More...
 
uint32_t mapRGBA (PixelFormat &pixelFormat, const color::RGBA &color)
 Map a color::RGBA to a uint32_t. More...
 
uint32_t mapRGBA (SDL_PixelFormat *format, const color::RGBA &color)
 Map a color::RGBA to a uint32_t. More...
 
color::RGBA getRGBA (PixelFormat &pixelFormat, uint32_t pixel)
 
color::RGBA getRGBA (SDL_PixelFormat *format, uint32_t pixel)
 
TextureData CreateTextureFromFile (Renderer &renderer, std::filesystem::path &filePath)
 Create texture data from a file system path. More...
 
template<typename String >
TextureData CreateTextureFromFile (Renderer &renderer, std::filesystem::path &dirPath, String fileName)
 Create texture data from a file system path. More...
 
template<typename Color >
sdl::Texture renderTextureBlended (sdl::Renderer &renderer, FontPointer &font, const std::string &text, const Color &color)
 Render text to a Texture. More...
 
template<typename Color >
sdl::Texture renderTextureBlendedUTF8 (sdl::Renderer &renderer, FontPointer &font, const std::string &text, const Color &color)
 Render text to a Texture. More...
 

Detailed Description

Class and functions that are used to access the SDL2 api.

Function Documentation

◆ CreateTextureFromFile() [1/2]

TextureData rose::sdl::CreateTextureFromFile ( Renderer renderer,
std::filesystem::path &  filePath 
)

Create texture data from a file system path.

Parameters
rendererThe Renderer to use.
filePathThe std::filesystem::path pointing to the file to load.
Returns
The TextureData object

◆ CreateTextureFromFile() [2/2]

template<typename String >
TextureData rose::sdl::CreateTextureFromFile ( Renderer renderer,
std::filesystem::path &  dirPath,
String  fileName 
)

Create texture data from a file system path.

Template Parameters
StringA type of a string like value.
Parameters
rendererThe Renderer to use.
dirPathThe std::filesystem::path pointing to the director to load the file from.
fileNameThe file name in a string like value.
Returns

◆ mapRGBA() [1/3]

uint32_t rose::sdl::mapRGBA ( SDL_PixelFormatEnum  pixelFormat,
const color::RGBA color 
)

Map a color::RGBA to a uint32_t.

This function will allocate a PixelFormat, call mapRGBA(PixelFormat,color::RGBA), then destroy a PixelFormat.

Parameters
pixelFormatThe SDL PixelFormat defined constant.
colorThe Colour to map.
Returns
The mapped Colour.

◆ mapRGBA() [2/3]

uint32_t rose::sdl::mapRGBA ( PixelFormat pixelFormat,
const color::RGBA color 
)

Map a color::RGBA to a uint32_t.

Parameters
pixelFormatA reference to a PixelFormat.
colorThe color to map.
Returns
The mapped color.

◆ mapRGBA() [3/3]

uint32_t rose::sdl::mapRGBA ( SDL_PixelFormat *  format,
const color::RGBA color 
)

Map a color::RGBA to a uint32_t.

Parameters
formatA pointer to an SDL_PixelFormat (from a Surface object for example).
colorThe color::RGBA to map.
Returns
The color::RGBA mapped to a uint32_t

◆ renderTextureBlended()

template<typename Color >
sdl::Texture rose::sdl::renderTextureBlended ( sdl::Renderer renderer,
FontPointer font,
const std::string &  text,
const Color &  color 
)
inline

Render text to a Texture.

Template Parameters
ColorThe type of the color argument.
Parameters
rendererThe renderer to use.
fontThe font to use.
textThe text to render
colorThe foreground Color.
Returns
The Texture.

◆ renderTextureBlendedUTF8()

template<typename Color >
sdl::Texture rose::sdl::renderTextureBlendedUTF8 ( sdl::Renderer renderer,
FontPointer font,
const std::string &  text,
const Color &  color 
)
inline

Render text to a Texture.

Template Parameters
ColorThe type of the color argument.
Parameters
rendererThe renderer to use.
fontThe font to use.
textThe text to render
colorThe foreground Color.
Returns
The Texture.