coastline 0.0.4
Loading...
Searching...
No Matches
coastline::RenderTexture Class Reference

A texture of the renderer for flat pictures and text. More...

#include <scenerenderer.h>

Public Member Functions

 ~RenderTexture ()
 Release the texture, sampler, and upload storage before GPU device destruction.
 RenderTexture (const RenderTexture &)=delete
 Prevent copying texture allocation and upload resources.
RenderTexture & operator= (const RenderTexture &)=delete
 Prevent assignment of texture allocation and upload resources.
int Width () const
int Height () const
bool Update (std::span< const std::uint8_t > rgba)
 Replace the texels in place, through an upload the texture keeps.

Static Public Member Functions

static std::unique_ptr< RenderTexture > Load (SceneRenderer &renderer, const std::filesystem::path &path, bool linear, bool repeat=false)
 Read a PNG image.
static std::unique_ptr< RenderTexture > FromTexels (SceneRenderer &renderer, int width, int height, std::span< const std::uint8_t > rgba, bool linear, bool repeat)
 Upload texels the game has in memory, such as a texture of the race built into the engine.

Friends

class SceneRenderer

Detailed Description

A texture of the renderer for flat pictures and text.

Constructor & Destructor Documentation

◆ ~RenderTexture()

coastline::RenderTexture::~RenderTexture ( )

Release the texture, sampler, and upload storage before GPU device destruction.

◆ RenderTexture()

coastline::RenderTexture::RenderTexture ( const RenderTexture & )
delete

Prevent copying texture allocation and upload resources.

Member Function Documentation

◆ Load()

std::unique_ptr< RenderTexture > coastline::RenderTexture::Load ( SceneRenderer & renderer,
const std::filesystem::path & path,
bool linear,
bool repeat = false )
static

Read a PNG image.

Parameters
rendererThe renderer that draws with the texture.
pathThe image.
linearWhether the texture filters linearly, or takes the nearest texel.
repeatWhether the texture repeats past its edges, or clamps to them.
Returns
The texture, or nothing with the reason logged.

◆ FromTexels()

std::unique_ptr< RenderTexture > coastline::RenderTexture::FromTexels ( SceneRenderer & renderer,
int width,
int height,
std::span< const std::uint8_t > rgba,
bool linear,
bool repeat )
static

Upload texels the game has in memory, such as a texture of the race built into the engine.

Parameters
rendererThe renderer that draws with the texture.
widthThe width in texels.
heightThe height in texels.
rgbaThe texels as 8-bit RGBA, row by row from the top.
linearWhether the texture filters linearly, or takes the nearest texel.
repeatWhether the texture repeats past its edges, or clamps to them.
Returns
The texture, or nothing when the upload failed.

◆ operator=()

RenderTexture & coastline::RenderTexture::operator= ( const RenderTexture & )
delete

Prevent assignment of texture allocation and upload resources.

◆ Width()

int coastline::RenderTexture::Width ( ) const
Returns
The width in texels.

◆ Height()

int coastline::RenderTexture::Height ( ) const
Returns
The height in texels.

◆ Update()

bool coastline::RenderTexture::Update ( std::span< const std::uint8_t > rgba)

Replace the texels in place, through an upload the texture keeps.

A frame that still draws the old texels keeps them.

Parameters
rgbaThe texels as 8-bit RGBA, row by row from the top, the size of the texture.
Returns
Whether the upload was submitted.

◆ SceneRenderer

friend class SceneRenderer
friend

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