Wii: Improve menu rendering

This commit is contained in:
Jeffrey Pfau 2015-08-28 21:29:38 -07:00
parent a88613abbe
commit c0d19a1ad5
2 changed files with 10 additions and 3 deletions

View File

@ -53,6 +53,7 @@ unsigned GUIFontGlyphWidth(const struct GUIFont* font, uint32_t glyph) {
} }
void GUIFontDrawGlyph(const struct GUIFont* font, int x, int y, uint32_t color, uint32_t glyph) { void GUIFontDrawGlyph(const struct GUIFont* font, int x, int y, uint32_t color, uint32_t glyph) {
color = (color >> 24) | (color << 8);
GXTexObj tex; GXTexObj tex;
// Grumble grumble, libogc is bad about const-correctness // Grumble grumble, libogc is bad about const-correctness
struct GUIFont* ncfont = font; struct GUIFont* ncfont = font;
@ -61,6 +62,7 @@ void GUIFontDrawGlyph(const struct GUIFont* font, int x, int y, uint32_t color,
GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_NOOP); GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_NOOP);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
if (glyph > 0x7F) { if (glyph > 0x7F) {
glyph = 0; glyph = 0;
@ -70,15 +72,19 @@ void GUIFontDrawGlyph(const struct GUIFont* font, int x, int y, uint32_t color,
s16 ty = (glyph >> 4) * CELL_HEIGHT + metric.padding.top; s16 ty = (glyph >> 4) * CELL_HEIGHT + metric.padding.top;
GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position2s16(x, y - GLYPH_HEIGHT + metric.padding.top); GX_Position2s16(x, y - GLYPH_HEIGHT + metric.padding.top);
GX_Color1u32(color);
GX_TexCoord2f32(tx / 256.f, ty / 128.f); GX_TexCoord2f32(tx / 256.f, ty / 128.f);
GX_Position2s16(x + CELL_WIDTH - (metric.padding.left + metric.padding.right), y - GLYPH_HEIGHT + metric.padding.top); GX_Position2s16(x + CELL_WIDTH - (metric.padding.left + metric.padding.right), y - GLYPH_HEIGHT + metric.padding.top);
GX_Color1u32(color);
GX_TexCoord2f32((tx + CELL_WIDTH - (metric.padding.left + metric.padding.right)) / 256.f, ty / 128.f); GX_TexCoord2f32((tx + CELL_WIDTH - (metric.padding.left + metric.padding.right)) / 256.f, ty / 128.f);
GX_Position2s16(x + CELL_WIDTH - (metric.padding.left + metric.padding.right), y - GLYPH_HEIGHT + CELL_HEIGHT - metric.padding.bottom); GX_Position2s16(x + CELL_WIDTH - (metric.padding.left + metric.padding.right), y - GLYPH_HEIGHT + CELL_HEIGHT - metric.padding.bottom);
GX_Color1u32(color);
GX_TexCoord2f32((tx + CELL_WIDTH - (metric.padding.left + metric.padding.right)) / 256.f, (ty + CELL_HEIGHT - (metric.padding.top + metric.padding.bottom)) / 128.f); GX_TexCoord2f32((tx + CELL_WIDTH - (metric.padding.left + metric.padding.right)) / 256.f, (ty + CELL_HEIGHT - (metric.padding.top + metric.padding.bottom)) / 128.f);
GX_Position2s16(x, y - GLYPH_HEIGHT + CELL_HEIGHT - metric.padding.bottom); GX_Position2s16(x, y - GLYPH_HEIGHT + CELL_HEIGHT - metric.padding.bottom);
GX_Color1u32(color);
GX_TexCoord2f32(tx / 256.f, (ty + CELL_HEIGHT - (metric.padding.top + metric.padding.bottom)) / 128.f); GX_TexCoord2f32(tx / 256.f, (ty + CELL_HEIGHT - (metric.padding.top + metric.padding.bottom)) / 128.f);
GX_End(); GX_End();
} }

View File

@ -108,7 +108,7 @@ int main() {
GX_SetNumChans(1); GX_SetNumChans(1);
GX_SetNumTexGens(1); GX_SetNumTexGens(1);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GX_SetTevOp(GX_TEVSTAGE0, GX_REPLACE); GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
GX_InvVtxCache(); GX_InvVtxCache();
@ -170,6 +170,7 @@ int main() {
char path[256]; char path[256];
guOrtho(proj, -20, 240, 0, 352, 0, 300); guOrtho(proj, -20, 240, 0, 352, 0, 300);
GX_LoadProjectionMtx(proj, GX_ORTHOGRAPHIC); GX_LoadProjectionMtx(proj, GX_ORTHOGRAPHIC);
GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);
struct GUIParams params = { struct GUIParams params = {
352, 230, 352, 230,
@ -182,6 +183,7 @@ int main() {
guOrtho(proj, -10, VIDEO_VERTICAL_PIXELS + 10, 0, VIDEO_HORIZONTAL_PIXELS, 0, 300); guOrtho(proj, -10, VIDEO_VERTICAL_PIXELS + 10, 0, VIDEO_HORIZONTAL_PIXELS, 0, 300);
GX_LoadProjectionMtx(proj, GX_ORTHOGRAPHIC); GX_LoadProjectionMtx(proj, GX_ORTHOGRAPHIC);
GX_SetVtxDesc(GX_VA_CLR0, GX_NONE);
while (true) { while (true) {
#if RESAMPLE_LIBRARY == RESAMPLE_BLIP_BUF #if RESAMPLE_LIBRARY == RESAMPLE_BLIP_BUF
@ -283,8 +285,6 @@ int main() {
} }
static void GBAWiiFrame(void) { static void GBAWiiFrame(void) {
VIDEO_WaitVSync();
size_t x, y; size_t x, y;
uint64_t* texdest = (uint64_t*) texmem; uint64_t* texdest = (uint64_t*) texmem;
uint64_t* texsrc = (uint64_t*) renderer.outputBuffer; uint64_t* texsrc = (uint64_t*) renderer.outputBuffer;
@ -355,6 +355,7 @@ static void _audioDMA(void) {
} }
static void _drawStart(void) { static void _drawStart(void) {
VIDEO_WaitVSync();
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
GX_SetColorUpdate(GX_TRUE); GX_SetColorUpdate(GX_TRUE);