stream world data from pxl8d to pxl8
This commit is contained in:
parent
39ee0fefb7
commit
a71a9840b2
55 changed files with 5290 additions and 2131 deletions
|
|
@ -1,15 +1,16 @@
|
|||
#include "pxl8_repl.h"
|
||||
#include "pxl8_mem.h"
|
||||
|
||||
#include <linenoise.h>
|
||||
#include <poll.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <stdatomic.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <linenoise.h>
|
||||
#include "pxl8_log.h"
|
||||
#include "pxl8_mem.h"
|
||||
|
||||
#define PXL8_MAX_REPL_COMMAND_SIZE 4096
|
||||
#define PXL8_REPL_QUEUE_SIZE 8
|
||||
|
|
@ -235,6 +236,7 @@ pxl8_repl* pxl8_repl_create(void) {
|
|||
linenoiseHistoryLoad(".pxl8_history");
|
||||
|
||||
g_repl = repl;
|
||||
pxl8_log_set_handler(pxl8_repl_push_log);
|
||||
|
||||
repl->thread = SDL_CreateThread(pxl8_repl_thread, "pxl8-repl", repl);
|
||||
if (!repl->thread) {
|
||||
|
|
@ -260,6 +262,7 @@ void pxl8_repl_destroy(pxl8_repl* repl) {
|
|||
pxl8_repl_flush_logs(repl);
|
||||
|
||||
g_repl = NULL;
|
||||
pxl8_log_set_handler(NULL);
|
||||
|
||||
system("stty sane 2>/dev/null");
|
||||
pxl8_free(repl);
|
||||
|
|
|
|||
|
|
@ -424,27 +424,33 @@ static const char* pxl8_ffi_cdefs =
|
|||
"void pxl8_graph_eval_texture(const pxl8_graph* graph, u8* buffer, i32 width, i32 height);\n"
|
||||
"\n"
|
||||
"typedef struct pxl8_bsp pxl8_bsp;\n"
|
||||
"typedef struct pxl8_bsp_face pxl8_bsp_face;\n"
|
||||
"typedef bool (*pxl8_texture_rule)(const pxl8_vec3* normal, const pxl8_bsp_face* face, const pxl8_bsp* bsp);\n"
|
||||
"\n"
|
||||
"typedef struct pxl8_world_texture {\n"
|
||||
" char name[16];\n"
|
||||
" unsigned int texture_id;\n"
|
||||
" pxl8_texture_rule rule;\n"
|
||||
"} pxl8_world_texture;\n"
|
||||
"u32 pxl8_bsp_face_count(const pxl8_bsp* bsp);\n"
|
||||
"pxl8_vec3 pxl8_bsp_face_normal(const pxl8_bsp* bsp, u32 face_id);\n"
|
||||
"void pxl8_bsp_face_set_material(pxl8_bsp* bsp, u32 face_id, u16 material_id);\n"
|
||||
"void pxl8_bsp_set_material(pxl8_bsp* bsp, u16 material_id, const pxl8_gfx_material* material);\n"
|
||||
"void pxl8_bsp_set_wireframe(pxl8_bsp* bsp, bool wireframe);\n"
|
||||
"\n"
|
||||
"typedef enum { PXL8_CHUNK_VXL = 0, PXL8_CHUNK_BSP = 1 } pxl8_chunk_type;\n"
|
||||
"\n"
|
||||
"typedef struct pxl8_chunk {\n"
|
||||
" pxl8_chunk_type type;\n"
|
||||
" u32 id;\n"
|
||||
" u32 version;\n"
|
||||
" i32 cx, cy, cz;\n"
|
||||
" union {\n"
|
||||
" void* voxel;\n"
|
||||
" pxl8_bsp* bsp;\n"
|
||||
" };\n"
|
||||
"} pxl8_chunk;\n"
|
||||
"\n"
|
||||
"typedef struct pxl8_world pxl8_world;\n"
|
||||
"pxl8_world* pxl8_world_create(void);\n"
|
||||
"void pxl8_world_destroy(pxl8_world* world);\n"
|
||||
"int pxl8_world_generate(pxl8_world* world, pxl8_gfx* gfx, const pxl8_procgen_params* params);\n"
|
||||
"int pxl8_world_load(pxl8_world* world, const char* path);\n"
|
||||
"void pxl8_world_unload(pxl8_world* world);\n"
|
||||
"int pxl8_world_apply_textures(pxl8_world* world, const pxl8_world_texture* textures, unsigned int count);\n"
|
||||
"\n"
|
||||
"pxl8_world* pxl8_get_world(pxl8* sys);\n"
|
||||
"pxl8_chunk* pxl8_world_active_chunk(pxl8_world* world);\n"
|
||||
"bool pxl8_world_check_collision(const pxl8_world* world, pxl8_vec3 pos, float radius);\n"
|
||||
"bool pxl8_world_is_loaded(const pxl8_world* world);\n"
|
||||
"void pxl8_world_render(pxl8_world* world, pxl8_gfx* gfx, pxl8_vec3 camera_pos);\n"
|
||||
"pxl8_vec3 pxl8_world_resolve_collision(const pxl8_world* world, pxl8_vec3 from, pxl8_vec3 to, float radius);\n"
|
||||
"void pxl8_world_set_wireframe(pxl8_world* world, bool enabled);\n"
|
||||
"\n"
|
||||
"typedef struct { i32 cursor_x; i32 cursor_y; bool cursor_down; bool cursor_clicked; u32 hot_id; u32 active_id; } pxl8_gui_state;\n"
|
||||
"pxl8_gui_state* pxl8_gui_state_create(void);\n"
|
||||
|
|
@ -517,8 +523,7 @@ static const char* pxl8_ffi_cdefs =
|
|||
"void pxl8_sfx_stop_voice(pxl8_sfx_context* ctx, u16 voice_id);\n"
|
||||
"\n"
|
||||
"typedef struct pxl8_net pxl8_net;\n"
|
||||
"typedef enum pxl8_net_mode { PXL8_NET_LOCAL = 0, PXL8_NET_REMOTE } pxl8_net_mode;\n"
|
||||
"typedef struct pxl8_net_config { const char* address; pxl8_net_mode mode; u16 port; } pxl8_net_config;\n"
|
||||
"typedef struct pxl8_net_config { const char* address; u16 port; } pxl8_net_config;\n"
|
||||
"typedef enum pxl8_cmd_type { PXL8_CMD_NONE = 0, PXL8_CMD_SPAWN_ENTITY } pxl8_cmd_type;\n"
|
||||
"\n"
|
||||
"typedef struct pxl8_command_msg {\n"
|
||||
|
|
@ -574,6 +579,7 @@ static const char* pxl8_ffi_cdefs =
|
|||
"const pxl8_snapshot_header* pxl8_net_snapshot(const pxl8_net* net);\n"
|
||||
"u64 pxl8_net_tick(const pxl8_net* net);\n"
|
||||
"void pxl8_net_update(pxl8_net* net, f32 dt);\n"
|
||||
"pxl8_net* pxl8_get_net(const pxl8* sys);\n"
|
||||
"\n"
|
||||
"void pxl8_bit_clear(u32* val, u8 bit);\n"
|
||||
"u32 pxl8_bit_count(u32 val);\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue