wip sw renderer...bsp is borked, also lots of other things
This commit is contained in:
parent
415d424057
commit
71787869e0
58 changed files with 8151 additions and 1261 deletions
|
|
@ -27,11 +27,16 @@ static const char* pxl8_ffi_cdefs =
|
|||
"u8 pxl8_gfx_find_color(pxl8_gfx* gfx, u32 color);\n"
|
||||
"i32 pxl8_gfx_get_height(pxl8_gfx* ctx);\n"
|
||||
"typedef struct pxl8_palette pxl8_palette;\n"
|
||||
"pxl8_palette* pxl8_gfx_get_palette(pxl8_gfx* gfx);\n"
|
||||
"pxl8_palette* pxl8_gfx_palette(pxl8_gfx* gfx);\n"
|
||||
"u32 pxl8_palette_color(const pxl8_palette* pal, u8 idx);\n"
|
||||
"void pxl8_palette_set_rgb(pxl8_palette* pal, u8 idx, u8 r, u8 g, u8 b);\n"
|
||||
"void pxl8_gfx_set_palette_colors(pxl8_gfx* gfx, const u32* colors, u16 count);\n"
|
||||
"i32 pxl8_palette_index(const pxl8_palette* pal, u32 color);\n"
|
||||
"u8 pxl8_palette_ramp_index(const pxl8_palette* pal, u8 position);\n"
|
||||
"typedef struct pxl8_colormap pxl8_colormap;\n"
|
||||
"pxl8_colormap* pxl8_gfx_colormap(pxl8_gfx* gfx);\n"
|
||||
"void pxl8_set_colormap(pxl8_colormap* cm, const u8* data, u32 size);\n"
|
||||
"void pxl8_gfx_ensure_blend_tables(pxl8_gfx* gfx);\n"
|
||||
"i32 pxl8_gfx_get_width(pxl8_gfx* ctx);\n"
|
||||
"void pxl8_2d_circle(pxl8_gfx* ctx, i32 x, i32 y, i32 r, u32 color);\n"
|
||||
"void pxl8_2d_circle_fill(pxl8_gfx* ctx, i32 x, i32 y, i32 r, u32 color);\n"
|
||||
|
|
@ -224,6 +229,8 @@ static const char* pxl8_ffi_cdefs =
|
|||
"pxl8_mat4 pxl8_3d_camera_get_view(const pxl8_3d_camera* cam);\n"
|
||||
"pxl8_mat4 pxl8_3d_camera_get_projection(const pxl8_3d_camera* cam);\n"
|
||||
"void pxl8_3d_camera_update(pxl8_3d_camera* cam, f32 dt);\n"
|
||||
"typedef struct pxl8_projected_point { i32 x; i32 y; f32 depth; bool visible; } pxl8_projected_point;\n"
|
||||
"pxl8_projected_point pxl8_3d_camera_world_to_screen(const pxl8_3d_camera* cam, pxl8_vec3 world_pos, u32 screen_width, u32 screen_height);\n"
|
||||
"\n"
|
||||
"typedef enum pxl8_gfx_effect { PXL8_GFX_EFFECT_GLOWS = 0 } pxl8_gfx_effect;\n"
|
||||
"\n"
|
||||
|
|
@ -252,8 +259,9 @@ static const char* pxl8_ffi_cdefs =
|
|||
"\n"
|
||||
"typedef enum pxl8_blend_mode { PXL8_BLEND_OPAQUE = 0, PXL8_BLEND_ALPHA_TEST, PXL8_BLEND_ALPHA, PXL8_BLEND_ADDITIVE } pxl8_blend_mode;\n"
|
||||
"\n"
|
||||
"typedef struct pxl8_material {\n"
|
||||
"typedef struct pxl8_gfx_material {\n"
|
||||
" u32 texture_id;\n"
|
||||
" u32 lightmap_id;\n"
|
||||
" u8 alpha;\n"
|
||||
" u8 blend_mode;\n"
|
||||
" bool dither;\n"
|
||||
|
|
@ -261,13 +269,15 @@ static const char* pxl8_ffi_cdefs =
|
|||
" bool dynamic_lighting;\n"
|
||||
" bool per_pixel;\n"
|
||||
" bool vertex_color_passthrough;\n"
|
||||
" bool wireframe;\n"
|
||||
" f32 emissive_intensity;\n"
|
||||
"} pxl8_material;\n"
|
||||
"} pxl8_gfx_material;\n"
|
||||
"\n"
|
||||
"typedef struct pxl8_vertex {\n"
|
||||
" pxl8_vec3 position;\n"
|
||||
" pxl8_vec3 normal;\n"
|
||||
" f32 u, v;\n"
|
||||
" f32 lu, lv;\n"
|
||||
" u8 color;\n"
|
||||
" u8 light;\n"
|
||||
" u8 _pad[2];\n"
|
||||
|
|
@ -287,7 +297,10 @@ static const char* pxl8_ffi_cdefs =
|
|||
"void pxl8_mesh_clear(pxl8_mesh* mesh);\n"
|
||||
"u16 pxl8_mesh_push_vertex(pxl8_mesh* mesh, pxl8_vertex v);\n"
|
||||
"void pxl8_mesh_push_triangle(pxl8_mesh* mesh, u16 i0, u16 i1, u16 i2);\n"
|
||||
"void pxl8_3d_draw_mesh(pxl8_gfx* gfx, const pxl8_mesh* mesh, const pxl8_mat4* model, const pxl8_material* material);\n"
|
||||
"void pxl8_3d_draw_mesh(pxl8_gfx* gfx, const pxl8_mesh* mesh, const pxl8_mat4* model, const pxl8_gfx_material* material);\n"
|
||||
"void pxl8_3d_draw_mesh_wireframe(pxl8_gfx* gfx, const pxl8_mesh* mesh, pxl8_mat4 model, u8 color);\n"
|
||||
"\n"
|
||||
"u32 pxl8_hash32(u32 x);\n"
|
||||
"\n"
|
||||
"pxl8_mat4 pxl8_mat4_identity(void);\n"
|
||||
"pxl8_mat4 pxl8_mat4_lookat(pxl8_vec3 eye, pxl8_vec3 center, pxl8_vec3 up);\n"
|
||||
|
|
@ -316,18 +329,76 @@ static const char* pxl8_ffi_cdefs =
|
|||
" int num_rooms;\n"
|
||||
"} pxl8_procgen_params;\n"
|
||||
"\n"
|
||||
"typedef struct pxl8_procgen_tex_params {\n"
|
||||
" char name[16];\n"
|
||||
" unsigned int seed;\n"
|
||||
" int width;\n"
|
||||
" int height;\n"
|
||||
" float scale;\n"
|
||||
" float roughness;\n"
|
||||
" unsigned char base_color;\n"
|
||||
" unsigned char variation;\n"
|
||||
"} pxl8_procgen_tex_params;\n"
|
||||
"typedef enum pxl8_graph_op {\n"
|
||||
" PXL8_OP_CONST = 0,\n"
|
||||
" PXL8_OP_INPUT_AGE,\n"
|
||||
" PXL8_OP_INPUT_SEED,\n"
|
||||
" PXL8_OP_INPUT_TIME,\n"
|
||||
" PXL8_OP_INPUT_X,\n"
|
||||
" PXL8_OP_INPUT_Y,\n"
|
||||
"\n"
|
||||
"void pxl8_procgen_tex(u8* buffer, const pxl8_procgen_tex_params* params);\n"
|
||||
" PXL8_OP_ABS,\n"
|
||||
" PXL8_OP_CEIL,\n"
|
||||
" PXL8_OP_COS,\n"
|
||||
" PXL8_OP_FLOOR,\n"
|
||||
" PXL8_OP_FRACT,\n"
|
||||
" PXL8_OP_NEGATE,\n"
|
||||
" PXL8_OP_SIN,\n"
|
||||
" PXL8_OP_SQRT,\n"
|
||||
"\n"
|
||||
" PXL8_OP_ADD,\n"
|
||||
" PXL8_OP_DIV,\n"
|
||||
" PXL8_OP_MAX,\n"
|
||||
" PXL8_OP_MIN,\n"
|
||||
" PXL8_OP_MOD,\n"
|
||||
" PXL8_OP_MUL,\n"
|
||||
" PXL8_OP_POW,\n"
|
||||
" PXL8_OP_SUB,\n"
|
||||
"\n"
|
||||
" PXL8_OP_CLAMP,\n"
|
||||
" PXL8_OP_LERP,\n"
|
||||
" PXL8_OP_SELECT,\n"
|
||||
" PXL8_OP_SMOOTHSTEP,\n"
|
||||
"\n"
|
||||
" PXL8_OP_NOISE_FBM,\n"
|
||||
" PXL8_OP_NOISE_PERLIN,\n"
|
||||
" PXL8_OP_NOISE_RIDGED,\n"
|
||||
" PXL8_OP_NOISE_TURBULENCE,\n"
|
||||
" PXL8_OP_NOISE_VALUE,\n"
|
||||
"\n"
|
||||
" PXL8_OP_VORONOI_CELL,\n"
|
||||
" PXL8_OP_VORONOI_EDGE,\n"
|
||||
" PXL8_OP_VORONOI_ID,\n"
|
||||
"\n"
|
||||
" PXL8_OP_GRADIENT_LINEAR,\n"
|
||||
" PXL8_OP_GRADIENT_RADIAL,\n"
|
||||
"\n"
|
||||
" PXL8_OP_QUANTIZE,\n"
|
||||
" PXL8_OP_COUNT\n"
|
||||
"} pxl8_graph_op;\n"
|
||||
"\n"
|
||||
"typedef struct pxl8_node {\n"
|
||||
" u8 in[4];\n"
|
||||
" u8 op;\n"
|
||||
" u8 out;\n"
|
||||
" f32 param;\n"
|
||||
"} pxl8_node;\n"
|
||||
"\n"
|
||||
"typedef struct pxl8_graph {\n"
|
||||
" u32 capacity;\n"
|
||||
" u32 count;\n"
|
||||
" pxl8_node* nodes;\n"
|
||||
" u8 output_reg;\n"
|
||||
" u32 seed;\n"
|
||||
"} pxl8_graph;\n"
|
||||
"\n"
|
||||
"pxl8_graph* pxl8_graph_create(u32 capacity);\n"
|
||||
"void pxl8_graph_destroy(pxl8_graph* graph);\n"
|
||||
"void pxl8_graph_clear(pxl8_graph* graph);\n"
|
||||
"u8 pxl8_graph_add_node(pxl8_graph* graph, pxl8_graph_op op, u8 in0, u8 in1, u8 in2, u8 in3, f32 param);\n"
|
||||
"void pxl8_graph_set_output(pxl8_graph* graph, u8 reg);\n"
|
||||
"void pxl8_graph_set_seed(pxl8_graph* graph, u32 seed);\n"
|
||||
"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"
|
||||
|
|
@ -350,12 +421,13 @@ static const char* pxl8_ffi_cdefs =
|
|||
"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, u8 color);\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"
|
||||
"void pxl8_gui_state_destroy(pxl8_gui_state* state);\n"
|
||||
"void pxl8_gui_begin_frame(pxl8_gui_state* state);\n"
|
||||
"void pxl8_gui_end_frame(pxl8_gui_state* state);\n"
|
||||
"void pxl8_gui_begin_frame(pxl8_gui_state* state, pxl8_gfx* gfx);\n"
|
||||
"void pxl8_gui_end_frame(pxl8_gui_state* state, pxl8_gfx* gfx);\n"
|
||||
"void pxl8_gui_cursor_move(pxl8_gui_state* state, i32 x, i32 y);\n"
|
||||
"void pxl8_gui_cursor_down(pxl8_gui_state* state);\n"
|
||||
"void pxl8_gui_cursor_up(pxl8_gui_state* state);\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue