diff --git a/armorforge/sources/tab_scene.ts b/armorforge/sources/tab_scene.ts index 037617a9..197c235a 100644 --- a/armorforge/sources/tab_scene.ts +++ b/armorforge/sources/tab_scene.ts @@ -40,7 +40,7 @@ function tab_scene_import_mesh_done() { tab_scene_select_object(mo); } - app_notify_on_next_frame(function() { + sys_notify_on_next_frame(function() { util_mesh_merge(); tab_scene_select_object(context_raw.selected_object.ext); tab_scene_sort(); @@ -141,7 +141,7 @@ function tab_scene_new_object(mesh_name: string) { map_set(data_cached_meshes, md._.handle, md); array_push(project_paint_objects, mo); tab_scene_import_mesh_done(); - app_notify_on_next_frame(function(mo: mesh_object_t) { + sys_notify_on_next_frame(function(mo: mesh_object_t) { tab_scene_select_object(mo); }, mo); } diff --git a/armorlab/sources/base_ext.ts b/armorlab/sources/base_ext.ts index 3ff7209a..5ea23a69 100644 --- a/armorlab/sources/base_ext.ts +++ b/armorlab/sources/base_ext.ts @@ -5,8 +5,8 @@ function base_ext_init() { function base_ext_render() { if (context_raw.frame == 2) { - app_notify_on_next_frame(function () { - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { tab_meshes_set_default_mesh(".Sphere"); }); }); diff --git a/armorlab/sources/layers_ext.ts b/armorlab/sources/layers_ext.ts index 13386386..95bf141b 100644 --- a/armorlab/sources/layers_ext.ts +++ b/armorlab/sources/layers_ext.ts @@ -73,7 +73,7 @@ function layers_ext_on_resized() { map_delete(render_path_render_targets, "texpaint_node_target"); } - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { layers_init(); }); diff --git a/armorlab/sources/make_material.ts b/armorlab/sources/make_material.ts index 92016db3..d43448bd 100644 --- a/armorlab/sources/make_material.ts +++ b/armorlab/sources/make_material.ts @@ -112,7 +112,7 @@ function make_material_get_displace_strength(): f32 { } function make_material_delete_context(c: shader_context_t) { - app_notify_on_next_frame(function (c: shader_context_t) { // Ensure pipeline is no longer in use + sys_notify_on_next_frame(function (c: shader_context_t) { // Ensure pipeline is no longer in use shader_context_delete(c); }, c); } diff --git a/armorlab/sources/nodes/brush_output_node_ext.ts b/armorlab/sources/nodes/brush_output_node_ext.ts index b78a0e4c..11bb9bac 100644 --- a/armorlab/sources/nodes/brush_output_node_ext.ts +++ b/armorlab/sources/nodes/brush_output_node_ext.ts @@ -73,7 +73,7 @@ function brush_output_node_get_as_image(self: brush_output_node_t, from: i32): i function brush_output_node_parse_inputs() { if (!context_raw.registered) { context_raw.registered = true; - app_notify_on_update(brush_output_node_update); + sys_notify_on_update(brush_output_node_update); } context_raw.paint_vec = context_raw.coords; @@ -131,20 +131,20 @@ function brush_output_node_run(from: i32) { } function brush_output_node_update() { - let paint_x: f32 = mouse_view_x() / app_w(); - let paint_y: f32 = mouse_view_y() / app_h(); + let paint_x: f32 = mouse_view_x() / sys_w(); + let paint_y: f32 = mouse_view_y() / sys_h(); if (mouse_started()) { - context_raw.start_x = mouse_view_x() / app_w(); - context_raw.start_y = mouse_view_y() / app_h(); + context_raw.start_x = mouse_view_x() / sys_w(); + context_raw.start_y = mouse_view_y() / sys_h(); } if (pen_down()) { - paint_x = pen_view_x() / app_w(); - paint_y = pen_view_y() / app_h(); + paint_x = pen_view_x() / sys_w(); + paint_y = pen_view_y() / sys_h(); } if (pen_started()) { - context_raw.start_x = pen_view_x() / app_w(); - context_raw.start_y = pen_view_y() / app_h(); + context_raw.start_x = pen_view_x() / sys_w(); + context_raw.start_y = pen_view_y() / sys_h(); } if (operator_shortcut(map_get(config_keymap, "brush_ruler") + "+" + map_get(config_keymap, "action_paint"), shortcut_type_t.DOWN)) { diff --git a/armorlab/sources/nodes/inpaint_node.ts b/armorlab/sources/nodes/inpaint_node.ts index edfaa5d8..fc4320e4 100644 --- a/armorlab/sources/nodes/inpaint_node.ts +++ b/armorlab/sources/nodes/inpaint_node.ts @@ -32,7 +32,7 @@ function inpaint_node_init() { if (inpaint_node_mask == null) { inpaint_node_mask = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { _gpu_begin(inpaint_node_mask); iron_gpu_clear(color_from_floats(1.0, 1.0, 1.0, 1.0)); _gpu_end(); @@ -85,7 +85,7 @@ function inpaint_node_get_as_image(self: inpaint_node_t, from: i32): iron_gpu_te } function inpaint_node_get_cached_image(self: inpaint_node_t): iron_gpu_texture_t { - app_notify_on_next_frame(function (self: inpaint_node_t) { + sys_notify_on_next_frame(function (self: inpaint_node_t) { let source: iron_gpu_texture_t = logic_node_input_get_as_image(self.base.inputs[0]); _gpu_begin(inpaint_node_image); iron_gpu_set_pipeline(pipes_inpaint_preview); diff --git a/armorlab/sources/nodes/photo_to_pbr_node.ts b/armorlab/sources/nodes/photo_to_pbr_node.ts index 76228f0f..6b584bfc 100644 --- a/armorlab/sources/nodes/photo_to_pbr_node.ts +++ b/armorlab/sources/nodes/photo_to_pbr_node.ts @@ -157,7 +157,7 @@ function photo_to_pbr_node_get_as_image(self: photo_to_pbr_node_t, from: i32): i draw_begin(photo_to_pbr_node_images[from]); draw_image(temp2, x * photo_to_pbr_node_tile_w, y * photo_to_pbr_node_tile_w); draw_end(); - app_notify_on_next_frame(function(temp2: iron_gpu_texture_t) { + sys_notify_on_next_frame(function(temp2: iron_gpu_texture_t) { iron_unload_image(temp2); }, temp2); } diff --git a/armorlab/sources/nodes/rgb_node.ts b/armorlab/sources/nodes/rgb_node.ts index 6282940d..74dca075 100644 --- a/armorlab/sources/nodes/rgb_node.ts +++ b/armorlab/sources/nodes/rgb_node.ts @@ -16,7 +16,7 @@ function rgb_node_create(raw: ui_node_t, args: f32_array_t): rgb_node_t { function rgb_node_get_as_image(self: rgb_node_t, from: i32): iron_gpu_texture_t { if (self.image != null) { - app_notify_on_next_frame(function (self: rgb_node_t) { + sys_notify_on_next_frame(function (self: rgb_node_t) { iron_unload_image(self.image); }, self); } diff --git a/armorlab/sources/render_path_paint.ts b/armorlab/sources/render_path_paint.ts index 41b95b65..b6cccf15 100644 --- a/armorlab/sources/render_path_paint.ts +++ b/armorlab/sources/render_path_paint.ts @@ -176,8 +176,8 @@ function render_path_paint_commands_cursor() { let mx: f32 = context_raw.paint_vec.x; let my: f32 = 1.0 - context_raw.paint_vec.y; if (context_raw.brush_locked) { - mx = (context_raw.lock_started_x - app_x()) / app_w(); - my = 1.0 - (context_raw.lock_started_y - app_y()) / app_h(); + mx = (context_raw.lock_started_x - sys_x()) / sys_w(); + my = 1.0 - (context_raw.lock_started_y - sys_y()) / sys_h(); } let radius: f32 = context_raw.brush_radius; render_path_paint_draw_cursor(mx, my, radius / 3.4); diff --git a/armorlab/sources/ui_nodes_ext.ts b/armorlab/sources/ui_nodes_ext.ts index 5e3242b2..2d2ed04e 100644 --- a/armorlab/sources/ui_nodes_ext.ts +++ b/armorlab/sources/ui_nodes_ext.ts @@ -8,7 +8,7 @@ function ui_nodes_ext_delay_idle_sleep() { function ui_nodes_ext_draw_buttons(ew: f32, start_y: f32) { let ui: ui_t = ui_nodes_ui; if (ui_button(tr("Run"))) { - // app_notify_on_init(function() { + // sys_notify_on_init(function() { ui_nodes_ext_run(); // }); } @@ -31,7 +31,7 @@ function ui_nodes_ext_draw_buttons(ew: f32, start_y: f32) { } function ui_nodes_ext_run() { - app_notify_on_render_2d(ui_nodes_ext_delay_idle_sleep); + sys_notify_on_render_2d(ui_nodes_ext_delay_idle_sleep); console_progress(tr("Processing")); @@ -124,7 +124,7 @@ function ui_nodes_ext_run() { console_progress(null); context_raw.ddirty = 2; - app_remove_render_2d(ui_nodes_ext_delay_idle_sleep); + sys_remove_render_2d(ui_nodes_ext_delay_idle_sleep); render_path_raytrace_ready = false; } diff --git a/armorpaint/sources/layers_ext.ts b/armorpaint/sources/layers_ext.ts index a9bb6a69..fde47f09 100644 --- a/armorpaint/sources/layers_ext.ts +++ b/armorpaint/sources/layers_ext.ts @@ -167,7 +167,7 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t } function layers_ext_on_resized() { - app_notify_on_init(function () { + sys_notify_on_init(function () { layers_resize(); let _layer: slot_layer_t = context_raw.layer; let _material: slot_material_t = context_raw.material; diff --git a/armorpaint/sources/make_material.ts b/armorpaint/sources/make_material.ts index 81560ba6..2f255d25 100644 --- a/armorpaint/sources/make_material.ts +++ b/armorpaint/sources/make_material.ts @@ -256,7 +256,7 @@ function make_material_bake_node_previews() { let key: string = keys[i]; if (array_index_of(context_raw.node_previews_used, key) == -1) { let image: iron_gpu_texture_t = map_get(context_raw.node_previews, key); - app_notify_on_next_frame(function (image: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (image: iron_gpu_texture_t) { iron_unload_image(image); }, image); map_delete(context_raw.node_previews, key); @@ -532,7 +532,7 @@ function make_material_get_displace_strength(): f32 { } function make_material_delete_context(c: shader_context_t) { - app_notify_on_next_frame(function (c: shader_context_t) { // Ensure pipeline is no longer in use + sys_notify_on_next_frame(function (c: shader_context_t) { // Ensure pipeline is no longer in use shader_context_delete(c); }, c); } diff --git a/armorpaint/sources/nodes/brush_output_node_ext.ts b/armorpaint/sources/nodes/brush_output_node_ext.ts index c5ecdfe4..ad066ace 100644 --- a/armorpaint/sources/nodes/brush_output_node_ext.ts +++ b/armorpaint/sources/nodes/brush_output_node_ext.ts @@ -82,8 +82,8 @@ function brush_output_node_run(self: brush_output_node_t, from: i32) { // Do not paint over floating toolbar if (context_is_floating_toolbar()) { let w: i32 = ui_toolbar_get_x() + ui_toolbar_get_w(); - left += w / app_w(); - top += w / app_h(); + left += w / sys_w(); + top += w / sys_h(); } // First time init diff --git a/armorpaint/sources/nodes/input_node.ts b/armorpaint/sources/nodes/input_node.ts index 36a4109b..6f849876 100644 --- a/armorpaint/sources/nodes/input_node.ts +++ b/armorpaint/sources/nodes/input_node.ts @@ -21,7 +21,7 @@ function input_node_create(raw: ui_node_t, args: f32_array_t): input_node_t { if (!input_node_registered) { input_node_registered = true; - app_notify_on_update(input_node_update, n); + sys_notify_on_update(input_node_update, n); } return n; @@ -39,21 +39,21 @@ function input_node_update(self: float_node_t) { operator_shortcut(map_get(config_keymap, "brush_ruler") + "+" + map_get(config_keymap, "action_paint"), shortcut_type_t.DOWN) || decal_mask); - let paint_x: f32 = mouse_view_x() / app_w(); - let paint_y: f32 = mouse_view_y() / app_h(); + let paint_x: f32 = mouse_view_x() / sys_w(); + let paint_y: f32 = mouse_view_y() / sys_h(); if (mouse_started()) { - input_node_start_x = mouse_view_x() / app_w(); - input_node_start_y = mouse_view_y() / app_h(); + input_node_start_x = mouse_view_x() / sys_w(); + input_node_start_y = mouse_view_y() / sys_h(); } if (pen_down()) { - paint_x = pen_view_x() / app_w(); - paint_y = pen_view_y() / app_h(); + paint_x = pen_view_x() / sys_w(); + paint_y = pen_view_y() / sys_h(); } if (pen_started()) { - input_node_start_x = pen_view_x() / app_w(); - input_node_start_y = pen_view_y() / app_h(); + input_node_start_x = pen_view_x() / sys_w(); + input_node_start_y = pen_view_y() / sys_h(); } if (operator_shortcut(map_get(config_keymap, "brush_ruler") + "+" + map_get(config_keymap, "action_paint"), shortcut_type_t.DOWN)) { @@ -102,8 +102,8 @@ function input_node_update(self: float_node_t) { } if (context_raw.brush_lazy_radius > 0) { - let v1: vec4_t = vec4_create(context_raw.brush_lazy_x * app_w(), context_raw.brush_lazy_y * app_h(), 0.0); - let v2: vec4_t = vec4_create(input_node_coords.x * app_w(), input_node_coords.y * app_h(), 0.0); + let v1: vec4_t = vec4_create(context_raw.brush_lazy_x * sys_w(), context_raw.brush_lazy_y * sys_h(), 0.0); + let v2: vec4_t = vec4_create(input_node_coords.x * sys_w(), input_node_coords.y * sys_h(), 0.0); let d: f32 = vec4_dist(v1, v2); let r: f32 = context_raw.brush_lazy_radius * 85; if (d > r) { @@ -113,8 +113,8 @@ function input_node_update(self: float_node_t) { v3 = vec4_mult(v3, 1.0 - context_raw.brush_lazy_step); v3 = vec4_mult(v3, r); v2 = vec4_add(v1, v3); - input_node_coords.x = v2.x / app_w(); - input_node_coords.y = v2.y / app_h(); + input_node_coords.x = v2.x / sys_w(); + input_node_coords.y = v2.y / sys_h(); // Parse brush inputs once on next draw context_raw.painted = -1; } diff --git a/armorpaint/sources/render_path_paint.ts b/armorpaint/sources/render_path_paint.ts index f6fb5f11..baea79a7 100644 --- a/armorpaint/sources/render_path_paint.ts +++ b/armorpaint/sources/render_path_paint.ts @@ -229,7 +229,7 @@ function render_path_paint_commands_paint(dilation: bool = true) { else { let texpaint: string = "texpaint" + tid; - if (context_raw.tool == workspace_tool_t.BAKE && context_raw.brush_time == time_delta()) { + if (context_raw.tool == workspace_tool_t.BAKE && context_raw.brush_time == sys_delta()) { // Clear to black on bake start render_path_set_target(texpaint); render_path_clear_target(0xff000000); @@ -377,8 +377,8 @@ function render_path_paint_commands_live_brush() { let _x: f32 = context_raw.paint_vec.x; let _y: f32 = context_raw.paint_vec.y; if (context_raw.brush_locked) { - context_raw.paint_vec.x = (context_raw.lock_started_x - app_x()) / app_w(); - context_raw.paint_vec.y = (context_raw.lock_started_y - app_y()) / app_h(); + context_raw.paint_vec.x = (context_raw.lock_started_x - sys_x()) / sys_w(); + context_raw.paint_vec.y = (context_raw.lock_started_y - sys_y()) / sys_h(); } let _last_x: f32 = context_raw.last_paint_vec_x; let _last_y: f32 = context_raw.last_paint_vec_y; @@ -427,8 +427,8 @@ function render_path_paint_commands_cursor() { let mx: f32 = context_raw.paint_vec.x; let my: f32 = 1.0 - context_raw.paint_vec.y; if (context_raw.brush_locked) { - mx = (context_raw.lock_started_x - app_x()) / app_w(); - my = 1.0 - (context_raw.lock_started_y - app_y()) / app_h(); + mx = (context_raw.lock_started_x - sys_x()) / sys_w(); + my = 1.0 - (context_raw.lock_started_y - sys_y()) / sys_h(); } let radius: f32 = decal_mask ? context_raw.brush_decal_mask_radius : context_raw.brush_radius; render_path_paint_draw_cursor(mx, my, context_raw.brush_nodes_radius * radius / 3.4); @@ -605,7 +605,7 @@ function _render_path_paint_deriv() { if (render_path_paint_push_undo_last) { history_paint(); } - app_notify_on_init(_render_path_paint_final); + sys_notify_on_init(_render_path_paint_final); } function render_path_paint_is_rt_bake(): bool { @@ -672,10 +672,10 @@ function render_path_paint_draw() { context_select_paint_object(_paint_object); if (context_raw.bake_type == bake_type_t.DERIVATIVE) { - app_notify_on_init(_render_path_paint_deriv); + sys_notify_on_init(_render_path_paint_deriv); } else { - app_notify_on_init(_render_path_paint_final); + sys_notify_on_init(_render_path_paint_final); } } } @@ -761,7 +761,7 @@ function render_path_paint_set_plane_mesh() { let tw: f32 = 0.95 * ui_view2d_pan_scale; let tx: f32 = ui_view2d_pan_x / ui_view2d_ww; - let ty: f32 = ui_view2d_pan_y / app_h(); + let ty: f32 = ui_view2d_pan_y / sys_h(); m = mat4_identity(); m = mat4_scale(m, vec4_create(tw, tw, 1)); m = mat4_set_loc(m, vec4_create(tx, ty, 0)); diff --git a/armorpaint/sources/ui_header_ext.ts b/armorpaint/sources/ui_header_ext.ts index 5463e65b..b354650e 100644 --- a/armorpaint/sources/ui_header_ext.ts +++ b/armorpaint/sources/ui_header_ext.ts @@ -51,7 +51,7 @@ function ui_header_draw_tool_properties(ui: ui_t) { context_set_layer(context_raw.layer.parent); } let m: slot_layer_t = layers_new_mask(false, context_raw.layer); - app_notify_on_next_frame(function (m: slot_layer_t) { + sys_notify_on_next_frame(function (m: slot_layer_t) { _gpu_begin(m.texpaint); iron_gpu_set_pipeline(pipes_colorid_to_mask); let rt: render_target_t = map_get(render_path_render_targets, "texpaint_colorid"); @@ -153,7 +153,7 @@ function ui_header_draw_tool_properties(ui: ui_t) { if (!baking && ui_button(tr("Bake"))) { context_raw.pdirty = rt_bake ? context_raw.bake_samples : 1; context_raw.rdirty = 3; - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { context_raw.layer_preview_dirty = true; }); ui_base_hwnds[0].redraws = 2; diff --git a/armorsculpt/sources/base_ext.ts b/armorsculpt/sources/base_ext.ts index 9a904310..bb5d4f8d 100644 --- a/armorsculpt/sources/base_ext.ts +++ b/armorsculpt/sources/base_ext.ts @@ -10,8 +10,8 @@ function base_ext_render() { base_init_undo_layers(); - app_notify_on_next_frame(function () { - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { context_raw.project_type = project_model_t.SPHERE; project_new(); }); diff --git a/armorsculpt/sources/import_mesh.ts b/armorsculpt/sources/import_mesh.ts index e2141092..fcd71aaf 100644 --- a/armorsculpt/sources/import_mesh.ts +++ b/armorsculpt/sources/import_mesh.ts @@ -108,7 +108,7 @@ function _import_mesh_make_mesh(mesh: raw_mesh_t) { slot_layer_unload(l); } layers_new_layer(false); - app_notify_on_init(layers_init); + sys_notify_on_init(layers_init); history_reset(); } @@ -124,9 +124,9 @@ function _import_mesh_make_mesh(mesh: raw_mesh_t) { ui_base_hwnds[tab_area_t.SIDEBAR1].redraws = 2; // Wait for add_mesh calls to finish - app_notify_on_init(import_mesh_finish_import); + sys_notify_on_init(import_mesh_finish_import); - app_notify_on_next_frame(function (mesh: raw_mesh_t) { + sys_notify_on_next_frame(function (mesh: raw_mesh_t) { import_mesh_pack_to_texture(mesh); }, mesh); } diff --git a/armorsculpt/sources/make_material.ts b/armorsculpt/sources/make_material.ts index aaa9a0ec..d993e7cf 100644 --- a/armorsculpt/sources/make_material.ts +++ b/armorsculpt/sources/make_material.ts @@ -233,7 +233,7 @@ function make_material_bake_node_previews() { let key: string = keys[i]; if (array_index_of(context_raw.node_previews_used, key) == -1) { let image: iron_gpu_texture_t = map_get(context_raw.node_previews, key); - app_notify_on_next_frame(function (image: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (image: iron_gpu_texture_t) { iron_unload_image(image); }, image); map_delete(context_raw.node_previews, key); @@ -340,7 +340,7 @@ function make_material_get_displace_strength(): f32 { } function make_material_delete_context(c: shader_context_t) { - app_notify_on_next_frame(function (c: shader_context_t) { // Ensure pipeline is no longer in use + sys_notify_on_next_frame(function (c: shader_context_t) { // Ensure pipeline is no longer in use shader_context_delete(c); }, c); } diff --git a/armorsculpt/sources/nodes/brush_output_node_ext.ts b/armorsculpt/sources/nodes/brush_output_node_ext.ts index 6c140c7e..95dec09d 100644 --- a/armorsculpt/sources/nodes/brush_output_node_ext.ts +++ b/armorsculpt/sources/nodes/brush_output_node_ext.ts @@ -78,8 +78,8 @@ function brush_output_node_run(self: brush_output_node_t, from: i32) { // Do not paint over floating toolbar if (context_is_floating_toolbar()) { let w: i32 = ui_toolbar_get_x() + ui_toolbar_get_w(); - left += w / app_w(); - top += w / app_h(); + left += w / sys_w(); + top += w / sys_h(); } // First time init diff --git a/armorsculpt/sources/tab_layers.ts b/armorsculpt/sources/tab_layers.ts index ac2d771a..a32f691f 100644 --- a/armorsculpt/sources/tab_layers.ts +++ b/armorsculpt/sources/tab_layers.ts @@ -290,7 +290,7 @@ function tab_layers_draw_layer_slot_full(l: slot_layer_t, i: i32) { // let _init() = function () { // delete_layer(context_raw.layer); // } - // app_notify_on_init(_init); + // sys_notify_on_init(_init); // } } ui._y -= center; diff --git a/base/sources/backends/android_native_app_glue.c b/base/sources/backends/android_native_app_glue.c index d503d8da..e54462b5 100644 --- a/base/sources/backends/android_native_app_glue.c +++ b/base/sources/backends/android_native_app_glue.c @@ -263,7 +263,7 @@ static struct android_app* android_app_create(ANativeActivity* activity, android_app->msgread = msgpipe[0]; android_app->msgwrite = msgpipe[1]; - pthread_attr_t attr; + pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_create(&android_app->thread, &attr, android_app_entry, android_app); @@ -278,7 +278,7 @@ static struct android_app* android_app_create(ANativeActivity* activity, return android_app; } -static void android_app_write_cmd(struct android_app* android_app, int8_t cmd) { +static void android_sys_write_cmd(struct android_app* android_app, int8_t cmd) { if (write(android_app->msgwrite, &cmd, sizeof(cmd)) != sizeof(cmd)) { LOGE("Failure writing android_app cmd: %s\n", strerror(errno)); } @@ -287,7 +287,7 @@ static void android_app_write_cmd(struct android_app* android_app, int8_t cmd) { static void android_app_set_input(struct android_app* android_app, AInputQueue* inputQueue) { pthread_mutex_lock(&android_app->mutex); android_app->pendingInputQueue = inputQueue; - android_app_write_cmd(android_app, APP_CMD_INPUT_CHANGED); + android_sys_write_cmd(android_app, APP_CMD_INPUT_CHANGED); while (android_app->inputQueue != android_app->pendingInputQueue) { pthread_cond_wait(&android_app->cond, &android_app->mutex); } @@ -297,11 +297,11 @@ static void android_app_set_input(struct android_app* android_app, AInputQueue* static void android_app_set_window(struct android_app* android_app, ANativeWindow* window) { pthread_mutex_lock(&android_app->mutex); if (android_app->pendingWindow != NULL) { - android_app_write_cmd(android_app, APP_CMD_TERM_WINDOW); + android_sys_write_cmd(android_app, APP_CMD_TERM_WINDOW); } android_app->pendingWindow = window; if (window != NULL) { - android_app_write_cmd(android_app, APP_CMD_INIT_WINDOW); + android_sys_write_cmd(android_app, APP_CMD_INIT_WINDOW); } while (android_app->window != android_app->pendingWindow) { pthread_cond_wait(&android_app->cond, &android_app->mutex); @@ -311,7 +311,7 @@ static void android_app_set_window(struct android_app* android_app, ANativeWindo static void android_app_set_activity_state(struct android_app* android_app, int8_t cmd) { pthread_mutex_lock(&android_app->mutex); - android_app_write_cmd(android_app, cmd); + android_sys_write_cmd(android_app, cmd); while (android_app->activityState != cmd) { pthread_cond_wait(&android_app->cond, &android_app->mutex); } @@ -320,7 +320,7 @@ static void android_app_set_activity_state(struct android_app* android_app, int8 static void android_app_free(struct android_app* android_app) { pthread_mutex_lock(&android_app->mutex); - android_app_write_cmd(android_app, APP_CMD_DESTROY); + android_sys_write_cmd(android_app, APP_CMD_DESTROY); while (!android_app->destroyed) { pthread_cond_wait(&android_app->cond, &android_app->mutex); } @@ -355,7 +355,7 @@ static void* onSaveInstanceState(ANativeActivity* activity, size_t* outLen) { LOGV("SaveInstanceState: %p\n", activity); pthread_mutex_lock(&android_app->mutex); android_app->stateSaved = 0; - android_app_write_cmd(android_app, APP_CMD_SAVE_STATE); + android_sys_write_cmd(android_app, APP_CMD_SAVE_STATE); while (!android_app->stateSaved) { pthread_cond_wait(&android_app->cond, &android_app->mutex); } @@ -385,18 +385,18 @@ static void onStop(ANativeActivity* activity) { static void onConfigurationChanged(ANativeActivity* activity) { struct android_app* android_app = (struct android_app*)activity->instance; LOGV("ConfigurationChanged: %p\n", activity); - android_app_write_cmd(android_app, APP_CMD_CONFIG_CHANGED); + android_sys_write_cmd(android_app, APP_CMD_CONFIG_CHANGED); } static void onLowMemory(ANativeActivity* activity) { struct android_app* android_app = (struct android_app*)activity->instance; LOGV("LowMemory: %p\n", activity); - android_app_write_cmd(android_app, APP_CMD_LOW_MEMORY); + android_sys_write_cmd(android_app, APP_CMD_LOW_MEMORY); } static void onWindowFocusChanged(ANativeActivity* activity, int focused) { LOGV("WindowFocusChanged: %p -- %d\n", activity, focused); - android_app_write_cmd((struct android_app*)activity->instance, + android_sys_write_cmd((struct android_app*)activity->instance, focused ? APP_CMD_GAINED_FOCUS : APP_CMD_LOST_FOCUS); } diff --git a/base/sources/backends/data/android/gradlew b/base/sources/backends/data/android/gradlew index 4f906e0c..8bf4cc32 100644 --- a/base/sources/backends/data/android/gradlew +++ b/base/sources/backends/data/android/gradlew @@ -22,7 +22,7 @@ ## ############################################################################## -# Attempt to set APP_HOME +# Attempt to set sys_hOME # Resolve links: $0 may be a link PRG="$0" # Need this for relative symlinks. @@ -37,7 +37,7 @@ while [ -h "$PRG" ] ; do done SAVED="`pwd`" cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" +sys_hOME="`pwd -P`" cd "$SAVED" >/dev/null APP_NAME="Gradle" @@ -80,7 +80,7 @@ case "`uname`" in ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH=$sys_hOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -123,12 +123,12 @@ fi # For Darwin, add options to specify how the application appears in the dock if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$sys_hOME/media/gradle.icns\"" fi # For Cygwin or MSYS, switch paths to Windows format before running java if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` + sys_hOME=`cygpath --path --mixed "$sys_hOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` diff --git a/base/sources/backends/data/android/gradlew.bat b/base/sources/backends/data/android/gradlew.bat index ac1b06f9..01c16b74 100644 --- a/base/sources/backends/data/android/gradlew.bat +++ b/base/sources/backends/data/android/gradlew.bat @@ -27,10 +27,10 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% +set sys_hOME=%DIRNAME% -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi +@rem Resolve any "." and ".." in sys_hOME to make it shorter. +for %%i in ("%sys_hOME%") do set sys_hOME=%%~fi @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -67,7 +67,7 @@ goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH=%sys_hOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle diff --git a/base/sources/backends/vulkan_gpu.c b/base/sources/backends/vulkan_gpu.c index d458e45d..7b2bae83 100644 --- a/base/sources/backends/vulkan_gpu.c +++ b/base/sources/backends/vulkan_gpu.c @@ -3,14 +3,14 @@ #define VALIDATE #endif -#include -#include #include #include #include #include #include #include +#include +#include #include #include #include @@ -19,28 +19,38 @@ static VkSemaphore framebuffer_available; static VkSemaphore relay_semaphore; static bool wait_for_relay = false; -static void command_list_should_wait_for_framebuffer(void); static VkDescriptorSetLayout compute_descriptor_layout; static int framebuffer_count = 0; -extern iron_gpu_texture_t *vulkan_textures[16]; -VkDescriptorSet getDescriptorSet(void); +iron_gpu_texture_t *vulkan_textures[16] = { + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL +}; + +VkSampler vulkan_samplers[16] = { + VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE, + VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE, + VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE, + VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE +}; + +VkDescriptorSet get_descriptor_set(void); static VkDescriptorSet get_compute_descriptor_set(void); void setImageLayout(VkCommandBuffer _buffer, VkImage image, VkImageAspectFlags aspectMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout); -VkRenderPassBeginInfo currentRenderPassBeginInfo; -VkPipeline currentVulkanPipeline; -iron_gpu_texture_t *currentRenderTargets[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; +VkRenderPassBeginInfo current_render_pass_begin_info; +VkPipeline current_vulkan_pipeline; +iron_gpu_texture_t *current_render_targets[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; -static bool onBackBuffer = false; -static uint32_t lastVertexConstantBufferOffset = 0; -static uint32_t lastFragmentConstantBufferOffset = 0; -static uint32_t lastComputeConstantBufferOffset = 0; +static bool on_back_buffer = false; +static uint32_t last_vertex_constant_buffer_offset = 0; +static uint32_t last_fragment_constant_buffer_offset = 0; +static uint32_t last_compute_constant_buffer_offset = 0; static iron_gpu_pipeline_t *current_pipeline = NULL; static iron_gpu_compute_shader *current_compute_shader = NULL; -static int mrtIndex = 0; -static VkFramebuffer mrtFramebuffer[16]; -static VkRenderPass mrtRenderPass[16]; +static int mrt_index = 0; +static VkFramebuffer mrt_framebuffer[16]; +static VkRenderPass mrt_render_pass[16]; static bool in_render_pass = false; static bool wait_for_framebuffer = false; @@ -50,12 +60,11 @@ static VkShaderModule create_shader_module(const void *code, size_t size); static VkDescriptorPool compute_descriptor_pool; VkDescriptorSetLayout desc_layout; -extern iron_gpu_texture_t *vulkan_textures[16]; -extern uint32_t swapchainImageCount; -extern uint32_t current_buffer; static VkDescriptorPool descriptor_pool; +bool iron_gpu_transpose_mat = true; + struct indexed_name { uint32_t id; char *name; @@ -69,8 +78,8 @@ struct indexed_index { #define MAX_THINGS 256 static struct indexed_name names[MAX_THINGS]; static uint32_t names_size = 0; -static struct indexed_name memberNames[MAX_THINGS]; -static uint32_t memberNames_size = 0; +static struct indexed_name member_names[MAX_THINGS]; +static uint32_t member_names_size = 0; static struct indexed_index locs[MAX_THINGS]; static uint32_t locs_size = 0; static struct indexed_index bindings[MAX_THINGS]; @@ -93,11 +102,8 @@ static int descriptor_sets_count = 0; static struct descriptor_set compute_descriptor_sets[MAX_DESCRIPTOR_SETS] = {0}; static int compute_descriptor_sets_count = 0; -bool use_staging_buffer = false; - void set_image_layout(VkImage image, VkImageAspectFlags aspectMask, VkImageLayout old_image_layout, VkImageLayout new_image_layout); - // djb2 uint32_t iron_internal_hash_name(unsigned char *str) { unsigned long hash = 5381; @@ -130,18 +136,6 @@ void create_descriptor_layout(void); static void create_compute_descriptor_layout(void); void set_image_layout(VkImage image, VkImageAspectFlags aspectMask, VkImageLayout old_image_layout, VkImageLayout new_image_layout); -iron_gpu_texture_t *vulkan_textures[16] = { - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL -}; - -VkSampler vulkan_samplers[16] = { - VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE, - VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE, - VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE, - VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE -}; - static bool began = false; static VkPhysicalDeviceProperties gpu_props; static VkQueueFamilyProperties *queue_props; @@ -187,7 +181,6 @@ void iron_internal_resize(int width, int height) { window->width = width; window->height = height; } - iron_gpu_internal_resize(width, height); } @@ -1148,7 +1141,7 @@ void iron_gpu_begin(iron_gpu_texture_t *renderTarget) { } // Get the index of the next available swapchain image: - command_list_should_wait_for_framebuffer(); + wait_for_framebuffer = true; VkResult err = -1; do { err = vk.fpAcquireNextImageKHR(vk_ctx.device, window->swapchain, UINT64_MAX, framebuffer_available, VK_NULL_HANDLE, &window->current_image); @@ -1232,7 +1225,7 @@ int iron_gpu_max_bound_textures(void) { } -static void endPass(iron_gpu_command_list_t *list) { +static void end_pass(iron_gpu_command_list_t *list) { if (in_render_pass) { vkCmdEndRenderPass(list->impl._buffer); in_render_pass = false; @@ -1395,7 +1388,7 @@ void set_viewport_and_scissor(iron_gpu_command_list_t *list) { VkRect2D scissor; memset(&scissor, 0, sizeof(scissor)); - if (currentRenderTargets[0] == NULL || currentRenderTargets[0]->framebuffer_index >= 0) { + if (current_render_targets[0] == NULL || current_render_targets[0]->framebuffer_index >= 0) { viewport.x = 0; viewport.y = (float)iron_window_height(); viewport.width = (float)iron_window_width(); @@ -1409,13 +1402,13 @@ void set_viewport_and_scissor(iron_gpu_command_list_t *list) { } else { viewport.x = 0; - viewport.y = (float)currentRenderTargets[0]->height; - viewport.width = (float)currentRenderTargets[0]->width; - viewport.height = -(float)currentRenderTargets[0]->height; + viewport.y = (float)current_render_targets[0]->height; + viewport.width = (float)current_render_targets[0]->width; + viewport.height = -(float)current_render_targets[0]->height; viewport.minDepth = (float)0.0f; viewport.maxDepth = (float)1.0f; - scissor.extent.width = currentRenderTargets[0]->width; - scissor.extent.height = currentRenderTargets[0]->height; + scissor.extent.width = current_render_targets[0]->width; + scissor.extent.height = current_render_targets[0]->height; scissor.offset.x = 0; scissor.offset.y = 0; } @@ -1508,18 +1501,18 @@ void iron_gpu_command_list_begin(iron_gpu_command_list_t *list) { pmemory_barrier); vkCmdBeginRenderPass(list->impl._buffer, &rp_begin, VK_SUBPASS_CONTENTS_INLINE); - currentRenderPassBeginInfo = rp_begin; + current_render_pass_begin_info = rp_begin; in_render_pass = true; set_viewport_and_scissor(list); - onBackBuffer = true; + on_back_buffer = true; - for (int i = 0; i < mrtIndex; ++i) { - vkDestroyFramebuffer(vk_ctx.device, mrtFramebuffer[i], NULL); - vkDestroyRenderPass(vk_ctx.device, mrtRenderPass[i], NULL); + for (int i = 0; i < mrt_index; ++i) { + vkDestroyFramebuffer(vk_ctx.device, mrt_framebuffer[i], NULL); + vkDestroyRenderPass(vk_ctx.device, mrt_render_pass[i], NULL); } - mrtIndex = 0; + mrt_index = 0; } void iron_gpu_command_list_end(iron_gpu_command_list_t *list) { @@ -1616,28 +1609,28 @@ void iron_gpu_command_list_scissor(iron_gpu_command_list_t *list, int x, int y, void iron_gpu_command_list_disable_scissor(iron_gpu_command_list_t *list) { VkRect2D scissor; memset(&scissor, 0, sizeof(scissor)); - if (currentRenderTargets[0] == NULL || currentRenderTargets[0]->framebuffer_index >= 0) { + if (current_render_targets[0] == NULL || current_render_targets[0]->framebuffer_index >= 0) { scissor.extent.width = iron_window_width(); scissor.extent.height = iron_window_height(); } else { - scissor.extent.width = currentRenderTargets[0]->width; - scissor.extent.height = currentRenderTargets[0]->height; + scissor.extent.width = current_render_targets[0]->width; + scissor.extent.height = current_render_targets[0]->height; } vkCmdSetScissor(list->impl._buffer, 0, 1, &scissor); } void iron_gpu_command_list_set_pipeline(iron_gpu_command_list_t *list, struct iron_gpu_pipeline *pipeline) { current_pipeline = pipeline; - lastVertexConstantBufferOffset = 0; - lastFragmentConstantBufferOffset = 0; + last_vertex_constant_buffer_offset = 0; + last_fragment_constant_buffer_offset = 0; - if (onBackBuffer) { - currentVulkanPipeline = current_pipeline->impl.framebuffer_pipeline; + if (on_back_buffer) { + current_vulkan_pipeline = current_pipeline->impl.framebuffer_pipeline; vkCmdBindPipeline(list->impl._buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, current_pipeline->impl.framebuffer_pipeline); } else { - currentVulkanPipeline = current_pipeline->impl.rendertarget_pipeline; + current_vulkan_pipeline = current_pipeline->impl.rendertarget_pipeline; vkCmdBindPipeline(list->impl._buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, current_pipeline->impl.rendertarget_pipeline); } } @@ -1673,14 +1666,14 @@ void iron_internal_restore_render_target(iron_gpu_command_list_t *list, struct i scissor.offset.y = 0; vkCmdSetScissor(list->impl._buffer, 0, 1, &scissor); - if (onBackBuffer && in_render_pass) { + if (on_back_buffer && in_render_pass) { return; } - endPass(list); + end_pass(list); - currentRenderTargets[0] = NULL; - onBackBuffer = true; + current_render_targets[0] = NULL; + on_back_buffer = true; VkClearValue clear_values[2]; memset(clear_values, 0, sizeof(VkClearValue) * 2); @@ -1702,21 +1695,21 @@ void iron_internal_restore_render_target(iron_gpu_command_list_t *list, struct i rp_begin.clearValueCount = 2; rp_begin.pClearValues = clear_values; vkCmdBeginRenderPass(list->impl._buffer, &rp_begin, VK_SUBPASS_CONTENTS_INLINE); - currentRenderPassBeginInfo = rp_begin; + current_render_pass_begin_info = rp_begin; in_render_pass = true; if (current_pipeline != NULL) { - currentVulkanPipeline = current_pipeline->impl.framebuffer_pipeline; + current_vulkan_pipeline = current_pipeline->impl.framebuffer_pipeline; vkCmdBindPipeline(list->impl._buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, current_pipeline->impl.framebuffer_pipeline); } } void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, struct iron_gpu_texture **targets, int count) { for (int i = 0; i < count; ++i) { - currentRenderTargets[i] = targets[i]; + current_render_targets[i] = targets[i]; } for (int i = count; i < 8; ++i) { - currentRenderTargets[i] = NULL; + current_render_targets[i] = NULL; } if (targets[0]->framebuffer_index >= 0) { @@ -1724,9 +1717,9 @@ void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, str return; } - endPass(list); + end_pass(list); - onBackBuffer = false; + on_back_buffer = false; VkClearValue clear_values[9]; memset(clear_values, 0, sizeof(VkClearValue)); @@ -1836,7 +1829,7 @@ void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, str rp_info.dependencyCount = 2; rp_info.pDependencies = dependencies; - VkResult err = vkCreateRenderPass(vk_ctx.device, &rp_info, NULL, &mrtRenderPass[mrtIndex]); + VkResult err = vkCreateRenderPass(vk_ctx.device, &rp_info, NULL, &mrt_render_pass[mrt_index]); assert(!err); VkImageView attachmentsViews[9]; @@ -1850,23 +1843,23 @@ void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, str VkFramebufferCreateInfo fbufCreateInfo = {0}; fbufCreateInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; fbufCreateInfo.pNext = NULL; - fbufCreateInfo.renderPass = mrtRenderPass[mrtIndex]; + fbufCreateInfo.renderPass = mrt_render_pass[mrt_index]; fbufCreateInfo.attachmentCount = targets[0]->impl.depthBufferBits > 0 ? count + 1 : count; fbufCreateInfo.pAttachments = attachmentsViews; fbufCreateInfo.width = targets[0]->width; fbufCreateInfo.height = targets[0]->height; fbufCreateInfo.layers = 1; - err = vkCreateFramebuffer(vk_ctx.device, &fbufCreateInfo, NULL, &mrtFramebuffer[mrtIndex]); + err = vkCreateFramebuffer(vk_ctx.device, &fbufCreateInfo, NULL, &mrt_framebuffer[mrt_index]); assert(!err); - rp_begin.renderPass = mrtRenderPass[mrtIndex]; - rp_begin.framebuffer = mrtFramebuffer[mrtIndex]; - mrtIndex++; + rp_begin.renderPass = mrt_render_pass[mrt_index]; + rp_begin.framebuffer = mrt_framebuffer[mrt_index]; + mrt_index++; } vkCmdBeginRenderPass(list->impl._buffer, &rp_begin, VK_SUBPASS_CONTENTS_INLINE); - currentRenderPassBeginInfo = rp_begin; + current_render_pass_begin_info = rp_begin; in_render_pass = true; VkViewport viewport; @@ -1888,7 +1881,7 @@ void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, str vkCmdSetScissor(list->impl._buffer, 0, 1, &scissor); if (current_pipeline != NULL) { - currentVulkanPipeline = current_pipeline->impl.rendertarget_pipeline; + current_vulkan_pipeline = current_pipeline->impl.rendertarget_pipeline; vkCmdBindPipeline(list->impl._buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, current_pipeline->impl.rendertarget_pipeline); } } @@ -1953,7 +1946,7 @@ void iron_gpu_command_list_get_render_target_pixels(iron_gpu_command_list_t *lis setImageLayout(list->impl._buffer, render_target->impl.image, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); - vkCmdBeginRenderPass(list->impl._buffer, ¤tRenderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE); + vkCmdBeginRenderPass(list->impl._buffer, ¤t_render_pass_begin_info, VK_SUBPASS_CONTENTS_INLINE); in_render_pass = true; iron_gpu_command_list_end(list); @@ -1977,30 +1970,26 @@ void iron_gpu_command_list_render_target_to_texture_barrier(iron_gpu_command_lis } void iron_gpu_command_list_set_vertex_constant_buffer(iron_gpu_command_list_t *list, struct iron_gpu_constant_buffer *buffer, int offset, size_t size) { - lastVertexConstantBufferOffset = offset; + last_vertex_constant_buffer_offset = offset; } void iron_gpu_command_list_set_fragment_constant_buffer(iron_gpu_command_list_t *list, struct iron_gpu_constant_buffer *buffer, int offset, size_t size) { - lastFragmentConstantBufferOffset = offset; + last_fragment_constant_buffer_offset = offset; - VkDescriptorSet descriptor_set = getDescriptorSet(); - uint32_t offsets[2] = {lastVertexConstantBufferOffset, lastFragmentConstantBufferOffset}; + VkDescriptorSet descriptor_set = get_descriptor_set(); + uint32_t offsets[2] = {last_vertex_constant_buffer_offset, last_fragment_constant_buffer_offset}; vkCmdBindDescriptorSets(list->impl._buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, current_pipeline->impl.pipeline_layout, 0, 1, &descriptor_set, 2, offsets); } void iron_gpu_command_list_set_compute_constant_buffer(iron_gpu_command_list_t *list, struct iron_gpu_constant_buffer *buffer, int offset, size_t size) { - lastComputeConstantBufferOffset = offset; + last_compute_constant_buffer_offset = offset; VkDescriptorSet descriptor_set = get_compute_descriptor_set(); - uint32_t offsets[2] = {lastComputeConstantBufferOffset, lastComputeConstantBufferOffset}; + uint32_t offsets[2] = {last_compute_constant_buffer_offset, last_compute_constant_buffer_offset}; vkCmdBindDescriptorSets(list->impl._buffer, VK_PIPELINE_BIND_POINT_COMPUTE, current_compute_shader->impl.pipeline_layout, 0, 1, &descriptor_set, 2, offsets); } -static void command_list_should_wait_for_framebuffer(void) { - wait_for_framebuffer = true; -} - void iron_gpu_command_list_execute(iron_gpu_command_list_t *list) { // Make sure the previous execution is done, so we can reuse the fence // Not optimal of course @@ -2073,7 +2062,6 @@ void iron_gpu_command_list_set_texture_from_render_target_depth(iron_gpu_command void iron_gpu_command_list_set_compute_shader(iron_gpu_command_list_t *list, iron_gpu_compute_shader *shader) { current_compute_shader = shader; vkCmdBindPipeline(list->impl._buffer, VK_PIPELINE_BIND_POINT_COMPUTE, shader->impl.pipeline); - //**vkCmdBindDescriptorSets(list->impl._buffer, VK_PIPELINE_BIND_POINT_COMPUTE, shader->impl.pipeline_layout, 0, 1, &shader->impl.descriptor_set, 0, 0); } void iron_gpu_command_list_compute(iron_gpu_command_list_t *list, int x, int y, int z) { @@ -2086,13 +2074,13 @@ void iron_gpu_command_list_compute(iron_gpu_command_list_t *list, int x, int y, int render_target_count = 0; for (int i = 0; i < 8; ++i) { - if (currentRenderTargets[i] == NULL) { + if (current_render_targets[i] == NULL) { break; } ++render_target_count; } if (render_target_count > 0) { - iron_gpu_command_list_set_render_targets(list, currentRenderTargets, render_target_count); + iron_gpu_command_list_set_render_targets(list, current_render_targets, render_target_count); } } @@ -2191,9 +2179,7 @@ void iron_gpu_compute_shader_destroy(iron_gpu_compute_shader *shader) {} iron_gpu_constant_location_t iron_gpu_compute_shader_get_constant_location(iron_gpu_compute_shader *shader, const char *name) { iron_gpu_constant_location_t location = {0}; - uint32_t hash = iron_internal_hash_name((unsigned char *)name); - return location; } @@ -2253,8 +2239,6 @@ static void set_number(iron_internal_named_number *named_numbers, const char *na return; } } - - assert(false); } static void add_name(uint32_t id, char *name) { @@ -2273,15 +2257,15 @@ static char *find_name(uint32_t id) { } static void add_member_name(uint32_t id, char *name) { - memberNames[memberNames_size].id = id; - memberNames[memberNames_size].name = name; - ++memberNames_size; + member_names[member_names_size].id = id; + member_names[member_names_size].name = name; + ++member_names_size; } static char *find_member_name(uint32_t id) { - for (uint32_t i = 0; i < memberNames_size; ++i) { - if (memberNames[i].id == id) { - return memberNames[i].name; + for (uint32_t i = 0; i < member_names_size; ++i) { + if (member_names[i].id == id) { + return member_names[i].name; } } return NULL; @@ -2308,7 +2292,7 @@ static void add_offset(uint32_t id, uint32_t offset) { static void parse_shader(uint32_t *shader_source, int shader_length, iron_internal_named_number *locations, iron_internal_named_number *textureBindings, iron_internal_named_number *uniformOffsets) { names_size = 0; - memberNames_size = 0; + member_names_size = 0; locs_size = 0; bindings_size = 0; offsets_size = 0; @@ -2425,19 +2409,22 @@ static VkShaderModule prepare_fs(VkShaderModule *frag_shader_module, iron_gpu_sh return *frag_shader_module; } -static VkFormat convert_format(iron_image_format_t format) { +static VkFormat convert_image_format(iron_image_format_t format) { switch (format) { case IRON_IMAGE_FORMAT_RGBA128: return VK_FORMAT_R32G32B32A32_SFLOAT; case IRON_IMAGE_FORMAT_RGBA64: return VK_FORMAT_R16G16B16A16_SFLOAT; - case IRON_IMAGE_FORMAT_R32: - return VK_FORMAT_R32_SFLOAT; - case IRON_IMAGE_FORMAT_R16: - return VK_FORMAT_R16_SFLOAT; case IRON_IMAGE_FORMAT_R8: return VK_FORMAT_R8_UNORM; + case IRON_IMAGE_FORMAT_R16: + return VK_FORMAT_R16_SFLOAT; + case IRON_IMAGE_FORMAT_R32: + return VK_FORMAT_R32_SFLOAT; + case IRON_IMAGE_FORMAT_BGRA32: + return VK_FORMAT_B8G8R8A8_UNORM; case IRON_IMAGE_FORMAT_RGBA32: + return VK_FORMAT_R8G8B8A8_UNORM; default: return VK_FORMAT_B8G8R8A8_UNORM; } @@ -2759,7 +2746,7 @@ void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipeline) { VkAttachmentDescription attachments[9]; for (int i = 0; i < pipeline->color_attachment_count; ++i) { - attachments[i].format = convert_format(pipeline->color_attachment[i]); + attachments[i].format = convert_image_format(pipeline->color_attachment[i]); attachments[i].samples = VK_SAMPLE_COUNT_1_BIT; attachments[i].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; attachments[i].storeOp = VK_ATTACHMENT_STORE_OP_STORE; @@ -2949,9 +2936,7 @@ static int write_tex_descs(VkDescriptorImageInfo *tex_descs) { static bool textures_changed(struct descriptor_set *set) { VkDescriptorImageInfo tex_desc[16]; - write_tex_descs(tex_desc); - return memcmp(&tex_desc, &set->tex_desc, sizeof(tex_desc)) != 0; } @@ -2983,7 +2968,7 @@ void reuse_descriptor_sets(void) { } } -VkDescriptorSet getDescriptorSet() { +VkDescriptorSet get_descriptor_set() { int id = calc_descriptor_id(); for (int i = 0; i < descriptor_sets_count; ++i) { if (descriptor_sets[i].id == id) { @@ -3279,8 +3264,6 @@ void iron_gpu_shader_destroy(iron_gpu_shader_t *shader) { shader->impl.source = NULL; } -static VkCompareOp convert_compare_mode(iron_gpu_compare_mode_t compare); - static VkSamplerAddressMode convert_addressing(iron_gpu_texture_addressing_t mode) { switch (mode) { case IRON_GPU_TEXTURE_ADDRESSING_REPEAT: @@ -3292,7 +3275,6 @@ static VkSamplerAddressMode convert_addressing(iron_gpu_texture_addressing_t mod case IRON_GPU_TEXTURE_ADDRESSING_MIRROR: return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT; default: - assert(false); return VK_SAMPLER_ADDRESS_MODE_REPEAT; } } @@ -3305,7 +3287,6 @@ static VkSamplerMipmapMode convert_mipmap_mode(iron_gpu_mipmap_filter_t filter) case IRON_GPU_MIPMAP_FILTER_LINEAR: return VK_SAMPLER_MIPMAP_MODE_LINEAR; default: - assert(false); return VK_SAMPLER_MIPMAP_MODE_NEAREST; } } @@ -3319,7 +3300,6 @@ static VkFilter convert_texture_filter(iron_gpu_texture_filter_t filter) { case IRON_GPU_TEXTURE_FILTER_ANISOTROPIC: return VK_FILTER_LINEAR; // ? default: - assert(false); return VK_FILTER_NEAREST; } } @@ -3499,45 +3479,6 @@ static void prepare_texture_image(uint8_t *tex_colors, uint32_t width, uint32_t set_image_layout(tex_obj->image, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_UNDEFINED, tex_obj->imageLayout); } -static VkFormat convert_image_format(iron_image_format_t format) { - switch (format) { - case IRON_IMAGE_FORMAT_RGBA128: - return VK_FORMAT_R32G32B32A32_SFLOAT; - case IRON_IMAGE_FORMAT_RGBA64: - return VK_FORMAT_R16G16B16A16_SFLOAT; - case IRON_IMAGE_FORMAT_R8: - return VK_FORMAT_R8_UNORM; - case IRON_IMAGE_FORMAT_R16: - return VK_FORMAT_R16_SFLOAT; - case IRON_IMAGE_FORMAT_R32: - return VK_FORMAT_R32_SFLOAT; - case IRON_IMAGE_FORMAT_BGRA32: - return VK_FORMAT_B8G8R8A8_UNORM; - case IRON_IMAGE_FORMAT_RGBA32: - return VK_FORMAT_R8G8B8A8_UNORM; - default: - return VK_FORMAT_B8G8R8A8_UNORM; - } -} - -static int format_byte_size(iron_image_format_t format) { - switch (format) { - case IRON_IMAGE_FORMAT_RGBA128: - return 16; - case IRON_IMAGE_FORMAT_RGBA64: - return 8; - case IRON_IMAGE_FORMAT_R16: - return 2; - case IRON_IMAGE_FORMAT_R8: - return 1; - case IRON_IMAGE_FORMAT_BGRA32: - case IRON_IMAGE_FORMAT_RGBA32: - case IRON_IMAGE_FORMAT_R32: - default: - return 4; - } -} - static void update_stride(iron_gpu_texture_t *texture) { VkImageSubresource subres = {0}; subres.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; @@ -3567,7 +3508,7 @@ void iron_gpu_texture_init_from_bytes(iron_gpu_texture_t *texture, void *data, i vkGetPhysicalDeviceFormatProperties(vk_ctx.gpu, tex_format, &props); - if ((props.linearTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) && !use_staging_buffer) { + if (props.linearTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) { // Device can texture using linear textures prepare_texture_image((uint8_t *)data, (uint32_t)width, (uint32_t)height, &texture->impl, VK_IMAGE_TILING_LINEAR, VK_IMAGE_USAGE_SAMPLED_BIT /*| VK_IMAGE_USAGE_STORAGE_BIT*/, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &texture->impl.deviceSize, @@ -3614,9 +3555,6 @@ void iron_gpu_texture_init_from_bytes(iron_gpu_texture_t *texture, void *data, i vkFreeMemory(vk_ctx.device, staging_texture.mem, NULL); } - else { - assert(!"No support for B8G8R8A8_UNORM as texture image format"); - } update_stride(texture); @@ -3831,8 +3769,6 @@ void iron_gpu_texture_set_mipmap(iron_gpu_texture_t *texture, iron_gpu_texture_t // texture->_uploaded = true; } -void setup_init_cmd(); - void setImageLayout(VkCommandBuffer _buffer, VkImage image, VkImageAspectFlags aspectMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout) { VkImageMemoryBarrier imageMemoryBarrier = {0}; imageMemoryBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; @@ -3892,7 +3828,7 @@ static void render_target_init(iron_gpu_texture_t *target, int width, int height target->width = width; target->height = height; target->data = NULL; - target->impl.format = convert_format(format); + target->impl.format = convert_image_format(format); target->impl.depthBufferBits = depthBufferBits; target->impl.stage = 0; target->impl.stage_depth = -1; @@ -4211,9 +4147,7 @@ int iron_gpu_vertex_buffer_stride(iron_gpu_vertex_buffer_t *buffer) { return buffer->impl.myStride; } -bool iron_gpu_transpose_mat = true; - -static void createUniformBuffer(VkBuffer *buf, VkMemoryAllocateInfo *mem_alloc, VkDeviceMemory *mem, VkDescriptorBufferInfo *buffer_info, int size) { +static void create_uniform_buffer(VkBuffer *buf, VkMemoryAllocateInfo *mem_alloc, VkDeviceMemory *mem, VkDescriptorBufferInfo *buffer_info, int size) { VkBufferCreateInfo buf_info; memset(&buf_info, 0, sizeof(buf_info)); buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; @@ -4253,7 +4187,7 @@ void iron_gpu_constant_buffer_init(iron_gpu_constant_buffer_t *buffer, int size) buffer->impl.mySize = size; buffer->data = NULL; - createUniformBuffer(&buffer->impl.buf, &buffer->impl.mem_alloc, &buffer->impl.mem, &buffer->impl.buffer_info, size); + create_uniform_buffer(&buffer->impl.buf, &buffer->impl.mem_alloc, &buffer->impl.mem, &buffer->impl.buffer_info, size); // buffer hack if (vk_ctx.vertex_uniform_buffer == NULL) { @@ -4296,9 +4230,6 @@ int iron_gpu_constant_buffer_size(iron_gpu_constant_buffer_t *buffer) { return buffer->impl.mySize; } -static void unset(iron_gpu_index_buffer_t *buffer) { -} - void iron_gpu_index_buffer_init(iron_gpu_index_buffer_t *buffer, int indexCount, bool gpuMemory) { buffer->impl.count = indexCount; @@ -4350,7 +4281,7 @@ void iron_gpu_index_buffer_init(iron_gpu_index_buffer_t *buffer, int indexCount, } void iron_gpu_index_buffer_destroy(iron_gpu_index_buffer_t *buffer) { - unset(buffer); + // unset(buffer); vkFreeMemory(vk_ctx.device, buffer->impl.mem, NULL); vkDestroyBuffer(vk_ctx.device, buffer->impl.buf, NULL); } @@ -4382,13 +4313,8 @@ int iron_gpu_index_buffer_count(iron_gpu_index_buffer_t *buffer) { return buffer->impl.count; } - #ifndef IRON_ANDROID -extern VkRenderPassBeginInfo currentRenderPassBeginInfo; -extern VkFramebuffer *framebuffers; -extern uint32_t current_buffer; - static const int INDEX_RAYGEN = 0; static const int INDEX_MISS = 1; static const int INDEX_CLOSEST_HIT = 2; @@ -5652,7 +5578,7 @@ void iron_gpu_raytrace_dispatch_rays(iron_gpu_command_list_t *command_list) { _vkCmdTraceRaysKHR(command_list->impl._buffer, &raygen_shader_sbt_entry, &miss_shader_sbt_entry, &hit_shader_sbt_entry, &callable_shader_sbt_entry, output->width, output->height, 1); - vkCmdBeginRenderPass(command_list->impl._buffer, ¤tRenderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE); + vkCmdBeginRenderPass(command_list->impl._buffer, ¤t_render_pass_begin_info, VK_SUBPASS_CONTENTS_INLINE); } #endif diff --git a/base/sources/ts/args.ts b/base/sources/ts/args.ts index 08df7196..75308ffe 100644 --- a/base/sources/ts/args.ts +++ b/base/sources/ts/args.ts @@ -63,7 +63,7 @@ function args_parse() { function args_run() { if (args_use) { - app_notify_on_init(function () { + sys_notify_on_init(function () { if (project_filepath != "") { import_arm_run_project(project_filepath); } @@ -121,7 +121,7 @@ function args_run() { data_delete_blob("export_presets/" + file); // Export queue - app_notify_on_init(function () { + sys_notify_on_init(function () { export_texture_run(args_export_textures_path); }); } diff --git a/base/sources/ts/base.ts b/base/sources/ts/base.ts index 0c7d35d3..3cbda24e 100644 --- a/base/sources/ts/base.ts +++ b/base/sources/ts/base.ts @@ -121,16 +121,16 @@ function base_init() { ui_view2d_init(); base_ext_init(); - app_notify_on_update(base_update); - app_notify_on_render_2d(ui_view2d_render); - app_notify_on_update(ui_view2d_update); - app_notify_on_render_2d(ui_base_render_cursor); - app_notify_on_update(ui_nodes_update); - app_notify_on_render_2d(ui_nodes_render); - app_notify_on_update(ui_base_update); - app_notify_on_render_2d(ui_base_render); - app_notify_on_update(camera_update); - app_notify_on_render_2d(base_render); + sys_notify_on_update(base_update); + sys_notify_on_render_2d(ui_view2d_render); + sys_notify_on_update(ui_view2d_update); + sys_notify_on_render_2d(ui_base_render_cursor); + sys_notify_on_update(ui_nodes_update); + sys_notify_on_render_2d(ui_nodes_render); + sys_notify_on_update(ui_base_update); + sys_notify_on_render_2d(ui_base_render); + sys_notify_on_update(camera_update); + sys_notify_on_render_2d(base_render); base_appx = ui_toolbar_w; base_appy = ui_header_h; @@ -266,8 +266,8 @@ function base_resize() { let cam: camera_object_t = scene_camera; if (cam.data.ortho != null) { - cam.data.ortho[2] = -2 * (app_h() / app_w()); - cam.data.ortho[3] = 2 * (app_h() / app_w()); + cam.data.ortho[2] = -2 * (sys_h() / sys_w()); + cam.data.ortho[3] = 2 * (sys_h() / sys_w()); } camera_object_build_proj(cam); @@ -330,7 +330,7 @@ function base_update() { // Touch and hold to activate dragging if (base_drag_start < 0.2) { if (has_drag && mouse_down()) { - base_drag_start += time_real_delta(); + base_drag_start += sys_real_delta(); } else { base_drag_start = 0; @@ -755,14 +755,14 @@ function base_init_layout() { array_push(new_layout, math_floor(iron_window_height() / 2)); // LayoutSidebarH1 ///if arm_ios - array_push(new_layout, show2d ? math_floor((app_w() + raw.layout[layout_size_t.NODES_W]) * 0.473) : math_floor(app_w() * 0.473)); // LayoutNodesW + array_push(new_layout, show2d ? math_floor((sys_w() + raw.layout[layout_size_t.NODES_W]) * 0.473) : math_floor(sys_w() * 0.473)); // LayoutNodesW ///elseif arm_android - array_push(new_layout, show2d ? math_floor((app_w() + raw.layout[layout_size_t.NODES_W]) * 0.473) : math_floor(app_w() * 0.473)); + array_push(new_layout, show2d ? math_floor((sys_w() + raw.layout[layout_size_t.NODES_W]) * 0.473) : math_floor(sys_w() * 0.473)); ///else - array_push(new_layout, show2d ? math_floor((app_w() + raw.layout[layout_size_t.NODES_W]) * 0.515) : math_floor(app_w() * 0.515)); // Align with ui header controls + array_push(new_layout, show2d ? math_floor((sys_w() + raw.layout[layout_size_t.NODES_W]) * 0.515) : math_floor(sys_w() * 0.515)); // Align with ui header controls ///end - array_push(new_layout, math_floor(app_h() / 2)); // LayoutNodesH + array_push(new_layout, math_floor(sys_h() / 2)); // LayoutNodesH array_push(new_layout, math_floor(ui_status_default_status_h * raw.window_scale)); // LayoutStatusH ///if (arm_android || arm_ios) diff --git a/base/sources/ts/box_export.ts b/base/sources/ts/box_export.ts index dd7e8c8e..ad7df59b 100644 --- a/base/sources/ts/box_export.ts +++ b/base/sources/ts/box_export.ts @@ -102,7 +102,7 @@ function box_export_tab_export_textures(ui: ui_t, title: string, bake_material: ui_combo(base_bits_handle, base_bits_combo, tr("Color"), true); if (base_bits_handle.changed) { - app_notify_on_init(layers_set_bits); + sys_notify_on_init(layers_set_bits); } ui_row2(); @@ -166,7 +166,7 @@ function box_export_tab_export_textures(ui: ui_t, title: string, bake_material: if (context_raw.layers_destination == export_destination_t.PACKED) { _box_export_bake_material = bake_material; context_raw.texture_export_path = "/"; - app_notify_on_init(function () { + sys_notify_on_init(function () { export_texture_run(context_raw.texture_export_path, _box_export_bake_material); }); } @@ -178,7 +178,7 @@ function box_export_tab_export_textures(ui: ui_t, title: string, bake_material: ///if (arm_android || arm_ios) console_toast(tr("Exporting textures")); ///end - app_notify_on_init(function () { + sys_notify_on_init(function () { export_texture_run(context_raw.texture_export_path, _box_export_bake_material); }); }); @@ -465,7 +465,7 @@ function box_export_show_material() { if (f == "") { f = tr("untitled"); } - app_notify_on_init(function (path: string) { + sys_notify_on_init(function (path: string) { export_arm_run_material(path); }, path + path_sep + f); }); @@ -494,7 +494,7 @@ function box_export_show_brush() { ui_files_show("arm", true, false, function (path: string) { let f: string = ui_files_filename; if (f == "") f = tr("untitled"); - app_notify_on_init(function (path: string) { + sys_notify_on_init(function (path: string) { export_arm_run_brush(path); }, path + path_sep + f); }); diff --git a/base/sources/ts/box_preferences.ts b/base/sources/ts/box_preferences.ts index 652374a6..6ed5b944 100644 --- a/base/sources/ts/box_preferences.ts +++ b/base/sources/ts/box_preferences.ts @@ -137,7 +137,7 @@ function box_preferences_show() { if (ui_button(tr("Restore")) && !ui_menu_show) { ui_menu_draw(function (ui: ui_t) { if (ui_menu_button(tr("Confirm"))) { - app_notify_on_init(function (ui: ui_t) { + sys_notify_on_init(function (ui: ui_t) { ui.ops.theme.ELEMENT_H = base_default_element_h; config_restore(); box_preferences_set_scale(); @@ -159,7 +159,7 @@ function box_preferences_show() { ui_files_show("json", false, false, function (path: string) { let b: buffer_t = data_get_blob(path); let raw: config_t = json_parse(sys_buffer_to_string(b)); - app_notify_on_init(function (raw: config_t) { + sys_notify_on_init(function (raw: config_t) { _box_preferences_ui.ops.theme.ELEMENT_H = base_default_element_h; config_import_from(raw); box_preferences_set_scale(); diff --git a/base/sources/ts/box_projects.ts b/base/sources/ts/box_projects.ts index 19e602f9..79576eaa 100644 --- a/base/sources/ts/box_projects.ts +++ b/base/sources/ts/box_projects.ts @@ -133,7 +133,7 @@ function box_projects_tab(ui: ui_t) { ///if (arm_android || arm_ios) console_toast(tr("Opening project")); ///end - app_notify_on_init(function (path: string) { + sys_notify_on_init(function (path: string) { ui_box_hide(); import_arm_run_project(path); }, path); @@ -147,7 +147,7 @@ function box_projects_tab(ui: ui_t) { ui_menu_draw(function (ui: ui_t) { // if (ui_menu_button(tr("Duplicate"))) {} if (ui_menu_button(tr("Delete"))) { - app_notify_on_init(function () { + sys_notify_on_init(function () { file_delete(_box_projects_path); file_delete(_box_projects_icon_path); let data_path: string = substring(_box_projects_path, 0, _box_projects_path.length - 4); diff --git a/base/sources/ts/camera.ts b/base/sources/ts/camera.ts index 206fc283..ea46de8b 100644 --- a/base/sources/ts/camera.ts +++ b/base/sources/ts/camera.ts @@ -14,25 +14,25 @@ function camera_update() { let camera: camera_object_t = scene_camera; if (mouse_view_x() < 0 || - mouse_view_x() > app_w() || + mouse_view_x() > sys_w() || mouse_view_y() < 0 || - mouse_view_y() > app_h()) { + mouse_view_y() > sys_h()) { if (config_raw.wrap_mouse && camera_controls_down) { if (mouse_view_x() < 0) { - mouse_x = mouse_last_x = app_x() + app_w(); + mouse_x = mouse_last_x = sys_x() + sys_w(); iron_mouse_set_position(math_floor(mouse_x), math_floor(mouse_y)); } - else if (mouse_view_x() > app_w()) { - mouse_x = mouse_last_x = app_x(); + else if (mouse_view_x() > sys_w()) { + mouse_x = mouse_last_x = sys_x(); iron_mouse_set_position(math_floor(mouse_x), math_floor(mouse_y)); } else if (mouse_view_y() < 0) { - mouse_y = mouse_last_y = app_y() + app_h(); + mouse_y = mouse_last_y = sys_y() + sys_h(); iron_mouse_set_position(math_floor(mouse_x), math_floor(mouse_y)); } - else if (mouse_view_y() > app_h()) { - mouse_y = mouse_last_y = app_y(); + else if (mouse_view_y() > sys_h()) { + mouse_y = mouse_last_y = sys_y(); iron_mouse_set_position(math_floor(mouse_x), math_floor(mouse_y)); } } @@ -125,7 +125,7 @@ function camera_update() { } if (move_forward || move_backward || strafe_right || strafe_left || strafe_up || strafe_down) { - camera_ease += time_delta() * 15; + camera_ease += sys_delta() * 15; if (camera_ease > 1.0) { camera_ease = 1.0; } @@ -152,14 +152,14 @@ function camera_update() { } } else { - camera_ease -= time_delta() * 20.0 * camera_ease; + camera_ease -= sys_delta() * 20.0 * camera_ease; if (camera_ease < 0.0) { camera_ease = 0.0; } } - let d: f32 = time_delta() * fast * camera_ease * 2.0 * ((move_forward || move_backward) ? config_raw.camera_zoom_speed : config_raw.camera_pan_speed); + let d: f32 = sys_delta() * fast * camera_ease * 2.0 * ((move_forward || move_backward) ? config_raw.camera_zoom_speed : config_raw.camera_pan_speed); if (d > 0.0) { transform_move(camera.base.transform, camera_dir, d); if (context_raw.camera_type == camera_type_t.ORTHOGRAPHIC) { diff --git a/base/sources/ts/compass.ts b/base/sources/ts/compass.ts index a64d6045..9562fe0c 100644 --- a/base/sources/ts/compass.ts +++ b/base/sources/ts/compass.ts @@ -16,7 +16,7 @@ function compass_render() { let _visible: bool = compass.base.visible; let _parent: object_t = compass.base.parent; let crot: quat_t = cam.base.transform.rot; - let ratio: f32 = app_w() / app_h(); + let ratio: f32 = sys_w() / sys_h(); let _P: mat4_t = cam.p; cam.p = mat4_ortho(-8 * ratio, 8 * ratio, -8, 8, -2, 2); compass.base.visible = true; @@ -79,14 +79,14 @@ function compass_update() { } _compass_hovered = null; - let x: f32 = mouse_view_x() / app_w(); - let y: f32 = mouse_view_y() / app_h(); + let x: f32 = mouse_view_x() / sys_w(); + let y: f32 = mouse_view_y() / sys_h(); let hover: bool = x > 0.9 && x < 1.0 && y < 0.14 && y > 0.0; if (hover) { compass_init_hitbox(); - let ratio: f32 = app_w() / app_h(); + let ratio: f32 = sys_w() / sys_h(); let _P: mat4_t = scene_camera.p; scene_camera.p = mat4_ortho(-8 * ratio, 8 * ratio, -8, 8, -2, 2); diff --git a/base/sources/ts/console.ts b/base/sources/ts/console.ts index 97e7f670..70281d3a 100644 --- a/base/sources/ts/console.ts +++ b/base/sources/ts/console.ts @@ -20,12 +20,12 @@ function console_draw_toast(s: string) { function _console_toast_render(s: string) { console_draw_toast(s); gpu_swap_buffers(); - app_remove_render_2d(_console_toast_render); + sys_remove_render_2d(_console_toast_render); } function console_toast(s: string) { // Show a popup message - app_notify_on_render_2d(_console_toast_render, s); + sys_notify_on_render_2d(_console_toast_render, s); console_trace(s); gpu_swap_buffers(); } @@ -37,10 +37,10 @@ function console_draw_progress() { function console_progress(s: string) { // Keep popup message displayed until s == null if (s == null) { - app_remove_render_2d(console_draw_progress); + sys_remove_render_2d(console_draw_progress); } else if (console_progress_text == null) { - app_notify_on_render_2d(console_draw_progress); + sys_notify_on_render_2d(console_draw_progress); } if (s != null) { console_trace(s); @@ -51,7 +51,7 @@ function console_progress(s: string) { ///if (!arm_vulkan) // TODO ui_end_input(); draw_end(); - app_render(); + sys_render(); draw_begin(); gpu_swap_buffers(); ///end diff --git a/base/sources/ts/context.ts b/base/sources/ts/context.ts index 66955b6b..3d7efc77 100644 --- a/base/sources/ts/context.ts +++ b/base/sources/ts/context.ts @@ -490,7 +490,7 @@ function context_set_material(m: slot_material_t) { let decal: bool = context_is_decal(); if (decal) { - app_notify_on_next_frame(util_render_make_decal_preview); + sys_notify_on_next_frame(util_render_make_decal_preview); } } @@ -644,12 +644,12 @@ function context_in_paint_area(): bool { return context_in_viewport(); ///end - let right: i32 = app_w(); + let right: i32 = sys_w(); if (ui_view2d_show) { right += ui_view2d_ww; } return mouse_view_x() > 0 && mouse_view_x() < right && - mouse_view_y() > 0 && mouse_view_y() < app_h(); + mouse_view_y() > 0 && mouse_view_y() < sys_h(); } function context_in_layers(): bool { @@ -778,7 +778,7 @@ function context_set_render_path() { else { render_path_commands = render_path_deferred_commands; } - app_notify_on_init(make_material_parse_mesh_material); + sys_notify_on_init(make_material_parse_mesh_material); } function context_enable_import_plugin(file: string): bool { diff --git a/base/sources/ts/export_arm.ts b/base/sources/ts/export_arm.ts index 5be0e9ed..9539672a 100644 --- a/base/sources/ts/export_arm.ts +++ b/base/sources/ts/export_arm.ts @@ -176,7 +176,7 @@ function export_arm_run_project() { let rt: render_target_t = map_get(render_path_render_targets, context_raw.render_mode == render_mode_t.FORWARD ? "buf" : "tex"); let tex: iron_gpu_texture_t = rt._image; let mesh_icon: iron_gpu_texture_t = gpu_create_render_target(256, 256); - let r: f32 = app_w() / app_h(); + let r: f32 = sys_w() / sys_h(); draw_begin(mesh_icon); draw_scaled_image(tex, -(256 * r - 256) / 2, 0, 256 * r, 256); draw_end(); @@ -196,7 +196,7 @@ function export_arm_run_project() { export_arm_bgra_swap(mesh_icon_pixels); ///end - app_notify_on_next_frame(function (mesh_icon: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (mesh_icon: iron_gpu_texture_t) { iron_unload_image(mesh_icon); }); @@ -501,7 +501,7 @@ function export_arm_pack_assets(raw: project_format_t, assets: asset_t[]) { array_push(raw.packed_assets, pa); } } - app_notify_on_next_frame(function (temp_images: iron_gpu_texture_t[]) { + sys_notify_on_next_frame(function (temp_images: iron_gpu_texture_t[]) { for (let i: i32 = 0; i < temp_images.length; ++i) { let image: iron_gpu_texture_t = temp_images[i]; iron_unload_image(image); diff --git a/base/sources/ts/history.ts b/base/sources/ts/history.ts index d830c02f..608cdb8a 100644 --- a/base/sources/ts/history.ts +++ b/base/sources/ts/history.ts @@ -42,7 +42,7 @@ function history_undo() { // Undo at least second time in order to avoid empty groups if (step.layer_type == layer_slot_type_t.GROUP) { - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { let active: i32 = history_steps.length - 1 - history_redos; // 1. Undo deleting group masks let n: i32 = 1; @@ -142,7 +142,7 @@ function history_undo() { context_set_layer(context_raw.layer); } else if (step.name == tr("Invert Mask")) { - app_notify_on_init(function (step: step_t) { + sys_notify_on_init(function (step: step_t) { context_raw.layer = project_layers[step.layer]; slot_layer_invert_mask(context_raw.layer); }, step); @@ -246,18 +246,18 @@ function history_redo() { let l: slot_layer_t = slot_layer_create("", step.layer_type, parent); array_insert(project_layers, step.layer, l); if (step.name == tr("New Black Mask")) { - app_notify_on_next_frame(function (l: slot_layer_t) { + sys_notify_on_next_frame(function (l: slot_layer_t) { slot_layer_clear(l, 0x00000000); }, l); } else if (step.name == tr("New White Mask")) { - app_notify_on_next_frame(function (l: slot_layer_t) { + sys_notify_on_next_frame(function (l: slot_layer_t) { slot_layer_clear(l, 0xffffffff); }, l); } else if (step.name == tr("New Fill Mask")) { context_raw.material = project_materials[step.material]; - app_notify_on_next_frame(function (l: slot_layer_t) { + sys_notify_on_next_frame(function (l: slot_layer_t) { slot_layer_to_fill_layer(l); }, l); } @@ -280,7 +280,7 @@ function history_redo() { // Redoing the last delete would result in an empty group // Redo deleting all group masks + the group itself if (step.layer_type == layer_slot_type_t.LAYER && history_steps.length >= active + 2 && (history_steps[active + 1].layer_type == layer_slot_type_t.GROUP || history_steps[active + 1].layer_type == layer_slot_type_t.MASK)) { - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { let active: i32 = history_steps.length - history_redos; let n: i32 = 1; while (history_steps[active + n].layer_type == layer_slot_type_t.MASK) { @@ -301,7 +301,7 @@ function history_redo() { } else if (step.name == tr("Duplicate Layer")) { context_raw.layer = project_layers[step.layer]; - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { layers_duplicate_layer(context_raw.layer); }); } @@ -312,8 +312,8 @@ function history_redo() { } else if (step.name == tr("Merge Layers")) { context_raw.layer = project_layers[step.layer + 1]; - app_notify_on_init(history_redo_merge_layers); - app_notify_on_init(layers_merge_down); + sys_notify_on_init(history_redo_merge_layers); + sys_notify_on_init(layers_merge_down); } else if (step.name == tr("Apply Mask")) { context_raw.layer = project_layers[step.layer]; @@ -328,14 +328,14 @@ function history_redo() { history_copy_merging_layers2(layers); } - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { slot_layer_apply_mask(context_raw.layer); context_set_layer(context_raw.layer); context_raw.layers_preview_dirty = true; }); } else if (step.name == tr("Invert Mask")) { - app_notify_on_init(function (step: step_t) { + sys_notify_on_init(function (step: step_t) { context_raw.layer = project_layers[step.layer]; slot_layer_invert_mask(context_raw.layer); }, step); diff --git a/base/sources/ts/import_arm.ts b/base/sources/ts/import_arm.ts index 50acdc81..ff386137 100644 --- a/base/sources/ts/import_arm.ts +++ b/base/sources/ts/import_arm.ts @@ -197,7 +197,7 @@ function import_arm_run_project(path: string) { let rts: map_t = render_path_render_targets; let blend0: render_target_t = map_get(rts, "texpaint_blend0"); let _texpaint_blend0: iron_gpu_texture_t = blend0._image; - app_notify_on_next_frame(function (_texpaint_blend0: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint_blend0: iron_gpu_texture_t) { iron_unload_image(_texpaint_blend0); }, _texpaint_blend0); blend0.width = config_get_texture_res_x(); @@ -205,7 +205,7 @@ function import_arm_run_project(path: string) { blend0._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8, 0); let blend1: render_target_t = map_get(rts, "texpaint_blend1"); let _texpaint_blend1: iron_gpu_texture_t = blend1._image; - app_notify_on_next_frame(function (_texpaint_blend1: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint_blend1: iron_gpu_texture_t) { iron_unload_image(_texpaint_blend1); }, _texpaint_blend1); blend1.width = config_get_texture_res_x(); @@ -301,18 +301,18 @@ function import_arm_run_project(path: string) { l.paint_subs = ld.paint_subs; ///end - app_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { iron_unload_image(_texpaint); }, _texpaint); ///if is_paint if (_texpaint_nor != null) { - app_notify_on_next_frame(function (_texpaint_nor: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint_nor: iron_gpu_texture_t) { iron_unload_image(_texpaint_nor); }, _texpaint_nor); } if (_texpaint_pack != null) { - app_notify_on_next_frame(function (_texpaint_pack: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint_pack: iron_gpu_texture_t) { iron_unload_image(_texpaint_pack); }, _texpaint_pack); } @@ -421,7 +421,7 @@ function import_arm_run_mesh(raw: project_format_t) { util_mesh_merge(); viewport_scale_to_bounds(); } - app_notify_on_init(layers_init); + sys_notify_on_init(layers_init); history_reset(); } @@ -494,7 +494,7 @@ function import_arm_run_material_from_project(project: project_format_t, path: s } } - app_notify_on_init(function (imported: slot_material_t[]) { + sys_notify_on_init(function (imported: slot_material_t[]) { for (let i: i32 = 0; i < imported.length; ++i) { let m: slot_material_t = imported[i]; context_set_material(m); @@ -584,7 +584,7 @@ function import_arm_run_brush_from_project(project: project_format_t, path: stri array_push(imported, context_raw.brush); } - app_notify_on_init(function (imported: slot_brush_t[]) { + sys_notify_on_init(function (imported: slot_brush_t[]) { for (let i: i32 = 0; i < imported.length; ++i) { let b: slot_brush_t = imported[i]; context_set_brush(b); diff --git a/base/sources/ts/import_blend_material.ts b/base/sources/ts/import_blend_material.ts index 36ef7886..c97370ee 100644 --- a/base/sources/ts/import_blend_material.ts +++ b/base/sources/ts/import_blend_material.ts @@ -38,7 +38,7 @@ function _import_blend_material() { if (g2_in_use) draw_begin(current); - app_notify_on_init(function () { + sys_notify_on_init(function () { let save: string; if (path_is_protected()) { diff --git a/base/sources/ts/import_envmap.ts b/base/sources/ts/import_envmap.ts index 46a4e635..4ca80fe4 100644 --- a/base/sources/ts/import_envmap.ts +++ b/base/sources/ts/import_envmap.ts @@ -44,7 +44,7 @@ function import_envmap_run(path: string, image: iron_gpu_texture_t) { let radiance_pixels: buffer_t = gpu_get_texture_pixels(import_envmap_radiance); if (import_envmap_radiance_cpu != null) { let _radiance_cpu: iron_gpu_texture_t = import_envmap_radiance_cpu; - app_notify_on_next_frame(function (_radiance_cpu: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_radiance_cpu: iron_gpu_texture_t) { iron_unload_image(_radiance_cpu); }, _radiance_cpu); } @@ -54,7 +54,7 @@ function import_envmap_run(path: string, image: iron_gpu_texture_t) { if (import_envmap_mips_cpu != null) { for (let i: i32 = 0; i < import_envmap_mips_cpu.length; ++i) { let mip: iron_gpu_texture_t = import_envmap_mips_cpu[i]; - app_notify_on_next_frame(function (mip: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (mip: iron_gpu_texture_t) { ///if (!arm_direct3d12) // TODO: crashes after 50+ imports iron_unload_image(mip); ///end diff --git a/base/sources/ts/import_font.ts b/base/sources/ts/import_font.ts index f0f36dc1..c341f91e 100644 --- a/base/sources/ts/import_font.ts +++ b/base/sources/ts/import_font.ts @@ -27,7 +27,7 @@ function import_font_run(path: string) { array_push(font_slots, font_slot); } - app_notify_on_init(function (font_slots: slot_font_t[]) { + sys_notify_on_init(function (font_slots: slot_font_t[]) { for (let i: i32 = 0; i < font_slots.length; ++i) { let f: slot_font_t = font_slots[i]; context_raw.font = f; diff --git a/base/sources/ts/import_mesh.ts b/base/sources/ts/import_mesh.ts index 148132fa..f83b69e3 100644 --- a/base/sources/ts/import_mesh.ts +++ b/base/sources/ts/import_mesh.ts @@ -127,7 +127,7 @@ function _import_mesh_make_mesh(mesh: raw_mesh_t) { let handle: string = context_raw.paint_object.data._.handle; if (handle != "SceneSphere" && handle != "ScenePlane") { - app_notify_on_init(function(md: mesh_data_t) { + sys_notify_on_init(function(md: mesh_data_t) { mesh_data_delete(md); }, context_raw.paint_object.data); } @@ -156,17 +156,17 @@ function _import_mesh_make_mesh(mesh: raw_mesh_t) { slot_layer_unload(l); } layers_new_layer(false); - app_notify_on_init(layers_init); + sys_notify_on_init(layers_init); history_reset(); } ///end // Wait for add_mesh calls to finish if (import_mesh_meshes_to_unwrap != null) { - app_notify_on_next_frame(import_mesh_finish_import); + sys_notify_on_next_frame(import_mesh_finish_import); } else { - app_notify_on_init(import_mesh_finish_import); + sys_notify_on_init(import_mesh_finish_import); } } diff --git a/base/sources/ts/import_texture.ts b/base/sources/ts/import_texture.ts index b1f71bfa..7e86178d 100644 --- a/base/sources/ts/import_texture.ts +++ b/base/sources/ts/import_texture.ts @@ -20,7 +20,7 @@ function import_texture_run(path: string, hdr_as_envmap: bool = true) { if (hdr_as_envmap && ends_with(to_lower_case(path), ".hdr")) { let image: iron_gpu_texture_t = data_get_image(path); let itd: import_texture_data_t = { path: path, image: image }; - app_notify_on_next_frame(function (itd: import_texture_data_t) { // Make sure file browser process did finish + sys_notify_on_next_frame(function (itd: import_texture_data_t) { // Make sure file browser process did finish import_envmap_run(itd.path, itd.image); }, itd); } @@ -56,7 +56,7 @@ function import_texture_run(path: string, hdr_as_envmap: bool = true) { // Set as envmap if (hdr_as_envmap && ends_with(to_lower_case(path), ".hdr")) { let itd: import_texture_data_t = { path: path, image: image }; - app_notify_on_next_frame(function (itd: import_texture_data_t) { // Make sure file browser process did finish + sys_notify_on_next_frame(function (itd: import_texture_data_t) { // Make sure file browser process did finish import_envmap_run(itd.path, itd.image); }, itd); } diff --git a/base/sources/ts/iron/app.ts b/base/sources/ts/iron/app.ts deleted file mode 100644 index 881b5c25..00000000 --- a/base/sources/ts/iron/app.ts +++ /dev/null @@ -1,223 +0,0 @@ - -type callback_t = { - f?: (data?: any)=>void; - data?: any; -}; - -let app_on_resets: callback_t[] = []; -let app_on_next_frames: callback_t[] = []; -let app_on_end_frames: callback_t[] = []; -let app_on_inits: callback_t[] = []; -let app_on_updates: callback_t[] = []; -let app_on_renders: callback_t[] = []; -let app_on_renders_2d: callback_t[] = []; -let app_pause_updates: bool = false; -let app_lastw: i32 = -1; -let app_lasth: i32 = -1; -let app_on_resize: ()=>void = null; -let app_on_w: ()=>i32 = null; -let app_on_h: ()=>i32 = null; -let app_on_x: ()=>i32 = null; -let app_on_y: ()=>i32 = null; - -function app_w(): i32 { - if (app_on_w != null) { - return app_on_w(); - } - return iron_window_width(); -} - -function app_h(): i32 { - if (app_on_h != null) { - return app_on_h(); - } - return iron_window_height(); -} - -function app_x(): i32 { - if (app_on_x != null) { - return app_on_x(); - } - return 0; -} - -function app_y(): i32 { - if (app_on_y != null) { - return app_on_y(); - } - return 0; -} - -function app_init() { - sys_notify_on_frames(app_render); -} - -function app_reset() { - app_on_next_frames = []; - app_on_end_frames = []; - app_on_inits = []; - app_on_updates = []; - app_on_renders = []; - app_on_renders_2d = []; - for (let i: i32 = 0; i < app_on_resets.length; ++i) { - let cb: callback_t = app_on_resets[i]; - cb.f(cb.data); - } -} - -function _app_run_callbacks(cbs: callback_t[]) { - for (let i: i32 = 0; i < cbs.length; ++i) { - let cb: callback_t = cbs[i]; - cb.f(cb.data); - } -} - -function app_update() { - if (!_scene_ready) { - return; - } - if (app_pause_updates) { - return; - } - - if (app_on_next_frames.length > 0) { - _app_run_callbacks(app_on_next_frames); - array_splice(app_on_next_frames, 0, app_on_next_frames.length); - } - - scene_update_frame(); - - let i: i32 = 0; - let l: i32 = app_on_updates.length; - while (i < l) { - if (app_on_inits.length > 0) { - _app_run_callbacks(app_on_inits); - array_splice(app_on_inits, 0, app_on_inits.length); - } - - let cb: callback_t = app_on_updates[i]; - cb.f(cb.data); - - // Account for removed traits - if (l <= app_on_updates.length) { - i++; - } - else { - l = app_on_updates.length; - } - } - - _app_run_callbacks(app_on_end_frames); - - // Rebuild projection on window resize - if (app_lastw == -1) { - app_lastw = app_w(); - app_lasth = app_h(); - } - if (app_lastw != app_w() || app_lasth != app_h()) { - if (app_on_resize != null) { - app_on_resize(); - } - else if (scene_camera != null) { - camera_object_build_proj(scene_camera); - } - } - app_lastw = app_w(); - app_lasth = app_h(); -} - -function app_render() { - app_update(); - time_update(); - - if (!_scene_ready) { - app_render_2d(); - return; - } - - if (app_on_inits.length > 0) { - _app_run_callbacks(app_on_inits); - array_splice(app_on_inits, 0, app_on_inits.length); - } - - scene_render_frame(); - _app_run_callbacks(app_on_renders); - app_render_2d(); -} - -function app_render_2d() { - if (app_on_renders_2d.length > 0) { - draw_begin(); - _app_run_callbacks(app_on_renders_2d); - draw_end(); - } -} - -function _callback_create(f: (data?: any)=>void, data: any): callback_t { - let cb: callback_t = {}; - cb.f = f; - cb.data = data; - return cb; -} - -// Hooks -function app_notify_on_init(f: (data?: any)=>void, data: any = null) { - array_push(app_on_inits, _callback_create(f, data)); -} - -function app_notify_on_update(f: (data?: any)=>void, data: any = null) { - array_push(app_on_updates, _callback_create(f, data)); -} - -function app_notify_on_render(f: (data?: any)=>void, data: any = null) { - array_push(app_on_renders, _callback_create(f, data)); -} - -function app_notify_on_render_2d(f: (data?: any)=>void, data: any = null) { - array_push(app_on_renders_2d, _callback_create(f, data)); -} - -function app_notify_on_reset(f: (data?: any)=>void, data: any = null) { - array_push(app_on_resets, _callback_create(f, data)); -} - -function app_notify_on_next_frame(f: (data?: any)=>void, data: any = null) { - array_push(app_on_next_frames, _callback_create(f, data)); -} - -function app_notify_on_end_frame(f: (data?: any)=>void, data: any = null) { - array_push(app_on_end_frames, _callback_create(f, data)); -} - -function _app_remove_callback(ar: callback_t[], f: (data?: any)=>void) { - for (let i: i32 = 0; i < ar.length; ++i) { - if (ar[i].f == f) { - array_splice(ar, i, 1); - break; - } - } -} - -function app_remove_init(f: (data?: any)=>void) { - _app_remove_callback(app_on_inits, f); -} - -function app_remove_update(f: (data?: any)=>void) { - _app_remove_callback(app_on_updates, f); -} - -function app_remove_render(f: (data?: any)=>void) { - _app_remove_callback(app_on_renders, f); -} - -function app_remove_render_2d(f: (data?: any)=>void) { - _app_remove_callback(app_on_renders_2d, f); -} - -function app_remove_reset(f: (data?: any)=>void) { - _app_remove_callback(app_on_resets, f); -} - -function app_remove_end_frame(f: (data?: any)=>void) { - _app_remove_callback(app_on_end_frames, f); -} diff --git a/base/sources/ts/iron/camera_object.ts b/base/sources/ts/iron/camera_object.ts index b1391f41..4ae864f7 100644 --- a/base/sources/ts/iron/camera_object.ts +++ b/base/sources/ts/iron/camera_object.ts @@ -46,7 +46,7 @@ function camera_object_build_proj(raw: camera_object_t, screen_aspect: f32 = -1. } else { if (screen_aspect < 0) { - screen_aspect = app_w() / app_h(); + screen_aspect = sys_w() / sys_h(); } let aspect: f32 = raw.data.aspect ? raw.data.aspect : screen_aspect; raw.p = mat4_persp(raw.data.fov, aspect, raw.data.near_plane, raw.data.far_plane); diff --git a/base/sources/ts/iron/input.ts b/base/sources/ts/iron/input.ts index e079a028..7d648f97 100644 --- a/base/sources/ts/iron/input.ts +++ b/base/sources/ts/iron/input.ts @@ -26,8 +26,8 @@ function input_register() { return; } _input_registered = true; - app_notify_on_end_frame(input_end_frame); - app_notify_on_reset(input_reset); + sys_notify_on_end_frame(input_end_frame); + sys_notify_on_reset(input_reset); // Reset mouse delta on foreground sys_notify_on_app_state(_input_on_foreground, null, null, null, null); keyboard_reset(); @@ -220,11 +220,11 @@ function mouse_on_touch_move(index: i32, x: i32, y: i32) { ///end function mouse_view_x(): f32 { - return mouse_x - app_x(); + return mouse_x - sys_x(); } function mouse_view_y(): f32 { - return mouse_y - app_y(); + return mouse_y - sys_y(); } let pen_buttons: string[] = ["tip"]; @@ -333,11 +333,11 @@ function pen_move_listener(x: i32, y: i32, pressure: f32) { } function pen_view_x(): f32 { - return pen_x - app_x(); + return pen_x - sys_x(); } function pen_view_y(): f32 { - return pen_y - app_y(); + return pen_y - sys_y(); } let keyboard_keys: string[] = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "space", "backspace", "tab", "enter", "shift", "control", "alt", "win", "escape", "delete", "up", "down", "left", "right", "back", ",", ".", ":", ";", "<", "=", ">", "?", "!", "\"", "#", "$", "%", "&", "_", "(", ")", "*", "|", "{", "}", "[", "]", "~", "`", "/", "\\", "@", "+", "-", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12"]; diff --git a/base/sources/ts/iron/object.ts b/base/sources/ts/iron/object.ts index c0da3adf..aaf12ec7 100644 --- a/base/sources/ts/iron/object.ts +++ b/base/sources/ts/iron/object.ts @@ -128,7 +128,7 @@ function object_setup_animation_super(raw: object_t, oactions: scene_t[] = null) // Parented to bone ///if arm_skin if (raw.raw.anim != null && raw.raw.anim.parent_bone != null) { - app_notify_on_init(_object_setup_animation_on_init, raw); + sys_notify_on_init(_object_setup_animation_on_init, raw); } ///end // object_t actions diff --git a/base/sources/ts/iron/raycast.ts b/base/sources/ts/iron/raycast.ts index d4ba970f..fdf188b7 100644 --- a/base/sources/ts/iron/raycast.ts +++ b/base/sources/ts/iron/raycast.ts @@ -19,8 +19,8 @@ function raycast_get_ray(input_x: f32, input_y: f32, camera: camera_object_t): r // Get 3D point form screen coords // Set two vectors with opposing z values - start.x = (input_x / app_w()) * 2.0 - 1.0; - start.y = -((input_y / app_h()) * 2.0 - 1.0); + start.x = (input_x / sys_w()) * 2.0 - 1.0; + start.y = -((input_y / sys_h()) * 2.0 - 1.0); start.z = -1.0; end.x = start.x; end.y = start.y; diff --git a/base/sources/ts/iron/render_path.ts b/base/sources/ts/iron/render_path.ts index f00b1c58..7c12a904 100644 --- a/base/sources/ts/iron/render_path.ts +++ b/base/sources/ts/iron/render_path.ts @@ -55,21 +55,21 @@ function render_path_ready(): bool { } function render_path_render_frame() { - if (!render_path_ready() ||_render_path_paused || app_w() == 0 || app_h() == 0) { + if (!render_path_ready() ||_render_path_paused || sys_w() == 0 || sys_h() == 0) { return; } - if (_render_path_last_w > 0 && (_render_path_last_w != app_w() ||_render_path_last_h != app_h())) { + if (_render_path_last_w > 0 && (_render_path_last_w != sys_w() ||_render_path_last_h != sys_h())) { render_path_resize(); } - _render_path_last_w = app_w(); - _render_path_last_h = app_h(); + _render_path_last_w = sys_w(); + _render_path_last_h = sys_h(); _render_path_frame_time = sys_time() -_render_path_last_frame_time; _render_path_last_frame_time = sys_time(); - render_path_current_w = app_w(); - render_path_current_h = app_h(); + render_path_current_w = sys_w(); + render_path_current_h = sys_h(); _render_path_meshes_sorted = false; render_path_commands(); @@ -80,11 +80,11 @@ function render_path_render_frame() { function render_path_set_target(target: string, additional: string[] = null) { if (target == "") { // Framebuffer _render_path_current_target = null; - render_path_current_w = app_w(); - render_path_current_h = app_h(); + render_path_current_w = sys_w(); + render_path_current_h = sys_h(); render_path_begin(); - render_path_set_current_viewport(app_w(), app_h()); - render_path_set_current_scissor(app_w(), app_h()); + render_path_set_current_viewport(sys_w(), sys_h()); + render_path_set_current_scissor(sys_w(), sys_h()); } else { // Render target let rt: render_target_t = map_get(render_path_render_targets, target); @@ -130,11 +130,11 @@ function render_path_end() { } function render_path_set_current_viewport(view_w: i32, view_h: i32) { - gpu_viewport(app_x(),render_path_current_h - (view_h - app_y()), view_w, view_h); + gpu_viewport(sys_x(),render_path_current_h - (view_h - sys_y()), view_w, view_h); } function render_path_set_current_scissor(view_w: i32, view_h: i32) { - gpu_scissor(app_x(),render_path_current_h - (view_h - app_y()), view_w, view_h); + gpu_scissor(sys_x(),render_path_current_h - (view_h - sys_y()), view_w, view_h); _render_path_scissor_set = true; } @@ -323,7 +323,7 @@ function render_path_resize() { let rt: render_target_t = map_get(render_path_render_targets, render_targets_keys[i]); if (rt != null && rt.width == 0) { let _image: iron_gpu_texture_t = rt._image; - app_notify_on_init(_render_path_resize_on_init, _image); + sys_notify_on_init(_render_path_resize_on_init, _image); rt._image = render_path_create_image(rt, rt._depth_buffer_bits); } } @@ -384,8 +384,8 @@ function render_path_create_target(t: render_target_t): render_target_t { } function render_path_create_image(t: render_target_t, depth_buffer_bits: i32): iron_gpu_texture_t { - let width: i32 = t.width == 0 ? app_w() : t.width; - let height: i32 = t.height == 0 ? app_h() : t.height; + let width: i32 = t.width == 0 ? sys_w() : t.width; + let height: i32 = t.height == 0 ? sys_h() : t.height; width = math_floor(width * t.scale); height = math_floor(height * t.scale); if (width < 1) { diff --git a/base/sources/ts/iron/scene.ts b/base/sources/ts/iron/scene.ts index 3f2b40e6..9545a14b 100644 --- a/base/sources/ts/iron/scene.ts +++ b/base/sources/ts/iron/scene.ts @@ -98,7 +98,7 @@ function scene_update_frame() { ///if arm_anim for (let i: i32 = 0; i < scene_animations.length; ++i) { let anim: anim_raw_t = scene_animations[i]; - anim_update(anim, time_delta()); + anim_update(anim, sys_delta()); } ///end for (let i: i32 = 0; i < scene_empties.length; ++i) { diff --git a/base/sources/ts/iron/speaker_object.ts b/base/sources/ts/iron/speaker_object.ts index 65a7b6da..ea0a32d3 100644 --- a/base/sources/ts/iron/speaker_object.ts +++ b/base/sources/ts/iron/speaker_object.ts @@ -26,7 +26,7 @@ function speaker_object_create(data: speaker_data_t): speaker_object_t { } raw.sound = data_get_sound(data.sound); - app_notify_on_init(_speaker_object_create_on_init, raw); + sys_notify_on_init(_speaker_object_create_on_init, raw); return raw; } @@ -52,7 +52,7 @@ function speaker_object_play(raw: speaker_object_t) { if (channel != null) { array_push(raw.channels, channel); if (raw.data.attenuation > 0 && raw.channels.length == 1) { - app_notify_on_update(speaker_object_update, raw); + sys_notify_on_update(speaker_object_update, raw); } } } @@ -84,7 +84,7 @@ function speaker_object_update(raw: speaker_object_t) { // } } if (raw.channels.length == 0) { - app_remove_update(speaker_object_update); + sys_remove_update(speaker_object_update); return; } diff --git a/base/sources/ts/iron/sys.ts b/base/sources/ts/iron/sys.ts index 29ab62de..11d93b6c 100644 --- a/base/sources/ts/iron/sys.ts +++ b/base/sources/ts/iron/sys.ts @@ -7,6 +7,11 @@ type sys_string_callback_t = { f?: (s: string)=>void; }; +type callback_t = { + f?: (data?: any)=>void; + data?: any; +}; + let _sys_render_listeners: sys_callback_t[] = []; let _sys_foreground_listeners: sys_callback_t[] = []; let _sys_resume_listeners: sys_callback_t[] = []; @@ -340,3 +345,239 @@ enum window_mode_t { WINDOWED, FULLSCREEN, } + +let _sys_on_resets: callback_t[] = []; +let _sys_on_next_frames: callback_t[] = []; +let _sys_on_end_frames: callback_t[] = []; +let _sys_on_inits: callback_t[] = []; +let _sys_on_updates: callback_t[] = []; +let _sys_on_renders: callback_t[] = []; +let _sys_on_renders_2d: callback_t[] = []; +let _sys_pause_updates: bool = false; +let _sys_lastw: i32 = -1; +let _sys_lasth: i32 = -1; +let sys_on_resize: ()=>void = null; +let sys_on_w: ()=>i32 = null; +let sys_on_h: ()=>i32 = null; +let sys_on_x: ()=>i32 = null; +let sys_on_y: ()=>i32 = null; + +function sys_w(): i32 { + if (sys_on_w != null) { + return sys_on_w(); + } + return iron_window_width(); +} + +function sys_h(): i32 { + if (sys_on_h != null) { + return sys_on_h(); + } + return iron_window_height(); +} + +function sys_x(): i32 { + if (sys_on_x != null) { + return sys_on_x(); + } + return 0; +} + +function sys_y(): i32 { + if (sys_on_y != null) { + return sys_on_y(); + } + return 0; +} + +function sys_init() { + sys_notify_on_frames(sys_render); +} + +function sys_reset() { + _sys_on_next_frames = []; + _sys_on_end_frames = []; + _sys_on_inits = []; + _sys_on_updates = []; + _sys_on_renders = []; + _sys_on_renders_2d = []; + for (let i: i32 = 0; i < _sys_on_resets.length; ++i) { + let cb: callback_t = _sys_on_resets[i]; + cb.f(cb.data); + } +} + +function _sys_run_callbacks(cbs: callback_t[]) { + for (let i: i32 = 0; i < cbs.length; ++i) { + let cb: callback_t = cbs[i]; + cb.f(cb.data); + } +} + +function sys_update() { + if (!_scene_ready) { + return; + } + if (_sys_pause_updates) { + return; + } + + if (_sys_on_next_frames.length > 0) { + _sys_run_callbacks(_sys_on_next_frames); + array_splice(_sys_on_next_frames, 0, _sys_on_next_frames.length); + } + + scene_update_frame(); + + let i: i32 = 0; + let l: i32 = _sys_on_updates.length; + while (i < l) { + if (_sys_on_inits.length > 0) { + _sys_run_callbacks(_sys_on_inits); + array_splice(_sys_on_inits, 0, _sys_on_inits.length); + } + + let cb: callback_t = _sys_on_updates[i]; + cb.f(cb.data); + + // Account for removed traits + if (l <= _sys_on_updates.length) { + i++; + } + else { + l = _sys_on_updates.length; + } + } + + _sys_run_callbacks(_sys_on_end_frames); + + // Rebuild projection on window resize + if (_sys_lastw == -1) { + _sys_lastw = sys_w(); + _sys_lasth = sys_h(); + } + if (_sys_lastw != sys_w() || _sys_lasth != sys_h()) { + if (sys_on_resize != null) { + sys_on_resize(); + } + else if (scene_camera != null) { + camera_object_build_proj(scene_camera); + } + } + _sys_lastw = sys_w(); + _sys_lasth = sys_h(); +} + +let _sys_time_last: f32 = 0.0; +let _sys_time_real_delta: f32 = 0.0; +let _sys_time_frequency: i32 = -1; + +function sys_delta(): f32 { + if (_sys_time_frequency < 0) { + _sys_time_frequency = sys_display_frequency(); + } + return (1 / _sys_time_frequency); +} + +function sys_real_delta(): f32 { + return _sys_time_real_delta; +} + +function sys_render() { + sys_update(); + + _sys_time_real_delta = sys_time() - _sys_time_last; + _sys_time_last = sys_time(); + + if (!_scene_ready) { + sys_render_2d(); + return; + } + + if (_sys_on_inits.length > 0) { + _sys_run_callbacks(_sys_on_inits); + array_splice(_sys_on_inits, 0, _sys_on_inits.length); + } + + scene_render_frame(); + _sys_run_callbacks(_sys_on_renders); + sys_render_2d(); +} + +function sys_render_2d() { + if (_sys_on_renders_2d.length > 0) { + draw_begin(); + _sys_run_callbacks(_sys_on_renders_2d); + draw_end(); + } +} + +function _callback_create(f: (data?: any)=>void, data: any): callback_t { + let cb: callback_t = {}; + cb.f = f; + cb.data = data; + return cb; +} + +// Hooks +function sys_notify_on_init(f: (data?: any)=>void, data: any = null) { + array_push(_sys_on_inits, _callback_create(f, data)); +} + +function sys_notify_on_update(f: (data?: any)=>void, data: any = null) { + array_push(_sys_on_updates, _callback_create(f, data)); +} + +function sys_notify_on_render(f: (data?: any)=>void, data: any = null) { + array_push(_sys_on_renders, _callback_create(f, data)); +} + +function sys_notify_on_render_2d(f: (data?: any)=>void, data: any = null) { + array_push(_sys_on_renders_2d, _callback_create(f, data)); +} + +function sys_notify_on_reset(f: (data?: any)=>void, data: any = null) { + array_push(_sys_on_resets, _callback_create(f, data)); +} + +function sys_notify_on_next_frame(f: (data?: any)=>void, data: any = null) { + array_push(_sys_on_next_frames, _callback_create(f, data)); +} + +function sys_notify_on_end_frame(f: (data?: any)=>void, data: any = null) { + array_push(_sys_on_end_frames, _callback_create(f, data)); +} + +function _sys_remove_callback(ar: callback_t[], f: (data?: any)=>void) { + for (let i: i32 = 0; i < ar.length; ++i) { + if (ar[i].f == f) { + array_splice(ar, i, 1); + break; + } + } +} + +function sys_remove_init(f: (data?: any)=>void) { + _sys_remove_callback(_sys_on_inits, f); +} + +function sys_remove_update(f: (data?: any)=>void) { + _sys_remove_callback(_sys_on_updates, f); +} + +function sys_remove_render(f: (data?: any)=>void) { + _sys_remove_callback(_sys_on_renders, f); +} + +function sys_remove_render_2d(f: (data?: any)=>void) { + _sys_remove_callback(_sys_on_renders_2d, f); +} + +function sys_remove_reset(f: (data?: any)=>void) { + _sys_remove_callback(_sys_on_resets, f); +} + +function sys_remove_end_frame(f: (data?: any)=>void) { + _sys_remove_callback(_sys_on_end_frames, f); +} + diff --git a/base/sources/ts/iron/tilesheet.ts b/base/sources/ts/iron/tilesheet.ts index 357c9c0f..22184bc3 100644 --- a/base/sources/ts/iron/tilesheet.ts +++ b/base/sources/ts/iron/tilesheet.ts @@ -52,7 +52,7 @@ function tilesheet_update(self: tilesheet_t) { return; } - self.time += time_real_delta(); + self.time += sys_real_delta(); let frame_time: f32 = 1 / self.raw.framerate; let frames_to_advance: i32 = 0; diff --git a/base/sources/ts/iron/time.ts b/base/sources/ts/iron/time.ts deleted file mode 100644 index 210b0492..00000000 --- a/base/sources/ts/iron/time.ts +++ /dev/null @@ -1,20 +0,0 @@ - -let _time_last: f32 = 0.0; -let _time_real_delta: f32 = 0.0; -let _time_frequency: i32 = -1; - -function time_delta(): f32 { - if (_time_frequency < 0) { - _time_frequency = sys_display_frequency(); - } - return (1 / _time_frequency); -} - -function time_real_delta(): f32 { - return _time_real_delta; -} - -function time_update() { - _time_real_delta = sys_time() - _time_last; - _time_last = sys_time(); -} diff --git a/base/sources/ts/iron/tween.ts b/base/sources/ts/iron/tween.ts index 8af7edb9..d4bc2f0c 100644 --- a/base/sources/ts/iron/tween.ts +++ b/base/sources/ts/iron/tween.ts @@ -3,14 +3,14 @@ let _tween_anims: tween_anim_t[] = []; let _tween_registered: bool = false; function tween_on_reset() { - app_notify_on_update(tween_update); + sys_notify_on_update(tween_update); tween_reset(); } function _tween_register() { _tween_registered = true; - app_notify_on_update(tween_update); - app_notify_on_reset(tween_on_reset); + sys_notify_on_update(tween_update); + sys_notify_on_reset(tween_on_reset); } function tween_to(anim: tween_anim_t): tween_anim_t { @@ -39,7 +39,7 @@ function tween_reset() { } function tween_update() { - let d: f32 = time_delta(); + let d: f32 = sys_delta(); let i: i32 = _tween_anims.length; while (i-- > 0 && _tween_anims.length > 0) { let a: tween_anim_t = _tween_anims[i]; diff --git a/base/sources/ts/iron/uniforms.ts b/base/sources/ts/iron/uniforms.ts index 91ee93fe..2722dc30 100644 --- a/base/sources/ts/iron/uniforms.ts +++ b/base/sources/ts/iron/uniforms.ts @@ -306,7 +306,7 @@ function uniforms_set_context_const(location: iron_gpu_constant_location_t, c: s f = sys_time(); } else if (c.link == "_aspect_ratio_window") { - f = app_w() / app_h(); + f = sys_w() / sys_h(); } else { return false; diff --git a/base/sources/ts/layers.ts b/base/sources/ts/layers.ts index d577e38c..4b809ec8 100644 --- a/base/sources/ts/layers.ts +++ b/base/sources/ts/layers.ts @@ -58,7 +58,7 @@ function layers_resize() { } while (history_undo_layers.length > conf.undo_steps) { let l: slot_layer_t = array_pop(history_undo_layers); - app_notify_on_next_frame(function (l: slot_layer_t) { + sys_notify_on_next_frame(function (l: slot_layer_t) { slot_layer_unload(l); }, l); } @@ -76,7 +76,7 @@ function layers_resize() { let blend0: render_target_t = map_get(rts, "texpaint_blend0"); let _texpaint_blend0: iron_gpu_texture_t = blend0._image; - app_notify_on_next_frame(function (_texpaint_blend0: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint_blend0: iron_gpu_texture_t) { iron_unload_image(_texpaint_blend0); }, _texpaint_blend0); blend0.width = config_get_texture_res_x(); @@ -85,7 +85,7 @@ function layers_resize() { let blend1: render_target_t = map_get(rts, "texpaint_blend1"); let _texpaint_blend1: iron_gpu_texture_t = blend1._image; - app_notify_on_next_frame(function (_texpaint_blend1: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint_blend1: iron_gpu_texture_t) { iron_unload_image(_texpaint_blend1); }, _texpaint_blend1); blend1.width = config_get_texture_res_x(); @@ -97,7 +97,7 @@ function layers_resize() { let blur: render_target_t = map_get(rts, "texpaint_blur"); if (blur != null) { let _texpaint_blur: iron_gpu_texture_t = blur._image; - app_notify_on_next_frame(function (_texpaint_blur: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint_blur: iron_gpu_texture_t) { iron_unload_image(_texpaint_blur); }, _texpaint_blur); let size_x: f32 = math_floor(config_get_texture_res_x() * 0.95); @@ -134,7 +134,7 @@ function layers_make_temp_img() { if (layers_temp_image != null && (layers_temp_image.width != l.texpaint.width || layers_temp_image.height != l.texpaint.height || layers_temp_image.format != l.texpaint.format)) { let _temptex0: render_target_t = map_get(render_path_render_targets, "temptex0"); - app_notify_on_next_frame(function (_temptex0: render_target_t) { + sys_notify_on_next_frame(function (_temptex0: render_target_t) { render_target_unload(_temptex0); }, _temptex0); map_delete(render_path_render_targets, "temptex0"); @@ -161,7 +161,7 @@ function layers_make_temp_img() { function layers_make_temp_mask_img() { if (pipes_temp_mask_image != null && (pipes_temp_mask_image.width != config_get_texture_res_x() || pipes_temp_mask_image.height != config_get_texture_res_y())) { let _temp_mask_image: iron_gpu_texture_t = pipes_temp_mask_image; - app_notify_on_next_frame(function (_temp_mask_image: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_temp_mask_image: iron_gpu_texture_t) { iron_unload_image(_temp_mask_image); }, _temp_mask_image); pipes_temp_mask_image = null; @@ -183,13 +183,13 @@ function layers_make_export_img() { let _expa: iron_gpu_texture_t = layers_expa; let _expb: iron_gpu_texture_t = layers_expb; let _expc: iron_gpu_texture_t = layers_expc; - app_notify_on_next_frame(function (_expa: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_expa: iron_gpu_texture_t) { iron_unload_image(_expa); }, _expa); - app_notify_on_next_frame(function (_expb: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_expb: iron_gpu_texture_t) { iron_unload_image(_expb); }, _expb); - app_notify_on_next_frame(function (_expc: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_expc: iron_gpu_texture_t) { iron_unload_image(_expc); }, _expc); layers_expa = null; @@ -491,7 +491,7 @@ function layers_new_layer(clear: bool = true, position: i32 = -1): slot_layer_t } } if (clear) { - app_notify_on_init(function (l: slot_layer_t) { + sys_notify_on_init(function (l: slot_layer_t) { slot_layer_clear(l); }, l); } @@ -510,7 +510,7 @@ function layers_new_mask(clear: bool = true, parent: slot_layer_t, position: i32 array_insert(project_layers, position, l); context_set_layer(l); if (clear) { - app_notify_on_init(function (l: slot_layer_t) { + sys_notify_on_init(function (l: slot_layer_t) { slot_layer_clear(l); }, l); } @@ -535,7 +535,7 @@ function layers_create_fill_layer(uv_type: uv_type_t = uv_type_t.UVMAP, decal_ma _layers_uv_type = uv_type; _layers_decal_mat = decal_mat; _layers_position = position; - app_notify_on_init(function () { + sys_notify_on_init(function () { let l: slot_layer_t = layers_new_layer(false, _layers_position); history_new_layer(); l.uv_type = _layers_uv_type; @@ -567,7 +567,7 @@ function layers_create_color_layer(base_color: i32, occlusion: f32 = 1.0, roughn _layers_metallic = metallic; _layers_position = position; - app_notify_on_init(function () { + sys_notify_on_init(function () { let l: slot_layer_t = layers_new_layer(false, _layers_position); history_new_layer(); l.uv_type = uv_type_t.UVMAP; diff --git a/base/sources/ts/main.ts b/base/sources/ts/main.ts index 870b6650..7e33719b 100644 --- a/base/sources/ts/main.ts +++ b/base/sources/ts/main.ts @@ -5,11 +5,11 @@ function main() { iron_set_app_name(manifest_title); config_load(); - app_on_resize = base_on_resize; - app_on_w = base_w; - app_on_h = base_h; - app_on_x = base_x; - app_on_y = base_y; + sys_on_resize = base_on_resize; + sys_on_w = base_w; + sys_on_h = base_h; + sys_on_x = base_x; + sys_on_y = base_y; config_init(); context_init(); @@ -18,7 +18,7 @@ function main() { base_init_layout(); } iron_set_app_name(manifest_title); - app_init(); + sys_init(); scene_set_active("Scene"); uniforms_ext_init(); render_path_base_init(); diff --git a/base/sources/ts/nodes/time_node.ts b/base/sources/ts/nodes/time_node.ts index cb8fa3a4..08d3feb1 100644 --- a/base/sources/ts/nodes/time_node.ts +++ b/base/sources/ts/nodes/time_node.ts @@ -16,7 +16,7 @@ function time_node_get(self: time_node_t, from: i32): logic_node_value_t { return v; } else if (from == 1) { - let v: logic_node_value_t = { _f32: time_delta() }; + let v: logic_node_value_t = { _f32: sys_delta() }; return v; } else { diff --git a/base/sources/ts/parser_material.ts b/base/sources/ts/parser_material.ts index 90c8f89e..245a89ce 100644 --- a/base/sources/ts/parser_material.ts +++ b/base/sources/ts/parser_material.ts @@ -464,7 +464,7 @@ function parser_material_parse_vector_input(inp: ui_node_socket_t): string { function _parser_material_cache_tex_text_node(file: string, text: string) { if (map_get(data_cached_images, file) == null) { - app_notify_on_init(function(text: string) { + sys_notify_on_init(function(text: string) { let _text_tool_text: string = context_raw.text_tool_text; let _text_tool_image: iron_gpu_texture_t = context_raw.text_tool_image; context_raw.text_tool_text = text; diff --git a/base/sources/ts/project.ts b/base/sources/ts/project.ts index a167fa09..4ecccdb4 100644 --- a/base/sources/ts/project.ts +++ b/base/sources/ts/project.ts @@ -76,7 +76,7 @@ function project_save(save_and_quit: bool = false) { _project_save_and_quit = save_and_quit; - app_notify_on_init(function () { + sys_notify_on_init(function () { export_arm_run_project(); if (_project_save_and_quit) { iron_stop(); @@ -202,8 +202,8 @@ function project_new(reset_layers: bool = true) { raw = import_mesh_raw_mesh(mesh); ///if is_sculpt - app_notify_on_next_frame(function (mesh: raw_mesh_t) { - app_notify_on_init(function (mesh: raw_mesh_t) { + sys_notify_on_next_frame(function (mesh: raw_mesh_t) { + sys_notify_on_init(function (mesh: raw_mesh_t) { import_mesh_pack_to_texture(mesh); }, mesh); }, mesh); @@ -309,11 +309,11 @@ function project_new(reset_layers: bool = true) { array_push(project_layers, layer); context_set_layer(layer); if (aspect_ratio_changed) { - app_notify_on_init(layers_resize); + sys_notify_on_init(layers_resize); } ///end - app_notify_on_init(layers_init); + sys_notify_on_init(layers_init); } if (g2_in_use) draw_begin(current); @@ -385,7 +385,7 @@ function project_import_brush() { // Parse brush make_material_parse_brush(); ui_nodes_hwnd.redraws = 2; - app_notify_on_init(util_render_make_brush_preview); + sys_notify_on_init(util_render_make_brush_preview); } // Import from project file else { @@ -617,7 +617,7 @@ function project_reimport_texture_load(path: string, asset: asset_t) { } ///end - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { make_material_parse_paint_material(); ///if (is_paint || is_sculpt) diff --git a/base/sources/ts/render_path_raytrace_bake.ts b/base/sources/ts/render_path_raytrace_bake.ts index 58bf4c0f..c79d8ad5 100644 --- a/base/sources/ts/render_path_raytrace_bake.ts +++ b/base/sources/ts/render_path_raytrace_bake.ts @@ -60,7 +60,7 @@ function render_path_raytrace_bake_commands(parse_paint_material: (b?: bool)=>vo render_path_set_target("baketex0", additional); render_path_draw_meshes("paint"); context_raw.bake_type = _bake_type; - app_notify_on_next_frame(parse_paint_material); + sys_notify_on_next_frame(parse_paint_material); render_path_raytrace_first = true; render_path_raytrace_raytrace_init(render_path_raytrace_bake_get_bake_shader_name(), rebuild, true); @@ -123,7 +123,7 @@ function render_path_raytrace_bake_commands(parse_paint_material: (b?: bool)=>vo render_path_raytrace_bake_rays_pix = render_path_raytrace_frame * samples_per_frame; render_path_raytrace_bake_rays_counter += samples_per_frame; - render_path_raytrace_bake_rays_timer += time_real_delta(); + render_path_raytrace_bake_rays_timer += sys_real_delta(); if (render_path_raytrace_bake_rays_timer >= 1) { render_path_raytrace_bake_rays_sec = render_path_raytrace_bake_rays_counter; render_path_raytrace_bake_rays_timer = 0; diff --git a/base/sources/ts/slot_layer.ts b/base/sources/ts/slot_layer.ts index c128f953..073b7625 100644 --- a/base/sources/ts/slot_layer.ts +++ b/base/sources/ts/slot_layer.ts @@ -184,17 +184,17 @@ function slot_layer_unload(raw: slot_layer_t) { let _texpaint_pack: iron_gpu_texture_t = raw.texpaint_pack; let _texpaint_preview: iron_gpu_texture_t = raw.texpaint_preview; - app_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { iron_unload_image(_texpaint); }, _texpaint); if (_texpaint_nor != null) { - app_notify_on_next_frame(function (_texpaint_nor: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint_nor: iron_gpu_texture_t) { iron_unload_image(_texpaint_nor); }, _texpaint_nor); } if (_texpaint_pack != null) { - app_notify_on_next_frame(function (_texpaint_pack: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint_pack: iron_gpu_texture_t) { iron_unload_image(_texpaint_pack); }, _texpaint_pack); } @@ -274,7 +274,7 @@ function slot_layer_invert_mask(raw: slot_layer_t) { draw_set_pipeline(null); draw_end(); let _texpaint: iron_gpu_texture_t = raw.texpaint; - app_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { iron_unload_image(_texpaint); }, _texpaint); let rt: render_target_t = map_get(render_path_render_targets, "texpaint" + raw.id); @@ -413,18 +413,18 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { draw_end(); } - app_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { iron_unload_image(_texpaint); }, _texpaint); if (_texpaint_nor != null) { - app_notify_on_next_frame(function (_texpaint_nor: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint_nor: iron_gpu_texture_t) { iron_unload_image(_texpaint_nor); }, _texpaint_nor); } if (_texpaint_pack != null) { - app_notify_on_next_frame(function (_texpaint_pack: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint_pack: iron_gpu_texture_t) { iron_unload_image(_texpaint_pack); }, _texpaint_pack); } @@ -452,7 +452,7 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { draw_set_pipeline(null); draw_end(); - app_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { iron_unload_image(_texpaint); }, _texpaint); @@ -465,7 +465,7 @@ function slot_layer_to_fill_layer(raw: slot_layer_t) { context_set_layer(raw); raw.fill_layer = context_raw.material; layers_update_fill_layer(); - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { make_material_parse_paint_material(); context_raw.layer_preview_dirty = true; ui_base_hwnds[tab_area_t.SIDEBAR0].redraws = 2; diff --git a/base/sources/ts/slot_material.ts b/base/sources/ts/slot_material.ts index 8dca3fe7..30ef5093 100644 --- a/base/sources/ts/slot_material.ts +++ b/base/sources/ts/slot_material.ts @@ -70,7 +70,7 @@ function slot_material_create(m: material_data_t = null, c: ui_node_canvas_t = n } function slot_material_unload(raw: slot_material_t) { - app_notify_on_next_frame(function (raw: slot_material_t) { + sys_notify_on_next_frame(function (raw: slot_material_t) { iron_unload_image(raw.image); iron_unload_image(raw.image_icon); }, raw); diff --git a/base/sources/ts/tab_browser.ts b/base/sources/ts/tab_browser.ts index 2f9b1966..d7f86e13 100644 --- a/base/sources/ts/tab_browser.ts +++ b/base/sources/ts/tab_browser.ts @@ -138,7 +138,7 @@ function tab_browser_draw(htab: ui_handle_t) { if (ui_menu_button(tr("Set as Envmap"))) { import_asset_run(file, -1.0, -1.0, true, true, function () { - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { let file: string = _tab_browser_draw_file; let asset_index: i32 = -1; @@ -158,7 +158,7 @@ function tab_browser_draw(htab: ui_handle_t) { ///if (is_paint || is_sculpt) if (ui_menu_button(tr("Set as Mask"))) { import_asset_run(file, -1.0, -1.0, true, true, function () { - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { let file: string = _tab_browser_draw_file; let asset_index: i32 = -1; @@ -179,7 +179,7 @@ function tab_browser_draw(htab: ui_handle_t) { ///if is_paint if (ui_menu_button(tr("Set as Color ID Map"))) { import_asset_run(file, -1.0, -1.0, true, true, function () { - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { let file: string = _tab_browser_draw_file; let asset_index: i32 = -1; @@ -211,7 +211,7 @@ function tab_browser_draw(htab: ui_handle_t) { if (tab_browser_known) { let path: string = tab_browser_hpath.text; - app_notify_on_init(function (path: string) { + sys_notify_on_init(function (path: string) { import_asset_run(path); }, path); tab_browser_hpath.text = substring(tab_browser_hpath.text, 0, string_last_index_of(tab_browser_hpath.text, path_sep)); diff --git a/base/sources/ts/tab_brushes.ts b/base/sources/ts/tab_brushes.ts index 9764d467..0c68229b 100644 --- a/base/sources/ts/tab_brushes.ts +++ b/base/sources/ts/tab_brushes.ts @@ -100,7 +100,7 @@ function tab_brushes_draw(htab: ui_handle_t) { } if (ui_menu_button(tr("Duplicate"))) { - app_notify_on_init(function () { + sys_notify_on_init(function () { let i: i32 = _tab_brushes_draw_i; context_raw.brush = slot_brush_create(); @@ -122,7 +122,7 @@ function tab_brushes_draw(htab: ui_handle_t) { if (img_full == null) { _tab_brushes_draw_i = i; - app_notify_on_init(function () { + sys_notify_on_init(function () { let i: i32 = _tab_brushes_draw_i; let _brush: slot_brush_t = context_raw.brush; diff --git a/base/sources/ts/tab_fonts.ts b/base/sources/ts/tab_fonts.ts index bb4f9f49..4669d1b3 100644 --- a/base/sources/ts/tab_fonts.ts +++ b/base/sources/ts/tab_fonts.ts @@ -92,7 +92,7 @@ function tab_fonts_draw(htab: ui_handle_t) { if (context_raw.font != project_fonts[i]) { _tab_fonts_draw_i = i; - app_notify_on_init(function () { + sys_notify_on_init(function () { let i: i32 = _tab_fonts_draw_i; context_select_font(i); @@ -119,7 +119,7 @@ function tab_fonts_draw(htab: ui_handle_t) { if (img == null) { _tab_fonts_draw_i = i; - app_notify_on_init(function () { + sys_notify_on_init(function () { let i: i32 = _tab_fonts_draw_i; let _font: slot_font_t = context_raw.font; @@ -161,7 +161,7 @@ function tab_fonts_draw(htab: ui_handle_t) { } function tab_fonts_delete_font(font: slot_font_t) { - app_notify_on_init(function (font: slot_font_t) { + sys_notify_on_init(function (font: slot_font_t) { let i: i32 = array_index_of(project_fonts, font); context_select_font(i == project_fonts.length - 1 ? i - 1 : i + 1); data_delete_font(project_fonts[i].file); diff --git a/base/sources/ts/tab_layers.ts b/base/sources/ts/tab_layers.ts index bc8b4046..a8b48a39 100644 --- a/base/sources/ts/tab_layers.ts +++ b/base/sources/ts/tab_layers.ts @@ -105,7 +105,7 @@ function tab_layers_button_new(text: string) { l = context_raw.layer; let m: slot_layer_t = layers_new_mask(false, l); - app_notify_on_next_frame(function (m: slot_layer_t) { + sys_notify_on_next_frame(function (m: slot_layer_t) { slot_layer_clear(m, 0x00000000); }, m); context_raw.layer_preview_dirty = true; @@ -119,7 +119,7 @@ function tab_layers_button_new(text: string) { l = context_raw.layer; let m: slot_layer_t = layers_new_mask(false, l); - app_notify_on_next_frame(function (m: slot_layer_t) { + sys_notify_on_next_frame(function (m: slot_layer_t) { slot_layer_clear(m, 0xffffffff); }, m); context_raw.layer_preview_dirty = true; @@ -133,7 +133,7 @@ function tab_layers_button_new(text: string) { l = context_raw.layer; let m: slot_layer_t = layers_new_mask(false, l); - app_notify_on_init(function (m: slot_layer_t) { + sys_notify_on_init(function (m: slot_layer_t) { slot_layer_to_fill_layer(m); }, m); context_raw.layer_preview_dirty = true; @@ -421,7 +421,7 @@ function tab_layers_draw_layer_slot_full(l: slot_layer_t, i: i32) { ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h; if (in_focus && ui.is_delete_down && tab_layers_can_delete(context_raw.layer)) { ui.is_delete_down = false; - app_notify_on_init(function () { + sys_notify_on_init(function () { tab_layers_delete_layer(context_raw.layer); }); } @@ -500,7 +500,7 @@ function tab_layers_combo_object(ui: ui_t, l: slot_layer_t, label: bool = false) context_set_layer(l); make_material_parse_mesh_material(); if (l.fill_layer != null) { // Fill layer - app_notify_on_init(function (l: slot_layer_t) { + sys_notify_on_init(function (l: slot_layer_t) { context_raw.material = l.fill_layer; slot_layer_clear(l); layers_update_fill_layers(); @@ -764,14 +764,14 @@ function tab_layers_draw_layer_context_menu(l: slot_layer_t, mini: bool) { let to_paint_string: string = slot_layer_is_layer(l) ? tr("To Paint Layer") : tr("To Paint Mask"); if (l.fill_layer == null && ui_menu_button(to_fill_string)) { - app_notify_on_init(function () { + sys_notify_on_init(function () { let l: slot_layer_t = tab_layers_l; slot_layer_is_layer(l) ? history_to_fill_layer() : history_to_fill_mask(); slot_layer_to_fill_layer(l); }); } if (l.fill_layer != null && ui_menu_button(to_paint_string)) { - app_notify_on_init(function () { + sys_notify_on_init(function () { let l: slot_layer_t = tab_layers_l; slot_layer_is_layer(l) ? history_to_paint_layer() : history_to_paint_mask(); slot_layer_to_paint_layer(l); @@ -781,7 +781,7 @@ function tab_layers_draw_layer_context_menu(l: slot_layer_t, mini: bool) { ui.enabled = tab_layers_can_delete(l); if (ui_menu_button(tr("Delete"), "delete")) { - app_notify_on_init(function () { + sys_notify_on_init(function () { tab_layers_delete_layer(context_raw.layer); }); } @@ -789,7 +789,7 @@ function tab_layers_draw_layer_context_menu(l: slot_layer_t, mini: bool) { if (l.fill_layer == null && ui_menu_button(tr("Clear"))) { context_set_layer(l); - app_notify_on_init(function () { + sys_notify_on_init(function () { let l: slot_layer_t = tab_layers_l; if (!slot_layer_is_group(l)) { history_clear_layer(); @@ -808,7 +808,7 @@ function tab_layers_draw_layer_context_menu(l: slot_layer_t, mini: bool) { }); } if (slot_layer_is_mask(l) && l.fill_layer == null && ui_menu_button(tr("Invert"))) { - app_notify_on_init(function () { + sys_notify_on_init(function () { let l: slot_layer_t = tab_layers_l; context_set_layer(l); history_invert_mask(); @@ -816,7 +816,7 @@ function tab_layers_draw_layer_context_menu(l: slot_layer_t, mini: bool) { }); } if (slot_layer_is_mask(l) && ui_menu_button(tr("Apply"))) { - app_notify_on_init(function () { + sys_notify_on_init(function () { let l: slot_layer_t = tab_layers_l; context_raw.layer = l; history_apply_mask(); @@ -827,14 +827,14 @@ function tab_layers_draw_layer_context_menu(l: slot_layer_t, mini: bool) { }); } if (slot_layer_is_group(l) && ui_menu_button(tr("Merge Group"))) { - app_notify_on_init(function () { + sys_notify_on_init(function () { let l: slot_layer_t = tab_layers_l; layers_merge_group(l); }); } ui.enabled = tab_layers_can_merge_down(l); if (ui_menu_button(tr("Merge Down"))) { - app_notify_on_init(function () { + sys_notify_on_init(function () { let l: slot_layer_t = tab_layers_l; context_set_layer(l); history_merge_layers(); @@ -844,7 +844,7 @@ function tab_layers_draw_layer_context_menu(l: slot_layer_t, mini: bool) { } ui.enabled = true; if (ui_menu_button(tr("Duplicate"))) { - app_notify_on_init(function () { + sys_notify_on_init(function () { let l: slot_layer_t = tab_layers_l; context_set_layer(l); history_duplicate_layer(); @@ -895,7 +895,7 @@ function tab_layers_draw_layer_context_menu(l: slot_layer_t, mini: bool) { ui_inline_radio(base_bits_handle, bits_items, ui_align_t.LEFT); ///end if (base_bits_handle.changed) { - app_notify_on_init(layers_set_bits); + sys_notify_on_init(layers_set_bits); ui_menu_keep_open = true; } } @@ -908,7 +908,7 @@ function tab_layers_draw_layer_context_menu(l: slot_layer_t, mini: bool) { if (scale_handle.changed) { context_set_material(l.fill_layer); context_set_layer(l); - app_notify_on_init(function () { + sys_notify_on_init(function () { layers_update_fill_layers(); }); ui_menu_keep_open = true; @@ -922,7 +922,7 @@ function tab_layers_draw_layer_context_menu(l: slot_layer_t, mini: bool) { context_set_material(l.fill_layer); context_set_layer(l); make_material_parse_paint_material(); - app_notify_on_init(function () { + sys_notify_on_init(function () { layers_update_fill_layers(); }); ui_menu_keep_open = true; @@ -937,7 +937,7 @@ function tab_layers_draw_layer_context_menu(l: slot_layer_t, mini: bool) { context_set_material(l.fill_layer); context_set_layer(l); make_material_parse_paint_material(); - app_notify_on_init(function () { + sys_notify_on_init(function () { layers_update_fill_layers(); }); ui_menu_keep_open = true; @@ -1004,7 +1004,7 @@ function tab_layers_make_mask_preview_rgba32(l: slot_layer_t) { if (context_raw.mask_preview_last != l) { context_raw.mask_preview_last = l; tab_layers_l = l; - app_notify_on_init(function () { + sys_notify_on_init(function () { let l: slot_layer_t = tab_layers_l; draw_begin(context_raw.mask_preview_rgba32); draw_set_pipeline(ui_view2d_pipe); diff --git a/base/sources/ts/tab_materials.ts b/base/sources/ts/tab_materials.ts index 679ed81d..0360ce2d 100644 --- a/base/sources/ts/tab_materials.ts +++ b/base/sources/ts/tab_materials.ts @@ -131,7 +131,7 @@ function tab_materials_draw_slots(mini: bool) { context_select_material(i); ///if is_paint if (context_raw.tool == workspace_tool_t.MATERIAL) { - app_notify_on_init(layers_update_fill_layers); + sys_notify_on_init(layers_update_fill_layers); } ///end } @@ -174,7 +174,7 @@ function tab_materials_draw_slots(mini: bool) { ///end if (ui_menu_button(tr("Duplicate"))) { - app_notify_on_init(function () { + sys_notify_on_init(function () { let i: i32 = _tab_materials_draw_slots; context_raw.material = slot_material_create(project_materials[0].data); @@ -302,7 +302,7 @@ function tab_materials_draw_slots(mini: bool) { function tab_materials_button_new(text: string) { if (ui_button(text)) { - app_notify_on_init(function() { + sys_notify_on_init(function() { context_raw.material = slot_material_create(project_materials[0].data); array_push(project_materials, context_raw.material); tab_materials_update_material(); diff --git a/base/sources/ts/tab_textures.ts b/base/sources/ts/tab_textures.ts index 2b40e4f3..4dbd3d56 100644 --- a/base/sources/ts/tab_textures.ts +++ b/base/sources/ts/tab_textures.ts @@ -139,7 +139,7 @@ function tab_textures_draw(htab: ui_handle_t) { ui_files_show("png", true, false, function (path: string) { _tab_textures_draw_path = path; - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { let img: iron_gpu_texture_t = _tab_textures_draw_img; let target: iron_gpu_texture_t = gpu_create_render_target(tab_textures_to_pow2(img.width), tab_textures_to_pow2(img.height)); draw_begin(target); @@ -147,7 +147,7 @@ function tab_textures_draw(htab: ui_handle_t) { draw_scaled_image(img, 0, 0, target.width, target.height); draw_set_pipeline(null); draw_end(); - app_notify_on_next_frame(function (target: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (target: iron_gpu_texture_t) { let path: string = _tab_textures_draw_path; let f: string = ui_files_filename; if (f == "") { @@ -168,14 +168,14 @@ function tab_textures_draw(htab: ui_handle_t) { ///if (is_paint || is_sculpt) if (ui_menu_button(tr("To Mask"))) { - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { layers_create_image_mask(_tab_textures_draw_asset); }); } ///end if (ui_menu_button(tr("Set as Envmap"))) { - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { import_envmap_run(_tab_textures_draw_asset.file, _tab_textures_draw_img); }); } @@ -280,7 +280,7 @@ function tab_textures_delete_texture(asset: asset_t) { map_delete(project_asset_map, asset.id); array_splice(project_assets, i, 1); array_splice(project_asset_names, i, 1); - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { make_material_parse_paint_material(); ///if (is_paint || is_sculpt) diff --git a/base/sources/ts/translator.ts b/base/sources/ts/translator.ts index 31c7f8b8..5154386e 100644 --- a/base/sources/ts/translator.ts +++ b/base/sources/ts/translator.ts @@ -148,7 +148,7 @@ function translator_init_font(cjk: bool, font_path: string, font_scale: f32) { _translator_init_font_font_scale = font_scale; // Load and assign font with cjk characters - app_notify_on_init(function () { + sys_notify_on_init(function () { let cjk: bool = _translator_init_font_cjk; let font_path: string = _translator_init_font_font_path; diff --git a/base/sources/ts/ui_base.ts b/base/sources/ts/ui_base.ts index 07a1f61c..cb09ef61 100644 --- a/base/sources/ts/ui_base.ts +++ b/base/sources/ts/ui_base.ts @@ -190,7 +190,7 @@ function ui_base_init() { project_paint_objects = [context_raw.paint_object]; if (project_filepath == "") { - app_notify_on_init(layers_init); + sys_notify_on_init(layers_init); } context_raw.project_objects = []; @@ -267,7 +267,7 @@ function ui_base_update() { box_export_show_textures(); } else { - app_notify_on_init(function () { + sys_notify_on_init(function () { export_texture_run(context_raw.texture_export_path); }); } @@ -517,7 +517,7 @@ function ui_base_update() { ///end // Viewpoint - if (mouse_view_x() < app_w()) { + if (mouse_view_x() < sys_w()) { if (operator_shortcut(map_get(config_keymap, "view_reset"))) { viewport_reset(); viewport_scale_to_bounds(); @@ -668,8 +668,8 @@ function ui_base_update() { if (config_raw.layout[layout_size_t.NODES_H] < 32) { config_raw.layout[layout_size_t.NODES_H] = 32; } - else if (config_raw.layout[layout_size_t.NODES_H] > app_h() * 0.95) { - config_raw.layout[layout_size_t.NODES_H] = math_floor(app_h() * 0.95); + else if (config_raw.layout[layout_size_t.NODES_H] > sys_h() * 0.95) { + config_raw.layout[layout_size_t.NODES_H] = math_floor(sys_h() * 0.95); } } } @@ -770,7 +770,7 @@ function ui_base_view_top() { let is_typing: bool = ui_base_ui.is_typing || ui_view2d_ui.is_typing || ui_nodes_ui.is_typing; if (context_in_paint_area() && !is_typing) { - if (mouse_view_x() < app_w()) { + if (mouse_view_x() < sys_w()) { viewport_set_view(0, 0, 1, 0, 0, 0); } } @@ -861,7 +861,7 @@ function ui_base_get_brush_stencil_rect(): rect_t { function ui_base_update_ui() { if (console_message_timer > 0) { - console_message_timer -= time_delta(); + console_message_timer -= sys_delta(); if (console_message_timer <= 0) { ui_base_hwnds[tab_area_t.STATUS].redraws = 2; } @@ -1003,17 +1003,17 @@ function ui_base_update_ui() { if (down) { let mx: i32 = mouse_view_x(); let my: i32 = mouse_view_y(); - let ww: i32 = app_w(); + let ww: i32 = sys_w(); if (context_raw.paint2d) { - mx -= app_w(); + mx -= sys_w(); ww = ui_view2d_ww; } if (mx < ww && - mx > app_x() && - my < app_h() && - my > app_y()) { + mx > sys_x() && + my < sys_h() && + my > sys_y()) { if (set_clone_source) { context_raw.clone_start_x = mx; @@ -1035,7 +1035,7 @@ function ui_base_update_ui() { if (context_raw.tool == workspace_tool_t.CLONE && context_raw.clone_start_x >= 0.0) { // Clone delta context_raw.clone_delta_x = (context_raw.clone_start_x - mx) / ww; - context_raw.clone_delta_y = (context_raw.clone_start_y - my) / app_h(); + context_raw.clone_delta_y = (context_raw.clone_start_y - my) / sys_h(); context_raw.clone_start_x = -1; } else if (context_raw.tool == workspace_tool_t.FILL && context_raw.fill_type_handle.position == fill_type_t.UV_ISLAND) { @@ -1043,7 +1043,7 @@ function ui_base_update_ui() { } } - context_raw.brush_time += time_delta(); + context_raw.brush_time += sys_delta(); if (context_raw.run_brush != null) { context_raw.run_brush(context_raw.brush_output_node_inst, 0); @@ -1064,7 +1064,7 @@ function ui_base_update_ui() { // New color id picked, update fill layer if (context_raw.tool == workspace_tool_t.COLORID && context_raw.layer.fill_layer != null) { - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { layers_update_fill_layer(); make_material_parse_paint_material(false); }); @@ -1353,7 +1353,7 @@ function ui_base_render_cursor() { // Clone source cursor if (context_raw.tool == workspace_tool_t.CLONE && !keyboard_down("alt") && (mouse_down() || pen_down())) { draw_set_color(0x66ffffff); - draw_scaled_image(cursor_img, mx + context_raw.clone_delta_x * app_w() - psize / 2, my + context_raw.clone_delta_y * app_h() - psize / 2, psize, psize); + draw_scaled_image(cursor_img, mx + context_raw.clone_delta_x * sys_w() - psize / 2, my + context_raw.clone_delta_y * sys_h() - psize / 2, psize, psize); draw_set_color(0xffffffff); } diff --git a/base/sources/ts/ui_files.ts b/base/sources/ts/ui_files.ts index 8983df8f..459850cc 100644 --- a/base/sources/ts/ui_files.ts +++ b/base/sources/ts/ui_files.ts @@ -204,7 +204,7 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = let f: string = map_get(ui_files_icon_file_map, icon_file); let data: draw_cloud_icon_data_t = make_draw_cloud_icon_data(f, image); - app_notify_on_init(function (data: draw_cloud_icon_data_t) { + sys_notify_on_init(function (data: draw_cloud_icon_data_t) { let icon: iron_gpu_texture_t = gpu_create_render_target(data.image.width, data.image.height); if (ends_with(data.f, ".arm")) { // Used for material sphere alpha cutout draw_begin(icon); @@ -321,7 +321,7 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = shandle: shandle, w: w }; - app_notify_on_init(ui_files_make_icon, args); + sys_notify_on_init(ui_files_make_icon, args); } if (icon != null) { if (i == ui_files_selected) { diff --git a/base/sources/ts/ui_header.ts b/base/sources/ts/ui_header.ts index 70b2274d..d1b7b345 100644 --- a/base/sources/ts/ui_header.ts +++ b/base/sources/ts/ui_header.ts @@ -29,7 +29,7 @@ function ui_header_render_ui() { let ww: i32 = iron_window_width() - ui_toolbar_w - config_raw.layout[layout_size_t.SIDEBAR_W] - nodesw; ///end - if (ui_window(ui_header_handle, app_x(), ui_header_h, ww, ui_header_h)) { + if (ui_window(ui_header_handle, sys_x(), ui_header_h, ww, ui_header_h)) { ui._y += 2; ui_header_draw_tool_properties(ui); } diff --git a/base/sources/ts/ui_menubar.ts b/base/sources/ts/ui_menubar.ts index cd172aed..fdabe093 100644 --- a/base/sources/ts/ui_menubar.ts +++ b/base/sources/ts/ui_menubar.ts @@ -16,11 +16,11 @@ function ui_menubar_render_ui() { let ui: ui_t = ui_base_ui; let item_w: i32 = ui_toolbar_get_w(); - let panel_x: i32 = app_x(); + let panel_x: i32 = sys_x(); ///if (is_paint || is_sculpt) if (config_raw.layout[layout_size_t.HEADER] == 1) { - panel_x = app_x() - item_w; + panel_x = sys_x() - item_w; } ///end @@ -44,7 +44,7 @@ function ui_menubar_render_ui() { console_toast(tr("Saving project")); project_save(); ///end - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { box_projects_show(); }); } @@ -121,15 +121,15 @@ function ui_menubar_draw_tab_header() { let ui: ui_t = ui_base_ui; let item_w: i32 = ui_toolbar_get_w(); - let panel_x: i32 = app_x(); + let panel_x: i32 = sys_x(); let nodesw: i32 = (ui_nodes_show || ui_view2d_show) ? config_raw.layout[layout_size_t.NODES_W] : 0; ///if (is_paint || is_sculpt) let ww: i32 = iron_window_width() - config_raw.layout[layout_size_t.SIDEBAR_W] - ui_menubar_w - nodesw; - panel_x = (app_x() - item_w) + ui_menubar_w; + panel_x = (sys_x() - item_w) + ui_menubar_w; ///else let ww: i32 = iron_window_width() - ui_menubar_w - nodesw; - panel_x = (app_x()) + ui_menubar_w; + panel_x = (sys_x()) + ui_menubar_w; ///end if (ui_window(ui_menubar_workspace_handle, panel_x, 0, ww, ui_header_h)) { diff --git a/base/sources/ts/ui_nodes.ts b/base/sources/ts/ui_nodes.ts index 7f18f8ec..1a574c96 100644 --- a/base/sources/ts/ui_nodes.ts +++ b/base/sources/ts/ui_nodes.ts @@ -161,7 +161,7 @@ function ui_viewnodes_on_socket_released(socket_id: i32) { _ui_nodes_on_socket_released_socket = socket; _ui_nodes_on_socket_released_node = node; - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { ui_menu_draw(function (ui: ui_t) { let socket: ui_node_socket_t = _ui_nodes_on_socket_released_socket; @@ -184,7 +184,7 @@ function ui_viewnodes_on_socket_released(socket_id: i32) { _ui_nodes_hval0.value = socket.default_value[0]; } - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { ui_end_input(); ui_box_show_custom(function (ui: ui_t) { @@ -321,7 +321,7 @@ function ui_viewnodes_on_canvas_released() { selected.type == "brush_output_node"; ui_menu.enabled = !is_protected; if (ui_menu_button(tr("Cut"), "ctrl+x")) { - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { ui_nodes_hwnd.redraws = 2; ui_is_copy = true; ui_is_cut = true; @@ -329,14 +329,14 @@ function ui_viewnodes_on_canvas_released() { }); } if (ui_menu_button(tr("Copy"), "ctrl+c")) { - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { ui_is_copy = true; ui_nodes_is_node_menu_op = true; }); } ui_menu.enabled = ui_clipboard != ""; if (ui_menu_button(tr("Paste"), "ctrl+v")) { - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { ui_nodes_hwnd.redraws = 2; ui_is_paste = true; ui_nodes_is_node_menu_op = true; @@ -344,14 +344,14 @@ function ui_viewnodes_on_canvas_released() { } ui_menu.enabled = !is_protected; if (ui_menu_button(tr("Delete"), "delete")) { - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { ui_nodes_hwnd.redraws = 2; ui_nodes_ui.is_delete_down = true; ui_nodes_is_node_menu_op = true; }); } if (ui_menu_button(tr("Duplicate"))) { - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { ui_nodes_hwnd.redraws = 2; ui_is_copy = true; ui_is_paste = true; @@ -542,15 +542,15 @@ function ui_nodes_update() { } ///if (is_paint || is_sculpt) - ui_nodes_wx = math_floor(app_w()) + ui_toolbar_w; + ui_nodes_wx = math_floor(sys_w()) + ui_toolbar_w; ///end ///if is_lab - ui_nodes_wx = math_floor(app_w()); + ui_nodes_wx = math_floor(sys_w()); ///end ui_nodes_wy = ui_header_h * 2; if (ui_view2d_show) { - ui_nodes_wy += app_h() - config_raw.layout[layout_size_t.NODES_H]; + ui_nodes_wy += sys_h() - config_raw.layout[layout_size_t.NODES_H]; } let ww: i32 = config_raw.layout[layout_size_t.NODES_W]; @@ -728,7 +728,7 @@ function ui_nodes_draw_grid(zoom: f32): iron_gpu_texture_t { } ///end - let wh: i32 = app_h(); + let wh: i32 = sys_h(); let step: f32 = ui_nodes_grid_cell_w * zoom; let mult: i32 = 5 * ui_SCALE(ui_nodes_ui); let w: i32 = math_floor(ww + step * mult); @@ -892,10 +892,10 @@ function ui_nodes_render() { ui_nodes_ww = config_raw.layout[layout_size_t.NODES_W]; ///if (is_paint || is_sculpt) - ui_nodes_wx = math_floor(app_w()) + ui_toolbar_w; + ui_nodes_wx = math_floor(sys_w()) + ui_toolbar_w; ///end ///if is_lab - ui_nodes_wx = math_floor(app_w()); + ui_nodes_wx = math_floor(sys_w()); ///end ui_nodes_wy = 0; @@ -908,14 +908,14 @@ function ui_nodes_render() { ///end let ew: i32 = math_floor(ui_ELEMENT_W(ui_nodes_ui) * 0.7); - ui_nodes_wh = app_h(); + ui_nodes_wh = sys_h(); if (config_raw.layout[layout_size_t.HEADER] == 1) { ui_nodes_wh += ui_header_h * 2; } if (ui_view2d_show) { ui_nodes_wh = config_raw.layout[layout_size_t.NODES_H]; - ui_nodes_wy = app_h() - config_raw.layout[layout_size_t.NODES_H] + ui_header_h; + ui_nodes_wy = sys_h() - config_raw.layout[layout_size_t.NODES_H] + ui_header_h; if (config_raw.layout[layout_size_t.HEADER] == 1) { ui_nodes_wy += ui_header_h; } @@ -1232,7 +1232,7 @@ function ui_nodes_render() { ui_nodes_node_search_x = ui_nodes_ui._window_x + ui_nodes_ui._x; ui_nodes_node_search_y = ui_nodes_ui._window_y + ui_nodes_ui._y; // Allow for node menu to be closed first - app_notify_on_init(function() { + sys_notify_on_init(function() { ui_nodes_node_search(math_floor(ui_nodes_node_search_x), math_floor(ui_nodes_node_search_y)); }); } diff --git a/base/sources/ts/ui_status.ts b/base/sources/ts/ui_status.ts index f759a528..99ee3bd4 100644 --- a/base/sources/ts/ui_status.ts +++ b/base/sources/ts/ui_status.ts @@ -18,7 +18,7 @@ function ui_status_render_ui() { let statush: i32 = config_raw.layout[layout_size_t.STATUS_H]; - if (ui_window(ui_base_hwnds[tab_area_t.STATUS], app_x(), iron_window_height() - statush, ui_status_width(), statush)) { + if (ui_window(ui_base_hwnds[tab_area_t.STATUS], sys_x(), iron_window_height() - statush, ui_status_width(), statush)) { ui._y += 2; // Border diff --git a/base/sources/ts/ui_toolbar.ts b/base/sources/ts/ui_toolbar.ts index 59bd1c2a..16acd1cc 100644 --- a/base/sources/ts/ui_toolbar.ts +++ b/base/sources/ts/ui_toolbar.ts @@ -43,7 +43,7 @@ function ui_toolbar_draw_tool(i: i32, ui: ui_t, img: iron_gpu_texture_t, icon_ac let image_state: ui_state_t = _ui_image(img, icon_accent, -1.0, rect.x, rect.y, rect.w, rect.h); if (image_state == ui_state_t.STARTED) { _ui_toolbar_i = i; - app_notify_on_next_frame(function() { + sys_notify_on_next_frame(function() { context_select_tool(_ui_toolbar_i); }); } diff --git a/base/sources/ts/ui_view2d.ts b/base/sources/ts/ui_view2d.ts index f9f9aed6..548e7ea8 100644 --- a/base/sources/ts/ui_view2d.ts +++ b/base/sources/ts/ui_view2d.ts @@ -64,9 +64,9 @@ function ui_view2d_render() { ui_view2d_ww = config_raw.layout[layout_size_t.NODES_W]; ///if (is_paint || is_sculpt) - ui_view2d_wx = math_floor(app_w()) + ui_toolbar_w; + ui_view2d_wx = math_floor(sys_w()) + ui_toolbar_w; ///else - ui_view2d_wx = math_floor(app_w()); + ui_view2d_wx = math_floor(sys_w()); ///end ui_view2d_wy = 0; @@ -256,7 +256,7 @@ function ui_view2d_render() { _ui_view2d_render_tw = tw; _ui_view2d_render_th = th; - app_notify_on_next_frame(function () { + sys_notify_on_next_frame(function () { let rt: render_target_t = map_get(render_path_render_targets, "texpaint_picker"); let texpaint_picker: iron_gpu_texture_t = rt._image; draw_begin(texpaint_picker); @@ -505,7 +505,7 @@ function ui_view2d_update() { let border: i32 = 32; let tw: f32 = ui_view2d_ww * 0.95 * ui_view2d_pan_scale; let tx: f32 = ui_view2d_ww / 2 - tw / 2 + ui_view2d_pan_x; - let hh: f32 = app_h(); + let hh: f32 = sys_h(); let ty: f32 = hh / 2 - tw / 2 + ui_view2d_pan_y; if (tx + border > ui_view2d_ww) { diff --git a/base/sources/ts/uniforms_ext.ts b/base/sources/ts/uniforms_ext.ts index 924ce8b1..99482573 100644 --- a/base/sources/ts/uniforms_ext.ts +++ b/base/sources/ts/uniforms_ext.ts @@ -354,18 +354,18 @@ function uniforms_ext_tex_link(object: object_t, mat: material_data_t, link: str else if (link == "_texuvmap") { if (!util_uv_uvmap_cached) { - app_notify_on_init(util_uv_cache_uv_map); + sys_notify_on_init(util_uv_cache_uv_map); } return util_uv_uvmap; } else if (link == "_textrianglemap") { if (!util_uv_trianglemap_cached) { - app_notify_on_init(util_uv_cache_triangle_map); + sys_notify_on_init(util_uv_cache_triangle_map); } return util_uv_trianglemap; } else if (link == "_texuvislandmap") { - app_notify_on_init(util_uv_cache_uv_island_map); + sys_notify_on_init(util_uv_cache_uv_island_map); if (util_uv_uvislandmap_cached) { return util_uv_uvislandmap; } diff --git a/base/sources/ts/util_render.ts b/base/sources/ts/util_render.ts index a21d8bcf..5d8e35f5 100644 --- a/base/sources/ts/util_render.ts +++ b/base/sources/ts/util_render.ts @@ -55,8 +55,8 @@ function util_render_make_material_preview() { render_path_commands = _commands; context_raw.material_preview = false; - _render_path_last_w = app_w(); - _render_path_last_h = app_h(); + _render_path_last_w = sys_w(); + _render_path_last_h = sys_h(); // Restore sphere.base.visible = false; @@ -120,8 +120,8 @@ function util_render_make_decal_preview() { render_path_commands = _commands; context_raw.decal_preview = false; - _render_path_last_w = app_w(); - _render_path_last_h = app_h(); + _render_path_last_w = sys_w(); + _render_path_last_h = sys_h(); // Restore plane.base.visible = false; @@ -343,7 +343,7 @@ function util_render_make_brush_preview() { context_raw.layer = _layer; context_raw.material = _material; context_raw.tool = _tool; - app_notify_on_init(function () { + sys_notify_on_init(function () { make_material_parse_paint_material(false); }); diff --git a/base/sources/ts/viewport.ts b/base/sources/ts/viewport.ts index 30520154..4bfb54a5 100644 --- a/base/sources/ts/viewport.ts +++ b/base/sources/ts/viewport.ts @@ -85,8 +85,8 @@ function viewport_update_camera_type(camera_type: i32) { let f: f32 = cam.data.fov * vec4_len(mat4_get_loc(cam.base.transform.world)) / 2.5; f32a[0] = -2 * f; f32a[1] = 2 * f; - f32a[2] = -2 * f * (app_h() / app_w()); - f32a[3] = 2 * f * (app_h() / app_w()); + f32a[2] = -2 * f * (sys_h() / sys_w()); + f32a[3] = 2 * f * (sys_h() / sys_w()); cam.data.ortho = f32a; } camera_object_build_proj(cam); diff --git a/base/tests/cube/sources/main.ts b/base/tests/cube/sources/main.ts index 10a52937..286e8783 100644 --- a/base/tests/cube/sources/main.ts +++ b/base/tests/cube/sources/main.ts @@ -13,8 +13,8 @@ function main() { vsync: true }; sys_start(ops); - app_init(); - app_ready(); + sys_init(); + ready(); } function render_commands() { @@ -23,7 +23,7 @@ function render_commands() { render_path_draw_meshes("mesh"); } -function app_ready() { +function ready() { render_path_commands = render_commands; let scene: scene_t = { @@ -124,7 +124,7 @@ function scene_ready() { transform_build_matrix(t); // Rotate cube - app_notify_on_update(spin_cube); + sys_notify_on_update(spin_cube); } function spin_cube() { diff --git a/base/tests/fall/sources/camera.ts b/base/tests/fall/sources/camera.ts index cbd1abbc..9ae7cba3 100644 --- a/base/tests/fall/sources/camera.ts +++ b/base/tests/fall/sources/camera.ts @@ -35,7 +35,7 @@ function camera_update() { } } - let d: f32 = time_delta() * speed * fast; + let d: f32 = sys_delta() * speed * fast; if (d > 0.0) { transform_move(camera.base.transform, dir, d); } diff --git a/base/tests/fall/sources/main.ts b/base/tests/fall/sources/main.ts index 6eed8af4..ab973e48 100644 --- a/base/tests/fall/sources/main.ts +++ b/base/tests/fall/sources/main.ts @@ -16,8 +16,8 @@ function main() { use_depth: true }; sys_start(ops); - app_init(); - app_ready(); + sys_init(); + ready(); } function render_commands() { @@ -26,7 +26,7 @@ function render_commands() { render_path_draw_meshes("mesh"); } -function app_ready() { +function ready() { render_path_commands = render_commands; let scene: scene_t = { @@ -138,7 +138,7 @@ function scene_ready() { t.rot = quat_from_to(vec4_create(0, 0, 1), vec4_create(0, -1, 0)); transform_build_matrix(t); - app_notify_on_update(scene_update); + sys_notify_on_update(scene_update); let cube: object_t = scene_get_child("Cube"); let mesh: mesh_object_t = cube.ext;