some progress

This commit is contained in:
veclavtlica
2026-10-07 11:21:21 +03:00
parent 14062e9d00
commit 8d502173a2
26 changed files with 705 additions and 212 deletions
+7 -6
View File
@@ -1,4 +1,5 @@
#include "../Common/cfg.h"
#include "../Common/def.h"
#include "../Common/gem.h"
#include "../Common/std.h"
@@ -6,7 +7,7 @@
#include <stdint.h>
#if COM_DEF_TARGET == COM_DEF_TARGET_WASM
uint8_t plr_draw_buffer[640 * 480 * 4];
uint8_t plr_draw_buffer[COM_CFG_WIDTH * COM_CFG_HEIGHT * 4];
com_def_export_sym(
"plr_draw_get_pixel_buffer") uint8_t *plr_draw_get_pixel_buffer(void) {
@@ -16,9 +17,9 @@ com_def_export_sym(
com_def_export_sym("plr_draw_screen") void plr_draw_screen(
uint8_t *pixel_buffer) {
for (int y = 0; y < 480; y++) {
for (int x = 0; x < 640; x++) {
int pixel_index = (y * 640 + x) * 4;
for (int y = 0; y < COM_CFG_HEIGHT; y++) {
for (int x = 0; x < COM_CFG_WIDTH; x++) {
int pixel_index = (y * COM_CFG_WIDTH + x) * 4;
// Assuming standard Little-Endian 32-bit BGRA format
pixel_buffer[pixel_index + 0] = (x) % 256; // Blue
@@ -28,8 +29,8 @@ com_def_export_sym("plr_draw_screen") void plr_draw_screen(
}
}
com_mat_t proj =
com_mat_perspective(640, 480, 1, 100 * COM_FIX_FRACUNIT, COM_FIX_PIHALF);
com_mat_t proj = com_mat_perspective(COM_CFG_WIDTH, COM_CFG_HEIGHT, 1,
100 * COM_FIX_FRACUNIT, COM_FIX_PIHALF);
com_mat_t view = com_mat_look_at(com_vec_from(0, 0, 0),
com_vec_from(0, COM_FIX_FRACUNIT, 0),
com_vec_from(-COM_FIX_FRACUNIT, 0, 0));