From 156f3eb274a18d83b86493cb56ee4b2452fe2d26 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Sat, 10 Feb 2024 19:26:53 +0100 Subject: [PATCH] Refactor --- armorforge/Sources/TabObjects.ts | 2 +- armorlab/Sources/UINodesExt.ts | 8 +- armorlab/Sources/nodes/InpaintNode.ts | 2 +- armorlab/Sources/nodes/PhotoToPBRNode.ts | 2 +- armorlab/Sources/nodes/TextToPhotoNode.ts | 8 +- armorlab/Sources/nodes/UpscaleNode.ts | 2 +- armorlab/Sources/nodes/VarianceNode.ts | 2 +- armorpaint/Sources/RenderPathPaint.ts | 18 +- armorpaint/Sources/SlotFont.ts | 4 +- armorpaint/Sources/TabLayers.ts | 10 +- armorsculpt/Sources/ExportObj.ts | 2 +- base/Sources/Args.ts | 28 +-- base/Sources/Base.ts | 240 +++++++++++----------- base/Sources/BoxExport.ts | 4 +- base/Sources/BoxPreferences.ts | 10 +- base/Sources/BoxProjects.ts | 2 +- base/Sources/Camera.ts | 17 +- base/Sources/Config.ts | 12 +- base/Sources/Console.ts | 2 +- base/Sources/ExportArm.ts | 22 +- base/Sources/ExportGpl.ts | 2 +- base/Sources/ExportObj.ts | 2 +- base/Sources/ExportTexture.ts | 6 +- base/Sources/File.ts | 36 ++-- base/Sources/Gizmo.ts | 10 +- base/Sources/ImportArm.ts | 2 +- base/Sources/ImportBlendMesh.ts | 2 +- base/Sources/ImportEnvmap.ts | 12 +- base/Sources/ImportFont.ts | 8 +- base/Sources/ImportObj.ts | 6 +- base/Sources/LineDraw.ts | 24 +-- base/Sources/MakeVoxel.ts | 16 +- base/Sources/ParserBlend.ts | 6 +- base/Sources/Path.ts | 10 +- base/Sources/PhysicsWorld.ts | 4 +- base/Sources/Plugin.ts | 2 +- base/Sources/Project.ts | 4 +- base/Sources/RenderPathBase.ts | 18 +- base/Sources/RenderPathRaytrace.ts | 40 ++-- base/Sources/RenderPathRaytraceBake.ts | 6 +- base/Sources/Res.ts | 2 +- base/Sources/TabBrowser.ts | 2 +- base/Sources/TabConsole.ts | 6 +- base/Sources/TabMaterials.ts | 4 +- base/Sources/TabScript.ts | 4 +- base/Sources/TabSwatches.ts | 2 +- base/Sources/TabTextures.ts | 2 +- base/Sources/Translator.ts | 12 +- base/Sources/UIBase.ts | 10 +- base/Sources/UIBox.ts | 2 +- base/Sources/UIFiles.ts | 14 +- base/Sources/UIHeader.ts | 4 +- base/Sources/UIMenu.ts | 10 +- base/Sources/UINodes.ts | 14 +- base/Sources/UIToolbar.ts | 2 +- base/Sources/UIView2D.ts | 20 +- base/Sources/UniformsExt.ts | 4 +- base/Sources/UtilMesh.ts | 30 +-- base/Sources/UtilRender.ts | 74 +++---- base/Sources/UtilUV.ts | 14 +- base/Sources/Viewport.ts | 6 +- base/Sources/main.ts | 12 +- misc/pad/Sources/main.ts | 30 +-- 63 files changed, 444 insertions(+), 449 deletions(-) diff --git a/armorforge/Sources/TabObjects.ts b/armorforge/Sources/TabObjects.ts index be4ac2819..3740deaf2 100644 --- a/armorforge/Sources/TabObjects.ts +++ b/armorforge/Sources/TabObjects.ts @@ -242,7 +242,7 @@ class TabObjects { fovHandle.value = Math.floor(cam.data.fov * 100) / 100; cam.data.fov = zui_slider(fovHandle, "FoV", 0.3, 2.0, true); if (fovHandle.changed) { - camera_object_build_projection(cam); + camera_object_build_proj(cam); } } } diff --git a/armorlab/Sources/UINodesExt.ts b/armorlab/Sources/UINodesExt.ts index 7ee331c31..4142a1bbb 100644 --- a/armorlab/Sources/UINodesExt.ts +++ b/armorlab/Sources/UINodesExt.ts @@ -9,7 +9,7 @@ class UINodesExt { Console.progress(tr("Processing")); let delayIdleSleep = () => { - Krom.delayIdleSleep(); + krom_delay_idle_sleep(); } app_notify_on_render_2d(delayIdleSleep); @@ -90,7 +90,7 @@ class UINodesExt { // Make copy of vertices before displacement let o = Project.paintObjects[0]; let g = o.data; - let vertices = vertex_buffer_lock(g._vertex_buffer); + let vertices = g4_vertex_buffer_lock(g._vertex_buffer); if (UINodesExt.lastVertices == null || UINodesExt.lastVertices.byteLength != vertices.byteLength) { UINodesExt.lastVertices = new DataView(new ArrayBuffer(vertices.byteLength)); for (let i = 0; i < Math.floor(vertices.byteLength / 2); ++i) { @@ -102,7 +102,7 @@ class UINodesExt { vertices.setInt16(i * 2, UINodesExt.lastVertices.getInt16(i * 2, true), true); } } - vertex_buffer_unlock(g._vertex_buffer); + g4_vertex_buffer_unlock(g._vertex_buffer); // Apply displacement if (Config.raw.displace_strength > 0) { @@ -121,7 +121,7 @@ class UINodesExt { } Console.log("Processing finished in " + (time_time() - timer)); - Krom.mlUnload(); + krom_ml_unload(); taskDone(); }); diff --git a/armorlab/Sources/nodes/InpaintNode.ts b/armorlab/Sources/nodes/InpaintNode.ts index 801a2a30f..c7762924c 100644 --- a/armorlab/Sources/nodes/InpaintNode.ts +++ b/armorlab/Sources/nodes/InpaintNode.ts @@ -141,7 +141,7 @@ class InpaintNode extends LogicNode { f32a[i + 512 * 512 * 2] = (u8a[i * 4 + 2] / 255.0) * 2.0 - 1.0; } - let latents_buf = Krom.mlInference(vae_encoder_blob, [f32a.buffer], [[1, 3, 512, 512]], [1, 4, 64, 64], Config.raw.gpu_inference); + let latents_buf = krom_ml_inference(vae_encoder_blob, [f32a.buffer], [[1, 3, 512, 512]], [1, 4, 64, 64], Config.raw.gpu_inference); let latents = new Float32Array(latents_buf); for (let i = 0; i < latents.length; ++i) { latents[i] = 0.18215 * latents[i]; diff --git a/armorlab/Sources/nodes/PhotoToPBRNode.ts b/armorlab/Sources/nodes/PhotoToPBRNode.ts index d7864e1f7..0e771528f 100644 --- a/armorlab/Sources/nodes/PhotoToPBRNode.ts +++ b/armorlab/Sources/nodes/PhotoToPBRNode.ts @@ -68,7 +68,7 @@ class PhotoToPBRNode extends LogicNode { } data_get_blob("models/photo_to_" + PhotoToPBRNode.modelNames[from] + ".quant.onnx", (model_blob: ArrayBuffer) => { - let buf = Krom.mlInference(model_blob, [f32a.buffer], null, null, Config.raw.gpu_inference); + let buf = krom_ml_inference(model_blob, [f32a.buffer], null, null, Config.raw.gpu_inference); let ar = new Float32Array(buf); let u8a = new Uint8Array(4 * PhotoToPBRNode.tileW * PhotoToPBRNode.tileW); let offsetG = (from == ChannelType.ChannelBaseColor || from == ChannelType.ChannelNormalMap) ? PhotoToPBRNode.tileWithBorderW * PhotoToPBRNode.tileWithBorderW : 0; diff --git a/armorlab/Sources/nodes/TextToPhotoNode.ts b/armorlab/Sources/nodes/TextToPhotoNode.ts index f11d8b64e..84b4b95b5 100644 --- a/armorlab/Sources/nodes/TextToPhotoNode.ts +++ b/armorlab/Sources/nodes/TextToPhotoNode.ts @@ -58,11 +58,11 @@ class TextToPhotoNode extends LogicNode { } let i32a = new Int32Array(TextToPhotoNode.text_input_ids); - let text_embeddings_buf = Krom.mlInference(TextToPhotoNode.text_encoder_blob, [i32a.buffer], [[1, 77]], [1, 77, 768], Config.raw.gpu_inference); + let text_embeddings_buf = krom_ml_inference(TextToPhotoNode.text_encoder_blob, [i32a.buffer], [[1, 77]], [1, 77, 768], Config.raw.gpu_inference); let text_embeddings = new Float32Array(text_embeddings_buf); i32a = new Int32Array(TextToPhotoNode.uncond_input_ids); - let uncond_embeddings_buf = Krom.mlInference(TextToPhotoNode.text_encoder_blob, [i32a.buffer], [[1, 77]], [1, 77, 768], Config.raw.gpu_inference); + let uncond_embeddings_buf = krom_ml_inference(TextToPhotoNode.text_encoder_blob, [i32a.buffer], [[1, 77]], [1, 77, 768], Config.raw.gpu_inference); let uncond_embeddings = new Float32Array(uncond_embeddings_buf); let f32a = new Float32Array(uncond_embeddings.length + text_embeddings.length); @@ -104,7 +104,7 @@ class TextToPhotoNode extends LogicNode { let t32 = new Int32Array(2); t32[0] = timestep; - let noise_pred_buf = Krom.mlInference(TextToPhotoNode.unet_blob, [latent_model_input.buffer, t32.buffer, text_embeddings.buffer], [[2, 4, 64, 64], [1], [2, 77, 768]], [2, 4, 64, 64], Config.raw.gpu_inference); + let noise_pred_buf = krom_ml_inference(TextToPhotoNode.unet_blob, [latent_model_input.buffer, t32.buffer, text_embeddings.buffer], [[2, 4, 64, 64], [1], [2, 77, 768]], [2, 4, 64, 64], Config.raw.gpu_inference); let noise_pred = new Float32Array(noise_pred_buf); for (let i = 0; i < noise_pred_uncond.length; ++i) noise_pred_uncond[i] = noise_pred[i]; @@ -202,7 +202,7 @@ class TextToPhotoNode extends LogicNode { latents[i] = 1.0 / 0.18215 * latents[i]; } - let pyimage_buf = Krom.mlInference(TextToPhotoNode.vae_decoder_blob, [latents.buffer], [[1, 4, 64, 64]], [1, 3, 512, 512], Config.raw.gpu_inference); + let pyimage_buf = krom_ml_inference(TextToPhotoNode.vae_decoder_blob, [latents.buffer], [[1, 4, 64, 64]], [1, 3, 512, 512], Config.raw.gpu_inference); let pyimage = new Float32Array(pyimage_buf); for (let i = 0; i < pyimage.length; ++i) { diff --git a/armorlab/Sources/nodes/UpscaleNode.ts b/armorlab/Sources/nodes/UpscaleNode.ts index 24a26fd85..8ca8eb062 100644 --- a/armorlab/Sources/nodes/UpscaleNode.ts +++ b/armorlab/Sources/nodes/UpscaleNode.ts @@ -64,7 +64,7 @@ class UpscaleNode extends LogicNode { f32a[i + size1w * size1w * 2] = (u8a[i * 4 + 2] / 255); } - let esrgan2x_buf = Krom.mlInference(UpscaleNode.esrgan_blob, [f32a.buffer], [[1, 3, size1w, size1h]], [1, 3, size2w, size2h], Config.raw.gpu_inference); + let esrgan2x_buf = krom_ml_inference(UpscaleNode.esrgan_blob, [f32a.buffer], [[1, 3, size1w, size1h]], [1, 3, size2w, size2h], Config.raw.gpu_inference); let esrgan2x = new Float32Array(esrgan2x_buf); for (let i = 0; i < esrgan2x.length; ++i) { if (esrgan2x[i] < 0) esrgan2x[i] = 0; diff --git a/armorlab/Sources/nodes/VarianceNode.ts b/armorlab/Sources/nodes/VarianceNode.ts index b5ad51d3c..b73e43d2f 100644 --- a/armorlab/Sources/nodes/VarianceNode.ts +++ b/armorlab/Sources/nodes/VarianceNode.ts @@ -43,7 +43,7 @@ class VarianceNode extends LogicNode { Console.progress(tr("Processing") + " - " + tr("Variance")); Base.notifyOnNextFrame(() => { data_get_blob("models/sd_vae_encoder.quant.onnx", (vae_encoder_blob: ArrayBuffer) => { - let latents_buf = Krom.mlInference(vae_encoder_blob, [f32a.buffer], [[1, 3, 512, 512]], [1, 4, 64, 64], Config.raw.gpu_inference); + let latents_buf = krom_ml_inference(vae_encoder_blob, [f32a.buffer], [[1, 3, 512, 512]], [1, 4, 64, 64], Config.raw.gpu_inference); let latents = new Float32Array(latents_buf); for (let i = 0; i < latents.length; ++i) { latents[i] = 0.18215 * latents[i]; diff --git a/armorpaint/Sources/RenderPathPaint.ts b/armorpaint/Sources/RenderPathPaint.ts index 6a775f953..dce235dfd 100644 --- a/armorpaint/Sources/RenderPathPaint.ts +++ b/armorpaint/Sources/RenderPathPaint.ts @@ -123,12 +123,12 @@ class RenderPathPaint { let mo: mesh_object_t = scene_get_child(".ParticleEmitter").ext; mo.base.visible = true; - mesh_object_render(mo, "mesh",render_path_bind_params); + mesh_object_render(mo, "mesh",_render_path_bind_params); mo.base.visible = false; mo = scene_get_child(".Particle").ext; mo.base.visible = true; - mesh_object_render(mo, "mesh",render_path_bind_params); + mesh_object_render(mo, "mesh",_render_path_bind_params); mo.base.visible = false; render_path_end(); } @@ -353,7 +353,7 @@ class RenderPathPaint { let cc_context = shaderContexts[0]; if (const_data_screen_aligned_vb == null) const_data_create_screen_aligned_data(); g4_set_pipeline(cc_context._pipe_state); - uniforms_set_context_consts(cc_context,render_path_bind_params); + uniforms_set_context_consts(cc_context,_render_path_bind_params); uniforms_set_obj_consts(cc_context, Project.paintObjects[0].base); uniforms_set_material_consts(cc_context, materialContexts[0]); g4_set_vertex_buffer(const_data_screen_aligned_vb); @@ -800,8 +800,8 @@ class RenderPathPaint { mat4_translate(m, 0, 0, 0.5); transform_set_matrix(cam.base.transform, m); cam.data.fov = Base.defaultFov; - camera_object_build_projection(cam); - camera_object_build_matrix(cam); + camera_object_build_proj(cam); + camera_object_build_mat(cam); let tw = 0.95 * UIView2D.panScale; let tx = UIView2D.panX / UIView2D.ww; @@ -845,11 +845,11 @@ class RenderPathPaint { Context.raw.paintObject = RenderPathPaint.planeo; let v = vec4_create(); - let sx = vec4_len(vec4_set(v, m._00, m._01, m._02)); + let sx = vec4_len(vec4_set(v, m.m[0], m.m[1], m.m[2])); quat_from_euler(RenderPathPaint.planeo.base.transform.rot, -Math.PI / 2, 0, 0); vec4_set(RenderPathPaint.planeo.base.transform.scale, sx, 1.0, sx); RenderPathPaint.planeo.base.transform.scale.z *= Config.getTextureResY() / Config.getTextureResX(); - vec4_set(RenderPathPaint.planeo.base.transform.loc, m._30, -m._31, 0.0); + vec4_set(RenderPathPaint.planeo.base.transform.loc, m.m[12], -m.m[13], 0.0); transform_build_matrix(RenderPathPaint.planeo.base.transform); } @@ -867,8 +867,8 @@ class RenderPathPaint { transform_set_matrix(scene_camera.base.transform, Context.raw.savedCamera); scene_camera.data.fov = RenderPathPaint.savedFov; Viewport.updateCameraType(Context.raw.cameraType); - camera_object_build_projection(scene_camera); - camera_object_build_matrix(scene_camera); + camera_object_build_proj(scene_camera); + camera_object_build_mat(scene_camera); RenderPathBase.drawGbuffer(); } diff --git a/armorpaint/Sources/SlotFont.ts b/armorpaint/Sources/SlotFont.ts index e32cdcce3..71a3a02b5 100644 --- a/armorpaint/Sources/SlotFont.ts +++ b/armorpaint/Sources/SlotFont.ts @@ -3,14 +3,14 @@ class SlotFontRaw { image: image_t = null; // 200px previewReady = false; id = 0; - font: font_t; + font: g2_font_t; name: string; file: string; } class SlotFont { - static create(name: string, font: font_t, file = ""): SlotFontRaw { + static create(name: string, font: g2_font_t, file = ""): SlotFontRaw { let raw = new SlotFontRaw(); for (let slot of Project.fonts) if (slot.id >= raw.id) raw.id = slot.id + 1; raw.name = name; diff --git a/armorpaint/Sources/TabLayers.ts b/armorpaint/Sources/TabLayers.ts index c19dadc53..0fd06c37a 100644 --- a/armorpaint/Sources/TabLayers.ts +++ b/armorpaint/Sources/TabLayers.ts @@ -616,9 +616,9 @@ class TabLayers { if (l.fill_layer == null && SlotLayer.isMask(l)) { g2_set_pipeline(UIView2D.pipe); ///if krom_opengl - Krom.setPipeline(UIView2D.pipe.pipeline_); + krom_g4_set_pipeline(UIView2D.pipe.pipeline_); ///end - Krom.setInt(UIView2D.channelLocation, 1); + krom_g4_set_int(UIView2D.channelLocation, 1); } let state = zui_image(icon, 0xffffffff, iconH); @@ -632,8 +632,8 @@ class TabLayers { if (!isTyping) { if (i < 9 && Operator.shortcut(Config.keymap.select_layer, ShortcutType.ShortcutDown)) { let number = String(i + 1) ; - let width = font_width(ui.font, ui.font_size, number) + 10; - let height = font_height(ui.font, ui.font_size); + let width = g2_font_width(ui.font, ui.font_size, number) + 10; + let height = g2_font_height(ui.font, ui.font_size); g2_set_color(ui.t.TEXT_COL); g2_fill_rect(uix, uiy, width, height); g2_set_color(ui.t.ACCENT_COL); @@ -710,7 +710,7 @@ class TabLayers { let f = UIFiles.filename; if (f == "") f = tr("untitled"); if (!f.endsWith(".png")) f += ".png"; - Krom.writePng(path + Path.sep + f, image_get_pixels(l.texpaint), l.texpaint.width, l.texpaint.height, 3); // RRR1 + krom_write_png(path + Path.sep + f, image_get_pixels(l.texpaint), l.texpaint.width, l.texpaint.height, 3); // RRR1 }); } else { diff --git a/armorsculpt/Sources/ExportObj.ts b/armorsculpt/Sources/ExportObj.ts index 7897fbcd8..b09ac31b2 100644 --- a/armorsculpt/Sources/ExportObj.ts +++ b/armorsculpt/Sources/ExportObj.ts @@ -93,6 +93,6 @@ class ExportObj { if (!path.endsWith(".obj")) path += ".obj"; let b = Uint8Array.from(o).buffer; - Krom.fileSaveBytes(path, b, b.byteLength); + krom_file_save_bytes(path, b, b.byteLength); } } diff --git a/base/Sources/Args.ts b/base/Sources/Args.ts index c0eeaf6ca..fcfc98429 100644 --- a/base/Sources/Args.ts +++ b/base/Sources/Args.ts @@ -21,13 +21,13 @@ class Args { ///end static parse = () => { - if (Krom.getArgCount() > 1) { + if (krom_get_arg_count() > 1) { Args.useArgs = true; let i = 0; - while (i < Krom.getArgCount()) { + while (i < krom_get_arg_count()) { // Process each arg - let currentArg = Krom.getArg(i); + let currentArg = krom_get_arg(i); if (Path.isProject(currentArg)) { Project.filepath = currentArg; @@ -40,14 +40,14 @@ class Args { else if (Path.isTexture(currentArg)) { Args.assetPath = currentArg; } - else if (currentArg == "--export-textures" && (i + 3) <= Krom.getArgCount()) { + else if (currentArg == "--export-textures" && (i + 3) <= krom_get_arg_count()) { Args.exportTextures = true; ++i; - Args.exportTexturesType = Krom.getArg(i); + Args.exportTexturesType = krom_get_arg(i); ++i; - Args.exportTexturesPreset = Krom.getArg(i); + Args.exportTexturesPreset = krom_get_arg(i); ++i; - Args.exportTexturesPath = Krom.getArg(i); + Args.exportTexturesPath = krom_get_arg(i); } ///end @@ -55,10 +55,10 @@ class Args { else if (currentArg == "--reload-mesh") { Args.reimportMesh = true; } - else if (currentArg == "--export-mesh" && (i + 1) <= Krom.getArgCount()) { + else if (currentArg == "--export-mesh" && (i + 1) <= krom_get_arg_count()) { Args.exportMesh = true; ++i; - Args.exportMeshPath = Krom.getArg(i); + Args.exportMeshPath = krom_get_arg(i); } else if (Path.isMesh(currentArg) || (i > 1 && !currentArg.startsWith("-") && Path.isFolder(currentArg))) { @@ -67,10 +67,10 @@ class Args { ///end ///if is_paint - else if (currentArg == "--export-material" && (i + 1) <= Krom.getArgCount()) { + else if (currentArg == "--export-material" && (i + 1) <= krom_get_arg_count()) { Args.exportMaterial = true; ++i; - Args.exportMaterialPath = Krom.getArg(i); + Args.exportMaterialPath = krom_get_arg(i); } ///end @@ -156,11 +156,11 @@ class Args { }); } else { - Krom.log(tr("Invalid export directory")); + krom_log(tr("Invalid export directory")); } } else { - Krom.log(tr("Invalid texture type")); + krom_log(tr("Invalid texture type")); } } ///end @@ -173,7 +173,7 @@ class Args { ExportMesh.run(Args.exportMeshPath + Path.sep + f, null, false); } else { - Krom.log(tr("Invalid export directory")); + krom_log(tr("Invalid export directory")); } } ///end diff --git a/base/Sources/Base.ts b/base/Sources/Base.ts index 423a7b42e..af66504df 100644 --- a/base/Sources/Base.ts +++ b/base/Sources/Base.ts @@ -16,7 +16,7 @@ class Base { static dragStart = 0.0; static dropX = 0.0; static dropY = 0.0; - static font: font_t = null; + static font: g2_font_t = null; static theme: theme_t; static colorWheel: image_t; static colorWheelGradient: image_t; @@ -136,9 +136,9 @@ class Base { } ); - Krom.setSaveAndQuitCallback(Base.saveAndQuitCallback); + krom_set_save_and_quit_callback(Base.saveAndQuitCallback); - data_get_font("font.ttf", (f: font_t) => { + data_get_font("font.ttf", (f: g2_font_t) => { data_get_image("color_wheel.k", (imageColorWheel: image_t) => { data_get_image("color_wheel_gradient.k", (imageColorWheelGradient: image_t) => { @@ -154,7 +154,7 @@ class Base { // Baked font for fast startup if (Config.raw.locale == "en") { - Base.font.font_ = Krom.g2_font_13(Base.font.blob); + Base.font.font_ = krom_g2_font_13(Base.font.blob); Base.font.glyphs = _g2_font_glyphs; } else g2_font_init(Base.font); @@ -209,7 +209,7 @@ class Base { if (Config.raw.layout[LayoutSize.LayoutHeader] == 1) Base.appy += UIHeader.headerh; let cam = scene_camera; cam.data.fov = Math.floor(cam.data.fov * 100) / 100; - camera_object_build_projection(cam); + camera_object_build_proj(cam); Args.run(); @@ -389,7 +389,7 @@ class Base { cam.data.ortho[2] = -2 * (app_h() / app_w()); cam.data.ortho[3] = 2 * (app_h() / app_w()); } - camera_object_build_projection(cam); + camera_object_build_proj(cam); if (Context.raw.cameraType == CameraType.CameraOrthographic) { Viewport.updateCameraType(Context.raw.cameraType); @@ -445,7 +445,7 @@ class Base { static update = () => { if (mouse_movement_x != 0 || mouse_movement_y != 0) { - Krom.setMouseCursor(0); // Arrow + krom_set_mouse_cursor(0); // Arrow } ///if (is_paint || is_sculpt) @@ -566,7 +566,7 @@ class Base { } ///end - Krom.setMouseCursor(0); // Arrow + krom_set_mouse_cursor(0); // Arrow Base.isDragging = false; } if (Context.raw.colorPickerCallback != null && (mouse_released() || mouse_released("right"))) { @@ -741,7 +741,7 @@ class Base { Context.raw.frame++; if (Base.isDragging) { - Krom.setMouseCursor(1); // Hand + krom_set_mouse_cursor(1); // Hand let img = Base.getDragImage(); ///if (is_paint || is_sculpt) @@ -1095,17 +1095,17 @@ class Base { } static makeMergePipe = (red: bool, green: bool, blue: bool, alpha: bool): pipeline_t => { - let pipe = pipeline_create(); + let pipe = g4_pipeline_create(); pipe.vertex_shader = sys_get_shader("pass.vert"); pipe.fragment_shader = sys_get_shader("layer_merge.frag"); - let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); + let vs = g4_vertex_struct_create(); + g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipe.input_layout = [vs]; pipe.color_write_masks_red = [red]; pipe.color_write_masks_green = [green]; pipe.color_write_masks_blue = [blue]; pipe.color_write_masks_alpha = [alpha]; - pipeline_compile(pipe); + g4_pipeline_compile(pipe); return pipe; } ///end @@ -1117,65 +1117,65 @@ class Base { Base.pipeMergeG = Base.makeMergePipe(false, true, false, false); Base.pipeMergeB = Base.makeMergePipe(false, false, true, false); Base.pipeMergeA = Base.makeMergePipe(false, false, false, true); - Base.tex0 =pipeline_get_tex_unit( Base.pipeMerge, "tex0"); // Always binding texpaint.a for blending - Base.tex1 =pipeline_get_tex_unit( Base.pipeMerge, "tex1"); - Base.texmask =pipeline_get_tex_unit( Base.pipeMerge, "texmask"); - Base.texa =pipeline_get_tex_unit( Base.pipeMerge, "texa"); - Base.opac =pipeline_get_const_loc( Base.pipeMerge, "opac"); - Base.blending =pipeline_get_const_loc( Base.pipeMerge, "blending"); + Base.tex0 =g4_pipeline_get_tex_unit( Base.pipeMerge, "tex0"); // Always binding texpaint.a for blending + Base.tex1 =g4_pipeline_get_tex_unit( Base.pipeMerge, "tex1"); + Base.texmask =g4_pipeline_get_tex_unit( Base.pipeMerge, "texmask"); + Base.texa =g4_pipeline_get_tex_unit( Base.pipeMerge, "texa"); + Base.opac =g4_pipeline_get_const_loc( Base.pipeMerge, "opac"); + Base.blending =g4_pipeline_get_const_loc( Base.pipeMerge, "blending"); ///end { - Base.pipeCopy = pipeline_create(); + Base.pipeCopy = g4_pipeline_create(); Base.pipeCopy.vertex_shader = sys_get_shader("layer_view.vert"); Base.pipeCopy.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + let vs = g4_vertex_struct_create(); + g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); Base.pipeCopy.input_layout = [vs]; - pipeline_compile(Base.pipeCopy); + g4_pipeline_compile(Base.pipeCopy); } { - Base.pipeCopyBGRA = pipeline_create(); + Base.pipeCopyBGRA = g4_pipeline_create(); Base.pipeCopyBGRA.vertex_shader = sys_get_shader("layer_view.vert"); Base.pipeCopyBGRA.fragment_shader = sys_get_shader("layer_copy_bgra.frag"); - let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + let vs = g4_vertex_struct_create(); + g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); Base.pipeCopyBGRA.input_layout = [vs]; - pipeline_compile(Base.pipeCopyBGRA); + g4_pipeline_compile(Base.pipeCopyBGRA); } ///if (krom_metal || krom_vulkan || krom_direct3d12) { - Base.pipeCopy8 = pipeline_create(); + Base.pipeCopy8 = g4_pipeline_create(); Base.pipeCopy8.vertex_shader = sys_get_shader("layer_view.vert"); Base.pipeCopy8.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + let vs = g4_vertex_struct_create(); + g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); Base.pipeCopy8.input_layout = [vs]; Base.pipeCopy8.color_attachment_count = 1; Base.pipeCopy8.color_attachments[0] = tex_format_t.R8; - pipeline_compile(Base.pipeCopy8); + g4_pipeline_compile(Base.pipeCopy8); } { - Base.pipeCopy128 = pipeline_create(); + Base.pipeCopy128 = g4_pipeline_create(); Base.pipeCopy128.vertex_shader = sys_get_shader("layer_view.vert"); Base.pipeCopy128.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + let vs = g4_vertex_struct_create(); + g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); Base.pipeCopy128.input_layout = [vs]; Base.pipeCopy128.color_attachment_count = 1; Base.pipeCopy128.color_attachments[0] = tex_format_t.RGBA128; - pipeline_compile(Base.pipeCopy128); + g4_pipeline_compile(Base.pipeCopy128); } ///else Base.pipeCopy8 = Base.pipeCopy; @@ -1184,174 +1184,174 @@ class Base { ///if (is_paint || is_sculpt) { - Base.pipeInvert8 = pipeline_create(); + Base.pipeInvert8 = g4_pipeline_create(); Base.pipeInvert8.vertex_shader = sys_get_shader("layer_view.vert"); Base.pipeInvert8.fragment_shader = sys_get_shader("layer_invert.frag"); - let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + let vs = g4_vertex_struct_create(); + g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); Base.pipeInvert8.input_layout = [vs]; Base.pipeInvert8.color_attachment_count = 1; Base.pipeInvert8.color_attachments[0] = tex_format_t.R8; - pipeline_compile(Base.pipeInvert8); + g4_pipeline_compile(Base.pipeInvert8); } { - Base.pipeApplyMask = pipeline_create(); + Base.pipeApplyMask = g4_pipeline_create(); Base.pipeApplyMask.vertex_shader = sys_get_shader("pass.vert"); Base.pipeApplyMask.fragment_shader = sys_get_shader("mask_apply.frag"); - let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); + let vs = g4_vertex_struct_create(); + g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); Base.pipeApplyMask.input_layout = [vs]; - pipeline_compile(Base.pipeApplyMask); - Base.tex0Mask = pipeline_get_tex_unit(Base.pipeApplyMask, "tex0"); - Base.texaMask = pipeline_get_tex_unit(Base.pipeApplyMask, "texa"); + g4_pipeline_compile(Base.pipeApplyMask); + Base.tex0Mask = g4_pipeline_get_tex_unit(Base.pipeApplyMask, "tex0"); + Base.texaMask = g4_pipeline_get_tex_unit(Base.pipeApplyMask, "texa"); } { - Base.pipeMergeMask = pipeline_create(); + Base.pipeMergeMask = g4_pipeline_create(); Base.pipeMergeMask.vertex_shader = sys_get_shader("pass.vert"); Base.pipeMergeMask.fragment_shader = sys_get_shader("mask_merge.frag"); - let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); + let vs = g4_vertex_struct_create(); + g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); Base.pipeMergeMask.input_layout = [vs]; - pipeline_compile(Base.pipeMergeMask); - Base.tex0MergeMask = pipeline_get_tex_unit(Base.pipeMergeMask, "tex0"); - Base.texaMergeMask = pipeline_get_tex_unit(Base.pipeMergeMask, "texa"); - Base.opacMergeMask = pipeline_get_const_loc(Base.pipeMergeMask, "opac"); - Base.blendingMergeMask = pipeline_get_const_loc(Base.pipeMergeMask, "blending"); + g4_pipeline_compile(Base.pipeMergeMask); + Base.tex0MergeMask = g4_pipeline_get_tex_unit(Base.pipeMergeMask, "tex0"); + Base.texaMergeMask = g4_pipeline_get_tex_unit(Base.pipeMergeMask, "texa"); + Base.opacMergeMask = g4_pipeline_get_const_loc(Base.pipeMergeMask, "opac"); + Base.blendingMergeMask = g4_pipeline_get_const_loc(Base.pipeMergeMask, "blending"); } { - Base.pipeColorIdToMask = pipeline_create(); + Base.pipeColorIdToMask = g4_pipeline_create(); Base.pipeColorIdToMask.vertex_shader = sys_get_shader("pass.vert"); Base.pipeColorIdToMask.fragment_shader = sys_get_shader("mask_colorid.frag"); - let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); + let vs = g4_vertex_struct_create(); + g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); Base.pipeColorIdToMask.input_layout = [vs]; - pipeline_compile(Base.pipeColorIdToMask); - Base.texpaintColorId = pipeline_get_tex_unit(Base.pipeColorIdToMask, "texpaint_colorid"); - Base.texColorId = pipeline_get_tex_unit(Base.pipeColorIdToMask, "texcolorid"); + g4_pipeline_compile(Base.pipeColorIdToMask); + Base.texpaintColorId = g4_pipeline_get_tex_unit(Base.pipeColorIdToMask, "texpaint_colorid"); + Base.texColorId = g4_pipeline_get_tex_unit(Base.pipeColorIdToMask, "texcolorid"); } ///end ///if is_lab { - Base.pipeCopyR = pipeline_create(); + Base.pipeCopyR = g4_pipeline_create(); Base.pipeCopyR.vertex_shader = sys_get_shader("layer_view.vert"); Base.pipeCopyR.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + let vs = g4_vertex_struct_create(); + g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); Base.pipeCopyR.input_layout = [vs]; Base.pipeCopyR.color_write_masks_green = [false]; Base.pipeCopyR.color_write_masks_blue = [false]; Base.pipeCopyR.color_write_masks_alpha = [false]; - pipeline_compile(Base.pipeCopyR); + g4_pipeline_compile(Base.pipeCopyR); } { - Base.pipeCopyG = pipeline_create(); + Base.pipeCopyG = g4_pipeline_create(); Base.pipeCopyG.vertex_shader = sys_get_shader("layer_view.vert"); Base.pipeCopyG.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + let vs = g4_vertex_struct_create(); + g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); Base.pipeCopyG.input_layout = [vs]; Base.pipeCopyG.color_write_masks_red = [false]; Base.pipeCopyG.color_write_masks_blue = [false]; Base.pipeCopyG.color_write_masks_alpha = [false]; - pipeline_compile(Base.pipeCopyG); + g4_pipeline_compile(Base.pipeCopyG); } { - Base.pipeCopyB = pipeline_create(); + Base.pipeCopyB = g4_pipeline_create(); Base.pipeCopyB.vertex_shader = sys_get_shader("layer_view.vert"); Base.pipeCopyB.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + let vs = g4_vertex_struct_create(); + g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); Base.pipeCopyB.input_layout = [vs]; Base.pipeCopyB.color_write_masks_red = [false]; Base.pipeCopyB.color_write_masks_green = [false]; Base.pipeCopyB.color_write_masks_alpha = [false]; - pipeline_compile(Base.pipeCopyB); + g4_pipeline_compile(Base.pipeCopyB); } { - Base.pipeInpaintPreview = pipeline_create(); + Base.pipeInpaintPreview = g4_pipeline_create(); Base.pipeInpaintPreview.vertex_shader = sys_get_shader("pass.vert"); Base.pipeInpaintPreview.fragment_shader = sys_get_shader("inpaint_preview.frag"); - let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); + let vs = g4_vertex_struct_create(); + g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); Base.pipeInpaintPreview.input_layout = [vs]; - pipeline_compile(Base.pipeInpaintPreview); - Base.tex0InpaintPreview = pipeline_get_tex_unit(Base.pipeInpaintPreview, "tex0"); - Base.texaInpaintPreview = pipeline_get_tex_unit(Base.pipeInpaintPreview, "texa"); + g4_pipeline_compile(Base.pipeInpaintPreview); + Base.tex0InpaintPreview = g4_pipeline_get_tex_unit(Base.pipeInpaintPreview, "tex0"); + Base.texaInpaintPreview = g4_pipeline_get_tex_unit(Base.pipeInpaintPreview, "texa"); } ///end } static makePipeCopyRGB = () => { - Base.pipeCopyRGB = pipeline_create(); + Base.pipeCopyRGB = g4_pipeline_create(); Base.pipeCopyRGB.vertex_shader = sys_get_shader("layer_view.vert"); Base.pipeCopyRGB.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + let vs = g4_vertex_struct_create(); + g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); Base.pipeCopyRGB.input_layout = [vs]; Base.pipeCopyRGB.color_write_masks_alpha = [false]; - pipeline_compile(Base.pipeCopyRGB); + g4_pipeline_compile(Base.pipeCopyRGB); } ///if is_lab static makePipeCopyA = () => { - Base.pipeCopyA = pipeline_create(); + Base.pipeCopyA = g4_pipeline_create(); Base.pipeCopyA.vertex_shader = sys_get_shader("pass.vert"); Base.pipeCopyA.fragment_shader = sys_get_shader("layer_copy_rrrr.frag"); - let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); + let vs = g4_vertex_struct_create(); + g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); Base.pipeCopyA.input_layout = [vs]; Base.pipeCopyA.color_write_masks_red = [false]; Base.pipeCopyA.color_write_masks_green = [false]; Base.pipeCopyA.color_write_masks_blue = [false]; - pipeline_compile(Base.pipeCopyA); - Base.pipeCopyATex = pipeline_get_tex_unit(Base.pipeCopyA, "tex"); + g4_pipeline_compile(Base.pipeCopyA); + Base.pipeCopyATex = g4_pipeline_get_tex_unit(Base.pipeCopyA, "tex"); } ///end static makeCursorPipe = () => { - Base.pipeCursor = pipeline_create(); + Base.pipeCursor = g4_pipeline_create(); Base.pipeCursor.vertex_shader = sys_get_shader("cursor.vert"); Base.pipeCursor.fragment_shader = sys_get_shader("cursor.frag"); - let vs = vertex_struct_create(); + let vs = g4_vertex_struct_create(); ///if (krom_metal || krom_vulkan) - vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); + g4_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); ///else - vertex_struct_add(vs, "pos", vertex_data_t.I16_4X_NORM); - vertex_struct_add(vs, "nor", vertex_data_t.I16_2X_NORM); - vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); + g4_vertex_struct_add(vs, "pos", vertex_data_t.I16_4X_NORM); + g4_vertex_struct_add(vs, "nor", vertex_data_t.I16_2X_NORM); + g4_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); ///end Base.pipeCursor.input_layout = [vs]; Base.pipeCursor.blend_source = blend_factor_t.SOURCE_ALPHA; Base.pipeCursor.blend_dest = blend_factor_t.INV_SOURCE_ALPHA; Base.pipeCursor.depth_write = false; Base.pipeCursor.depth_mode = compare_mode_t.ALWAYS; - pipeline_compile(Base.pipeCursor); - Base.cursorVP = pipeline_get_const_loc(Base.pipeCursor, "VP"); - Base.cursorInvVP = pipeline_get_const_loc(Base.pipeCursor, "invVP"); - Base.cursorMouse = pipeline_get_const_loc(Base.pipeCursor, "mouse"); - Base.cursorTexStep = pipeline_get_const_loc(Base.pipeCursor, "texStep"); - Base.cursorRadius = pipeline_get_const_loc(Base.pipeCursor, "radius"); - Base.cursorCameraRight = pipeline_get_const_loc(Base.pipeCursor, "cameraRight"); - Base.cursorTint = pipeline_get_const_loc(Base.pipeCursor, "tint"); - Base.cursorGbufferD = pipeline_get_tex_unit(Base.pipeCursor, "gbufferD"); - Base.cursorTex = pipeline_get_tex_unit(Base.pipeCursor, "tex"); + g4_pipeline_compile(Base.pipeCursor); + Base.cursorVP = g4_pipeline_get_const_loc(Base.pipeCursor, "VP"); + Base.cursorInvVP = g4_pipeline_get_const_loc(Base.pipeCursor, "invVP"); + Base.cursorMouse = g4_pipeline_get_const_loc(Base.pipeCursor, "mouse"); + Base.cursorTexStep = g4_pipeline_get_const_loc(Base.pipeCursor, "texStep"); + Base.cursorRadius = g4_pipeline_get_const_loc(Base.pipeCursor, "radius"); + Base.cursorCameraRight = g4_pipeline_get_const_loc(Base.pipeCursor, "cameraRight"); + Base.cursorTint = g4_pipeline_get_const_loc(Base.pipeCursor, "tint"); + Base.cursorGbufferD = g4_pipeline_get_tex_unit(Base.pipeCursor, "gbufferD"); + Base.cursorTex = g4_pipeline_get_tex_unit(Base.pipeCursor, "tex"); } static makeTempImg = () => { diff --git a/base/Sources/BoxExport.ts b/base/Sources/BoxExport.ts index 310ac26bc..0951acd91 100644 --- a/base/Sources/BoxExport.ts +++ b/base/Sources/BoxExport.ts @@ -458,14 +458,14 @@ class BoxExport { `; if (!name.endsWith(".json")) name += ".json"; let path = Path.data() + Path.sep + "export_presets" + Path.sep + name; - Krom.fileSaveBytes(path, sys_string_to_buffer(template)); + krom_file_save_bytes(path, sys_string_to_buffer(template)); } static savePreset = () => { let name = BoxExport.files[BoxExport.hpreset.position]; if (name == "generic") return; // generic is const let path = Path.data() + Path.sep + "export_presets" + Path.sep + name + ".json"; - Krom.fileSaveBytes(path, sys_string_to_buffer(JSON.stringify(BoxExport.preset))); + krom_file_save_bytes(path, sys_string_to_buffer(JSON.stringify(BoxExport.preset))); } ///end } diff --git a/base/Sources/BoxPreferences.ts b/base/Sources/BoxPreferences.ts index 6c729add7..2b853d6c8 100644 --- a/base/Sources/BoxPreferences.ts +++ b/base/Sources/BoxPreferences.ts @@ -149,7 +149,7 @@ class BoxPreferences { let template = JSON.stringify(Base.theme); if (!themeName.endsWith(".json")) themeName += ".json"; let path = Path.data() + Path.sep + "themes" + Path.sep + themeName; - Krom.fileSaveBytes(path, sys_string_to_buffer(template)); + krom_file_save_bytes(path, sys_string_to_buffer(template)); BoxPreferences.fetchThemes(); // Refresh file list Config.raw.theme = themeName; BoxPreferences.themeHandle.position = BoxPreferences.getThemeIndex(); @@ -171,7 +171,7 @@ class BoxPreferences { UIFiles.show("json", true, false, (path: string) => { path += Path.sep + UIFiles.filename; if (!path.endsWith(".json")) path += ".json"; - Krom.fileSaveBytes(path, sys_string_to_buffer(JSON.stringify(Base.theme))); + krom_file_save_bytes(path, sys_string_to_buffer(JSON.stringify(Base.theme))); }); } @@ -480,7 +480,7 @@ class BoxPreferences { camRaw.near_plane = zui_slider(near_handle, tr("Clip Start"), 0.001, 1.0, true); camRaw.far_plane = zui_slider(far_handle, tr("Clip End"), 50.0, 100.0, true); if (near_handle.changed || far_handle.changed) { - camera_object_build_projection(cam); + camera_object_build_proj(cam); } let dispHandle = zui_handle("boxpreferences_49", { value: Config.raw.displace_strength }); @@ -516,7 +516,7 @@ class BoxPreferences { let template = JSON.stringify(Base.defaultKeymap); if (!keymapName.endsWith(".json")) keymapName += ".json"; let path = Path.data() + Path.sep + "keymap_presets" + Path.sep + keymapName; - Krom.fileSaveBytes(path, sys_string_to_buffer(template)); + krom_file_save_bytes(path, sys_string_to_buffer(template)); BoxPreferences.fetchKeymaps(); // Refresh file list Config.raw.keymap = keymapName; BoxPreferences.presetHandle.position = BoxPreferences.getPresetIndex(); @@ -580,7 +580,7 @@ plugin.drawUI = (ui) { => `; if (!pluginName.endsWith(".js")) pluginName += ".js"; let path = Path.data() + Path.sep + "plugins" + Path.sep + pluginName; - Krom.fileSaveBytes(path, sys_string_to_buffer(template)); + krom_file_save_bytes(path, sys_string_to_buffer(template)); BoxPreferences.filesPlugin = null; // Refresh file list UIBox.hide(); BoxPreferences.htab.position = 6; // Plugins diff --git a/base/Sources/BoxProjects.ts b/base/Sources/BoxProjects.ts index e3aefd757..7913484f8 100644 --- a/base/Sources/BoxProjects.ts +++ b/base/Sources/BoxProjects.ts @@ -91,7 +91,7 @@ class BoxProjects { let path = recent_projects[i]; ///if krom_ios - let documentDirectory = Krom.saveDialog("", ""); + let documentDirectory = krom_save_dialog("", ""); documentDirectory = documentDirectory.substr(0, documentDirectory.length - 8); // Strip /'untitled' path = documentDirectory + path; ///end diff --git a/base/Sources/Camera.ts b/base/Sources/Camera.ts index 9a3b10abb..da83dc2bf 100644 --- a/base/Sources/Camera.ts +++ b/base/Sources/Camera.ts @@ -23,19 +23,19 @@ class Camera { if (Config.raw.wrap_mouse && Camera.controlsDown) { if (mouse_view_x() < 0) { mouse_x = mouse_last_x = app_x() + app_w(); - Krom.setMousePosition(Math.floor(mouse_x), Math.floor(mouse_y)); + krom_set_mouse_position(Math.floor(mouse_x), Math.floor(mouse_y)); } else if (mouse_view_x() > app_w()) { mouse_x = mouse_last_x = app_x(); - Krom.setMousePosition(Math.floor(mouse_x), Math.floor(mouse_y)); + krom_set_mouse_position(Math.floor(mouse_x), Math.floor(mouse_y)); } else if (mouse_view_y() < 0) { mouse_y = mouse_last_y = app_y() + app_h(); - Krom.setMousePosition(Math.floor(mouse_x), Math.floor(mouse_y)); + krom_set_mouse_position(Math.floor(mouse_x), Math.floor(mouse_y)); } else if (mouse_view_y() > app_h()) { mouse_y = mouse_last_y = app_y(); - Krom.setMousePosition(Math.floor(mouse_x), Math.floor(mouse_y)); + krom_set_mouse_position(Math.floor(mouse_x), Math.floor(mouse_y)); } } else { @@ -68,12 +68,7 @@ class Camera { Camera.controlsDown = false; } - if (_input_occupied || - !Base.uiEnabled || - Base.isDragging || - Base.isScrolling() || - Base.isComboSelected() || - !Camera.controlsDown) { + if (_input_occupied || !Base.uiEnabled || Base.isDragging || Base.isScrolling() || Base.isComboSelected() || !Camera.controlsDown) { return; } @@ -223,7 +218,7 @@ class Camera { vec4_add(camera.base.transform.loc, right); vec4_add(Camera.origins[Camera.index()], look); vec4_add(Camera.origins[Camera.index()], right); - camera_object_build_matrix(camera); + camera_object_build_mat(camera); } } diff --git a/base/Sources/Config.ts b/base/Sources/Config.ts index 94b914e94..c594b7b9c 100644 --- a/base/Sources/Config.ts +++ b/base/Sources/Config.ts @@ -10,7 +10,7 @@ class Config { static load = (done: ()=>void) => { try { - data_get_blob((Path.isProtected() ? Krom.savePath() : "") + "config.json", (blob: ArrayBuffer) => { + data_get_blob((Path.isProtected() ? krom_save_path() : "") + "config.json", (blob: ArrayBuffer) => { Config.configLoaded = true; Config.raw = JSON.parse(sys_buffer_to_string(blob)); @@ -20,7 +20,7 @@ class Config { catch (e: any) { ///if krom_linux try { // Protected directory - data_get_blob(Krom.savePath() + "config.json", (blob: ArrayBuffer) => { + data_get_blob(krom_save_path() + "config.json", (blob: ArrayBuffer) => { Config.configLoaded = true; Config.raw = JSON.parse(sys_buffer_to_string(blob)); done(); @@ -38,12 +38,12 @@ class Config { static save = () => { // Use system application data folder // when running from protected path like "Program Files" - let path = (Path.isProtected() ? Krom.savePath() : Path.data() + Path.sep) + "config.json"; + let path = (Path.isProtected() ? krom_save_path() : Path.data() + Path.sep) + "config.json"; let buffer = sys_string_to_buffer(JSON.stringify(Config.raw)); - Krom.fileSaveBytes(path, buffer); + krom_file_save_bytes(path, buffer); ///if krom_linux // Protected directory - if (!File.exists(path)) Krom.fileSaveBytes(Krom.savePath() + "config.json", buffer); + if (!File.exists(path)) krom_file_save_bytes(krom_save_path() + "config.json", buffer); ///end } @@ -207,7 +207,7 @@ class Config { if (Config.raw.keymap == "default.json") return; let path = data_path() + "keymap_presets/" + Config.raw.keymap; let buffer = sys_string_to_buffer(JSON.stringify(Config.keymap)); - Krom.fileSaveBytes(path, buffer); + krom_file_save_bytes(path, buffer); } static getSuperSampleQuality = (f: f32): i32 => { diff --git a/base/Sources/Console.ts b/base/Sources/Console.ts index 076900036..218974b38 100644 --- a/base/Sources/Console.ts +++ b/base/Sources/Console.ts @@ -17,7 +17,7 @@ class Console { g2_set_font(Base.font); g2_set_font_size(Math.floor(22 * scale)); g2_set_color(0xffffffff); - g2_draw_string(s, x - font_width(_g2_font, _g2_font_size, s) / 2, y + 40 * scale - font_height(_g2_font, _g2_font_size) / 2); + g2_draw_string(s, x - g2_font_width(_g2_font, _g2_font_size, s) / 2, y + 40 * scale - g2_font_height(_g2_font, _g2_font_size) / 2); } static toast = (s: string) => { diff --git a/base/Sources/ExportArm.ts b/base/Sources/ExportArm.ts index a4d03a942..af1c9ffdb 100644 --- a/base/Sources/ExportArm.ts +++ b/base/Sources/ExportArm.ts @@ -7,7 +7,7 @@ class ExportArm { let raw: scene_t = { mesh_datas: mesh_datas }; let b = armpack_encode(raw); if (!path.endsWith(".arm")) path += ".arm"; - Krom.fileSaveBytes(path, b, b.byteLength + 1); + krom_file_save_bytes(path, b, b.byteLength + 1); } static runProject = () => { @@ -170,7 +170,7 @@ class ExportArm { // ///else // [encode(mesh_icon_pixels)]; // ///end - Krom.writePng(Project.filepath.substr(0, Project.filepath.length - 4) + "_icon.png", mesh_icon_pixels, 256, 256, 0); + krom_write_png(Project.filepath.substr(0, Project.filepath.length - 4) + "_icon.png", mesh_icon_pixels, 256, 256, 0); ///end ///if (is_paint || is_sculpt) @@ -181,7 +181,7 @@ class ExportArm { ///end let buffer = armpack_encode(Project.raw); - Krom.fileSaveBytes(Project.filepath, buffer, buffer.byteLength + 1); + krom_file_save_bytes(Project.filepath, buffer, buffer.byteLength + 1); // Save to recent ///if krom_ios @@ -262,9 +262,9 @@ class ExportArm { }; if (Context.raw.writeIconOnExport) { // Separate icon files - Krom.writePng(path.substr(0, path.length - 4) + "_icon.png", image_get_pixels(m.image), m.image.width, m.image.height, 0); + krom_write_png(path.substr(0, path.length - 4) + "_icon.png", image_get_pixels(m.image), m.image.width, m.image.height, 0); if (isCloud) { - Krom.writeJpg(path.substr(0, path.length - 4) + "_icon.jpg", image_get_pixels(m.image), m.image.width, m.image.height, 0, 50); + krom_write_jpg(path.substr(0, path.length - 4) + "_icon.jpg", image_get_pixels(m.image), m.image.width, m.image.height, 0, 50); } } @@ -273,7 +273,7 @@ class ExportArm { } let buffer = armpack_encode(raw); - Krom.fileSaveBytes(path, buffer, buffer.byteLength + 1); + krom_file_save_bytes(path, buffer, buffer.byteLength + 1); } ///end @@ -321,7 +321,7 @@ class ExportArm { }; if (Context.raw.writeIconOnExport) { // Separate icon file - Krom.writePng(path.substr(0, path.length - 4) + "_icon.png", image_get_pixels(b.image), b.image.width, b.image.height, 0); + krom_write_png(path.substr(0, path.length - 4) + "_icon.png", image_get_pixels(b.image), b.image.width, b.image.height, 0); } if (Context.raw.packAssetsOnExport) { // Pack textures @@ -329,7 +329,7 @@ class ExportArm { } let buffer = armpack_encode(raw); - Krom.fileSaveBytes(path, buffer, buffer.byteLength + 1); + krom_file_save_bytes(path, buffer, buffer.byteLength + 1); } ///end @@ -434,8 +434,8 @@ class ExportArm { raw.packed_assets.push({ name: assets[i].file, bytes: assets[i].file.endsWith(".jpg") ? - Krom.encodeJpg(image_get_pixels(temp), temp.width, temp.height, 0, 80) : - Krom.encodePng(image_get_pixels(temp), temp.width, temp.height, 0) + krom_encode_jpg(image_get_pixels(temp), temp.width, temp.height, 0, 80) : + krom_encode_png(image_get_pixels(temp), temp.width, temp.height, 0) }); } } @@ -451,7 +451,7 @@ class ExportArm { swatches: Project.raw.swatches }; let buffer = armpack_encode(raw); - Krom.fileSaveBytes(path, buffer, buffer.byteLength + 1); + krom_file_save_bytes(path, buffer, buffer.byteLength + 1); } static vec3f32 = (v: vec4_t): Float32Array => { diff --git a/base/Sources/ExportGpl.ts b/base/Sources/ExportGpl.ts index 25bbc967e..60b988b91 100644 --- a/base/Sources/ExportGpl.ts +++ b/base/Sources/ExportGpl.ts @@ -12,6 +12,6 @@ class ExportGpl { o += String(color_get_rb(swatch.base)) + " " + String(color_get_gb(swatch.base)) + " " + String(color_get_bb(swatch.base)) + "\n"; } - Krom.fileSaveBytes(path, sys_string_to_buffer(o), o.length); + krom_file_save_bytes(path, sys_string_to_buffer(o), o.length); } } diff --git a/base/Sources/ExportObj.ts b/base/Sources/ExportObj.ts index 6ab7a6d10..a245aa896 100644 --- a/base/Sources/ExportObj.ts +++ b/base/Sources/ExportObj.ts @@ -168,6 +168,6 @@ class ExportObj { if (!path.endsWith(".obj")) path += ".obj"; let b = Uint8Array.from(o).buffer; - Krom.fileSaveBytes(path, b, b.byteLength); + krom_file_save_bytes(path, b, b.byteLength); } } diff --git a/base/Sources/ExportTexture.ts b/base/Sources/ExportTexture.ts index 284db458e..6a5d040e7 100644 --- a/base/Sources/ExportTexture.ts +++ b/base/Sources/ExportTexture.ts @@ -375,14 +375,14 @@ class ExportTexture { } if (bits == 8 && Context.raw.formatType == TextureLdrFormat.FormatPng) { - Krom.writePng(file, pixels, resX, resY, format); + krom_write_png(file, pixels, resX, resY, format); } else if (bits == 8 && Context.raw.formatType == TextureLdrFormat.FormatJpg) { - Krom.writeJpg(file, pixels, resX, resY, format, Math.floor(Context.raw.formatQuality)); + krom_write_jpg(file, pixels, resX, resY, format, Math.floor(Context.raw.formatQuality)); } else { // Exr let b = ParserExr.run(resX, resY, pixels, bits, type, off); - Krom.fileSaveBytes(file, b, b.byteLength); + krom_file_save_bytes(file, b, b.byteLength); } } diff --git a/base/Sources/File.ts b/base/Sources/File.ts index 6b311d1d2..96902ba0f 100644 --- a/base/Sources/File.ts +++ b/base/Sources/File.ts @@ -34,60 +34,60 @@ class File { // } // if (internal.exists(path)) return internal.get(path); // ///end - return Krom.readDirectory(path, foldersOnly).split("\n"); + return krom_read_directory(path, foldersOnly).split("\n"); } static createDirectory = (path: string) => { - Krom.sysCommand(File.cmd_mkdir + ' "' + path + '"'); + krom_sys_command(File.cmd_mkdir + ' "' + path + '"'); } static copy = (srcPath: string, dstPath: string) => { - Krom.sysCommand(File.cmd_copy + ' "' + srcPath + '" "' + dstPath + '"'); + krom_sys_command(File.cmd_copy + ' "' + srcPath + '" "' + dstPath + '"'); } static start = (path: string) => { ///if krom_windows - Krom.sysCommand('start "" "' + path + '"'); + krom_sys_command('start "" "' + path + '"'); ///elseif krom_linux - Krom.sysCommand('xdg-open "' + path + '"'); + krom_sys_command('xdg-open "' + path + '"'); ///else - Krom.sysCommand('open "' + path + '"'); + krom_sys_command('open "' + path + '"'); ///end } static loadUrl = (url: string) => { - Krom.loadUrl(url); + krom_load_url(url); } static delete = (path: string) => { - Krom.deleteFile(path); + krom_delete_file(path); } static exists = (path: string): bool => { - return Krom.fileExists(path); + return krom_file_exists(path); } static download = (url: string, dstPath: string, done: ()=>void, size = 0) => { ///if (krom_windows || krom_darwin || krom_ios || krom_android) - Krom.httpRequest(url, size, (ab: ArrayBuffer) => { - if (ab != null) Krom.fileSaveBytes(dstPath, ab); + krom_http_request(url, size, (ab: ArrayBuffer) => { + if (ab != null) krom_file_save_bytes(dstPath, ab); done(); }); ///elseif krom_linux - Krom.sysCommand('wget -O "' + dstPath + '" "' + url + '"'); + krom_sys_command('wget -O "' + dstPath + '" "' + url + '"'); done(); ///else - Krom.sysCommand('curl -L ' + url + ' -o "' + dstPath + '"'); + krom_sys_command('curl -L ' + url + ' -o "' + dstPath + '"'); done(); ///end } static downloadBytes = (url: string, done: (ab: ArrayBuffer)=>void) => { - let save = (Path.isProtected() ? Krom.savePath() : Path.data() + Path.sep) + "download.bin"; + let save = (Path.isProtected() ? krom_save_path() : Path.data() + Path.sep) + "download.bin"; File.download(url, save, () => { let buffer: ArrayBuffer = null; try { - buffer = Krom.loadBlob(save); + buffer = krom_load_blob(save); } catch (e: any) {} done(buffer); @@ -100,12 +100,12 @@ class File { ///else let path2 = path; ///end - let dest = (Path.isProtected() ? Krom.savePath() : Krom.getFilesLocation() + Path.sep) + path2; + let dest = (Path.isProtected() ? krom_save_path() : krom_get_files_location() + Path.sep) + path2; if (File.exists(dest)) { ///if (krom_darwin || krom_ios) done(dest); ///else - done((Path.isProtected() ? Krom.savePath() : Path.workingDir() + Path.sep) + path); + done((Path.isProtected() ? krom_save_path() : Path.workingDir() + Path.sep) + path); ///end return; } @@ -127,7 +127,7 @@ class File { ///if (krom_darwin || krom_ios) done(dest); ///else - done((Path.isProtected() ? Krom.savePath() : Path.workingDir() + Path.sep) + path); + done((Path.isProtected() ? krom_save_path() : Path.workingDir() + Path.sep) + path); ///end }, File.cloudSizes.get(path)); } diff --git a/base/Sources/Gizmo.ts b/base/Sources/Gizmo.ts index c2e363fb0..8f2e872c4 100644 --- a/base/Sources/Gizmo.ts +++ b/base/Sources/Gizmo.ts @@ -28,7 +28,7 @@ class Gizmo { vec4_set_from(gizmo.transform.loc, paintObject.transform.loc); } else if (isDecal) { - vec4_set(gizmo.transform.loc, Context.raw.layer.decalMat._30, Context.raw.layer.decalMat._31, Context.raw.layer.decalMat._32); + vec4_set(gizmo.transform.loc, Context.raw.layer.decalMat.m[12], Context.raw.layer.decalMat.m[13], Context.raw.layer.decalMat.m[14]); } let cam = scene_camera; let fov = cam.data.fov; @@ -91,13 +91,13 @@ class Gizmo { else if (isDecal) { if (Context.raw.translateX || Context.raw.translateY || Context.raw.translateZ || Context.raw.scaleX || Context.raw.scaleY || Context.raw.scaleZ || Context.raw.rotateX || Context.raw.rotateY || Context.raw.rotateZ) { if (Context.raw.translateX) { - Context.raw.layer.decalMat._30 = Context.raw.gizmoDrag; + Context.raw.layer.decalMat.m[12] = Context.raw.gizmoDrag; } else if (Context.raw.translateY) { - Context.raw.layer.decalMat._31 = Context.raw.gizmoDrag; + Context.raw.layer.decalMat.m[13] = Context.raw.gizmoDrag; } else if (Context.raw.translateZ) { - Context.raw.layer.decalMat._32 = Context.raw.gizmoDrag; + Context.raw.layer.decalMat.m[14] = Context.raw.gizmoDrag; } else if (Context.raw.scaleX) { mat4_decompose(Context.raw.layer.decalMat, Gizmo.v, Gizmo.q, Gizmo.v0); @@ -188,7 +188,7 @@ class Gizmo { vec4_set(Gizmo.v, transform_world_x(t), transform_world_y(t), transform_world_z(t)); } else if (isDecal) { - vec4_set(Gizmo.v, Context.raw.layer.decalMat._30, Context.raw.layer.decalMat._31, Context.raw.layer.decalMat._32); + vec4_set(Gizmo.v, Context.raw.layer.decalMat.m[12], Context.raw.layer.decalMat.m[13], Context.raw.layer.decalMat.m[14]); } if (Context.raw.translateX || Context.raw.scaleX) { diff --git a/base/Sources/ImportArm.ts b/base/Sources/ImportArm.ts index 3cca3717c..bf17f5426 100644 --- a/base/Sources/ImportArm.ts +++ b/base/Sources/ImportArm.ts @@ -81,7 +81,7 @@ class ImportArm { scene_camera.base.transform.local = mat4_from_f32_array(Project.raw.camera_world); transform_decompose(scene_camera.base.transform); scene_camera.data.fov = Project.raw.camera_fov; - camera_object_build_projection(scene_camera); + camera_object_build_proj(scene_camera); let origin = Project.raw.camera_origin; Camera.origins[0].x = origin[0]; Camera.origins[0].y = origin[1]; diff --git a/base/Sources/ImportBlendMesh.ts b/base/Sources/ImportBlendMesh.ts index 77dcebc6e..3f8123fd6 100644 --- a/base/Sources/ImportBlendMesh.ts +++ b/base/Sources/ImportBlendMesh.ts @@ -407,7 +407,7 @@ class ImportBlendMesh { } mat4_get_inv(mat, mat); mat4_transpose3x3(mat); - mat._30 = mat._31 = mat._32 = mat._33 = 0; + mat.m[12] = mat.m[13] = mat.m[14] = mat.m[15] = 0; for (let i = 0; i < Math.floor(nora.length / 2); ++i) { vec4_set(v, nora[i * 2] / 32767, nora[i * 2 + 1] / 32767, posa[i * 4 + 3] / 32767); vec4_apply_mat(v, mat); diff --git a/base/Sources/ImportEnvmap.ts b/base/Sources/ImportEnvmap.ts index 4985d58e8..2505bc473 100644 --- a/base/Sources/ImportEnvmap.ts +++ b/base/Sources/ImportEnvmap.ts @@ -15,17 +15,17 @@ class ImportEnvmap { // Init if (ImportEnvmap.pipeline == null) { - ImportEnvmap.pipeline = pipeline_create(); + ImportEnvmap.pipeline = g4_pipeline_create(); ImportEnvmap.pipeline.vertex_shader = sys_get_shader("pass.vert"); ImportEnvmap.pipeline.fragment_shader = sys_get_shader("prefilter_envmap.frag"); - let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); + let vs = g4_vertex_struct_create(); + g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); ImportEnvmap.pipeline.input_layout = [vs]; ImportEnvmap.pipeline.color_attachment_count = 1; ImportEnvmap.pipeline.color_attachments[0] = tex_format_t.RGBA128; - pipeline_compile(ImportEnvmap.pipeline); - ImportEnvmap.paramsLocation = pipeline_get_const_loc(ImportEnvmap.pipeline, "params"); - ImportEnvmap.radianceLocation = pipeline_get_tex_unit(ImportEnvmap.pipeline, "radiance"); + g4_pipeline_compile(ImportEnvmap.pipeline); + ImportEnvmap.paramsLocation = g4_pipeline_get_const_loc(ImportEnvmap.pipeline, "params"); + ImportEnvmap.radianceLocation = g4_pipeline_get_tex_unit(ImportEnvmap.pipeline, "radiance"); ImportEnvmap.radiance = image_create_render_target(1024, 512, tex_format_t.RGBA128); diff --git a/base/Sources/ImportFont.ts b/base/Sources/ImportFont.ts index 24a345792..e366d15a0 100644 --- a/base/Sources/ImportFont.ts +++ b/base/Sources/ImportFont.ts @@ -10,15 +10,15 @@ class ImportFont { return; } } - data_get_font(path, (font: font_t) => { + data_get_font(path, (font: g2_font_t) => { g2_font_init(font); // Make sure font_ is ready - let count = Krom.g2_font_count(font.font_); + let count = krom_g2_font_count(font.font_); let fontSlots: SlotFontRaw[] = []; for (let i = 0; i < count; ++i) { let ar = path.split(Path.sep); let name = ar[ar.length - 1]; - let f = font_clone(font); - font_set_font_index(f, i); + let f = g2_font_clone(font); + g2_font_set_font_index(f, i); let fontSlot = SlotFont.create(name, f, path); fontSlots.push(fontSlot); } diff --git a/base/Sources/ImportObj.ts b/base/Sources/ImportObj.ts index a47e89726..1897698ba 100644 --- a/base/Sources/ImportObj.ts +++ b/base/Sources/ImportObj.ts @@ -12,7 +12,7 @@ class ImportObj { data_get_blob(path, (b: ArrayBuffer) => { if (isUdim) { - let part = Krom.io_obj_parse(b, splitCode, 0, isUdim); + let part = krom_io_obj_parse(b, splitCode, 0, isUdim); let name = part.name; for (let i = 0; i < part.udims.length; ++i) { if (part.udims[i].length == 0) continue; @@ -25,10 +25,10 @@ class ImportObj { } else { let parts: any[] = []; - let part = Krom.io_obj_parse(b, splitCode, 0, false); + let part = krom_io_obj_parse(b, splitCode, 0, false); parts.push(part); while (part.has_next) { - part = Krom.io_obj_parse(b, splitCode, part.pos, false); + part = krom_io_obj_parse(b, splitCode, part.pos, false); // This part does not contain faces (may contain lines only) if (part.inda.length == 0) { continue; diff --git a/base/Sources/LineDraw.ts b/base/Sources/LineDraw.ts index 039fed41b..457a43201 100644 --- a/base/Sources/LineDraw.ts +++ b/base/Sources/LineDraw.ts @@ -26,10 +26,10 @@ class LineDraw { LineDraw.dim = mat4_get_scale(matrix); if (LineDraw.pipeline == null) { - let structure = vertex_struct_create(); - vertex_struct_add(structure, "pos", vertex_data_t.F32_3X); - vertex_struct_add(structure, "col", vertex_data_t.F32_3X); - LineDraw.pipeline = pipeline_create(); + let structure = g4_vertex_struct_create(); + g4_vertex_struct_add(structure, "pos", vertex_data_t.F32_3X); + g4_vertex_struct_add(structure, "col", vertex_data_t.F32_3X); + LineDraw.pipeline = g4_pipeline_create(); LineDraw.pipeline.input_layout = [structure]; LineDraw.pipeline.fragment_shader = sys_get_shader("line.frag"); LineDraw.pipeline.vertex_shader = sys_get_shader("line.vert"); @@ -41,11 +41,11 @@ class LineDraw { LineDraw.pipeline.color_attachments[1] = tex_format_t.RGBA64; LineDraw.pipeline.color_attachments[2] = tex_format_t.RGBA64; LineDraw.pipeline.depth_attachment = depth_format_t.DEPTH24; - pipeline_compile(LineDraw.pipeline); - LineDraw.vpID = pipeline_get_const_loc(LineDraw.pipeline, "VP"); + g4_pipeline_compile(LineDraw.pipeline); + LineDraw.vpID = g4_pipeline_get_const_loc(LineDraw.pipeline, "VP"); LineDraw.vp = mat4_identity(); - LineDraw.vertexBuffer = vertex_buffer_create(LineDraw.maxVertices, structure, usage_t.DYNAMIC); - LineDraw.indexBuffer = index_buffer_create(LineDraw.maxIndices); + LineDraw.vertexBuffer = g4_vertex_buffer_create(LineDraw.maxVertices, structure, usage_t.DYNAMIC); + LineDraw.indexBuffer = g4_index_buffer_create(LineDraw.maxIndices); } LineDraw.begin(); @@ -167,13 +167,13 @@ class LineDraw { static begin = () => { LineDraw.lines = 0; - LineDraw.vbData = vertex_buffer_lock(LineDraw.vertexBuffer); - LineDraw.ibData = index_buffer_lock(LineDraw.indexBuffer); + LineDraw.vbData = g4_vertex_buffer_lock(LineDraw.vertexBuffer); + LineDraw.ibData = g4_index_buffer_lock(LineDraw.indexBuffer); } static end = () => { - vertex_buffer_unlock(LineDraw.vertexBuffer); - index_buffer_unlock(LineDraw.indexBuffer); + g4_vertex_buffer_unlock(LineDraw.vertexBuffer); + g4_index_buffer_unlock(LineDraw.indexBuffer); g4_set_vertex_buffer(LineDraw.vertexBuffer); g4_set_index_buffer(LineDraw.indexBuffer); diff --git a/base/Sources/MakeVoxel.ts b/base/Sources/MakeVoxel.ts index 263db5c06..644206974 100644 --- a/base/Sources/MakeVoxel.ts +++ b/base/Sources/MakeVoxel.ts @@ -3,10 +3,10 @@ class MakeVoxel { ///if arm_voxels static run = (data: shader_context_t) => { - let structure = vertex_struct_create(); - vertex_struct_add(structure, "pos", vertex_data_t.I16_4X_NORM); - vertex_struct_add(structure, "nor", vertex_data_t.I16_2X_NORM); - vertex_struct_add(structure, "tex", vertex_data_t.I16_2X_NORM); + let structure = g4_vertex_struct_create(); + g4_vertex_struct_add(structure, "pos", vertex_data_t.I16_4X_NORM); + g4_vertex_struct_add(structure, "nor", vertex_data_t.I16_2X_NORM); + g4_vertex_struct_add(structure, "tex", vertex_data_t.I16_2X_NORM); let pipeState = data._pipe_state; pipeState.input_layout = [structure]; @@ -24,13 +24,13 @@ class MakeVoxel { // ///end let ds = MakeMaterial.getDisplaceStrength(); - pipeState.vertex_shader = shader_from_source(MakeVoxel.voxelSource(), shader_type_t.VERTEX); + pipeState.vertex_shader = g4_shader_from_source(MakeVoxel.voxelSource(), shader_type_t.VERTEX); - pipeline_compile(pipeState); + g4_pipeline_compile(pipeState); data.constants = [{ name: "W", type: "mat4", link: "_worldMatrix" }, { name: "N", type: "mat3", link: "_normalMatrix" }]; - data._constants = [pipeline_get_const_loc(pipeState, "W"), pipeline_get_const_loc(pipeState, "N")]; + data._constants = [g4_pipeline_get_const_loc(pipeState, "W"), g4_pipeline_get_const_loc(pipeState, "N")]; data.texture_units = [{ name: "texpaint_pack" }, { name: "voxels", is_image: true }]; - data._tex_units = [pipeline_get_tex_unit(pipeState, "texpaint_pack"), pipeline_get_tex_unit(pipeState, "voxels")]; + data._tex_units = [g4_pipeline_get_tex_unit(pipeState, "texpaint_pack"), g4_pipeline_get_tex_unit(pipeState, "voxels")]; } static voxelSource = (): string => { diff --git a/base/Sources/ParserBlend.ts b/base/Sources/ParserBlend.ts index 2b242ca31..f21075eec 100644 --- a/base/Sources/ParserBlend.ts +++ b/base/Sources/ParserBlend.ts @@ -4,9 +4,9 @@ // https://web.archive.org/web/20170630054951/http://www.atmind.nl/blender/mystery_ot_blend.html // Usage: // let bl = ParserBlend.init(blob: DataView); -// Krom.log(ParserBlend.dir(bl, "Scene")); +// krom_log(ParserBlend.dir(bl, "Scene")); // let scenes = ParserBlend.get(bl, "Scene"); -// Krom.log(BlHandle.get(BlHandle.get(scenes[0], "id"), "name")); +// krom_log(BlHandle.get(BlHandle.get(scenes[0], "id"), "name")); class BlendRaw { pos: i32; @@ -29,7 +29,7 @@ class ParserBlend { raw.view = new DataView(buffer); raw.pos = 0; if (ParserBlend.readChars(raw, 7) != "BLENDER") { - raw.view = new DataView(Krom.inflate(buffer, false)); + raw.view = new DataView(krom_inflate(buffer, false)); raw.pos = 0; if (ParserBlend.readChars(raw, 7) != "BLENDER") return null; } diff --git a/base/Sources/Path.ts b/base/Sources/Path.ts index 861c1437f..8da9e65a9 100644 --- a/base/Sources/Path.ts +++ b/base/Sources/Path.ts @@ -26,7 +26,7 @@ class Path { static workingDirCache: string = null; static data = (): string => { - return Krom.getFilesLocation() + Path.sep + data_path(); + return krom_get_files_location() + Path.sep + data_path(); } static toRelative = (from: string, to: string): string => { @@ -71,9 +71,9 @@ class Path { static workingDir = (): string => { if (Path.workingDirCache == null) { let cmd = Path.pwd; - let save = (Path.isProtected() ? Krom.savePath() : Path.data() + Path.sep) + "working_dir.txt"; - Krom.sysCommand(cmd + ' > "' + save + '"'); - Path.workingDirCache = trim_end(sys_buffer_to_string(Krom.loadBlob(save))); + let save = (Path.isProtected() ? krom_save_path() : Path.data() + Path.sep) + "working_dir.txt"; + krom_sys_command(cmd + ' > "' + save + '"'); + Path.workingDirCache = trim_end(sys_buffer_to_string(krom_load_blob(save))); } return Path.workingDirCache; } @@ -165,7 +165,7 @@ class Path { static isProtected = (): bool => { ///if krom_windows - return Krom.getFilesLocation().indexOf("Program Files") >= 0; + return krom_get_files_location().indexOf("Program Files") >= 0; ///elseif krom_android return true; ///elseif krom_ios diff --git a/base/Sources/PhysicsWorld.ts b/base/Sources/PhysicsWorld.ts index ae3953660..dba0e190b 100644 --- a/base/Sources/PhysicsWorld.ts +++ b/base/Sources/PhysicsWorld.ts @@ -20,9 +20,9 @@ class PhysicsWorld { static v2 = vec4_create(); static load = (done: ()=>void) => { - let b = Krom.loadBlob("data/plugins/ammo.js"); + let b = krom_load_blob("data/plugins/ammo.js"); globalThis.eval(sys_buffer_to_string(b)); - let print = (s: string) => { Krom.log(s); }; + let print = (s: string) => { krom_log(s); }; Ammo({print: print}).then(done); } diff --git a/base/Sources/Plugin.ts b/base/Sources/Plugin.ts index e489cfb9e..e14c98fc3 100644 --- a/base/Sources/Plugin.ts +++ b/base/Sources/Plugin.ts @@ -32,7 +32,7 @@ class Plugin { } catch (e: any) { Console.error(tr("Failed to load plugin") + " '" + plugin + "'"); - Krom.log(e); + krom_log(e); } } diff --git a/base/Sources/Project.ts b/base/Sources/Project.ts index e7e623174..18ce22c7e 100644 --- a/base/Sources/Project.ts +++ b/base/Sources/Project.ts @@ -46,11 +46,11 @@ class Project { static projectSave = (saveAndQuit = false) => { if (Project.filepath == "") { ///if krom_ios - let documentDirectory = Krom.saveDialog("", ""); + let documentDirectory = krom_save_dialog("", ""); documentDirectory = documentDirectory.substr(0, documentDirectory.length - 8); // Strip /'untitled' Project.filepath = documentDirectory + "/" + sys_title() + ".arm"; ///elseif krom_android - Project.filepath = Krom.savePath() + "/" + sys_title() + ".arm"; + Project.filepath = krom_save_path() + "/" + sys_title() + ".arm"; ///else Project.projectSaveAs(saveAndQuit); return; diff --git a/base/Sources/RenderPathBase.ts b/base/Sources/RenderPathBase.ts index 560d99782..4d5ce0fbe 100644 --- a/base/Sources/RenderPathBase.ts +++ b/base/Sources/RenderPathBase.ts @@ -112,15 +112,15 @@ class RenderPathBase { } transform_set_matrix(cam.base.transform, Camera.views[Context.raw.viewIndex]); - camera_object_build_matrix(cam); - camera_object_build_projection(cam); + camera_object_build_mat(cam); + camera_object_build_proj(cam); } // Match projection matrix jitter let skipTaa = Context.raw.splitView || ((Context.raw.tool == WorkspaceTool.ToolClone || Context.raw.tool == WorkspaceTool.ToolBlur || Context.raw.tool == WorkspaceTool.ToolSmudge) && Context.raw.pdirty > 0); scene_camera.frame = skipTaa ? 0 : RenderPathBase.taaFrame; - camera_object_projection_jitter(scene_camera); - camera_object_build_matrix(scene_camera); + camera_object_proj_jitter(scene_camera); + camera_object_build_mat(scene_camera); } static end = () => { @@ -245,8 +245,8 @@ class RenderPathBase { Context.raw.viewIndex = Context.raw.viewIndex == 0 ? 1 : 0; transform_set_matrix(cam.base.transform, Camera.views[Context.raw.viewIndex]); - camera_object_build_matrix(cam); - camera_object_build_projection(cam); + camera_object_build_mat(cam); + camera_object_build_proj(cam); RenderPathBase.drawGbuffer(); @@ -263,8 +263,8 @@ class RenderPathBase { Context.raw.viewIndex = Context.raw.viewIndex == 0 ? 1 : 0; transform_set_matrix(cam.base.transform, Camera.views[Context.raw.viewIndex]); - camera_object_build_matrix(cam); - camera_object_build_projection(cam); + camera_object_build_mat(cam); + camera_object_build_proj(cam); } } @@ -375,7 +375,7 @@ class RenderPathBase { static drawSSR = () => { if (Config.raw.rp_ssr != false) { - if (render_path_cached_shader_contexts.get("shader_datas/ssr_pass/ssr_pass") == null) { + if (_render_path_cached_shader_contexts.get("shader_datas/ssr_pass/ssr_pass") == null) { { let t = render_target_create(); t.name = "bufb"; diff --git a/base/Sources/RenderPathRaytrace.ts b/base/Sources/RenderPathRaytrace.ts index a4dd84680..c2d3ec95d 100644 --- a/base/Sources/RenderPathRaytrace.ts +++ b/base/Sources/RenderPathRaytrace.ts @@ -57,7 +57,7 @@ class RenderPathRaytrace { let bnoise_rank = scene_embedded.get("bnoise_rank.k"); let l = Base.flatten(true); - Krom.raytraceSetTextures(l.texpaint, l.texpaint_nor, l.texpaint_pack, savedEnvmap.texture_, bnoise_sobol.texture_, bnoise_scramble.texture_, bnoise_rank.texture_); + krom_raytrace_set_textures(l.texpaint, l.texpaint_nor, l.texpaint_pack, savedEnvmap.texture_, bnoise_sobol.texture_, bnoise_scramble.texture_, bnoise_rank.texture_); } ///if is_lab @@ -69,7 +69,7 @@ class RenderPathRaytrace { let bnoise_scramble = scene_embedded.get("bnoise_scramble.k"); let bnoise_rank = scene_embedded.get("bnoise_rank.k"); - Krom.raytraceSetTextures(l.texpaint, l.texpaint_nor, l.texpaint_pack, savedEnvmap.texture_, bnoise_sobol.texture_, bnoise_scramble.texture_, bnoise_rank.texture_); + krom_raytrace_set_textures(l.texpaint, l.texpaint_nor, l.texpaint_pack, savedEnvmap.texture_, bnoise_sobol.texture_, bnoise_scramble.texture_, bnoise_rank.texture_); } ///end @@ -93,22 +93,22 @@ class RenderPathRaytrace { RenderPathRaytrace.frame = (RenderPathRaytrace.frame % 4) + 1; // _PAINT // frame = frame + 1; // _RENDER ///end - RenderPathRaytrace.f32a[4] = RenderPathRaytrace.helpMat._00; - RenderPathRaytrace.f32a[5] = RenderPathRaytrace.helpMat._01; - RenderPathRaytrace.f32a[6] = RenderPathRaytrace.helpMat._02; - RenderPathRaytrace.f32a[7] = RenderPathRaytrace.helpMat._03; - RenderPathRaytrace.f32a[8] = RenderPathRaytrace.helpMat._10; - RenderPathRaytrace.f32a[9] = RenderPathRaytrace.helpMat._11; - RenderPathRaytrace.f32a[10] = RenderPathRaytrace.helpMat._12; - RenderPathRaytrace.f32a[11] = RenderPathRaytrace.helpMat._13; - RenderPathRaytrace.f32a[12] = RenderPathRaytrace.helpMat._20; - RenderPathRaytrace.f32a[13] = RenderPathRaytrace.helpMat._21; - RenderPathRaytrace.f32a[14] = RenderPathRaytrace.helpMat._22; - RenderPathRaytrace.f32a[15] = RenderPathRaytrace.helpMat._23; - RenderPathRaytrace.f32a[16] = RenderPathRaytrace.helpMat._30; - RenderPathRaytrace.f32a[17] = RenderPathRaytrace.helpMat._31; - RenderPathRaytrace.f32a[18] = RenderPathRaytrace.helpMat._32; - RenderPathRaytrace.f32a[19] = RenderPathRaytrace.helpMat._33; + RenderPathRaytrace.f32a[4] = RenderPathRaytrace.helpMat.m[0]; + RenderPathRaytrace.f32a[5] = RenderPathRaytrace.helpMat.m[1]; + RenderPathRaytrace.f32a[6] = RenderPathRaytrace.helpMat.m[2]; + RenderPathRaytrace.f32a[7] = RenderPathRaytrace.helpMat.m[3]; + RenderPathRaytrace.f32a[8] = RenderPathRaytrace.helpMat.m[4]; + RenderPathRaytrace.f32a[9] = RenderPathRaytrace.helpMat.m[5]; + RenderPathRaytrace.f32a[10] = RenderPathRaytrace.helpMat.m[6]; + RenderPathRaytrace.f32a[11] = RenderPathRaytrace.helpMat.m[7]; + RenderPathRaytrace.f32a[12] = RenderPathRaytrace.helpMat.m[8]; + RenderPathRaytrace.f32a[13] = RenderPathRaytrace.helpMat.m[9]; + RenderPathRaytrace.f32a[14] = RenderPathRaytrace.helpMat.m[10]; + RenderPathRaytrace.f32a[15] = RenderPathRaytrace.helpMat.m[11]; + RenderPathRaytrace.f32a[16] = RenderPathRaytrace.helpMat.m[12]; + RenderPathRaytrace.f32a[17] = RenderPathRaytrace.helpMat.m[13]; + RenderPathRaytrace.f32a[18] = RenderPathRaytrace.helpMat.m[14]; + RenderPathRaytrace.f32a[19] = RenderPathRaytrace.helpMat.m[15]; RenderPathRaytrace.f32a[20] = scene_world.strength * 1.5; if (!Context.raw.showEnvmap) RenderPathRaytrace.f32a[20] = -RenderPathRaytrace.f32a[20]; RenderPathRaytrace.f32a[21] = Context.raw.envmapAngle; @@ -118,7 +118,7 @@ class RenderPathRaytrace { ///end let framebuffer = render_path_render_targets.get("buf").image; - Krom.raytraceDispatchRays(framebuffer.render_target_, RenderPathRaytrace.f32a.buffer); + krom_raytrace_dispatch_rays(framebuffer.render_target_, RenderPathRaytrace.f32a.buffer); if (Context.raw.ddirty == 1 || Context.raw.pdirty == 1) { ///if krom_metal @@ -147,7 +147,7 @@ class RenderPathRaytrace { let bnoise_sobol = scene_embedded.get("bnoise_sobol.k"); let bnoise_scramble = scene_embedded.get("bnoise_scramble.k"); let bnoise_rank = scene_embedded.get("bnoise_rank.k"); - Krom.raytraceInit(shader, RenderPathRaytrace.vb.buffer_, RenderPathRaytrace.ib.buffer_, RenderPathRaytrace.vb_scale); + krom_raytrace_init(shader, RenderPathRaytrace.vb.buffer_, RenderPathRaytrace.ib.buffer_, RenderPathRaytrace.vb_scale); }); } diff --git a/base/Sources/RenderPathRaytraceBake.ts b/base/Sources/RenderPathRaytraceBake.ts index dd6e0ad60..c8bef0412 100644 --- a/base/Sources/RenderPathRaytraceBake.ts +++ b/base/Sources/RenderPathRaytraceBake.ts @@ -86,7 +86,7 @@ class RenderPathRaytraceBake { let bnoise_scramble = scene_embedded.get("bnoise_scramble.k"); let bnoise_rank = scene_embedded.get("bnoise_rank.k"); let texpaint_undo = render_path_render_targets.get("texpaint_undo" + History.undoI).image; - Krom.raytraceSetTextures(baketex0, baketex1, texpaint_undo, savedEnvmap.texture_, bnoise_sobol.texture_, bnoise_scramble.texture_, bnoise_rank.texture_); + krom_raytrace_set_textures(baketex0, baketex1, texpaint_undo, savedEnvmap.texture_, bnoise_sobol.texture_, bnoise_scramble.texture_, bnoise_rank.texture_); } if (Context.raw.brushTime > 0) { @@ -105,7 +105,7 @@ class RenderPathRaytraceBake { f32a[6] = Context.raw.envmapAngle; let framebuffer = render_path_render_targets.get("baketex2").image; - Krom.raytraceDispatchRays(framebuffer.render_target_, f32a.buffer); + krom_raytrace_dispatch_rays(framebuffer.render_target_, f32a.buffer); render_path_set_target("texpaint" + Context.raw.layer.id); render_path_bind_target("baketex2", "tex"); @@ -126,7 +126,7 @@ class RenderPathRaytraceBake { RenderPathRaytraceBake.raysCounter = 0; } RenderPathRaytraceBake.currentSample++; - Krom.delayIdleSleep(); + krom_delay_idle_sleep(); return true; } else { diff --git a/base/Sources/Res.ts b/base/Sources/Res.ts index ee0a342a8..bcf774002 100644 --- a/base/Sources/Res.ts +++ b/base/Sources/Res.ts @@ -45,7 +45,7 @@ class Res { } static embedFont = (name: string, file: ArrayBuffer) => { - data_cached_fonts.set(name, font_create(file)); + data_cached_fonts.set(name, g2_font_create(file)); } ///end } diff --git a/base/Sources/TabBrowser.ts b/base/Sources/TabBrowser.ts index 36e12a310..6b0792362 100644 --- a/base/Sources/TabBrowser.ts +++ b/base/Sources/TabBrowser.ts @@ -193,7 +193,7 @@ class TabBrowser { TabBrowser.hpath.text = "/storage/emulated/0/DCIM/Camera"; } if (UIMenu.menuButton(ui, tr("Projects"))) { - TabBrowser.hpath.text = Krom.savePath(); + TabBrowser.hpath.text = krom_save_path(); } }, 4); ///else diff --git a/base/Sources/TabConsole.ts b/base/Sources/TabConsole.ts index bf8fb8ef8..94920e672 100644 --- a/base/Sources/TabConsole.ts +++ b/base/Sources/TabConsole.ts @@ -37,13 +37,13 @@ class TabConsole { if (f == "") f = tr("untitled"); path = path + Path.sep + f; if (!path.endsWith(".txt")) path += ".txt"; - Krom.fileSaveBytes(path, sys_string_to_buffer(str)); + krom_file_save_bytes(path, sys_string_to_buffer(str)); }); } ///if (krom_windows || krom_linux || krom_darwin) if (zui_button(tr("Copy"))) { let str = Console.lastTraces.join("\n"); - Krom.copyToClipboard(str); + krom_copy_to_clipboard(str); } ///end @@ -51,7 +51,7 @@ class TabConsole { let _font = ui.font; let _fontSize = ui.font_size; - data_get_font("font_mono.ttf", (f: font_t) => { zui_set_font(ui, f); }); // Sync + data_get_font("font_mono.ttf", (f: g2_font_t) => { zui_set_font(ui, f); }); // Sync ui.font_size = Math.floor(15 * zui_SCALE(ui)); for (let t of Console.lastTraces) { zui_text(t); diff --git a/base/Sources/TabMaterials.ts b/base/Sources/TabMaterials.ts index 1824e9217..b7fb7a1de 100644 --- a/base/Sources/TabMaterials.ts +++ b/base/Sources/TabMaterials.ts @@ -110,8 +110,8 @@ class TabMaterials { if (!isTyping) { if (i < 9 && Operator.shortcut(Config.keymap.select_material, ShortcutType.ShortcutDown)) { let number = String(i + 1); - let width = font_width(ui.font, ui.font_size, number) + 10; - let height = font_height(ui.font, ui.font_size); + let width = g2_font_width(ui.font, ui.font_size, number) + 10; + let height = g2_font_height(ui.font, ui.font_size); g2_set_color(ui.t.TEXT_COL); g2_fill_rect(uix, uiy, width, height); g2_set_color(ui.t.ACCENT_COL); diff --git a/base/Sources/TabScript.ts b/base/Sources/TabScript.ts index 3dca38737..4a0d94935 100644 --- a/base/Sources/TabScript.ts +++ b/base/Sources/TabScript.ts @@ -42,14 +42,14 @@ class TabScript { if (f == "") f = tr("untitled"); path = path + Path.sep + f; if (!path.endsWith(".js")) path += ".js"; - Krom.fileSaveBytes(path, sys_string_to_buffer(str)); + krom_file_save_bytes(path, sys_string_to_buffer(str)); }); } zui_end_sticky(); let _font = ui.font; let _fontSize = ui.font_size; - data_get_font("font_mono.ttf", (f: font_t) => { zui_set_font(ui, f); }); // Sync + data_get_font("font_mono.ttf", (f: g2_font_t) => { zui_set_font(ui, f); }); // Sync ui.font_size = Math.floor(15 * zui_SCALE(ui)); zui_set_text_area_line_numbers(true); zui_set_text_area_scroll_past_end(true); diff --git a/base/Sources/TabSwatches.ts b/base/Sources/TabSwatches.ts index 3e77bbff0..ed14b45d0 100644 --- a/base/Sources/TabSwatches.ts +++ b/base/Sources/TabSwatches.ts @@ -180,7 +180,7 @@ class TabSwatches { color = color_set_ab(color, Context.raw.swatch.opacity * 255); let val = color; if (val < 0) val += 4294967296; - Krom.copyToClipboard(val.toString(16)); + krom_copy_to_clipboard(val.toString(16)); } ///end else if (Project.raw.swatches.length > 1 && UIMenu.menuButton(ui, tr("Delete"), "delete")) { diff --git a/base/Sources/TabTextures.ts b/base/Sources/TabTextures.ts index 5e5798a10..ea6a7e2ac 100644 --- a/base/Sources/TabTextures.ts +++ b/base/Sources/TabTextures.ts @@ -129,7 +129,7 @@ class TabTextures { let f = UIFiles.filename; if (f == "") f = tr("untitled"); if (!f.endsWith(".png")) f += ".png"; - Krom.writePng(path + Path.sep + f, image_get_pixels(target), target.width, target.height, 0); + krom_write_png(path + Path.sep + f, image_get_pixels(target), target.width, target.height, 0); image_unload(target); }); }); diff --git a/base/Sources/Translator.ts b/base/Sources/Translator.ts index acd6d471c..f65c59717 100644 --- a/base/Sources/Translator.ts +++ b/base/Sources/Translator.ts @@ -42,7 +42,7 @@ class Translator { // (Re)loads translations for the specified locale static loadTranslations = (newLocale: string) => { if (newLocale == "system") { - Config.raw.locale = Krom.language(); + Config.raw.locale = krom_language(); } // Check whether the requested or detected locale is available @@ -63,7 +63,7 @@ class Translator { if (Config.raw.locale != "en") { // Load the translation file - let translationJson = sys_buffer_to_string(Krom.loadBlob(`data/locale/${Config.raw.locale}.json`)); + let translationJson = sys_buffer_to_string(krom_load_blob(`data/locale/${Config.raw.locale}.json`)); let data = JSON.parse(translationJson); for (let field in data) { @@ -91,8 +91,8 @@ class Translator { } if (cjk) { - let cjkFontPath = (Path.isProtected() ? Krom.savePath() : "") + "font_cjk.ttc"; - let cjkFontDiskPath = (Path.isProtected() ? Krom.savePath() : Path.data() + Path.sep) + "font_cjk.ttc"; + let cjkFontPath = (Path.isProtected() ? krom_save_path() : "") + "font_cjk.ttc"; + let cjkFontDiskPath = (Path.isProtected() ? krom_save_path() : Path.data() + Path.sep) + "font_cjk.ttc"; if (!File.exists(cjkFontDiskPath)) { File.download("https://github.com/armory3d/armorbase/raw/main/Assets/common/extra/font_cjk.ttc", cjkFontDiskPath, () => { if (!File.exists(cjkFontDiskPath)) { @@ -114,11 +114,11 @@ class Translator { _g2_font_glyphs.sort((a: i32, b: i32) => { return a - b; }); // Load and assign font with cjk characters app_notify_on_init(() => { - data_get_font(fontPath, (f: font_t) => { + data_get_font(fontPath, (f: g2_font_t) => { if (cjk) { let acjkFontIndices = Translator.cjkFontIndices as any; let fontIndex = Translator.cjkFontIndices.has(Config.raw.locale) ? acjkFontIndices[Config.raw.locale] : 0; - font_set_font_index(f, fontIndex); + g2_font_set_font_index(f, fontIndex); } Base.font = f; // Scale up the font size and elements width a bit diff --git a/base/Sources/UIBase.ts b/base/Sources/UIBase.ts index d206d0c24..50e563587 100644 --- a/base/Sources/UIBase.ts +++ b/base/Sources/UIBase.ts @@ -568,7 +568,7 @@ class UIBase { let shortcuts = ["l", "b", "n", "o", "r", "m", "a", "h", "e", "s", "t", "1", "2", "3", "4"]; ///if (krom_direct3d12 || krom_vulkan || krom_metal) - if (Krom.raytraceSupported()) { + if (krom_raytrace_supported()) { modes.push(tr("Path Traced")); shortcuts.push("p"); } @@ -1219,7 +1219,7 @@ class UIBase { // Expand button if (Config.raw.layout[LayoutSize.LayoutSidebarW] == 0) { - let width = Math.floor(font_width(UIBase.ui.font, UIBase.ui.font_size, "<<") + 25 * zui_SCALE(UIBase.ui)); + let width = Math.floor(g2_font_width(UIBase.ui.font, UIBase.ui.font_size, "<<") + 25 * zui_SCALE(UIBase.ui)); if (zui_window(UIBase.hminimized, sys_width() - width, 0, width, Math.floor(zui_ELEMENT_H(UIBase.ui) + zui_ELEMENT_OFFSET(UIBase.ui) + 1))) { UIBase.ui._w = width; let _BUTTON_H = UIBase.ui.t.BUTTON_H; @@ -1486,8 +1486,8 @@ class UIBase { if (side == BorderSide.SideRight) return; // UI is snapped to the right side side == BorderSide.SideLeft || side == BorderSide.SideRight ? - Krom.setMouseCursor(3) : // Horizontal - Krom.setMouseCursor(4); // Vertical + krom_set_mouse_cursor(3) : // Horizontal + krom_set_mouse_cursor(4); // Vertical if (zui_current.input_started) { UIBase.borderStarted = side; @@ -1497,7 +1497,7 @@ class UIBase { } static onTextHover = () => { - Krom.setMouseCursor(2); // I-cursor + krom_set_mouse_cursor(2); // I-cursor } static onDeselectText = () => { diff --git a/base/Sources/UIBox.ts b/base/Sources/UIBox.ts index 026f69074..56f4ca157 100644 --- a/base/Sources/UIBox.ts +++ b/base/Sources/UIBox.ts @@ -84,7 +84,7 @@ class UIBox { ///if (krom_windows || krom_linux || krom_darwin) if (UIBox.copyable && zui_button(tr("Copy"))) { - Krom.copyToClipboard(UIBox.boxText); + krom_copy_to_clipboard(UIBox.boxText); } ///end if (zui_button(tr("OK"))) { diff --git a/base/Sources/UIFiles.ts b/base/Sources/UIFiles.ts index c0d26b744..74d4afb96 100644 --- a/base/Sources/UIFiles.ts +++ b/base/Sources/UIFiles.ts @@ -25,7 +25,7 @@ class UIFiles { static show = (filters: string, isSave: bool, openMultiple: bool, filesDone: (s: string)=>void) => { if (isSave) { - UIFiles.path = Krom.saveDialog(filters, ""); + UIFiles.path = krom_save_dialog(filters, ""); if (UIFiles.path != null) { while (UIFiles.path.indexOf(Path.sep + Path.sep) >= 0) UIFiles.path = UIFiles.path.replaceAll(Path.sep + Path.sep, Path.sep); UIFiles.path = UIFiles.path.replaceAll("\r", ""); @@ -35,7 +35,7 @@ class UIFiles { } } else { - let paths = Krom.openDialog(filters, "", openMultiple); + let paths = krom_open_dialog(filters, "", openMultiple); if (paths != null) { for (let path of paths) { while (path.indexOf(Path.sep + Path.sep) >= 0) path = path.replaceAll(Path.sep + Path.sep, Path.sep); @@ -90,7 +90,7 @@ class UIFiles { if (isCloud && File.readDirectory("cloud", false).length == 0) return handle.text; ///if krom_ios - let documentDirectory = Krom.saveDialog("", ""); + let documentDirectory = krom_save_dialog("", ""); documentDirectory = documentDirectory.substr(0, documentDirectory.length - 8); // Strip /'untitled' ///end @@ -226,7 +226,7 @@ class UIFiles { // TODO: implement native .arm parsing first ///else - let buffer = Krom.loadBlob(blobPath); + let buffer = krom_load_blob(blobPath); let raw = armpack_decode(buffer); if (raw.material_icons != null) { let bytesIcon = raw.material_icons[0]; @@ -358,7 +358,7 @@ class UIFiles { ui._y += slotw * 0.75; let label0 = (UIFiles.showExtensions || f.indexOf(".") <= 0) ? f : f.substr(0, f.lastIndexOf(".")); let label1 = ""; - while (label0.length > 0 && font_width(ui.font, ui.font_size, label0) > ui._w - 6) { // 2 line split + while (label0.length > 0 && g2_font_width(ui.font, ui.font_size, label0) > ui._w - 6) { // 2 line split label1 = label0.charAt(label0.length - 1) + label1; label0 = label0.substr(0, label0.length - 1); } @@ -367,10 +367,10 @@ class UIFiles { if (ui.is_hovered) zui_tooltip(label0 + label1); if (label1 != "") { // Second line ui._x = _x; - ui._y += font_height(ui.font, ui.font_size); + ui._y += g2_font_height(ui.font, ui.font_size); zui_text(label1, Align.Center); if (ui.is_hovered) zui_tooltip(label0 + label1); - ui._y -= font_height(ui.font, ui.font_size); + ui._y -= g2_font_height(ui.font, ui.font_size); } ui._y -= slotw * 0.75; diff --git a/base/Sources/UIHeader.ts b/base/Sources/UIHeader.ts index f199fbcf7..333d5b2b4 100644 --- a/base/Sources/UIHeader.ts +++ b/base/Sources/UIHeader.ts @@ -200,7 +200,7 @@ class UIHeader { tr("Vertex Color"), ]; ///if (krom_direct3d12 || krom_vulkan || krom_metal) - if (Krom.raytraceSupported()) { + if (krom_raytrace_supported()) { bakes.push(tr("Lightmap")); bakes.push(tr("Bent Normal")); bakes.push(tr("Thickness")); @@ -213,7 +213,7 @@ class UIHeader { Context.raw.bakeType = zui_combo(bakeHandle, bakes, tr("Bake")); ///if (krom_direct3d12 || krom_vulkan || krom_metal) - if (!Krom.raytraceSupported()) { + if (!krom_raytrace_supported()) { Context.raw.bakeType += 1; // Offset for removed AO } ///end diff --git a/base/Sources/UIMenu.ts b/base/Sources/UIMenu.ts index 01d8c7e33..ab4fd991a 100644 --- a/base/Sources/UIMenu.ts +++ b/base/Sources/UIMenu.ts @@ -286,7 +286,7 @@ class UIMenu { let shortcuts = ["l", "b", "n", "o", "r", "m", "a", "h", "e", "s", "t", "1", "2", "3", "4"]; ///if (krom_direct3d12 || krom_vulkan || krom_metal) - if (Krom.raytraceSupported()) { + if (krom_raytrace_supported()) { modes.push(tr("Path Traced")); shortcuts.push("p"); } @@ -458,9 +458,9 @@ class UIMenu { msg += sys_system_id() + " - " + Strings.graphics_api; ///if krom_windows - let save = (Path.isProtected() ? Krom.savePath() : Path.data()) + Path.sep + "tmp.txt"; - Krom.sysCommand('wmic path win32_VideoController get name > "' + save + '"'); - let blob = Krom.loadBlob(save); + let save = (Path.isProtected() ? krom_save_path() : Path.data()) + Path.sep + "tmp.txt"; + krom_sys_command('wmic path win32_VideoController get name > "' + save + '"'); + let blob = krom_load_blob(save); let u8 = new Uint8Array(blob); let gpuRaw = ""; for (let i = 0; i < Math.floor(u8.length / 2); ++i) { @@ -495,7 +495,7 @@ class UIMenu { ///if (krom_windows || krom_linux || krom_darwin) if (zui_button(tr("Copy"))) { - Krom.copyToClipboard(msg); + krom_copy_to_clipboard(msg); } ///else zui_end_element(); diff --git a/base/Sources/UINodes.ts b/base/Sources/UINodes.ts index 5b8d2626e..91c772547 100644 --- a/base/Sources/UINodes.ts +++ b/base/Sources/UINodes.ts @@ -322,19 +322,19 @@ class UINodes { if (Config.raw.wrap_mouse && parent.controlsDown) { if (ui.input_x < ui._window_x) { ui.input_x = ui._window_x + ui._window_w; - Krom.setMousePosition(Math.floor(ui.input_x), Math.floor(ui.input_y)); + krom_set_mouse_position(Math.floor(ui.input_x), Math.floor(ui.input_y)); } else if (ui.input_x > ui._window_x + ui._window_w) { ui.input_x = ui._window_x; - Krom.setMousePosition(Math.floor(ui.input_x), Math.floor(ui.input_y)); + krom_set_mouse_position(Math.floor(ui.input_x), Math.floor(ui.input_y)); } else if (ui.input_y < ui._window_y) { ui.input_y = ui._window_y + ui._window_h; - Krom.setMousePosition(Math.floor(ui.input_x), Math.floor(ui.input_y)); + krom_set_mouse_position(Math.floor(ui.input_x), Math.floor(ui.input_y)); } else if (ui.input_y > ui._window_y + ui._window_h) { ui.input_y = ui._window_y; - Krom.setMousePosition(Math.floor(ui.input_x), Math.floor(ui.input_y)); + krom_set_mouse_position(Math.floor(ui.input_x), Math.floor(ui.input_y)); } } @@ -864,9 +864,9 @@ class UINodes { if (singleChannel) { g2_set_pipeline(UIView2D.pipe); ///if krom_opengl - Krom.setPipeline(UIView2D.pipe.pipeline_); + krom_g4_set_pipeline(UIView2D.pipe.pipeline_); ///end - Krom.setInt(UIView2D.channelLocation, 1); + krom_g4_set_int(UIView2D.channelLocation, 1); } ///end @@ -897,7 +897,7 @@ class UINodes { // Editable canvas name let h = zui_handle("uinodes_11"); h.text = c.name; - UINodes.ui._w = Math.floor(Math.min(font_width(UINodes.ui.font, UINodes.ui.font_size, h.text) + 15 * zui_SCALE(UINodes.ui), 100 * zui_SCALE(UINodes.ui))); + UINodes.ui._w = Math.floor(Math.min(g2_font_width(UINodes.ui.font, UINodes.ui.font_size, h.text) + 15 * zui_SCALE(UINodes.ui), 100 * zui_SCALE(UINodes.ui))); let newName = zui_text_input(h, ""); UINodes.ui._x += UINodes.ui._w + 3; UINodes.ui._y = 2 + startY; diff --git a/base/Sources/UIToolbar.ts b/base/Sources/UIToolbar.ts index 4f893cff5..0a801841a 100644 --- a/base/Sources/UIToolbar.ts +++ b/base/Sources/UIToolbar.ts @@ -68,7 +68,7 @@ class UIToolbar { ui.t.ELEMENT_H = Math.floor(ui.t.ELEMENT_H * 1.5); ui.t.BUTTON_H = ui.t.ELEMENT_H; ui.t.BUTTON_COL = ui.t.WINDOW_BG_COL; - let fontHeight = font_height(ui.font, ui.font_size); + let fontHeight = g2_font_height(ui.font, ui.font_size); ui.font_offset_y = (zui_ELEMENT_H(ui) - fontHeight) / 2; let _w = ui._w; ui._w = UIToolbar.toolbarw; diff --git a/base/Sources/UIView2D.ts b/base/Sources/UIView2D.ts index 5258990d4..c53819c77 100644 --- a/base/Sources/UIView2D.ts +++ b/base/Sources/UIView2D.ts @@ -31,19 +31,19 @@ class UIView2D { constructor() { ///if (is_paint || is_sculpt) - UIView2D.pipe = pipeline_create(); + UIView2D.pipe = g4_pipeline_create(); UIView2D.pipe.vertex_shader = sys_get_shader("layer_view.vert"); UIView2D.pipe.fragment_shader = sys_get_shader("layer_view.frag"); - let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + let vs = g4_vertex_struct_create(); + g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); UIView2D.pipe.input_layout = [vs]; UIView2D.pipe.blend_source = blend_factor_t.BLEND_ONE; UIView2D.pipe.blend_dest = blend_factor_t.BLEND_ZERO; UIView2D.pipe.color_write_masks_alpha[0] = false; - pipeline_compile(UIView2D.pipe); - UIView2D.channelLocation = pipeline_get_const_loc(UIView2D.pipe, "channel"); + g4_pipeline_compile(UIView2D.pipe); + UIView2D.channelLocation = g4_pipeline_get_const_loc(UIView2D.pipe, "channel"); ///end let scale = Config.raw.window_scale; @@ -199,9 +199,9 @@ class UIView2D { g2_set_bilinear_filter(false); } ///if krom_opengl - Krom.setPipeline(UIView2D.pipe.pipeline_); + krom_g4_set_pipeline(UIView2D.pipe.pipeline_); ///end - Krom.setInt(UIView2D.channelLocation, channel); + krom_g4_set_int(UIView2D.channelLocation, channel); } ///end @@ -282,7 +282,7 @@ class UIView2D { let text = h.text; ///end - UIView2D.ui._w = Math.floor(Math.min(font_width(UIView2D.ui.font, UIView2D.ui.font_size, text) + 15 * zui_SCALE(UIView2D.ui), 100 * zui_SCALE(UIView2D.ui))); + UIView2D.ui._w = Math.floor(Math.min(g2_font_width(UIView2D.ui.font, UIView2D.ui.font_size, text) + 15 * zui_SCALE(UIView2D.ui), 100 * zui_SCALE(UIView2D.ui))); if (UIView2D.type == View2DType.View2DAsset) { let asset = Context.raw.texture; diff --git a/base/Sources/UniformsExt.ts b/base/Sources/UniformsExt.ts index 446ecfc2d..97850a7dd 100644 --- a/base/Sources/UniformsExt.ts +++ b/base/Sources/UniformsExt.ts @@ -211,12 +211,12 @@ class UniformsExt { } case "_decalLayerLoc": { v = _uniforms_vec; - vec4_set(v, Context.raw.layer.decalMat._30, Context.raw.layer.decalMat._31, Context.raw.layer.decalMat._32); + vec4_set(v, Context.raw.layer.decalMat.m[12], Context.raw.layer.decalMat.m[13], Context.raw.layer.decalMat.m[14]); return v; } case "_decalLayerNor": { v = _uniforms_vec; - vec4_normalize(vec4_set(v, Context.raw.layer.decalMat._20, Context.raw.layer.decalMat._21, Context.raw.layer.decalMat._22)); + vec4_normalize(vec4_set(v, Context.raw.layer.decalMat.m[8], Context.raw.layer.decalMat.m[9], Context.raw.layer.decalMat.m[10])); return v; } case "_pickerBase": { diff --git a/base/Sources/UtilMesh.ts b/base/Sources/UtilMesh.ts index caf0be5a6..5c6160d4b 100644 --- a/base/Sources/UtilMesh.ts +++ b/base/Sources/UtilMesh.ts @@ -120,8 +120,8 @@ class UtilMesh { } let g = o.data; - let l = vertex_struct_byte_size(g._struct) / 2; - let vertices = vertex_buffer_lock(g._vertex_buffer); // posnortex + let l = g4_vertex_struct_byte_size(g._struct) / 2; + let vertices = g4_vertex_buffer_lock(g._vertex_buffer); // posnortex for (let i = 0; i < Math.floor(vertices.byteLength / 2 / l); ++i) { vertices.setInt16((i * l ) * 2, vas[0].values[i * 4 ], true); vertices.setInt16((i * l + 1) * 2, vas[0].values[i * 4 + 1], true); @@ -130,7 +130,7 @@ class UtilMesh { vertices.setInt16((i * l + 4) * 2, vas[1].values[i * 2 ], true); vertices.setInt16((i * l + 5) * 2, vas[1].values[i * 2 + 1], true); } - vertex_buffer_unlock(g._vertex_buffer); + g4_vertex_buffer_unlock(g._vertex_buffer); } UtilMesh.removeMergedMesh(); @@ -144,8 +144,8 @@ class UtilMesh { let va0 = vas[0].values; let va1 = vas[1].values; let g = o.data; - let l = vertex_struct_byte_size(g._struct) / 2; - let vertices = vertex_buffer_lock(g._vertex_buffer); // posnortex + let l = g4_vertex_struct_byte_size(g._struct) / 2; + let vertices = g4_vertex_buffer_lock(g._vertex_buffer); // posnortex for (let i = 0; i < Math.floor(vertices.byteLength / 2 / l); ++i) { va0[i * 4 + 3] = -va0[i * 4 + 3]; va1[i * 2] = -va1[i * 2]; @@ -154,7 +154,7 @@ class UtilMesh { vertices.setInt16((i * l + 4) * 2, -vertices.getInt16((i * l + 4) * 2, true), true); vertices.setInt16((i * l + 5) * 2, -vertices.getInt16((i * l + 5) * 2, true), true); } - vertex_buffer_unlock(g._vertex_buffer); + g4_vertex_buffer_unlock(g._vertex_buffer); } ///if (krom_direct3d12 || krom_vulkan || krom_metal) @@ -171,9 +171,9 @@ class UtilMesh { let objects = Project.paintObjects; for (let o of objects) { let g = o.data; - let l = vertex_struct_byte_size(g._struct) / 2; + let l = g4_vertex_struct_byte_size(g._struct) / 2; let inda = g._indices[0]; - let vertices = vertex_buffer_lock(g._vertex_buffer); // posnortex + let vertices = g4_vertex_buffer_lock(g._vertex_buffer); // posnortex for (let i = 0; i < Math.floor(inda.length / 3); ++i) { let i1 = inda[i * 3 ]; let i2 = inda[i * 3 + 1]; @@ -240,7 +240,7 @@ class UtilMesh { } } } - vertex_buffer_unlock(g._vertex_buffer); + g4_vertex_buffer_unlock(g._vertex_buffer); let va0 = o.data.vertex_arrays[0].values; let va1 = o.data.vertex_arrays[1].values; @@ -306,14 +306,14 @@ class UtilMesh { va[i * 4 + 2] = Math.floor((va[i * 4 + 2] * sc - dz) / maxScale * 32767); } - let l = vertex_struct_byte_size(g._struct) / 2; - let vertices = vertex_buffer_lock(g._vertex_buffer); // posnortex + let l = g4_vertex_struct_byte_size(g._struct) / 2; + let vertices = g4_vertex_buffer_lock(g._vertex_buffer); // posnortex for (let i = 0; i < Math.floor(vertices.byteLength / 2 / l); ++i) { vertices.setInt16((i * l ) * 2, va[i * 4 ], true); vertices.setInt16((i * l + 1) * 2, va[i * 4 + 1], true); vertices.setInt16((i * l + 2) * 2, va[i * 4 + 2], true); } - vertex_buffer_unlock(g._vertex_buffer); + g4_vertex_buffer_unlock(g._vertex_buffer); } UtilMesh.mergeMesh(); @@ -325,8 +325,8 @@ class UtilMesh { let res = texpaint_pack.width; let o = Project.paintObjects[0]; let g = o.data; - let l = vertex_struct_byte_size(g._struct) / 2; - let vertices = vertex_buffer_lock(g._vertex_buffer); // posnortex + let l = g4_vertex_struct_byte_size(g._struct) / 2; + let vertices = g4_vertex_buffer_lock(g._vertex_buffer); // posnortex for (let i = 0; i < Math.floor(vertices.byteLength / 2 / l); ++i) { let x = Math.floor(vertices.getInt16((i * l + 6) * 2, true) / 32767 * res); let y = Math.floor(vertices.getInt16((i * l + 7) * 2, true) / 32767 * res); @@ -337,7 +337,7 @@ class UtilMesh { vertices.setInt16((i * l + 1) * 2, vertices.getInt16((i * l + 1) * 2, true) - Math.floor(vertices.getInt16((i * l + 5) * 2, true) * h), true); vertices.setInt16((i * l + 2) * 2, vertices.getInt16((i * l + 2) * 2, true) - Math.floor(vertices.getInt16((i * l + 3) * 2, true) * h), true); } - vertex_buffer_unlock(g._vertex_buffer); + g4_vertex_buffer_unlock(g._vertex_buffer); let va0 = o.data.vertex_arrays[0].values; for (let i = 0; i < Math.floor(vertices.byteLength / 4 / l); ++i) { diff --git a/base/Sources/UtilRender.ts b/base/Sources/UtilRender.ts index 2fb6a6e0d..9ace5dd8c 100644 --- a/base/Sources/UtilRender.ts +++ b/base/Sources/UtilRender.ts @@ -43,10 +43,10 @@ class UtilRender { scene_world._envmap = Context.raw.previewEnvmap; // No resize - render_path_last_w = UtilRender.materialPreviewSize; - render_path_last_h = UtilRender.materialPreviewSize; - camera_object_build_projection(scene_camera); - camera_object_build_matrix(scene_camera); + _render_path_last_w = UtilRender.materialPreviewSize; + _render_path_last_h = UtilRender.materialPreviewSize; + camera_object_build_proj(scene_camera); + camera_object_build_mat(scene_camera); MakeMaterial.parseMeshPreviewMaterial(); let _commands = render_path_commands; @@ -55,8 +55,8 @@ class UtilRender { render_path_commands = _commands; Context.raw.materialPreview = false; - render_path_last_w = app_w(); - render_path_last_h = app_h(); + _render_path_last_w = app_w(); + _render_path_last_h = app_h(); // Restore sphere.base.visible = false; @@ -66,8 +66,8 @@ class UtilRender { transform_set_matrix(scene_camera.base.transform, Context.raw.savedCamera); Viewport.updateCameraType(Context.raw.cameraType); scene_camera.data.fov = savedFov; - camera_object_build_projection(scene_camera); - camera_object_build_matrix(scene_camera); + camera_object_build_proj(scene_camera); + camera_object_build_mat(scene_camera); light.data.strength = _lightStrength; probe.strength = _probeStrength; Context.raw.envmapAngle = _envmapAngle; @@ -109,10 +109,10 @@ class UtilRender { scene_world._envmap = Context.raw.previewEnvmap; // No resize - render_path_last_w = UtilRender.decalPreviewSize; - render_path_last_h = UtilRender.decalPreviewSize; - camera_object_build_projection(scene_camera); - camera_object_build_matrix(scene_camera); + _render_path_last_w = UtilRender.decalPreviewSize; + _render_path_last_h = UtilRender.decalPreviewSize; + camera_object_build_proj(scene_camera); + camera_object_build_mat(scene_camera); MakeMaterial.parseMeshPreviewMaterial(); let _commands = render_path_commands; @@ -121,8 +121,8 @@ class UtilRender { render_path_commands = _commands; Context.raw.decalPreview = false; - render_path_last_w = app_w(); - render_path_last_h = app_h(); + _render_path_last_w = app_w(); + _render_path_last_h = app_h(); // Restore plane.base.visible = false; @@ -132,8 +132,8 @@ class UtilRender { transform_set_matrix(scene_camera.base.transform, Context.raw.savedCamera); scene_camera.data.fov = savedFov; Viewport.updateCameraType(Context.raw.cameraType); - camera_object_build_projection(scene_camera); - camera_object_build_matrix(scene_camera); + camera_object_build_proj(scene_camera); + camera_object_build_mat(scene_camera); light = scene_lights[0]; light.base.visible = true; scene_world._envmap = Context.raw.showEnvmap ? Context.raw.savedEnvmap : Context.raw.emptyEnvmap; @@ -151,8 +151,8 @@ class UtilRender { let text = Context.raw.textToolText; let font = Context.raw.font.font; let fontSize = 200; - let textW = Math.floor(font_width(font, fontSize, text)); - let textH = Math.floor(font_height(font, fontSize)); + let textW = Math.floor(g2_font_width(font, fontSize, text)); + let textH = Math.floor(g2_font_height(font, fontSize)); let texW = textW + 32; if (texW < 512) texW = 512; if (Context.raw.textToolImage != null && Context.raw.textToolImage.width < texW) { @@ -183,8 +183,8 @@ class UtilRender { let text = "Abg"; let font = Context.raw.font.font; let fontSize = 318; - let textW = Math.floor(font_width(font, fontSize, text)) + 8; - let textH = Math.floor(font_height(font, fontSize)) + 8; + let textW = Math.floor(g2_font_width(font, fontSize, text)) + 8; + let textH = Math.floor(g2_font_height(font, fontSize)) + 8; if (Context.raw.font.image == null) { Context.raw.font.image = image_create_render_target(512, 512, tex_format_t.RGBA32); } @@ -259,8 +259,8 @@ class UtilRender { mat4_translate(m, 0, 0, 0.5); transform_set_matrix(cam.base.transform, m); cam.data.fov = 0.92; - camera_object_build_projection(cam); - camera_object_build_matrix(cam); + camera_object_build_proj(cam); + camera_object_build_mat(cam); mat4_get_inv(m, scene_camera.vp); let planeo: mesh_object_t = scene_get_child(".Plane").ext; @@ -268,10 +268,10 @@ class UtilRender { Context.raw.paintObject = planeo; let v = vec4_create(); - let sx = vec4_len(vec4_set(v, m._00, m._01, m._02)); + let sx = vec4_len(vec4_set(v, m.m[0], m.m[1], m.m[2])); quat_from_euler(planeo.base.transform.rot, -Math.PI / 2, 0, 0); vec4_set(planeo.base.transform.scale, sx, 1.0, sx); - vec4_set(planeo.base.transform.loc, m._30, -m._31, 0.0); + vec4_set(planeo.base.transform.loc, m.m[12], -m.m[13], 0.0); transform_build_matrix(planeo.base.transform); RenderPathPaint.liveLayerDrawn = 0; @@ -334,8 +334,8 @@ class UtilRender { transform_set_matrix(scene_camera.base.transform, Context.raw.savedCamera); scene_camera.data.fov = savedFov; Viewport.updateCameraType(Context.raw.cameraType); - camera_object_build_projection(scene_camera); - camera_object_build_matrix(scene_camera); + camera_object_build_proj(scene_camera); + camera_object_build_mat(scene_camera); // Scale layer down to to image preview if (Base.pipeMerge == null) Base.makePipe(); @@ -427,20 +427,20 @@ class UtilRender { let indices = [0, 1, 2]; // Mandatory vertex data names and sizes - let structure = vertex_struct_create(); - vertex_struct_add(structure, "pos", vertex_data_t.I16_4X_NORM); - vertex_struct_add(structure, "nor", vertex_data_t.I16_2X_NORM); - vertex_struct_add(structure, "tex", vertex_data_t.I16_2X_NORM); - vertex_struct_add(structure, "col", vertex_data_t.I16_4X_NORM); - UtilRender.screenAlignedFullVB = vertex_buffer_create(Math.floor(data.length / Math.floor(vertex_struct_byte_size(structure) / 4)), structure, usage_t.STATIC); - let vertices = vertex_buffer_lock(UtilRender.screenAlignedFullVB); + let structure = g4_vertex_struct_create(); + g4_vertex_struct_add(structure, "pos", vertex_data_t.I16_4X_NORM); + g4_vertex_struct_add(structure, "nor", vertex_data_t.I16_2X_NORM); + g4_vertex_struct_add(structure, "tex", vertex_data_t.I16_2X_NORM); + g4_vertex_struct_add(structure, "col", vertex_data_t.I16_4X_NORM); + UtilRender.screenAlignedFullVB = g4_vertex_buffer_create(Math.floor(data.length / Math.floor(g4_vertex_struct_byte_size(structure) / 4)), structure, usage_t.STATIC); + let vertices = g4_vertex_buffer_lock(UtilRender.screenAlignedFullVB); for (let i = 0; i < Math.floor(vertices.byteLength / 2); ++i) vertices.setInt16(i * 2, data[i], true); - vertex_buffer_unlock(UtilRender.screenAlignedFullVB); + g4_vertex_buffer_unlock(UtilRender.screenAlignedFullVB); - UtilRender.screenAlignedFullIB = index_buffer_create(indices.length); - let id = index_buffer_lock(UtilRender.screenAlignedFullIB); + UtilRender.screenAlignedFullIB = g4_index_buffer_create(indices.length); + let id = g4_index_buffer_lock(UtilRender.screenAlignedFullIB); for (let i = 0; i < id.length; ++i) id[i] = indices[i]; - index_buffer_unlock(UtilRender.screenAlignedFullIB); + g4_index_buffer_unlock(UtilRender.screenAlignedFullIB); } } diff --git a/base/Sources/UtilUV.ts b/base/Sources/UtilUV.ts index 253d8d2c9..f44e1b89a 100644 --- a/base/Sources/UtilUV.ts +++ b/base/Sources/UtilUV.ts @@ -104,22 +104,22 @@ class UtilUV { } if (UtilUV.pipeDilate == null) { - UtilUV.pipeDilate = pipeline_create(); + UtilUV.pipeDilate = g4_pipeline_create(); UtilUV.pipeDilate.vertex_shader = sys_get_shader("dilate_map.vert"); UtilUV.pipeDilate.fragment_shader = sys_get_shader("dilate_map.frag"); - let vs = vertex_struct_create(); + let vs = g4_vertex_struct_create(); ///if (krom_metal || krom_vulkan) - vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); + g4_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); ///else - vertex_struct_add(vs, "pos", vertex_data_t.I16_4X_NORM); - vertex_struct_add(vs, "nor", vertex_data_t.I16_2X_NORM); - vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); + g4_vertex_struct_add(vs, "pos", vertex_data_t.I16_4X_NORM); + g4_vertex_struct_add(vs, "nor", vertex_data_t.I16_2X_NORM); + g4_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); ///end UtilUV.pipeDilate.input_layout = [vs]; UtilUV.pipeDilate.depth_write = false; UtilUV.pipeDilate.depth_mode = compare_mode_t.ALWAYS; UtilUV.pipeDilate.color_attachments[0] = tex_format_t.R8; - pipeline_compile(UtilUV.pipeDilate); + g4_pipeline_compile(UtilUV.pipeDilate); // dilateTexUnpack = getConstantLocation(UtilUV.pipeDilate, "texUnpack"); } diff --git a/base/Sources/Viewport.ts b/base/Sources/Viewport.ts index 14bafbc90..d788895a7 100644 --- a/base/Sources/Viewport.ts +++ b/base/Sources/Viewport.ts @@ -28,7 +28,7 @@ class Viewport { if (Context.raw.fovHandle != null) Context.raw.fovHandle.value = cam.data.fov = Base.defaultFov; Context.raw.camHandle.position = 0; cam.data.ortho = null; - camera_object_build_projection(cam); + camera_object_build_proj(cam); Context.raw.ddirty = 2; Camera.reset(); transform_reset(Context.mainObject().base.transform); @@ -45,7 +45,7 @@ class Viewport { vec4_set(cam.base.transform.loc, x * dist, y * dist, z * dist); quat_from_euler(cam.base.transform.rot, rx, ry, rz); transform_build_matrix(cam.base.transform); - camera_object_build_projection(cam); + camera_object_build_proj(cam); Context.raw.ddirty = 2; Camera.reset(Context.raw.viewIndexLast); } @@ -89,7 +89,7 @@ class Viewport { cam.data.ortho = f32a; light.base.visible = false; } - camera_object_build_projection(cam); + camera_object_build_proj(cam); Context.raw.ddirty = 2; } } diff --git a/base/Sources/main.ts b/base/Sources/main.ts index 54d231d92..d6ea37502 100644 --- a/base/Sources/main.ts +++ b/base/Sources/main.ts @@ -25,21 +25,21 @@ function main() { function kickstart() { // Used to locate external application data folder - Krom.setApplicationName(manifest_title); + krom_set_app_name(manifest_title); Config.load(main_start); } function main_start() { app_on_resize = Base.onResize; - app_w = Base.w; - app_h = Base.h; - app_x = Base.x; - app_y = Base.y; + app_on_w = Base.w; + app_on_h = Base.h; + app_on_x = Base.x; + app_on_y = Base.y; Config.init(); sys_start(Config.getOptions(), function() { if (Config.raw.layout == null) Base.initLayout(); - Krom.setApplicationName(manifest_title); + krom_set_app_name(manifest_title); app_init(function() { scene_set_active("Scene", function(o: object_t) { UniformsExt.init(); diff --git a/misc/pad/Sources/main.ts b/misc/pad/Sources/main.ts index 22bdcd7e1..a8c8251a3 100644 --- a/misc/pad/Sources/main.ts +++ b/misc/pad/Sources/main.ts @@ -29,8 +29,8 @@ function main() { zui_set_text_area_line_numbers(true); zui_set_text_area_scroll_past_end(true); - Krom.setApplicationName("ArmorPad"); - let blob_storage = Krom.loadBlob(Krom.savePath() + "/config.json"); + krom_set_application_name("ArmorPad"); + let blob_storage = krom_load_blob(krom_save_path() + "/config.json"); if (blob_storage == null) { storage = { project: "", @@ -94,24 +94,24 @@ function main() { }); }); - Krom.setDropFilesCallback(function (path: string) { + krom_set_drop_files_callback(function (path: string) { storage.project = path; sidebar_handle.redraws = 1; }); - Krom.setApplicationStateCallback( + krom_set_application_state_callback( function() {}, function() {}, function() {}, function() {}, function () { // Shutdown - Krom.fileSaveBytes(Krom.savePath() + "/config.json", sys_string_to_buffer(JSON.stringify(storage))); + krom_file_save_bytes(krom_save_path() + "/config.json", sys_string_to_buffer(JSON.stringify(storage))); } ); } function list_folder(path: string) { - let files = Krom.readDirectory(path, false).split("\n"); + let files = krom_read_directory(path, false).split("\n"); for (let f of files) { let abs = path + "/" + f; let is_file = f.indexOf(".") >= 0; @@ -131,12 +131,12 @@ function list_folder(path: string) { // Open file if (is_file) { storage.file = abs; - let bytes = Krom.loadBlob(storage.file); + let bytes = krom_load_blob(storage.file); storage.text = f.endsWith(".arm") ? JSON.stringify(armpack_decode(bytes), null, 4) : sys_buffer_to_string(bytes); storage.text = storage.text.replaceAll("\r", ""); text_handle.text = storage.text; editor_handle.redraws = 1; - Krom.setWindowTitle(abs); + krom_set_window_title(abs); } // Expand folder else { @@ -155,10 +155,10 @@ function list_folder(path: string) { function render() { storage.window_w = sys_width(); storage.window_h = sys_height(); - storage.window_x = Krom.windowX(); - storage.window_y = Krom.windowY(); + storage.window_x = krom_window_x(); + storage.window_y = krom_window_y(); if (ui.input_dx != 0 || ui.input_dy != 0) { - Krom.setMouseCursor(0); // Arrow + krom_set_mouse_cursor(0); // Arrow } zui_begin(ui); @@ -263,7 +263,7 @@ function save_file() { text_handle.text = storage.text; // Write bytes let bytes = storage.file.endsWith(".arm") ? armpack_encode(JSON.parse(storage.text)) : sys_string_to_buffer(storage.text); - Krom.fileSaveBytes(storage.file, bytes, bytes.byteLength); + krom_file_save_bytes(storage.file, bytes, bytes.byteLength); storage.modified = false; } @@ -276,7 +276,7 @@ function build_file(): string { } function build_project() { - Krom.sysCommand(storage.project + build_file() + " " + storage.project); + krom_sys_command(storage.project + build_file() + " " + storage.project); } function draw_minimap() { @@ -333,7 +333,7 @@ function on_border_hover(handle: zui_handle_t, side: i32) { return; // Right } - Krom.setMouseCursor(3); // Horizontal + krom_set_mouse_cursor(3); // Horizontal if (zui_current.input_started) { resizing_sidebar = true; @@ -341,7 +341,7 @@ function on_border_hover(handle: zui_handle_t, side: i32) { } function on_text_hover() { - Krom.setMouseCursor(2); // I-cursor + krom_set_mouse_cursor(2); // I-cursor } main();