libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
Texture2DShader Class Reference

Textured quad shader (images, glyphs), used by WutImageRenderer and WutGlyphRenderer. More...

#include <Texture2DShader.h>

Inheritance diagram for Texture2DShader:
[legend]

Public Member Functions

void setShaders () const
 Binds the fetch, vertex and pixel shaders for subsequent draws.
 
void setAttributeBuffer () const
 Binds the quad position and texture-coordinate buffers.
 
void resetFrame ()
 Call once per frame, before any draws - rewinds the rotated-quad slot counter (see WutVideoDriver::prepareFrame()).
 
bool uploadRotatedQuad (const float ndcCorners[8], uint32_t &slotOut)
 Copies a pre-rotated quad into its own vertex slot.
 
void setRotatedAttributeBuffer (uint32_t slot) const
 Binds a slot from uploadRotatedQuad() as the position stream (plus the shared texcoords).
 
void setAngle (float angleRadians)
 
void setOffset (const float offset[3])
 
void setScale (const float scale[3])
 
void setColorIntensity (const float colorIntensity[4])
 
void setTextureAndSampler (const GX2Texture *texture, const GX2Sampler *sampler) const
 Binds the texture to sample and the sampler describing its filtering.
 
void clearBlur () const
 The compiled pixel shader reads a per-draw blur-direction uniform that this driver doesn't expose as a feature.
 

Static Public Member Functions

static Texture2DShader * instance ()
 
static void destroyInstance ()
 Destroys the shared instance; the next instance() call creates a new one.
 
- Static Public Member Functions inherited from Shader
static void draw (int32_t primitive=GX2_PRIMITIVE_MODE_QUADS, uint32_t vtxCount=4)
 Issues the draw call for the currently bound shaders and attribute buffers.
 

Additional Inherited Members

- Static Public Attributes inherited from Shader
static const uint16_t cuVertexAttrSize = sizeof(float) * 3
 Size in bytes of one position vertex (3 floats)
 
static const uint16_t cuTexCoordAttrSize = sizeof(float) * 2
 Size in bytes of one texture coordinate (2 floats)
 
static const uint16_t cuColorAttrSize = sizeof(uint8_t) * 4
 Size in bytes of one vertex color (4 bytes, RGBA)
 

Detailed Description

Textured quad shader (images, glyphs), used by WutImageRenderer and WutGlyphRenderer.

Singleton, accessed through instance().

Definition at line 19 of file Texture2DShader.h.

Member Function Documentation

◆ clearBlur()

void Texture2DShader::clearBlur ( ) const
inline

The compiled pixel shader reads a per-draw blur-direction uniform that this driver doesn't expose as a feature.

Uniform registers aren't guaranteed to hold their value across a shader switch, so this must be called every draw (not just once at init) to keep blurLocation pinned at zero.

Definition at line 170 of file Texture2DShader.h.

◆ destroyInstance()

static void Texture2DShader::destroyInstance ( )
inlinestatic

Destroys the shared instance; the next instance() call creates a new one.

Definition at line 71 of file Texture2DShader.h.

◆ instance()

static Texture2DShader * Texture2DShader::instance ( )
inlinestatic
Returns
the shared Texture2DShader, created on first use

Definition at line 63 of file Texture2DShader.h.

◆ resetFrame()

void Texture2DShader::resetFrame ( )
inline

Call once per frame, before any draws - rewinds the rotated-quad slot counter (see WutVideoDriver::prepareFrame()).

Definition at line 94 of file Texture2DShader.h.

◆ setAngle()

void Texture2DShader::setAngle ( float angleRadians)
inline
Parameters
angleRadiansRotation about the quad's own center, in radians. Only correct for a 16:9 canvas - for anything else draw rotated quads via uploadRotatedQuad() instead.

Definition at line 138 of file Texture2DShader.h.

◆ setAttributeBuffer()

void Texture2DShader::setAttributeBuffer ( ) const
inline

Binds the quad position and texture-coordinate buffers.

Definition at line 86 of file Texture2DShader.h.

◆ setColorIntensity()

void Texture2DShader::setColorIntensity ( const float colorIntensity[4])
inline
Parameters
colorIntensity(r, g, b, a) modulation, 0..1 per channel - alpha carries the draw's overall opacity.

Definition at line 153 of file Texture2DShader.h.

◆ setOffset()

void Texture2DShader::setOffset ( const float offset[3])
inline
Parameters
offsetNDC-space (x, y, z) position of the quad's center.

Definition at line 143 of file Texture2DShader.h.

◆ setRotatedAttributeBuffer()

void Texture2DShader::setRotatedAttributeBuffer ( uint32_t slot) const
inline

Binds a slot from uploadRotatedQuad() as the position stream (plus the shared texcoords).

Pair with setAngle(0), setOffset({0,0,0}) and setScale({1,1,1}) so the vertex shader leaves the corners untouched.

Definition at line 129 of file Texture2DShader.h.

◆ setScale()

void Texture2DShader::setScale ( const float scale[3])
inline
Parameters
scaleNDC-space (x, y, z) half-extents of the quad.

Definition at line 148 of file Texture2DShader.h.

◆ setShaders()

void Texture2DShader::setShaders ( ) const
inline

Binds the fetch, vertex and pixel shaders for subsequent draws.

Definition at line 78 of file Texture2DShader.h.

◆ setTextureAndSampler()

void Texture2DShader::setTextureAndSampler ( const GX2Texture * texture,
const GX2Sampler * sampler ) const
inline

Binds the texture to sample and the sampler describing its filtering.

Definition at line 159 of file Texture2DShader.h.

◆ uploadRotatedQuad()

bool Texture2DShader::uploadRotatedQuad ( const float ndcCorners[8],
uint32_t & slotOut )
inline

Copies a pre-rotated quad into its own vertex slot.

Parameters
ndcCorners4 (x, y) pairs in NDC, in the same vertex order as the default unit square (bottom-left, bottom-right, top-right, top-left).
slotOutReceives the slot to pass to setRotatedAttributeBuffer().
Returns
false if the per-frame slots are exhausted (or the buffer couldn't be created) - the caller should fall back to setAngle().

Definition at line 105 of file Texture2DShader.h.


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