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

GX-backed ImageRenderer for GuiImage/GuiImageData textures. More...

#include <OgcVideoDriver.h>

Inheritance diagram for OgcImageRenderer:
[legend]

Public Member Functions

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.
 
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.
 
- Public Member Functions inherited from ImageRenderer
virtual bool canReuseTexture (int allocWidth, int allocHeight, int width, int height) const
 Whether a texture allocated for allocWidth x allocHeight can be reloaded in place.
 

Detailed Description

GX-backed ImageRenderer for GuiImage/GuiImageData textures.

Definition at line 49 of file OgcVideoDriver.h.

Member Function Documentation

◆ createMesh()

void * OgcImageRenderer::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 330 of file OgcVideoDriver.cpp.

◆ createTexture()

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

Allocates an empty hardware-aligned texture buffer.

Implements ImageRenderer.

Definition at line 183 of file OgcVideoDriver.cpp.

◆ destroyMesh()

void OgcImageRenderer::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 389 of file OgcVideoDriver.cpp.

◆ destroyTexture()

void OgcImageRenderer::destroyTexture ( void * texture)
overridevirtual

Destroys a texture created by createTexture.

Implements ImageRenderer.

Definition at line 219 of file OgcVideoDriver.cpp.

◆ drawMesh()

void OgcImageRenderer::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 291 of file OgcVideoDriver.cpp.

◆ drawMeshInstance()

void OgcImageRenderer::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 420 of file OgcVideoDriver.cpp.

◆ drawRectangle()

void OgcImageRenderer::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 275 of file OgcVideoDriver.cpp.

◆ drawTexture()

void OgcImageRenderer::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 225 of file OgcVideoDriver.cpp.

◆ loadTextureData()

void OgcImageRenderer::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 192 of file OgcVideoDriver.cpp.


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