Working wasm build!
This commit is contained in:
parent
456fb19829
commit
5d9d321695
@ -367,7 +367,7 @@ main :: proc() {
|
|||||||
"-sWASM_BIGINT",
|
"-sWASM_BIGINT",
|
||||||
"-sWARN_ON_UNDEFINED_SYMBOLS=0",
|
"-sWARN_ON_UNDEFINED_SYMBOLS=0",
|
||||||
"-sALLOW_MEMORY_GROWTH",
|
"-sALLOW_MEMORY_GROWTH",
|
||||||
"-sASSERTIONS=2",
|
// "-sASSERTIONS=2",
|
||||||
"--shell-file",
|
"--shell-file",
|
||||||
"main_web/index_template.html",
|
"main_web/index_template.html",
|
||||||
"--preload-file",
|
"--preload-file",
|
||||||
|
@ -8,7 +8,8 @@ import "core:sync"
|
|||||||
import "libs:tracy"
|
import "libs:tracy"
|
||||||
|
|
||||||
// When enabled name globals will be initialized automatically
|
// When enabled name globals will be initialized automatically
|
||||||
NAME_STATIC_INIT :: #config(NAME_STATIC_INIT, true)
|
// TODO: this breaks wasm, because it's trying to allocate something before we set up a working allocator...
|
||||||
|
NAME_STATIC_INIT :: #config(NAME_STATIC_INIT, false)
|
||||||
MAX_STATIC_NAMES :: #config(MAX_STATIC_NAMES, 1024)
|
MAX_STATIC_NAMES :: #config(MAX_STATIC_NAMES, 1024)
|
||||||
|
|
||||||
Name :: distinct u32
|
Name :: distinct u32
|
||||||
|
@ -126,6 +126,9 @@ world_init :: proc(world: ^World) {
|
|||||||
physics.scene_init(&world.physics_scene, &g_mem.assetman)
|
physics.scene_init(&world.physics_scene, &g_mem.assetman)
|
||||||
}
|
}
|
||||||
copy_world :: proc(dst, src: ^World) {
|
copy_world :: proc(dst, src: ^World) {
|
||||||
|
if dst == src {
|
||||||
|
return
|
||||||
|
}
|
||||||
copy_track(&dst.track, &src.track)
|
copy_track(&dst.track, &src.track)
|
||||||
physics.copy_physics_scene(&dst.physics_scene, &src.physics_scene)
|
physics.copy_physics_scene(&dst.physics_scene, &src.physics_scene)
|
||||||
scene_copy(&dst.main_scene, &src.main_scene)
|
scene_copy(&dst.main_scene, &src.main_scene)
|
||||||
@ -1483,7 +1486,7 @@ game_init :: proc() {
|
|||||||
assets.assetman_init(&g_mem.assetman)
|
assets.assetman_init(&g_mem.assetman)
|
||||||
|
|
||||||
editor_state_init(&g_mem.es, 100)
|
editor_state_init(&g_mem.es, 100)
|
||||||
runtime_world_init(&g_mem.runtime_world, DEV_BUILD ? 100 : 2)
|
runtime_world_init(&g_mem.runtime_world, DEV_BUILD ? 100 : 1)
|
||||||
|
|
||||||
g_mem.default_font = rl.GetFontDefault()
|
g_mem.default_font = rl.GetFontDefault()
|
||||||
ui.init(&g_mem.ui_context)
|
ui.init(&g_mem.ui_context)
|
||||||
@ -1546,3 +1549,7 @@ game_force_reload :: proc() -> bool {
|
|||||||
game_force_restart :: proc() -> bool {
|
game_force_restart :: proc() -> bool {
|
||||||
return rl.IsKeyPressed(.F6)
|
return rl.IsKeyPressed(.F6)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
game_parent_window_size_changed :: proc(w, h: int) {
|
||||||
|
rl.SetWindowSize(i32(w), i32(h))
|
||||||
|
}
|
||||||
|
@ -5,6 +5,7 @@ import "core:container/bit_array"
|
|||||||
import "core:log"
|
import "core:log"
|
||||||
import "core:math"
|
import "core:math"
|
||||||
import lg "core:math/linalg"
|
import lg "core:math/linalg"
|
||||||
|
import "core:sync"
|
||||||
import "game:halfedge"
|
import "game:halfedge"
|
||||||
import rl "libs:raylib"
|
import rl "libs:raylib"
|
||||||
import "libs:raylib/rlgl"
|
import "libs:raylib/rlgl"
|
||||||
@ -37,8 +38,10 @@ box_mesh: Convex
|
|||||||
@(private = "file")
|
@(private = "file")
|
||||||
triangle_mesh: Convex
|
triangle_mesh: Convex
|
||||||
|
|
||||||
@(init)
|
@(private = "file")
|
||||||
init_box_mesh :: proc() {
|
init_globals_once: sync.Once
|
||||||
|
|
||||||
|
init_globals :: proc() {
|
||||||
box_mesh = Convex(halfedge.mesh_from_vertex_index_list(box_corners_norm[:], box_indices[:], 4))
|
box_mesh = Convex(halfedge.mesh_from_vertex_index_list(box_corners_norm[:], box_indices[:], 4))
|
||||||
|
|
||||||
triangle_mesh = Convex(
|
triangle_mesh = Convex(
|
||||||
@ -50,14 +53,16 @@ init_box_mesh :: proc() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@(fini)
|
// @(fini)
|
||||||
deinit_box_mesh :: proc() {
|
// deinit_box_mesh :: proc() {
|
||||||
delete(box_mesh.vertices)
|
// delete(box_mesh.vertices)
|
||||||
delete(box_mesh.faces)
|
// delete(box_mesh.faces)
|
||||||
delete(box_mesh.edges)
|
// delete(box_mesh.edges)
|
||||||
}
|
// }
|
||||||
|
|
||||||
box_to_convex :: proc(box: Box, allocator := context.allocator) -> (convex: Convex) {
|
box_to_convex :: proc(box: Box, allocator := context.allocator) -> (convex: Convex) {
|
||||||
|
sync.once_do(&init_globals_once, init_globals)
|
||||||
|
|
||||||
convex = halfedge.copy_mesh(box_mesh, allocator)
|
convex = halfedge.copy_mesh(box_mesh, allocator)
|
||||||
|
|
||||||
for &v in convex.vertices {
|
for &v in convex.vertices {
|
||||||
@ -73,6 +78,8 @@ double_sided_triangle_to_convex :: proc(
|
|||||||
) -> (
|
) -> (
|
||||||
convex: Convex,
|
convex: Convex,
|
||||||
) {
|
) {
|
||||||
|
sync.once_do(&init_globals_once, init_globals)
|
||||||
|
|
||||||
convex = halfedge.copy_mesh(triangle_mesh, allocator)
|
convex = halfedge.copy_mesh(triangle_mesh, allocator)
|
||||||
convex.vertices[0].pos = tri[0]
|
convex.vertices[0].pos = tri[0]
|
||||||
convex.vertices[1].pos = tri[1]
|
convex.vertices[1].pos = tri[1]
|
||||||
|
@ -121,15 +121,21 @@ Sim_State :: struct {
|
|||||||
dynamic_tlas: Dynamic_TLAS,
|
dynamic_tlas: Dynamic_TLAS,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEV_BUILD :: #config(DEV, false)
|
||||||
|
NUM_SIM_STATES :: 2 when DEV_BUILD else 1
|
||||||
|
|
||||||
Scene :: struct {
|
Scene :: struct {
|
||||||
assetman: ^assets.Asset_Manager,
|
assetman: ^assets.Asset_Manager,
|
||||||
simulation_states: [2]Sim_State,
|
simulation_states: [NUM_SIM_STATES]Sim_State,
|
||||||
simulation_state_index: i32,
|
simulation_state_index: i32,
|
||||||
solver_state: Solver_State,
|
solver_state: Solver_State,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy current state to next
|
// Copy current state to next
|
||||||
copy_sim_state :: proc(dst: ^Sim_State, src: ^Sim_State) {
|
copy_sim_state :: proc(dst: ^Sim_State, src: ^Sim_State) {
|
||||||
|
if dst == src {
|
||||||
|
return
|
||||||
|
}
|
||||||
tracy.Zone()
|
tracy.Zone()
|
||||||
convex_container_reconcile(&src.convex_container)
|
convex_container_reconcile(&src.convex_container)
|
||||||
|
|
||||||
@ -176,8 +182,9 @@ copy_physics_scene :: proc(dst, src: ^Scene) {
|
|||||||
dst.assetman = src.assetman
|
dst.assetman = src.assetman
|
||||||
dst.simulation_state_index = src.simulation_state_index
|
dst.simulation_state_index = src.simulation_state_index
|
||||||
|
|
||||||
copy_sim_state(&dst.simulation_states[0], &src.simulation_states[0])
|
for i in 0 ..< NUM_SIM_STATES {
|
||||||
copy_sim_state(&dst.simulation_states[1], &src.simulation_states[1])
|
copy_sim_state(&dst.simulation_states[i], &src.simulation_states[i])
|
||||||
|
}
|
||||||
copy_solver_state(&dst.solver_state, &src.solver_state)
|
copy_solver_state(&dst.solver_state, &src.solver_state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ main_start :: proc "c" () {
|
|||||||
// Since we now use js_wasm32 we should be able to remove this and use
|
// Since we now use js_wasm32 we should be able to remove this and use
|
||||||
// context.logger = log.create_console_logger(). However, that one produces
|
// context.logger = log.create_console_logger(). However, that one produces
|
||||||
// extra newlines on web. So it's a bug in that core lib.
|
// extra newlines on web. So it's a bug in that core lib.
|
||||||
// context.logger = create_emscripten_logger()
|
context.logger = create_emscripten_logger()
|
||||||
|
|
||||||
web_context = context
|
web_context = context
|
||||||
|
|
||||||
@ -49,5 +49,5 @@ main_end :: proc "c" () {
|
|||||||
@(export)
|
@(export)
|
||||||
web_window_size_changed :: proc "c" (w: c.int, h: c.int) {
|
web_window_size_changed :: proc "c" (w: c.int, h: c.int) {
|
||||||
context = web_context
|
context = web_context
|
||||||
// game.game_parent_window_size_changed(int(w), int(h))
|
game.game_parent_window_size_changed(int(w), int(h))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user