From a354bc37d1dc1a0b29447502f6dd7b6ffe742eee Mon Sep 17 00:00:00 2001 From: xtreme8000 Date: Sat, 17 Dec 2022 12:12:17 +0100 Subject: [PATCH] Allow immediate drawing of displaylist --- Makefile | 2 +- source/platform/graphics/displaylist.c | 16 ++++++++++++++++ source/platform/graphics/displaylist.h | 2 ++ source/platform/graphics/gfx.c | 16 +++++++++------- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 15d6731..a14c94b 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ include $(DEVKITPPC)/wii_rules #--------------------------------------------------------------------------------- TARGET := $(notdir $(CURDIR)) BUILD := build -SOURCES := source source/block source/platform/graphics source/network source/game source/game/gui source/platform source/cNBT +SOURCES := source source/block source/platform/graphics source/network source/game source/game/gui source/platform source/item source/cNBT DATA := TEXTURES := textures INCLUDES := diff --git a/source/platform/graphics/displaylist.c b/source/platform/graphics/displaylist.c index 5ee0682..3ed129a 100644 --- a/source/platform/graphics/displaylist.c +++ b/source/platform/graphics/displaylist.c @@ -90,3 +90,19 @@ void displaylist_render(struct displaylist* l) { (l->index + (uintptr_t)l->data % DISPLAYLIST_CLL - 1) / DISPLAYLIST_CLL * DISPLAYLIST_CLL); } + +void displaylist_render_immediate(struct displaylist* l, uint8_t primitve, + uint8_t vtxfmt, uint16_t vtxcnt) { + assert(l && l->data); + + uint8_t* base = (uint8_t*)l->data + DISPLAYLIST_CLL + 3; + + GX_Begin(primitve, vtxfmt, vtxcnt); + for(uint16_t k = 0; k < vtxcnt; k++) { + GX_Position3s16(MEM_U16(base, 0), MEM_U16(base, 2), MEM_U16(base, 4)); + GX_Color1x8(MEM_U8(base, 6)); + GX_TexCoord2u8(MEM_U8(base, 7), MEM_U8(base, 8)); + base += 9; + } + GX_End(); +} diff --git a/source/platform/graphics/displaylist.h b/source/platform/graphics/displaylist.h index 9a0e3bc..6f403e0 100644 --- a/source/platform/graphics/displaylist.h +++ b/source/platform/graphics/displaylist.h @@ -18,6 +18,8 @@ void displaylist_destroy(struct displaylist* l); void displaylist_finalize(struct displaylist* l, uint8_t primitve, uint8_t vtxfmt, uint16_t vtxcnt); void displaylist_render(struct displaylist* l); +void displaylist_render_immediate(struct displaylist* l, uint8_t primitve, + uint8_t vtxfmt, uint16_t vtxcnt); void displaylist_pos(struct displaylist* l, int16_t x, int16_t y, int16_t z); void displaylist_color(struct displaylist* l, uint8_t index); diff --git a/source/platform/graphics/gfx.c b/source/platform/graphics/gfx.c index 81a0cd5..cdd4172 100644 --- a/source/platform/graphics/gfx.c +++ b/source/platform/graphics/gfx.c @@ -212,6 +212,8 @@ void gfx_setup() { GX_SetTexCoordGen(GX_TEXCOORD1, GX_TG_MTX2x4, GX_TG_POS, GX_TEXMTX1); + gfx_update_light(1.0F); + GX_DrawDone(); } @@ -288,23 +290,23 @@ void gfx_bind_texture(enum gfx_texture tex) { } } -void gfx_mode_world() { } +void gfx_mode_world() { + gfx_write_buffers(true, true, true); +} void gfx_mode_gui() { gfx_fog(false); Mtx44 projection; - Mtx44 identity; - guMtxIdentity(identity); - guOrtho(projection, 0, gfx_height(), 0, gfx_width(), 0, 10); + guOrtho(projection, 0, gfx_height(), 0, gfx_width(), 0, 256); GX_LoadProjectionMtx(projection, GX_ORTHOGRAPHIC); - GX_LoadPosMtxImm(identity, GX_PNMTX0); - - GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT); + gfx_matrix_modelview(GLM_MAT4_IDENTITY); + gfx_lighting(false); gfx_blending(MODE_BLEND); gfx_alpha_test(true); + gfx_write_buffers(true, false, false); } void gfx_matrix_projection(mat4 proj, bool is_perspective) {