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

GX2-backed ImageRenderer for GuiImage/GuiImageData, using Texture2DShader. More...

#include <WutVideoDriver.h>

Inheritance diagram for WutImageRenderer:
[legend]

Public Member Functions

 WutImageRenderer (WutVideoDriver *driver)
 
void * createTexture (int width, int height) override
 Allocates an empty hardware-aligned texture buffer.
 
void loadTextureData (void *texture, const uint8_t *rgba, int width, int height) override
 Loads raw RGBA8 pixels into the pre-allocated texture.
 
bool canReuseTexture (int allocWidth, int allocHeight, int width, int height) const override
 Whether a texture allocated for allocWidth x allocHeight can be reloaded in place.
 
void destroyTexture (void *texture) override
 Destroys a texture created by createTexture.
 
void drawTexture (void *texture, float xpos, float ypos, uint16_t width, uint16_t height, float degrees, float scaleX, float scaleY, uint8_t alpha) override
 Draws a texture created by createTexture.
 
void drawRectangle (float x, float y, float width, float height, PixelColor color) override
 Draws a solid-color rectangle (alpha-blended using color.a).
 
void drawMesh (const MeshVertex *vertices, size_t count) override
 Draws a triangle list: three vertices per triangle, each with its own color.
 
void * createMesh (const MeshVertex *vertices, size_t count) override
 Hands a triangle list to the backend to keep in its own ready-to-draw form (a GX display list, a GX2 vertex buffer), so drawing it again with drawMeshInstance() costs the CPU almost nothing, where drawMesh() sends every vertex every time.
 
void destroyMesh (void *mesh) override
 Releases a mesh from createMesh().
 
void drawMeshInstance (void *mesh, float x, float y, float scaleX, float scaleY) override
 Draws a mesh from createMesh() fully opaque, as its vertex colors say.
 

Detailed Description

GX2-backed ImageRenderer for GuiImage/GuiImageData, using Texture2DShader.

Definition at line 217 of file WutVideoDriver.h.

Constructor & Destructor Documentation

◆ WutImageRenderer()

WutImageRenderer::WutImageRenderer ( WutVideoDriver * driver)
Parameters
driverThe video driver draws are queued on

Definition at line 604 of file WutVideoDriver.cpp.

Member Function Documentation

◆ canReuseTexture()

bool WutImageRenderer::canReuseTexture ( int allocWidth,
int allocHeight,
int width,
int height ) const
overridevirtual

Whether a texture allocated for allocWidth x allocHeight can be reloaded in place.

Reimplemented from ImageRenderer.

Definition at line 649 of file WutVideoDriver.cpp.

◆ createMesh()

void * WutImageRenderer::createMesh ( const MeshVertex * vertices,
size_t count )
overridevirtual

Hands a triangle list to the backend to keep in its own ready-to-draw form (a GX display list, a GX2 vertex buffer), so drawing it again with drawMeshInstance() costs the CPU almost nothing, where drawMesh() sends every vertex every time.

Same vertex rules as drawMesh(); the vertices are copied. Call while drawing, since a backend may record from its current render state.

Returns
An opaque handle for drawMeshInstance() and destroyMesh(), or nullptr if the backend can't, in which case the caller keeps using drawMesh()

Reimplemented from ImageRenderer.

Definition at line 715 of file WutVideoDriver.cpp.

◆ createTexture()

void * WutImageRenderer::createTexture ( int width,
int height )
overridevirtual

Allocates an empty hardware-aligned texture buffer.

Implements ImageRenderer.

Definition at line 610 of file WutVideoDriver.cpp.

◆ destroyMesh()

void WutImageRenderer::destroyMesh ( void * mesh)
overridevirtual

Releases a mesh from createMesh().

Safe to call while draws that use it are still waiting to be submitted; the backend keeps it until they are done.

Reimplemented from ImageRenderer.

Definition at line 758 of file WutVideoDriver.cpp.

◆ destroyTexture()

void WutImageRenderer::destroyTexture ( void * texture)
overridevirtual

Destroys a texture created by createTexture.

Implements ImageRenderer.

Definition at line 654 of file WutVideoDriver.cpp.

◆ drawMesh()

void WutImageRenderer::drawMesh ( const MeshVertex * vertices,
size_t count )
overridevirtual

Draws a triangle list: three vertices per triangle, each with its own color.

Positions are in design-canvas pixels (the same space as drawRectangle()), colors are straight (non-premultiplied) RGBA blended source-over, so per-vertex alpha gives gradients and soft edges (see GuiMesh). Winding does not matter. A count that is not a multiple of 3 is rounded down. The vertices are copied (or consumed) before this returns, so the caller can free or reuse the array immediately.

Parameters
verticesTriangle list
countNumber of vertices

Implements ImageRenderer.

Definition at line 707 of file WutVideoDriver.cpp.

◆ drawMeshInstance()

void WutImageRenderer::drawMeshInstance ( void * mesh,
float x,
float y,
float scaleX,
float scaleY )
overridevirtual

Draws a mesh from createMesh() fully opaque, as its vertex colors say.

Mesh vertex (vx, vy) lands at (x + vx * scaleX, y + vy * scaleY) in design-canvas pixels.

Parameters
meshHandle from createMesh()
xWhere mesh (0,0) lands
yWhere mesh (0,0) lands
scaleXHorizontal stretch about (x,y)
scaleYVertical stretch about (x,y)

Reimplemented from ImageRenderer.

Definition at line 764 of file WutVideoDriver.cpp.

◆ drawRectangle()

void WutImageRenderer::drawRectangle ( float x,
float y,
float width,
float height,
PixelColor color )
overridevirtual

Draws a solid-color rectangle (alpha-blended using color.a).

Implements ImageRenderer.

Definition at line 772 of file WutVideoDriver.cpp.

◆ drawTexture()

void WutImageRenderer::drawTexture ( void * texture,
float xpos,
float ypos,
uint16_t width,
uint16_t height,
float degrees,
float scaleX,
float scaleY,
uint8_t alpha )
overridevirtual

Draws a texture created by createTexture.

Implements ImageRenderer.

Definition at line 667 of file WutVideoDriver.cpp.

◆ loadTextureData()

void WutImageRenderer::loadTextureData ( void * texture,
const uint8_t * rgba,
int width,
int height )
overridevirtual

Loads raw RGBA8 pixels into the pre-allocated texture.

Implements ImageRenderer.

Definition at line 631 of file WutVideoDriver.cpp.


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