Flat-color quad shader (rectangles, keyboard/dialog chrome), used via WutGlyphRenderer's drawFeature().
More...
#include <ColorShader.h>
|
| void | setShaders () const |
| | Binds the fetch, vertex and pixel shaders for subsequent draws.
|
| |
| void | resetFrame () |
| | Call once per frame, before any draws - rewinds the per-draw color slot counter so this frame starts writing from slot 0 again.
|
| |
| void | setAttributeBuffer (const uint8_t *colorAttr) |
| |
| void | bindMesh (const float *positions, const uint8_t *colors, uint32_t vertexCapacity, const float *offset=nullptr, const float *scale=nullptr) |
| | Binds caller-owned vertex streams for mesh draws and sets the uniforms so vertices pass through unchanged: positions are already NDC (3 floats each, z = 0), colors are RGBA8 per vertex and are multiplied by 1.
|
| |
| void | setAngle (float angleRadians) |
| | Sets the quad rotation in radians.
|
| |
| void | setOffset (const float offset[3]) |
| | Sets the NDC position of the quad's center.
|
| |
| void | setScale (const float scale[3]) |
| | Sets the NDC half-extents of the quad.
|
| |
| void | setColorIntensity (const float colorIntensity[4]) |
| | Sets the RGBA color the quad is filled with.
|
| |
|
| static ColorShader * | instance () |
| |
| static void | destroyInstance () |
| | Destroys the shared instance; the next instance() call creates a new one.
|
| |
| static void | drawMesh (uint32_t firstVertex, uint32_t vertexCount) |
| | Draws triangles from the streams bound with bindMesh().
|
| |
| 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.
|
| |
|
| static const uint32_t | cuColorVtxsSize = 4 * cuColorAttrSize |
| | Size in bytes of the four per-vertex colors of one quad.
|
| |
| 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)
|
| |
Flat-color quad shader (rectangles, keyboard/dialog chrome), used via WutGlyphRenderer's drawFeature().
Singleton, accessed through instance().
Definition at line 19 of file ColorShader.h.
◆ bindMesh()
| void ColorShader::bindMesh |
( |
const float * | positions, |
|
|
const uint8_t * | colors, |
|
|
uint32_t | vertexCapacity, |
|
|
const float * | offset = nullptr, |
|
|
const float * | scale = nullptr ) |
|
inline |
Binds caller-owned vertex streams for mesh draws and sets the uniforms so vertices pass through unchanged: positions are already NDC (3 floats each, z = 0), colors are RGBA8 per vertex and are multiplied by 1.
The streams must stay valid and unmodified until the GPU has finished the draws.
- Parameters
-
| positions | Vertex positions, GX2_VERTEX_BUFFER_ALIGNMENT aligned |
| colors | Vertex colors, GX2_VERTEX_BUFFER_ALIGNMENT aligned |
| vertexCapacity | Number of vertices both streams hold |
| offset | NDC offset added to every vertex after scaling (nullptr = none). For a mesh kept across frames, whose positions are NDC for an instance at the canvas origin |
| scale | NDC scale applied to every vertex (nullptr = 1) |
Definition at line 133 of file ColorShader.h.
◆ destroyInstance()
| static void ColorShader::destroyInstance |
( |
| ) |
|
|
inlinestatic |
◆ drawMesh()
| static void ColorShader::drawMesh |
( |
uint32_t | firstVertex, |
|
|
uint32_t | vertexCount ) |
|
inlinestatic |
Draws triangles from the streams bound with bindMesh().
- Parameters
-
| firstVertex | Index of the first vertex |
| vertexCount | Number of vertices (a multiple of 3) |
Definition at line 149 of file ColorShader.h.
◆ instance()
◆ resetFrame()
| void ColorShader::resetFrame |
( |
| ) |
|
|
inline |
Call once per frame, before any draws - rewinds the per-draw color slot counter so this frame starts writing from slot 0 again.
Safe to call even before the first frame's draws: slots from a completed frame are free to reuse once GX2DrawDone has run (WHBGfxFinishRender does this every frame), so by the time prepareFrame() runs for the next frame, every slot used last frame is guaranteed consumed.
Definition at line 86 of file ColorShader.h.
◆ setAngle()
| void ColorShader::setAngle |
( |
float | angleRadians | ) |
|
|
inline |
Sets the quad rotation in radians.
Definition at line 155 of file ColorShader.h.
◆ setAttributeBuffer()
| void ColorShader::setAttributeBuffer |
( |
const uint8_t * | colorAttr | ) |
|
|
inline |
- Parameters
-
| colorAttr | Packed RGBA8 color, 4 vertices (cuColorVtxsSize bytes). Copied into this draw's own slot in a GX2R buffer this shader owns - the caller's memory (a stack array at every current call site) isn't guaranteed to still be valid, unmodified, or cache-flushed by the time the GPU actually executes this draw, and a single shared destination wouldn't survive multiple in-flight draws within the same frame (see cuMaxColorDraws above). |
Definition at line 99 of file ColorShader.h.
◆ setColorIntensity()
| void ColorShader::setColorIntensity |
( |
const float | colorIntensity[4] | ) |
|
|
inline |
Sets the RGBA color the quad is filled with.
Definition at line 170 of file ColorShader.h.
◆ setOffset()
| void ColorShader::setOffset |
( |
const float | offset[3] | ) |
|
|
inline |
Sets the NDC position of the quad's center.
Definition at line 160 of file ColorShader.h.
◆ setScale()
| void ColorShader::setScale |
( |
const float | scale[3] | ) |
|
|
inline |
Sets the NDC half-extents of the quad.
Definition at line 165 of file ColorShader.h.
◆ setShaders()
| void ColorShader::setShaders |
( |
| ) |
const |
|
inline |
Binds the fetch, vertex and pixel shaders for subsequent draws.
Definition at line 72 of file ColorShader.h.
◆ cuColorVtxsSize
Size in bytes of the four per-vertex colors of one quad.
Definition at line 54 of file ColorShader.h.
The documentation for this class was generated from the following files: