Allow immediate drawing of displaylist

This commit is contained in:
xtreme8000 2022-12-17 12:12:17 +01:00
parent 2bbae6cb96
commit a354bc37d1
4 changed files with 28 additions and 8 deletions

View file

@ -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 :=

View file

@ -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();
}

View file

@ -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);

View file

@ -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) {