libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
OgcVideoDriver.h
1/****************************************************************************
2 * Platform Abstraction Layer (OGC driver)
3 * Daryl Borth 2026
4 * OgcVideoDriver.h
5 ***************************************************************************/
6#pragma once
7
8#include <gccore.h>
9#include "../VideoDriver.h"
10
13class OgcVideoDriver : public VideoDriver
14{
15 public:
16 OgcVideoDriver();
17 ~OgcVideoDriver() override;
18
19 void init(int width, int height) override;
20 void shutdown() override;
21 void render() override;
22 void clearScreen(const PixelColor& color) override;
23
24 int getScreenWidth() const override { return screenWidth; }
25 int getScreenHeight() const override { return screenHeight; }
26 int getRefreshRate() const override { return vmode && (vmode->viTVMode >> 2) == VI_PAL ? 50 : 60; }
27 float getDeltaTime() const override { return vmode && (vmode->viTVMode >> 2) == VI_PAL ? (1.0f / 50.0f) : (1.0f / 60.0f); }
28 uint32_t getFrameTimer() override { return frameTimer; }
29
30 ImageRenderer* getImageRenderer() override { return imageRenderer; }
31 GlyphRenderer* getGlyphRenderer() override { return glyphRenderer; }
32
33 private:
34 void resetVideoMenu();
35 int screenWidth = 0;
36 int screenHeight = 0;
37 uint32_t frameTimer = 0;
38 uint32_t* xfb[2] = { nullptr, nullptr };
39 int whichfb = 0;
40 GXRModeObj* vmode = nullptr;
41 void* gp_fifo = nullptr;
42
43 ImageRenderer* imageRenderer = nullptr;
44 GlyphRenderer* glyphRenderer = nullptr;
45};
46
50{
51 public:
52 void * createTexture(int width, int height) override;
53 void loadTextureData(void * texture, const uint8_t * rgba, int width, int height) override;
54 void destroyTexture(void * texture) override;
55 void drawTexture(void * texture, float xpos, float ypos, uint16_t width, uint16_t height, float degrees, float scaleX, float scaleY, uint8_t alpha) override;
56 void drawRectangle(float x, float y, float width, float height, PixelColor color) override;
57 void drawMesh(const MeshVertex* vertices, size_t count) override;
58 void* createMesh(const MeshVertex* vertices, size_t count) override;
59 void destroyMesh(void* mesh) override;
60 void drawMeshInstance(void* mesh, float x, float y, float scaleX, float scaleY) override;
61};
62
66void OgcFreeRetiredMeshes();
67
72 private:
73 uint8_t vertexIndex;
74
75 public:
77 OgcGlyphRenderer(uint8_t vtxFmtIndex = GX_VTXFMT1);
78 ~OgcGlyphRenderer() override;
79
80 void* createTexture(uint16_t width, uint16_t height) override;
81 void loadTextureData(void* texture, FT_Bitmap* bitmap) override;
82 void destroyTexture(void* texture) override;
83
84 void drawQuad(void* texture, int16_t screenX, int16_t screenY, uint16_t width, uint16_t height, const PixelColor& color) override;
85 void drawFeature(int16_t screenX, int16_t screenY, uint16_t width, uint16_t height, const PixelColor& color) override;
86
88 void setVertexFormat(uint8_t vtxFmtIndex);
89};
Draws glyph textures and solid rectangles on behalf of GuiTextRenderer.
Platform image/texture backend GuiImageData and GuiImage delegate to.
Definition VideoDriver.h:72
void loadTextureData(void *texture, FT_Bitmap *bitmap) override
Uploads a rasterized FreeType glyph bitmap into a texture from createTexture().
void setVertexFormat(uint8_t vtxFmtIndex)
Changes which GX vertex format slot subsequent draws use.
void destroyTexture(void *texture) override
Destroys a texture created by createTexture().
void drawFeature(int16_t screenX, int16_t screenY, uint16_t width, uint16_t height, const PixelColor &color) override
Draws a solid-color rectangle used for text decoration (underline/strike-through).
OgcGlyphRenderer(uint8_t vtxFmtIndex=GX_VTXFMT1)
void * createTexture(uint16_t width, uint16_t height) override
Allocates an empty single-channel glyph texture. Returns an opaque handle.
void drawQuad(void *texture, int16_t screenX, int16_t screenY, uint16_t width, uint16_t height, const PixelColor &color) override
Draws a glyph texture as a quad tinted with color.
GX-backed ImageRenderer for GuiImage/GuiImageData textures.
void loadTextureData(void *texture, const uint8_t *rgba, int width, int height) override
Loads raw RGBA8 pixels into the pre-allocated texture.
void * createTexture(int width, int height) override
Allocates an empty hardware-aligned texture buffer.
void destroyTexture(void *texture) override
Destroys a texture created by createTexture.
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.
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,...
void drawRectangle(float x, float y, float width, float height, PixelColor color) override
Draws a solid-color rectangle (alpha-blended using color.a).
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 destroyMesh(void *mesh) override
Releases a mesh from createMesh().
GlyphRenderer * getGlyphRenderer() override
int getScreenWidth() const override
void shutdown() override
Releases the video backend. Call after every other user of the renderers has finished.
uint32_t getFrameTimer() override
float getDeltaTime() const override
void render() override
Flushes the current frame to the screen and swaps buffers.
int getScreenHeight() const override
int getRefreshRate() const override
void clearScreen(const PixelColor &color) override
Clears the current frame buffer.
void init(int width, int height) override
ImageRenderer * getImageRenderer() override
Platform video backend owning the frame lifecycle (init/render/clear, screen size,...
Definition VideoDriver.h:28
A single 2D vertex with its own color, in design-canvas coordinates.
Definition Mesh.h:27
8-bit-per-channel RGBA color used by the video interfaces.
Definition Mesh.h:16