Testing some wii rendering bugs

This commit is contained in:
2026-04-18 15:29:40 -05:00
parent 3b94598d2c
commit 8e49be5ac4
9 changed files with 95 additions and 16 deletions
-3
View File
@@ -101,9 +101,6 @@ errorret_t displayUpdate(void) {
errorChain(sceneRender()); errorChain(sceneRender());
// Render UI
// uiRender();
// Finish up // Finish up
screenUnbind(); screenUnbind();
screenRender(); screenRender();
+6 -3
View File
@@ -70,9 +70,7 @@ errorret_t textDraw(
const float_t x, const float_t x,
const float_t y, const float_t y,
const char_t *text, const char_t *text,
#if MESH_ENABLE_COLOR const color_t color,
const color_t color,
#endif
const tileset_t *tileset, const tileset_t *tileset,
texture_t *texture texture_t *texture
) { ) {
@@ -83,6 +81,11 @@ errorret_t textDraw(
errorChain(shaderSetTexture(&SHADER_UNLIT, SHADER_UNLIT_TEXTURE, texture)); errorChain(shaderSetTexture(&SHADER_UNLIT, SHADER_UNLIT_TEXTURE, texture));
#if MESH_ENABLE_COLOR
#else
errorChain(shaderSetColor(&SHADER_UNLIT, SHADER_UNLIT_COLOR, color));
#endif
// errorChain(spriteBatchPush( // errorChain(spriteBatchPush(
// // texture, // // texture,
// posX, posY, // posX, posY,
+1 -3
View File
@@ -66,9 +66,7 @@ errorret_t textDraw(
const float_t x, const float_t x,
const float_t y, const float_t y,
const char_t *text, const char_t *text,
#if MESH_ENABLE_COLOR const color_t color,
const color_t color,
#endif
const tileset_t *tileset, const tileset_t *tileset,
texture_t *texture texture_t *texture
); );
+1 -1
View File
@@ -112,7 +112,7 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
physicsManagerInit(); physicsManagerInit();
errorChain(networkInit()); errorChain(networkInit());
errorChain(gameInit()); errorChain(gameInit());
// printf("Init done, going to queue online in 3 seconds...\n"); // printf("Init done, going to queue online in 3 seconds...\n");
// onlineSwapTime = TIME.time + 3.0f; // onlineSwapTime = TIME.time + 3.0f;
+3 -2
View File
@@ -8,6 +8,7 @@
#include "entitymanager.h" #include "entitymanager.h"
#include "assert/assert.h" #include "assert/assert.h"
#include "util/memory.h" #include "util/memory.h"
#include "scene/scene.h"
entitymanager_t ENTITY_MANAGER; entitymanager_t ENTITY_MANAGER;
@@ -18,8 +19,8 @@ void entityManagerInit(void) {
sizeof(entityid_t) * COMPONENT_TYPE_COUNT * ENTITY_COUNT_MAX sizeof(entityid_t) * COMPONENT_TYPE_COUNT * ENTITY_COUNT_MAX
); );
printf( sceneLog(
"Entity Manager size is currently: %zu bytes (%.2f KB)\n", "Entity Manager size: %zu bytes (%.2f KB)\n",
sizeof(entitymanager_t), sizeof(entitymanager_t),
sizeof(entitymanager_t) / 1024.0f sizeof(entitymanager_t) / 1024.0f
); );
+78
View File
@@ -12,12 +12,59 @@
#include "entity/entitymanager.h" #include "entity/entitymanager.h"
#include "display/shader/shaderunlit.h" #include "display/shader/shaderunlit.h"
#include "display/mesh/cube.h" #include "display/mesh/cube.h"
#include "display/spritebatch/spritebatch.h"
#include "display/text/text.h"
#include "display/screen/screen.h"
scene_t SCENE; scene_t SCENE;
char_t SCENE_LOG[SCENE_LOG_SIZE];
void sceneLog(const char *fmt, ...) {
char temp[512];
// 1. Format input like printf
va_list args;
va_start(args, fmt);
vsnprintf(temp, sizeof(temp), fmt, args);
va_end(args);
printf("%s", temp);
// 2. Split into lines
char *lines[64];
int line_count = 0;
char *ptr = temp;
while (*ptr && line_count < 64) {
lines[line_count++] = ptr;
char *nl = strchr(ptr, '\n');
if (!nl) break;
*nl = '\0';
ptr = nl + 1;
}
// 3. Prepend lines in reverse order (so final order is correct)
for (int i = 0; i < line_count; i++) {
char new_log[SCENE_LOG_SIZE];
snprintf(new_log, sizeof(new_log), "%s\n%s", lines[i], SCENE_LOG);
// Copy back safely
strncpy(SCENE_LOG, new_log, SCENE_LOG_SIZE - 1);
SCENE_LOG[SCENE_LOG_SIZE - 1] = '\0';
}
}
errorret_t sceneInit(void) { errorret_t sceneInit(void) {
memoryZero(&SCENE, sizeof(scene_t)); memoryZero(&SCENE, sizeof(scene_t));
memoryZero(SCENE_LOG, sizeof(SCENE_LOG));
sceneLog("Init\n");
errorOk(); errorOk();
} }
@@ -52,6 +99,7 @@ errorret_t sceneRender(void) {
mat4 view, proj, model; mat4 view, proj, model;
errorChain(shaderBind(&SHADER_UNLIT)); errorChain(shaderBind(&SHADER_UNLIT));
// For each camera.
for(entityid_t camIndex = 0; camIndex < camCount; camIndex++) { for(entityid_t camIndex = 0; camIndex < camCount; camIndex++) {
entityid_t camEnt = camEnts[camIndex]; entityid_t camEnt = camEnts[camIndex];
componentid_t camComp = camComps[camIndex]; componentid_t camComp = camComps[camIndex];
@@ -110,6 +158,36 @@ errorret_t sceneRender(void) {
} }
} }
// Here is where UI will go
glm_ortho(
0.0f, SCREEN.width,
SCREEN.height, 0.0f,
0.1f, 100.0f,
proj
);
glm_lookat(
(vec3){ 0.0f, 0.0f, 1.0f },
(vec3){ 0.0f, 0.0f, 0.0f },
(vec3){ 0.0f, 1.0f, 0.0f },
view
);
glm_mat4_identity(model);
errorChain(shaderBind(&SHADER_UNLIT));
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_PROJECTION, proj));
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_VIEW, view));
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_MODEL, model));
// errorChain(shaderSetTexture(&SHADER_UNLIT, SHADER_UNLIT_0TEXTURE, &DEFAULT_FONT_TEXTURE));
// errorChain(shaderSetColor(&SHADER_UNLIT, SHADER_UNLIT_COLOR, COLOR_WHITE));
errorChain(textDraw(
100, 100,
"Hello World",
COLOR_WHITE,
&DEFAULT_FONT_TILESET,
&DEFAULT_FONT_TEXTURE
));
errorChain(spriteBatchFlush());
errorOk(); errorOk();
} }
+4
View File
@@ -14,6 +14,10 @@ typedef struct {
extern scene_t SCENE; extern scene_t SCENE;
#define SCENE_LOG_SIZE 1024
extern char_t SCENE_LOG[SCENE_LOG_SIZE];
void sceneLog(const char *fmt, ...);
/** /**
* Initialize the scene subsystem. * Initialize the scene subsystem.
* *
+1 -3
View File
@@ -52,9 +52,7 @@ int moduleTextDraw(lua_State *L) {
x, x,
y, y,
text, text,
#if MESH_ENABLE_COLOR color == NULL ? COLOR_WHITE : *color,
color == NULL ? COLOR_WHITE : *color,
#endif
&DEFAULT_FONT_TILESET, &DEFAULT_FONT_TILESET,
&DEFAULT_FONT_TEXTURE &DEFAULT_FONT_TEXTURE
); );
+1 -1
View File
@@ -76,7 +76,7 @@ errorret_t displayInitDolphin(void) {
); );
// Setup cull modes // Setup cull modes
GX_SetCullMode(GX_CULL_BACK); GX_SetCullMode(GX_CULL_NONE);
GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
GX_SetZMode(GX_TRUE, GX_ALWAYS, GX_FALSE); GX_SetZMode(GX_TRUE, GX_ALWAYS, GX_FALSE);
GX_SetDispCopyGamma(GX_GM_1_0); GX_SetDispCopyGamma(GX_GM_1_0);