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

Platform image/texture backend GuiImageData and GuiImage delegate to. More...

#include <VideoDriver.h>

Inheritance diagram for ImageRenderer:
[legend]

Public Member Functions

virtual void * createTexture (int width, int height)=0
 Allocates an empty hardware-aligned texture buffer.
 
virtual void loadTextureData (void *texture, const uint8_t *rgba, int width, int height)=0
 Loads raw RGBA8 pixels into the pre-allocated texture.
 
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.
 
virtual void destroyTexture (void *texture)=0
 Destroys a texture created by createTexture.
 
virtual void drawTexture (void *texture, float xpos, float ypos, uint16_t width, uint16_t height, float degrees, float scaleX, float scaleY, uint8_t alpha)=0
 Draws a texture created by createTexture.
 
virtual void drawRectangle (float x, float y, float width, float height, PixelColor color)=0
 Draws a solid-color rectangle (alpha-blended using color.a).
 
virtual void drawMesh (const MeshVertex *vertices, size_t count)=0
 Draws a triangle list: three vertices per triangle, each with its own color.
 
virtual void * createMesh (const MeshVertex *vertices, size_t count)
 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.
 
virtual void destroyMesh (void *mesh)
 Releases a mesh from createMesh().
 
virtual void drawMeshInstance (void *mesh, float x, float y, float scaleX, float scaleY)
 Draws a mesh from createMesh() fully opaque, as its vertex colors say.
 

Detailed Description

Platform image/texture backend GuiImageData and GuiImage delegate to.

Exactly one driver implements this and assigns the single global instance below. GuiImageData/GuiImage never touch any platform texture type directly, only imageSystem.

Definition at line 71 of file VideoDriver.h.

Member Function Documentation

◆ canReuseTexture()

virtual bool ImageRenderer::canReuseTexture ( int allocWidth,
int allocHeight,
int width,
int height ) const
inlinevirtual

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

Reimplemented in WutImageRenderer.

Definition at line 80 of file VideoDriver.h.

◆ createMesh()

virtual void * ImageRenderer::createMesh ( const MeshVertex * vertices,
size_t count )
inlinevirtual

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 in OgcImageRenderer, and WutImageRenderer.

Definition at line 108 of file VideoDriver.h.

◆ createTexture()

virtual void * ImageRenderer::createTexture ( int width,
int height )
pure virtual

Allocates an empty hardware-aligned texture buffer.

Implemented in OgcImageRenderer, and WutImageRenderer.

◆ destroyMesh()

virtual void ImageRenderer::destroyMesh ( void * mesh)
inlinevirtual

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 in OgcImageRenderer, and WutImageRenderer.

Definition at line 111 of file VideoDriver.h.

◆ destroyTexture()

virtual void ImageRenderer::destroyTexture ( void * texture)
pure virtual

Destroys a texture created by createTexture.

Implemented in OgcImageRenderer, and WutImageRenderer.

◆ drawMesh()

virtual void ImageRenderer::drawMesh ( const MeshVertex * vertices,
size_t count )
pure virtual

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

Implemented in OgcImageRenderer, and WutImageRenderer.

◆ drawMeshInstance()

virtual void ImageRenderer::drawMeshInstance ( void * mesh,
float x,
float y,
float scaleX,
float scaleY )
inlinevirtual

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 in OgcImageRenderer, and WutImageRenderer.

Definition at line 119 of file VideoDriver.h.

◆ drawRectangle()

virtual void ImageRenderer::drawRectangle ( float x,
float y,
float width,
float height,
PixelColor color )
pure virtual

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

Implemented in OgcImageRenderer, and WutImageRenderer.

◆ drawTexture()

virtual void ImageRenderer::drawTexture ( void * texture,
float xpos,
float ypos,
uint16_t width,
uint16_t height,
float degrees,
float scaleX,
float scaleY,
uint8_t alpha )
pure virtual

Draws a texture created by createTexture.

Implemented in OgcImageRenderer, and WutImageRenderer.

◆ loadTextureData()

virtual void ImageRenderer::loadTextureData ( void * texture,
const uint8_t * rgba,
int width,
int height )
pure virtual

Loads raw RGBA8 pixels into the pre-allocated texture.

Implemented in OgcImageRenderer, and WutImageRenderer.


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