From 9c7960f8f839ae24aa091661ba701687387777c2 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Sun, 9 Mar 2025 17:02:12 +0100 Subject: [PATCH] Unify namespaces --- armorforge/sources/ui_toolbar_ext.ts | 2 +- armorlab/sources/layers_ext.ts | 8 +- .../sources/nodes/brush_output_node_ext.ts | 12 +- armorlab/sources/nodes/image_texture_node.ts | 6 +- armorlab/sources/nodes/inpaint_node.ts | 42 +- armorlab/sources/nodes/photo_to_pbr_node.ts | 14 +- armorlab/sources/nodes/rgb_node.ts | 6 +- armorlab/sources/nodes/text_to_photo_node.ts | 14 +- armorlab/sources/nodes/tiling_node.ts | 16 +- armorlab/sources/nodes/upscale_node.ts | 22 +- armorlab/sources/nodes/variance_node.ts | 10 +- armorlab/sources/render_path_paint.ts | 26 +- armorlab/sources/ui_nodes_ext.ts | 24 +- armorlab/sources/ui_toolbar_ext.ts | 2 +- armorpaint/plugins/proc_xatlas/xatlas.cpp | 4 +- armorpaint/sources/layers_ext.ts | 90 +- armorpaint/sources/make_material.ts | 12 +- .../sources/nodes/brush_output_node_ext.ts | 4 +- armorpaint/sources/render_path_paint.ts | 30 +- armorpaint/sources/ui_header_ext.ts | 24 +- armorpaint/sources/ui_toolbar_ext.ts | 2 +- armorsculpt/sources/export_obj.ts | 2 +- armorsculpt/sources/import_mesh.ts | 4 +- armorsculpt/sources/make_material.ts | 10 +- .../sources/nodes/brush_output_node_ext.ts | 4 +- armorsculpt/sources/render_path_sculpt.ts | 6 +- armorsculpt/sources/tab_layers.ts | 2 +- armorsculpt/sources/ui_toolbar_ext.ts | 2 +- base/make | 2 +- base/project.js | 22 +- base/sources/backends/KincActivity.kt | 14 +- base/sources/backends/KincMoviePlayer.kt | 18 +- base/sources/backends/KincMovieTexture.kt | 6 +- base/sources/backends/android_audio.c | 18 +- base/sources/backends/android_file_dialog.c | 40 +- base/sources/backends/android_http_request.c | 12 +- base/sources/backends/android_http_request.h | 4 +- base/sources/backends/android_system.c | 712 +++++----- base/sources/backends/android_system.h | 6 +- base/sources/backends/android_video.c | 52 +- base/sources/backends/android_video.h | 18 +- base/sources/backends/apple_net.m | 12 +- base/sources/backends/apple_thread.m | 18 +- base/sources/backends/apple_video.h | 18 +- base/sources/backends/apple_video.m | 94 +- .../backends/data/android/app/CMakeLists.txt | 6 +- .../data/android/app/proguard-rules.pro | 6 +- .../data/android/main/AndroidManifest.xml | 4 +- base/sources/backends/data/mac.plist | 2 +- base/sources/backends/direct3d12_gpu.c | 754 +++++------ base/sources/backends/direct3d12_gpu.h | 58 +- base/sources/backends/ios_audio.m | 32 +- base/sources/backends/ios_system.h | 4 +- base/sources/backends/ios_system.m | 236 ++-- base/sources/backends/linux_audio.c | 16 +- base/sources/backends/linux_system.c | 1178 ++++++++--------- base/sources/backends/linux_system.h | 34 +- base/sources/backends/linux_video.c | 36 +- base/sources/backends/linux_video.h | 16 +- base/sources/backends/macos_audio.c | 46 +- base/sources/backends/macos_system.h | 8 +- base/sources/backends/macos_system.m | 398 +++--- base/sources/backends/metal_gpu.h | 22 +- base/sources/backends/metal_gpu.m | 604 ++++----- base/sources/backends/posix_thread.c | 28 +- base/sources/backends/posix_thread.h | 54 +- base/sources/backends/vulkan_gpu.c | 696 +++++----- base/sources/backends/vulkan_gpu.h | 40 +- base/sources/backends/wasm_audio.c | 14 +- base/sources/backends/wasm_system.c | 142 +- base/sources/backends/wasm_thread.c | 22 +- base/sources/backends/wasm_thread.h | 16 +- base/sources/backends/wasm_video.c | 36 +- base/sources/backends/wasm_video.h | 16 +- base/sources/backends/webgpu_gpu.c | 246 ++-- base/sources/backends/webgpu_gpu.h | 8 +- base/sources/backends/windows_audio.c | 38 +- base/sources/backends/windows_net.c | 22 +- base/sources/backends/windows_system.c | 708 +++++----- base/sources/backends/windows_system.h | 20 +- base/sources/backends/windows_thread.c | 24 +- base/sources/backends/windows_thread.h | 36 +- base/sources/backends/windows_video.c | 36 +- base/sources/backends/windows_video.h | 16 +- base/sources/iron.h | 658 ++++----- base/sources/iron_audio.c | 212 +-- base/sources/iron_audio.h | 148 +-- base/sources/iron_draw.c | 424 +++--- base/sources/iron_draw.h | 20 +- base/sources/iron_file.c | 152 +-- base/sources/iron_file.h | 86 +- base/sources/iron_global.h | 18 +- base/sources/iron_gpu.c | 620 ++++----- base/sources/iron_gpu.h | 730 +++++----- base/sources/iron_math.c | 132 +- base/sources/iron_math.h | 82 +- base/sources/iron_net.h | 274 ++-- base/sources/iron_obj.c | 10 +- base/sources/iron_simd.h | 368 ++--- base/sources/iron_system.c | 295 +++-- base/sources/iron_system.h | 677 +++++----- base/sources/iron_thread.h | 36 +- base/sources/iron_ui.c | 230 ++-- base/sources/iron_ui.h | 26 +- base/sources/iron_ui_nodes.c | 10 +- base/sources/iron_vec4.h | 12 +- base/sources/iron_video.h | 34 +- base/sources/libs/gc.c | 4 +- base/sources/libs/miniclib/license.txt | 2 +- base/sources/libs/miniclib/math.c | 26 +- base/sources/libs/miniclib/memory.c | 8 +- base/sources/libs/miniclib/stdio.c | 12 +- base/sources/libs/stb_image.h | 2 +- base/sources/ts/args.ts | 8 +- base/sources/ts/base.ts | 80 +- base/sources/ts/box_preferences.ts | 2 +- base/sources/ts/box_projects.ts | 20 +- base/sources/ts/camera.ts | 8 +- base/sources/ts/config.ts | 14 +- base/sources/ts/console.ts | 8 +- base/sources/ts/context.ts | 26 +- base/sources/ts/export_arm.ts | 16 +- base/sources/ts/export_texture.ts | 76 +- base/sources/ts/file.ts | 12 +- base/sources/ts/import_arm.ts | 26 +- base/sources/ts/import_blend_material.ts | 4 +- base/sources/ts/import_blend_mesh.ts | 2 +- base/sources/ts/import_envmap.ts | 42 +- base/sources/ts/import_texture.ts | 10 +- base/sources/ts/iron/app.ts | 4 +- base/sources/ts/iron/audio.ts | 4 +- base/sources/ts/iron/camera_data.ts | 2 +- base/sources/ts/iron/const_data.ts | 24 +- base/sources/ts/iron/data.ts | 12 +- base/sources/ts/iron/g2.ts | 8 +- base/sources/ts/iron/input.ts | 8 +- base/sources/ts/iron/iron.ts | 162 +-- base/sources/ts/iron/lz4.ts | 2 +- base/sources/ts/iron/material_data.ts | 10 +- base/sources/ts/iron/mesh_data.ts | 30 +- base/sources/ts/iron/mesh_object.ts | 8 +- base/sources/ts/iron/render_path.ts | 50 +- base/sources/ts/iron/scene.ts | 30 +- base/sources/ts/iron/shader_data.ts | 6 +- base/sources/ts/iron/sys.ts | 24 +- base/sources/ts/iron/ui.ts | 12 +- base/sources/ts/iron/uniforms.ts | 70 +- base/sources/ts/iron/world_data.ts | 8 +- base/sources/ts/layers.ts | 168 +-- base/sources/ts/line_draw.ts | 48 +- base/sources/ts/logic_node.ts | 10 +- base/sources/ts/main.ts | 4 +- base/sources/ts/nodes/color_node.ts | 4 +- base/sources/ts/nodes/float_node.ts | 4 +- base/sources/ts/nodes/vector_node.ts | 4 +- base/sources/ts/parser_material.ts | 2 +- base/sources/ts/path.ts | 4 +- base/sources/ts/pipes.ts | 122 +- base/sources/ts/project.ts | 12 +- base/sources/ts/render_path_base.ts | 2 +- base/sources/ts/render_path_raytrace.ts | 26 +- base/sources/ts/render_path_raytrace_bake.ts | 10 +- base/sources/ts/resource.ts | 12 +- base/sources/ts/slot_brush.ts | 4 +- base/sources/ts/slot_font.ts | 2 +- base/sources/ts/slot_layer.ts | 74 +- base/sources/ts/slot_material.ts | 4 +- base/sources/ts/tab_browser.ts | 2 +- base/sources/ts/tab_brushes.ts | 4 +- base/sources/ts/tab_console.ts | 2 +- base/sources/ts/tab_fonts.ts | 6 +- base/sources/ts/tab_layers.ts | 14 +- base/sources/ts/tab_materials.ts | 4 +- base/sources/ts/tab_swatches.ts | 8 +- base/sources/ts/tab_textures.ts | 16 +- base/sources/ts/translator.ts | 6 +- base/sources/ts/ui_base.ts | 46 +- base/sources/ts/ui_box.ts | 18 +- base/sources/ts/ui_files.ts | 30 +- base/sources/ts/ui_header.ts | 4 +- base/sources/ts/ui_menu.ts | 38 +- base/sources/ts/ui_menubar.ts | 6 +- base/sources/ts/ui_nodes.ts | 22 +- base/sources/ts/ui_status.ts | 6 +- base/sources/ts/ui_toolbar.ts | 6 +- base/sources/ts/ui_view2d.ts | 28 +- base/sources/ts/uniforms_ext.ts | 2 +- base/sources/ts/util_mesh.ts | 22 +- base/sources/ts/util_render.ts | 40 +- base/sources/ts/util_uv.ts | 30 +- base/tests/cube/sources/main.ts | 2 +- base/tests/fall/sources/main.ts | 2 +- base/tests/triangle/main.ts | 28 +- base/tools/amake/aimage.c | 18 +- base/tools/amake/alang.js | 4 +- base/tools/amake/alang.ts | 4 +- base/tools/amake/project.js | 2 +- base/tools/make.js | 4 +- base/tools/pad/sources/main.ts | 38 +- base/tools/platform.sh | 6 +- 200 files changed, 7132 insertions(+), 7132 deletions(-) diff --git a/armorforge/sources/ui_toolbar_ext.ts b/armorforge/sources/ui_toolbar_ext.ts index b02cc013..36001042 100644 --- a/armorforge/sources/ui_toolbar_ext.ts +++ b/armorforge/sources/ui_toolbar_ext.ts @@ -1,5 +1,5 @@ -function ui_toolbar_ext_draw_tools(ui: ui_t, img: kinc_g5_texture_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_ext_draw_tools(ui: ui_t, img: iron_g5_texture_t, icon_accent: i32, keys: string[]) { ui_toolbar_draw_tool(workspace_tool_t.GIZMO, ui, img, icon_accent, keys); ui_toolbar_draw_tool(workspace_tool_t.BRUSH, ui, img, icon_accent, keys); diff --git a/armorlab/sources/layers_ext.ts b/armorlab/sources/layers_ext.ts index fd08cb7e..fd790b53 100644 --- a/armorlab/sources/layers_ext.ts +++ b/armorlab/sources/layers_ext.ts @@ -1,8 +1,8 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t[] = null): slot_layer_t { - let texpaint: kinc_g5_texture_t = context_raw.brush_output_node_inst.texpaint; - let texpaint_nor: kinc_g5_texture_t = context_raw.brush_output_node_inst.texpaint_nor; - let texpaint_pack: kinc_g5_texture_t = context_raw.brush_output_node_inst.texpaint_pack; + let texpaint: iron_g5_texture_t = context_raw.brush_output_node_inst.texpaint; + let texpaint_nor: iron_g5_texture_t = context_raw.brush_output_node_inst.texpaint_nor; + let texpaint_pack: iron_g5_texture_t = context_raw.brush_output_node_inst.texpaint_pack; let nodes: ui_nodes_t = ui_nodes_get_nodes(); let canvas: ui_node_canvas_t = ui_nodes_get_canvas(true); @@ -45,7 +45,7 @@ function layers_ext_on_resized() { if (photo_to_pbr_node_images != null) { for (let i: i32 = 0; i < photo_to_pbr_node_images.length; ++i) { - let image: kinc_g5_texture_t = photo_to_pbr_node_images[i]; + let image: iron_g5_texture_t = photo_to_pbr_node_images[i]; iron_unload_image(image); } photo_to_pbr_node_images = null; diff --git a/armorlab/sources/nodes/brush_output_node_ext.ts b/armorlab/sources/nodes/brush_output_node_ext.ts index bbf58fcb..3cc0e170 100644 --- a/armorlab/sources/nodes/brush_output_node_ext.ts +++ b/armorlab/sources/nodes/brush_output_node_ext.ts @@ -4,11 +4,11 @@ type brush_output_node_t = { raw?: ui_node_t; id?: i32; - texpaint?: kinc_g5_texture_t; - texpaint_nor?: kinc_g5_texture_t; - texpaint_pack?: kinc_g5_texture_t; - texpaint_nor_empty?: kinc_g5_texture_t; - texpaint_pack_empty?: kinc_g5_texture_t; + texpaint?: iron_g5_texture_t; + texpaint_nor?: iron_g5_texture_t; + texpaint_pack?: iron_g5_texture_t; + texpaint_nor_empty?: iron_g5_texture_t; + texpaint_pack_empty?: iron_g5_texture_t; }; function brush_output_node_create_ext(n: brush_output_node_t) { @@ -66,7 +66,7 @@ function brush_output_node_create_ext(n: brush_output_node_t) { context_raw.brush_output_node_inst = n; } -function brush_output_node_get_as_image(self: brush_output_node_t, from: i32): kinc_g5_texture_t { +function brush_output_node_get_as_image(self: brush_output_node_t, from: i32): iron_g5_texture_t { return logic_node_input_get_as_image(self.base.inputs[from]); } diff --git a/armorlab/sources/nodes/image_texture_node.ts b/armorlab/sources/nodes/image_texture_node.ts index 753bc422..4f461055 100644 --- a/armorlab/sources/nodes/image_texture_node.ts +++ b/armorlab/sources/nodes/image_texture_node.ts @@ -13,7 +13,7 @@ function image_texture_node_create(raw: ui_node_t, args: f32_array_t): image_tex return n; } -function image_texture_node_get_as_image(self: image_texture_node_t, from: i32): kinc_g5_texture_t { +function image_texture_node_get_as_image(self: image_texture_node_t, from: i32): iron_g5_texture_t { if (project_assets.length == 0) { return null; } @@ -22,8 +22,8 @@ function image_texture_node_get_as_image(self: image_texture_node_t, from: i32): return project_get_image(asset); } -function image_texture_node_get_cached_image(self: image_texture_node_t): kinc_g5_texture_t { - let image: kinc_g5_texture_t = self.base.get_as_image(self, 0); +function image_texture_node_get_cached_image(self: image_texture_node_t): iron_g5_texture_t { + let image: iron_g5_texture_t = self.base.get_as_image(self, 0); return image; } diff --git a/armorlab/sources/nodes/inpaint_node.ts b/armorlab/sources/nodes/inpaint_node.ts index f5e376b9..d0dee037 100644 --- a/armorlab/sources/nodes/inpaint_node.ts +++ b/armorlab/sources/nodes/inpaint_node.ts @@ -5,11 +5,11 @@ type inpaint_node_t = { base?: logic_node_t; }; -let inpaint_node_image: kinc_g5_texture_t = null; -let inpaint_node_mask: kinc_g5_texture_t = null; -let inpaint_node_result: kinc_g5_texture_t = null; +let inpaint_node_image: iron_g5_texture_t = null; +let inpaint_node_mask: iron_g5_texture_t = null; +let inpaint_node_result: iron_g5_texture_t = null; -let inpaint_node_temp: kinc_g5_texture_t = null; +let inpaint_node_temp: iron_g5_texture_t = null; let inpaint_node_prompt: string = ""; let inpaint_node_strength: f32 = 0.5; let inpaint_node_auto: bool = true; @@ -33,9 +33,9 @@ function inpaint_node_init() { if (inpaint_node_mask == null) { inpaint_node_mask = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); app_notify_on_next_frame(function () { - iron_g4_begin(inpaint_node_mask); - kinc_g5_clear(color_from_floats(1.0, 1.0, 1.0, 1.0)); - iron_g4_end(); + _iron_g4_begin(inpaint_node_mask); + iron_g5_clear(color_from_floats(1.0, 1.0, 1.0, 1.0)); + _iron_g4_end(); }); } @@ -68,8 +68,8 @@ function inpaint_node_button(node_id: i32) { } } -function inpaint_node_get_as_image(self: inpaint_node_t, from: i32): kinc_g5_texture_t { - let source: kinc_g5_texture_t = logic_node_input_get_as_image(self.base.inputs[0]); +function inpaint_node_get_as_image(self: inpaint_node_t, from: i32): iron_g5_texture_t { + let source: iron_g5_texture_t = logic_node_input_get_as_image(self.base.inputs[0]); console_progress(tr("Processing") + " - " + tr("Inpaint")); g2_begin(inpaint_node_image); @@ -84,26 +84,26 @@ function inpaint_node_get_as_image(self: inpaint_node_t, from: i32): kinc_g5_tex } } -function inpaint_node_get_cached_image(self: inpaint_node_t): kinc_g5_texture_t { +function inpaint_node_get_cached_image(self: inpaint_node_t): iron_g5_texture_t { app_notify_on_next_frame(function (self: inpaint_node_t) { - let source: kinc_g5_texture_t = logic_node_input_get_as_image(self.base.inputs[0]); - iron_g4_begin(inpaint_node_image); - kinc_g5_set_pipeline(pipes_inpaint_preview); - iron_g4_set_texture(pipes_tex0_inpaint_preview, source); - iron_g4_set_texture(pipes_texa_inpaint_preview, inpaint_node_mask); - kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); - kinc_g4_set_index_buffer(const_data_screen_aligned_ib); + let source: iron_g5_texture_t = logic_node_input_get_as_image(self.base.inputs[0]); + _iron_g4_begin(inpaint_node_image); + iron_g5_set_pipeline(pipes_inpaint_preview); + _iron_g4_set_texture(pipes_tex0_inpaint_preview, source); + _iron_g4_set_texture(pipes_texa_inpaint_preview, inpaint_node_mask); + iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); + iron_g4_set_index_buffer(const_data_screen_aligned_ib); iron_g4_draw_indexed_vertices(); - iron_g4_end(); + _iron_g4_end(); }, self); return inpaint_node_image; } -function inpaint_node_get_target(): kinc_g5_texture_t { +function inpaint_node_get_target(): iron_g5_texture_t { return inpaint_node_mask; } -function inpaint_node_texsynth_inpaint(image: kinc_g5_texture_t, tiling: bool, mask: kinc_g5_texture_t): kinc_g5_texture_t { +function inpaint_node_texsynth_inpaint(image: iron_g5_texture_t, tiling: bool, mask: iron_g5_texture_t): iron_g5_texture_t { let w: i32 = config_get_texture_res_x(); let h: i32 = config_get_texture_res_y(); @@ -116,7 +116,7 @@ function inpaint_node_texsynth_inpaint(image: kinc_g5_texture_t, tiling: bool, m return inpaint_node_result; } -function inpaint_node_sd_inpaint(image: kinc_g5_texture_t, mask: kinc_g5_texture_t): kinc_g5_texture_t { +function inpaint_node_sd_inpaint(image: iron_g5_texture_t, mask: iron_g5_texture_t): iron_g5_texture_t { inpaint_node_init(); let bytes_img: buffer_t = iron_g4_get_texture_pixels(mask); diff --git a/armorlab/sources/nodes/photo_to_pbr_node.ts b/armorlab/sources/nodes/photo_to_pbr_node.ts index b146ddbb..09781a09 100644 --- a/armorlab/sources/nodes/photo_to_pbr_node.ts +++ b/armorlab/sources/nodes/photo_to_pbr_node.ts @@ -3,11 +3,11 @@ type photo_to_pbr_node_t = { base?: logic_node_t; }; -let photo_to_pbr_node_temp: kinc_g5_texture_t = null; -let photo_to_pbr_node_images: kinc_g5_texture_t[] = null; +let photo_to_pbr_node_temp: iron_g5_texture_t = null; +let photo_to_pbr_node_images: iron_g5_texture_t[] = null; let photo_to_pbr_node_model_names: string[] = ["base", "occlusion", "roughness", "metallic", "normal", "height"]; -let photo_to_pbr_node_cached_source: kinc_g5_texture_t = null; +let photo_to_pbr_node_cached_source: iron_g5_texture_t = null; let photo_to_pbr_node_border_w: i32 = 64; let photo_to_pbr_node_tile_w: i32 = 2048; let photo_to_pbr_node_tile_with_border_w: i32 = photo_to_pbr_node_tile_w + photo_to_pbr_node_border_w * 2; @@ -35,9 +35,9 @@ function photo_to_pbr_node_init() { } } -function photo_to_pbr_node_get_as_image(self: photo_to_pbr_node_t, from: i32): kinc_g5_texture_t { +function photo_to_pbr_node_get_as_image(self: photo_to_pbr_node_t, from: i32): iron_g5_texture_t { - let source: kinc_g5_texture_t; + let source: iron_g5_texture_t; if (photo_to_pbr_node_cached_source != null) { source = photo_to_pbr_node_cached_source; } @@ -153,11 +153,11 @@ function photo_to_pbr_node_get_as_image(self: photo_to_pbr_node_t, from: i32): k } ///end - let temp2: kinc_g5_texture_t = iron_g4_create_texture_from_bytes(u8a, photo_to_pbr_node_tile_w, photo_to_pbr_node_tile_w); + let temp2: iron_g5_texture_t = iron_g4_create_texture_from_bytes(u8a, photo_to_pbr_node_tile_w, photo_to_pbr_node_tile_w); g2_begin(photo_to_pbr_node_images[from]); draw_image(temp2, x * photo_to_pbr_node_tile_w, y * photo_to_pbr_node_tile_w); g2_end(); - app_notify_on_next_frame(function(temp2: kinc_g5_texture_t) { + app_notify_on_next_frame(function(temp2: iron_g5_texture_t) { iron_unload_image(temp2); }, temp2); } diff --git a/armorlab/sources/nodes/rgb_node.ts b/armorlab/sources/nodes/rgb_node.ts index ed3811ed..ba4ddb12 100644 --- a/armorlab/sources/nodes/rgb_node.ts +++ b/armorlab/sources/nodes/rgb_node.ts @@ -1,7 +1,7 @@ type rgb_node_t = { base?: logic_node_t; - image?: kinc_g5_texture_t; + image?: iron_g5_texture_t; raw?: ui_node_t; }; @@ -14,7 +14,7 @@ function rgb_node_create(raw: ui_node_t, args: f32_array_t): rgb_node_t { return n; } -function rgb_node_get_as_image(self: rgb_node_t, from: i32): kinc_g5_texture_t { +function rgb_node_get_as_image(self: rgb_node_t, from: i32): iron_g5_texture_t { if (self.image != null) { app_notify_on_next_frame(function (self: rgb_node_t) { iron_unload_image(self.image); @@ -33,7 +33,7 @@ function rgb_node_get_as_image(self: rgb_node_t, from: i32): kinc_g5_texture_t { return self.image; } -function rgb_node_get_cached_image(self: rgb_node_t): kinc_g5_texture_t { +function rgb_node_get_cached_image(self: rgb_node_t): iron_g5_texture_t { self.base.get_as_image(self, 0); return self.image; } diff --git a/armorlab/sources/nodes/text_to_photo_node.ts b/armorlab/sources/nodes/text_to_photo_node.ts index d4438140..9a9f9d33 100644 --- a/armorlab/sources/nodes/text_to_photo_node.ts +++ b/armorlab/sources/nodes/text_to_photo_node.ts @@ -4,7 +4,7 @@ type text_to_photo_node_t = { }; let text_to_photo_node_prompt: string = ""; -let text_to_photo_node_image: kinc_g5_texture_t = null; +let text_to_photo_node_image: iron_g5_texture_t = null; let text_to_photo_node_tiling: bool = false; let text_to_photo_node_text_encoder_blob: buffer_t; let text_to_photo_node_unet_blob: buffer_t; @@ -18,12 +18,12 @@ function text_to_photo_node_create(raw: ui_node_t, args: f32_array_t): text_to_p return n; } -function text_to_photo_node_get_as_image(self: text_to_photo_node_t, from: i32): kinc_g5_texture_t { +function text_to_photo_node_get_as_image(self: text_to_photo_node_t, from: i32): iron_g5_texture_t { text_to_photo_node_image = text_to_photo_node_stable_diffusion(text_to_photo_node_prompt); return text_to_photo_node_image; } -function text_to_photo_node_get_cached_image(self: text_to_photo_node_t): kinc_g5_texture_t { +function text_to_photo_node_get_cached_image(self: text_to_photo_node_t): iron_g5_texture_t { return text_to_photo_node_image; } @@ -35,7 +35,7 @@ function text_to_photo_node_button(node_id: i32) { node.buttons[1].height = string_split(text_to_photo_node_prompt, "\n").length; } -function text_to_photo_node_stable_diffusion(prompt: string, inpaint_latents: f32_array_t = null, offset: i32 = 0, upscale: bool = true, mask: f32_array_t = null, latents_orig: f32_array_t = null): kinc_g5_texture_t { +function text_to_photo_node_stable_diffusion(prompt: string, inpaint_latents: f32_array_t = null, offset: i32 = 0, upscale: bool = true, mask: f32_array_t = null, latents_orig: f32_array_t = null): iron_g5_texture_t { let _text_encoder_blob: buffer_t = data_get_blob("models/sd_text_encoder.quant.onnx"); let _unet_blob: buffer_t = data_get_blob("models/sd_unet.quant.onnx"); let _vae_decoder_blob: buffer_t = data_get_blob("models/sd_vae_decoder.quant.onnx"); @@ -239,7 +239,7 @@ function text_to_photo_node_unet(latents: f32_array_t, text_embeddings: f32_arra return latents; } -function text_to_photo_node_vae_decoder(latents: f32_array_t, upscale: bool): kinc_g5_texture_t { +function text_to_photo_node_vae_decoder(latents: f32_array_t, upscale: bool): iron_g5_texture_t { console_progress(tr("Processing") + " - " + tr("Text to Photo")); for (let i: i32 = 0; i < latents.length; ++i) { @@ -267,7 +267,7 @@ function text_to_photo_node_vae_decoder(latents: f32_array_t, upscale: bool): ki u8a[i * 4 + 2] = math_floor(pyimage[i + 512 * 512 * 2] * 255); u8a[i * 4 + 3] = 255; } - let image: kinc_g5_texture_t = iron_g4_create_texture_from_bytes(u8a, 512, 512); + let image: iron_g5_texture_t = iron_g4_create_texture_from_bytes(u8a, 512, 512); if (text_to_photo_node_tiling) { tiling_node_prompt = text_to_photo_node_prompt; @@ -278,7 +278,7 @@ function text_to_photo_node_vae_decoder(latents: f32_array_t, upscale: bool): ki if (upscale) { upscale_node_load_blob(); while (image.width < config_get_texture_res_x()) { - let last_image: kinc_g5_texture_t = image; + let last_image: iron_g5_texture_t = image; image = upscale_node_esrgan(image); iron_unload_image(last_image); } diff --git a/armorlab/sources/nodes/tiling_node.ts b/armorlab/sources/nodes/tiling_node.ts index e6d137e6..36c6790b 100644 --- a/armorlab/sources/nodes/tiling_node.ts +++ b/armorlab/sources/nodes/tiling_node.ts @@ -1,10 +1,10 @@ type tiling_node_t = { base?: logic_node_t; - result?: kinc_g5_texture_t; + result?: iron_g5_texture_t; }; -let tiling_node_image: kinc_g5_texture_t = null; +let tiling_node_image: iron_g5_texture_t = null; let tiling_node_prompt: string = ""; let tiling_node_strength: f32 = 0.5; let tiling_node_auto: bool = true; @@ -43,8 +43,8 @@ function tiling_node_button(node_id: i32) { } } -function tiling_node_get_as_image(self: tiling_node_t, from: i32): kinc_g5_texture_t { - let source: kinc_g5_texture_t = logic_node_input_get_as_image(self.base.inputs[0]); +function tiling_node_get_as_image(self: tiling_node_t, from: i32): iron_g5_texture_t { + let source: iron_g5_texture_t = logic_node_input_get_as_image(self.base.inputs[0]); g2_begin(tiling_node_image); draw_scaled_image(source, 0, 0, config_get_texture_res_x(), config_get_texture_res_y()); g2_end(); @@ -60,13 +60,13 @@ function tiling_node_get_as_image(self: tiling_node_t, from: i32): kinc_g5_textu return self.result; } -function tiling_node_get_cached_image(self: tiling_node_t): kinc_g5_texture_t { +function tiling_node_get_cached_image(self: tiling_node_t): iron_g5_texture_t { return self.result; } -function tiling_node_sd_tiling(image: kinc_g5_texture_t, seed: i32): kinc_g5_texture_t { +function tiling_node_sd_tiling(image: iron_g5_texture_t, seed: i32): iron_g5_texture_t { text_to_photo_node_tiling = false; - let tile: kinc_g5_texture_t = iron_g4_create_render_target(512, 512); + let tile: iron_g5_texture_t = iron_g4_create_render_target(512, 512); g2_begin(tile); draw_scaled_image(image, -256, -256, 512, 512); draw_scaled_image(image, 256, -256, 512, 512); @@ -92,7 +92,7 @@ function tiling_node_sd_tiling(image: kinc_g5_texture_t, seed: i32): kinc_g5_tex // u8a[y * 512 + x] = 0; // } // } - let mask: kinc_g5_texture_t = iron_g4_create_texture_from_bytes(u8a, 512, 512, tex_format_t.R8); + let mask: iron_g5_texture_t = iron_g4_create_texture_from_bytes(u8a, 512, 512, tex_format_t.R8); inpaint_node_prompt = tiling_node_prompt; inpaint_node_strength = tiling_node_strength; diff --git a/armorlab/sources/nodes/upscale_node.ts b/armorlab/sources/nodes/upscale_node.ts index 496e5f02..6a9585a4 100644 --- a/armorlab/sources/nodes/upscale_node.ts +++ b/armorlab/sources/nodes/upscale_node.ts @@ -3,8 +3,8 @@ type upscale_node_t = { base?: logic_node_t; }; -let upscale_node_temp: kinc_g5_texture_t = null; -let upscale_node_image: kinc_g5_texture_t = null; +let upscale_node_temp: iron_g5_texture_t = null; +let upscale_node_image: iron_g5_texture_t = null; let upscale_node_esrgan_blob: buffer_t; function upscale_node_create(raw: ui_node_t, args: f32_array_t): upscale_node_t { @@ -15,7 +15,7 @@ function upscale_node_create(raw: ui_node_t, args: f32_array_t): upscale_node_t return n; } -function upscale_node_get_as_image(self: upscale_node_t, from: i32): kinc_g5_texture_t { +function upscale_node_get_as_image(self: upscale_node_t, from: i32): iron_g5_texture_t { upscale_node_image = logic_node_input_get_as_image(self.base.inputs[0]); console_progress(tr("Processing") + " - " + tr("Upscale")); @@ -24,7 +24,7 @@ function upscale_node_get_as_image(self: upscale_node_t, from: i32): kinc_g5_tex if (upscale_node_image.width < config_get_texture_res_x()) { upscale_node_image = upscale_node_esrgan(upscale_node_image); while (upscale_node_image.width < config_get_texture_res_x()) { - let last_image: kinc_g5_texture_t = upscale_node_image; + let last_image: iron_g5_texture_t = upscale_node_image; upscale_node_image = upscale_node_esrgan(upscale_node_image); iron_unload_image(last_image); } @@ -36,12 +36,12 @@ function upscale_node_load_blob() { upscale_node_esrgan_blob = data_get_blob("models/esrgan.quant.onnx"); } -function upscale_node_get_cached_image(self: upscale_node_t): kinc_g5_texture_t { +function upscale_node_get_cached_image(self: upscale_node_t): iron_g5_texture_t { return upscale_node_image; } -function upscale_node_do_tile(source: kinc_g5_texture_t): kinc_g5_texture_t { - let result: kinc_g5_texture_t = null; +function upscale_node_do_tile(source: iron_g5_texture_t): iron_g5_texture_t { + let result: iron_g5_texture_t = null; let size1w: i32 = source.width; let size1h: i32 = source.height; let size2w: i32 = math_floor(size1w * 2); @@ -91,8 +91,8 @@ function upscale_node_do_tile(source: kinc_g5_texture_t): kinc_g5_texture_t { return result; } -function upscale_node_esrgan(source: kinc_g5_texture_t): kinc_g5_texture_t { - let result: kinc_g5_texture_t = null; +function upscale_node_esrgan(source: iron_g5_texture_t): iron_g5_texture_t { + let result: iron_g5_texture_t = null; let size1w: i32 = source.width; let size1h: i32 = source.height; let tile_size: i32 = 512; @@ -102,7 +102,7 @@ function upscale_node_esrgan(source: kinc_g5_texture_t): kinc_g5_texture_t { let size2w: i32 = math_floor(size1w * 2); let size2h: i32 = math_floor(size1h * 2); result = iron_g4_create_render_target(size2w, size2h); - let tile_source: kinc_g5_texture_t = iron_g4_create_render_target(tile_size + 32 * 2, tile_size + 32 * 2); + let tile_source: iron_g5_texture_t = iron_g4_create_render_target(tile_size + 32 * 2, tile_size + 32 * 2); for (let x: i32 = 0; x < math_floor(size1w / tile_size); ++x) { for (let y: i32 = 0; y < math_floor(size1h / tile_size); ++y) { g2_begin(tile_source); @@ -114,7 +114,7 @@ function upscale_node_esrgan(source: kinc_g5_texture_t): kinc_g5_texture_t { draw_scaled_image(source, 32 - x * tile_size + tile_size, 32 - y * tile_size + tile_size, source.width, -source.height); draw_scaled_image(source, 32 - x * tile_size, 32 - y * tile_size, source.width, source.height); g2_end(); - let tile_result: kinc_g5_texture_t = upscale_node_do_tile(tile_source); + let tile_result: iron_g5_texture_t = upscale_node_do_tile(tile_source); g2_begin(result); draw_sub_image(tile_result, x * tile_size2x, y * tile_size2x, 64, 64, tile_size2x, tile_size2x); g2_end(); diff --git a/armorlab/sources/nodes/variance_node.ts b/armorlab/sources/nodes/variance_node.ts index 0429ca68..fcad4931 100644 --- a/armorlab/sources/nodes/variance_node.ts +++ b/armorlab/sources/nodes/variance_node.ts @@ -3,8 +3,8 @@ type variance_node_t = { base?: logic_node_t; }; -let variance_node_temp: kinc_g5_texture_t = null; -let variance_node_image: kinc_g5_texture_t = null; +let variance_node_temp: iron_g5_texture_t = null; +let variance_node_image: iron_g5_texture_t = null; let variance_node_inst: variance_node_t = null; let variance_node_prompt: string = ""; @@ -33,11 +33,11 @@ function variance_node_button(node_id: i32) { node.buttons[0].height = string_split(variance_node_prompt, "\n").length; } -function variance_node_get_as_image(self: variance_node_t, from: i32): kinc_g5_texture_t { +function variance_node_get_as_image(self: variance_node_t, from: i32): iron_g5_texture_t { let node: float_node_t = variance_node_inst.base.inputs[1].node; let strength: f32 = node.value; - let source: kinc_g5_texture_t = logic_node_input_get_as_image(variance_node_inst.base.inputs[0]); + let source: iron_g5_texture_t = logic_node_input_get_as_image(variance_node_inst.base.inputs[0]); g2_begin(variance_node_temp); draw_scaled_image(source, 0, 0, 512, 512); g2_end(); @@ -83,7 +83,7 @@ function variance_node_get_as_image(self: variance_node_t, from: i32): kinc_g5_t return variance_node_image; } -function variance_node_get_cached_image(self: variance_node_t): kinc_g5_texture_t { +function variance_node_get_cached_image(self: variance_node_t): iron_g5_texture_t { return variance_node_image; } diff --git a/armorlab/sources/render_path_paint.ts b/armorlab/sources/render_path_paint.ts index 3e94757c..854e0b5a 100644 --- a/armorlab/sources/render_path_paint.ts +++ b/armorlab/sources/render_path_paint.ts @@ -188,19 +188,19 @@ function render_path_paint_draw_cursor(mx: f32, my: f32, radius: f32, tint_r: f3 let geom: mesh_data_t = plane.data; render_path_set_target(""); - kinc_g5_set_pipeline(pipes_cursor); + iron_g5_set_pipeline(pipes_cursor); let gbuffer0: render_target_t = map_get(render_path_render_targets, "gbuffer0"); iron_g4_set_texture_depth(pipes_cursor_gbufferd, gbuffer0._image); - iron_g4_set_float2(pipes_cursor_mouse, mx, my); - iron_g4_set_float2(pipes_cursor_tex_step, 1 / gbuffer0._image.width, 1 / gbuffer0._image.height); - iron_g4_set_float(pipes_cursor_radius, radius); + _iron_g4_set_float2(pipes_cursor_mouse, mx, my); + _iron_g4_set_float2(pipes_cursor_tex_step, 1 / gbuffer0._image.width, 1 / gbuffer0._image.height); + _iron_g4_set_float(pipes_cursor_radius, radius); let right: vec4_t = vec4_norm(camera_object_right_world(scene_camera)); - iron_g4_set_float3(pipes_cursor_camera_right, right.x, right.y, right.z); - iron_g4_set_float3(pipes_cursor_tint, tint_r, tint_g, tint_b); - iron_g4_set_matrix4(pipes_cursor_vp, scene_camera.vp); + _iron_g4_set_float3(pipes_cursor_camera_right, right.x, right.y, right.z); + _iron_g4_set_float3(pipes_cursor_tint, tint_r, tint_g, tint_b); + _iron_g4_set_matrix4(pipes_cursor_vp, scene_camera.vp); let help_mat: mat4_t = mat4_identity(); help_mat = mat4_inv(scene_camera.vp); - iron_g4_set_matrix4(pipes_cursor_inv_vp, help_mat); + _iron_g4_set_matrix4(pipes_cursor_inv_vp, help_mat); ///if (arm_metal || arm_vulkan) let vs: vertex_element_t[] = [ { @@ -208,14 +208,14 @@ function render_path_paint_draw_cursor(mx: f32, my: f32, radius: f32, tint_r: f3 data: "short2norm" } ]; - kinc_g4_set_vertex_buffer(mesh_data_get(geom, vs)); + iron_g4_set_vertex_buffer(mesh_data_get(geom, vs)); ///else - kinc_g4_set_vertex_buffer(geom._.vertex_buffer); + iron_g4_set_vertex_buffer(geom._.vertex_buffer); ///end - kinc_g4_set_index_buffer(geom._.index_buffers[0]); + iron_g4_set_index_buffer(geom._.index_buffers[0]); iron_g4_draw_indexed_vertices(); - kinc_g4_disable_scissor(); + iron_g4_disable_scissor(); render_path_end(); } @@ -263,7 +263,7 @@ function render_path_paint_draw() { } function render_path_paint_bind_layers() { - let image: kinc_g5_texture_t = null; + let image: iron_g5_texture_t = null; let nodes: ui_nodes_t = ui_nodes_get_nodes(); let canvas: ui_node_canvas_t = ui_nodes_get_canvas(true); if (nodes.nodes_selected_id.length > 0) { diff --git a/armorlab/sources/ui_nodes_ext.ts b/armorlab/sources/ui_nodes_ext.ts index 659659fd..30f1e8ae 100644 --- a/armorlab/sources/ui_nodes_ext.ts +++ b/armorlab/sources/ui_nodes_ext.ts @@ -39,11 +39,11 @@ function ui_nodes_ext_run() { parser_logic_parse(project_canvas); photo_to_pbr_node_cached_source = null; - let texbase: kinc_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.BASE_COLOR); - let texocc: kinc_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.OCCLUSION); - let texrough: kinc_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.ROUGHNESS); - let texnor: kinc_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.NORMAL_MAP); - let texheight: kinc_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.HEIGHT); + let texbase: iron_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.BASE_COLOR); + let texocc: iron_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.OCCLUSION); + let texrough: iron_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.ROUGHNESS); + let texnor: iron_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.NORMAL_MAP); + let texheight: iron_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.HEIGHT); if (texbase != null) { let texpaint: render_target_t = map_get(render_path_render_targets, "texpaint"); @@ -78,13 +78,13 @@ function ui_nodes_ext_run() { } if (texheight != null) { - iron_g4_begin(texpaint_pack._image); - kinc_g5_set_pipeline(pipes_copy_a); - iron_g4_set_texture(pipes_copy_a_tex, texheight); - kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); - kinc_g4_set_index_buffer(const_data_screen_aligned_ib); + _iron_g4_begin(texpaint_pack._image); + iron_g5_set_pipeline(pipes_copy_a); + _iron_g4_set_texture(pipes_copy_a_tex, texheight); + iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); + iron_g4_set_index_buffer(const_data_screen_aligned_ib); iron_g4_draw_indexed_vertices(); - iron_g4_end(); + _iron_g4_end(); let is_float_node: bool = context_raw.brush_output_node_inst.base.inputs[channel_type_t.HEIGHT].node.base.get == float_node_get; @@ -105,7 +105,7 @@ function ui_nodes_ext_run() { buffer_set_i16(vertices, i * 2, buffer_get_i16(ui_nodes_ext_last_vertices, i * 2)); } } - kinc_g4_vertex_buffer_unlock_all(g._.vertex_buffer); + iron_g4_vertex_buffer_unlock_all(g._.vertex_buffer); // Apply displacement if (config_raw.displace_strength > 0) { diff --git a/armorlab/sources/ui_toolbar_ext.ts b/armorlab/sources/ui_toolbar_ext.ts index ebcf1b43..545c9c36 100644 --- a/armorlab/sources/ui_toolbar_ext.ts +++ b/armorlab/sources/ui_toolbar_ext.ts @@ -1,4 +1,4 @@ -function ui_toolbar_ext_draw_tools(ui: ui_t, img: kinc_g5_texture_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_ext_draw_tools(ui: ui_t, img: iron_g5_texture_t, icon_accent: i32, keys: string[]) { } diff --git a/armorpaint/plugins/proc_xatlas/xatlas.cpp b/armorpaint/plugins/proc_xatlas/xatlas.cpp index 6b4fbc1c..4233b127 100644 --- a/armorpaint/plugins/proc_xatlas/xatlas.cpp +++ b/armorpaint/plugins/proc_xatlas/xatlas.cpp @@ -10060,7 +10060,7 @@ extern "C" { #include void proc_xatlas_unwrap(raw_mesh_t *mesh) { - double t = kinc_time(); + double t = iron_time(); int vertex_count = mesh->posa->length / 4; float *pa = (float *)malloc(sizeof(float) * vertex_count * 3); float *na = (float *)malloc(sizeof(float) * vertex_count * 3); @@ -10126,7 +10126,7 @@ void proc_xatlas_unwrap(raw_mesh_t *mesh) { free(pa); free(na); - kinc_log("Unwrapped in %fs.\n", kinc_time() - t); + iron_log("Unwrapped in %fs.\n", iron_time() - t); } #ifdef __cplusplus diff --git a/armorpaint/sources/layers_ext.ts b/armorpaint/sources/layers_ext.ts index 48f8a6c4..c4dfb08c 100644 --- a/armorpaint/sources/layers_ext.ts +++ b/armorpaint/sources/layers_ext.ts @@ -7,18 +7,18 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t layers_make_export_img(); let empty_rt: render_target_t = map_get(render_path_render_targets, "empty_white"); - let empty: kinc_g5_texture_t = empty_rt._image; + let empty: iron_g5_texture_t = empty_rt._image; // Clear export layer - iron_g4_begin(layers_expa); - kinc_g5_clear(color_from_floats(0.0, 0.0, 0.0, 0.0)); - iron_g4_end(); - iron_g4_begin(layers_expb); - kinc_g5_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); - iron_g4_end(); - iron_g4_begin(layers_expc); - kinc_g5_clear(color_from_floats(1.0, 0.0, 0.0, 0.0)); - iron_g4_end(); + _iron_g4_begin(layers_expa); + iron_g5_clear(color_from_floats(0.0, 0.0, 0.0, 0.0)); + _iron_g4_end(); + _iron_g4_begin(layers_expb); + iron_g5_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); + _iron_g4_end(); + _iron_g4_begin(layers_expc); + iron_g5_clear(color_from_floats(1.0, 0.0, 0.0, 0.0)); + _iron_g4_end(); // Flatten layers for (let i: i32 = 0; i < layers.length; ++i) { @@ -30,13 +30,13 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t continue; } - let mask: kinc_g5_texture_t = empty; + let mask: iron_g5_texture_t = empty; let l1masks: slot_layer_t[] = slot_layer_get_masks(l1); if (l1masks != null) { if (l1masks.length > 1) { layers_make_temp_mask_img(); g2_begin(pipes_temp_mask_image); - kinc_g5_clear(0x00000000); + iron_g5_clear(0x00000000); g2_end(); let l1: slot_layer_t = { texpaint: pipes_temp_mask_image }; for (let i: i32 = 0; i < l1masks.length; ++i) { @@ -64,18 +64,18 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t draw_set_pipeline(null); g2_end(); ///else - iron_g4_begin(layers_expa); - kinc_g5_set_pipeline(pipes_merge); - iron_g4_set_texture(pipes_tex0, l1.texpaint); - iron_g4_set_texture(pipes_tex1, empty); - iron_g4_set_texture(pipes_texmask, mask); - iron_g4_set_texture(pipes_texa, layers_temp_image); - iron_g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); - iron_g4_set_int(pipes_blending, layers.length > 1 ? l1.blending : 0); - kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); - kinc_g4_set_index_buffer(const_data_screen_aligned_ib); + _iron_g4_begin(layers_expa); + iron_g5_set_pipeline(pipes_merge); + _iron_g4_set_texture(pipes_tex0, l1.texpaint); + _iron_g4_set_texture(pipes_tex1, empty); + _iron_g4_set_texture(pipes_texmask, mask); + _iron_g4_set_texture(pipes_texa, layers_temp_image); + _iron_g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); + _iron_g4_set_int(pipes_blending, layers.length > 1 ? l1.blending : 0); + iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); + iron_g4_set_index_buffer(const_data_screen_aligned_ib); iron_g4_draw_indexed_vertices(); - iron_g4_end(); + _iron_g4_end(); ///end } @@ -86,18 +86,18 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t draw_set_pipeline(null); g2_end(); - iron_g4_begin(layers_expb); - kinc_g5_set_pipeline(pipes_merge); - iron_g4_set_texture(pipes_tex0, l1.texpaint); - iron_g4_set_texture(pipes_tex1, l1.texpaint_nor); - iron_g4_set_texture(pipes_texmask, mask); - iron_g4_set_texture(pipes_texa, layers_temp_image); - iron_g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); - iron_g4_set_int(pipes_blending, l1.paint_nor_blend ? -2 : -1); - kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); - kinc_g4_set_index_buffer(const_data_screen_aligned_ib); + _iron_g4_begin(layers_expb); + iron_g5_set_pipeline(pipes_merge); + _iron_g4_set_texture(pipes_tex0, l1.texpaint); + _iron_g4_set_texture(pipes_tex1, l1.texpaint_nor); + _iron_g4_set_texture(pipes_texmask, mask); + _iron_g4_set_texture(pipes_texa, layers_temp_image); + _iron_g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); + _iron_g4_set_int(pipes_blending, l1.paint_nor_blend ? -2 : -1); + iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); + iron_g4_set_index_buffer(const_data_screen_aligned_ib); iron_g4_draw_indexed_vertices(); - iron_g4_end(); + _iron_g4_end(); } if (l1.paint_occ || l1.paint_rough || l1.paint_met || l1.paint_height) { @@ -149,18 +149,18 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t draw_set_pipeline(null); g2_end(); - iron_g4_begin(l0.texpaint_nor); - kinc_g5_set_pipeline(pipes_merge); - iron_g4_set_texture(pipes_tex0, layers_temp_image); - iron_g4_set_texture(pipes_tex1, l0.texpaint_pack); - iron_g4_set_texture(pipes_texmask, empty); - iron_g4_set_texture(pipes_texa, empty); - iron_g4_set_float(pipes_opac, 1.0); - iron_g4_set_int(pipes_blending, -4); - kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); - kinc_g4_set_index_buffer(const_data_screen_aligned_ib); + _iron_g4_begin(l0.texpaint_nor); + iron_g5_set_pipeline(pipes_merge); + _iron_g4_set_texture(pipes_tex0, layers_temp_image); + _iron_g4_set_texture(pipes_tex1, l0.texpaint_pack); + _iron_g4_set_texture(pipes_texmask, empty); + _iron_g4_set_texture(pipes_texa, empty); + _iron_g4_set_float(pipes_opac, 1.0); + _iron_g4_set_int(pipes_blending, -4); + iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); + iron_g4_set_index_buffer(const_data_screen_aligned_ib); iron_g4_draw_indexed_vertices(); - iron_g4_end(); + _iron_g4_end(); } return l0; diff --git a/armorpaint/sources/make_material.ts b/armorpaint/sources/make_material.ts index d44386a1..e95e5a94 100644 --- a/armorpaint/sources/make_material.ts +++ b/armorpaint/sources/make_material.ts @@ -175,7 +175,7 @@ function make_material_parse_paint_material(bake_previews: bool = true) { } if (bake_previews) { - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); make_material_bake_node_previews(); @@ -255,8 +255,8 @@ function make_material_bake_node_previews() { for (let i: i32 = 0; i < keys.length; ++i) { let key: string = keys[i]; if (array_index_of(context_raw.node_previews_used, key) == -1) { - let image: kinc_g5_texture_t = map_get(context_raw.node_previews, key); - app_notify_on_next_frame(function (image: kinc_g5_texture_t) { + let image: iron_g5_texture_t = map_get(context_raw.node_previews, key); + app_notify_on_next_frame(function (image: iron_g5_texture_t) { iron_unload_image(image); }, image); map_delete(context_raw.node_previews, key); @@ -286,7 +286,7 @@ function make_material_traverse_nodes(nodes: ui_node_t[], group: ui_node_canvas_ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_t, parents: ui_node_t[]) { if (node.type == "BLUR") { let id: string = parser_material_node_name(node, parents); - let image: kinc_g5_texture_t = map_get(context_raw.node_previews, id); + let image: iron_g5_texture_t = map_get(context_raw.node_previews, id); array_push(context_raw.node_previews_used, id); let res_x: i32 = math_floor(config_get_texture_res_x() / 4); let res_y: i32 = math_floor(config_get_texture_res_y() / 4); @@ -304,7 +304,7 @@ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_ } else if (node.type == "DIRECT_WARP") { let id: string = parser_material_node_name(node, parents); - let image: kinc_g5_texture_t = map_get(context_raw.node_previews, id); + let image: iron_g5_texture_t = map_get(context_raw.node_previews, id); array_push(context_raw.node_previews_used, id); let res_x: i32 = math_floor(config_get_texture_res_x()); let res_y: i32 = math_floor(config_get_texture_res_y()); @@ -320,7 +320,7 @@ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_ } else if (node.type == "BAKE_CURVATURE") { let id: string = parser_material_node_name(node, parents); - let image: kinc_g5_texture_t = map_get(context_raw.node_previews, id); + let image: iron_g5_texture_t = map_get(context_raw.node_previews, id); array_push(context_raw.node_previews_used, id); let res_x: i32 = math_floor(config_get_texture_res_x()); let res_y: i32 = math_floor(config_get_texture_res_y()); diff --git a/armorpaint/sources/nodes/brush_output_node_ext.ts b/armorpaint/sources/nodes/brush_output_node_ext.ts index f4799207..05406a7c 100644 --- a/armorpaint/sources/nodes/brush_output_node_ext.ts +++ b/armorpaint/sources/nodes/brush_output_node_ext.ts @@ -10,8 +10,8 @@ function brush_output_node_create_ext(n: brush_output_node_t) { function brush_output_node_parse_inputs(self: brush_output_node_t) { - let last_mask: kinc_g5_texture_t = context_raw.brush_mask_image; - let last_stencil: kinc_g5_texture_t = context_raw.brush_stencil_image; + let last_mask: iron_g5_texture_t = context_raw.brush_mask_image; + let last_stencil: iron_g5_texture_t = context_raw.brush_stencil_image; let input0: logic_node_value_t = logic_node_input_get(self.base.inputs[0]); let input1: logic_node_value_t = logic_node_input_get(self.base.inputs[1]); diff --git a/armorpaint/sources/render_path_paint.ts b/armorpaint/sources/render_path_paint.ts index c1444632..161c4ce3 100644 --- a/armorpaint/sources/render_path_paint.ts +++ b/armorpaint/sources/render_path_paint.ts @@ -140,8 +140,8 @@ function render_path_paint_commands_paint(dilation: bool = true) { render_path_draw_meshes("paint"); let picker0: render_target_t = map_get(render_path_render_targets, "texpaint_posnortex_picker0"); let picker1: render_target_t = map_get(render_path_render_targets, "texpaint_posnortex_picker1"); - let texpaint_posnortex_picker0: kinc_g5_texture_t = picker0._image; - let texpaint_posnortex_picker1: kinc_g5_texture_t = picker1._image; + let texpaint_posnortex_picker0: iron_g5_texture_t = picker0._image; + let texpaint_posnortex_picker1: iron_g5_texture_t = picker1._image; let a: buffer_t = iron_g4_get_texture_pixels(texpaint_posnortex_picker0); let b: buffer_t = iron_g4_get_texture_pixels(texpaint_posnortex_picker1); context_raw.posx_picked = buffer_get_f32(a, 0); @@ -439,20 +439,20 @@ function render_path_paint_draw_cursor(mx: f32, my: f32, radius: f32, tint_r: f3 let geom: mesh_data_t = plane.data; render_path_set_target(""); - kinc_g5_set_pipeline(pipes_cursor); + iron_g5_set_pipeline(pipes_cursor); let rt: render_target_t = map_get(render_path_render_targets, "gbuffer0"); - let gbuffer0: kinc_g5_texture_t = rt._image; + let gbuffer0: iron_g5_texture_t = rt._image; iron_g4_set_texture_depth(pipes_cursor_gbufferd, gbuffer0); - iron_g4_set_float2(pipes_cursor_mouse, mx, my); - iron_g4_set_float2(pipes_cursor_tex_step, 1 / gbuffer0.width, 1 / gbuffer0.height); - iron_g4_set_float(pipes_cursor_radius, radius); + _iron_g4_set_float2(pipes_cursor_mouse, mx, my); + _iron_g4_set_float2(pipes_cursor_tex_step, 1 / gbuffer0.width, 1 / gbuffer0.height); + _iron_g4_set_float(pipes_cursor_radius, radius); let right: vec4_t = vec4_norm(camera_object_right_world(scene_camera)); - iron_g4_set_float3(pipes_cursor_camera_right, right.x, right.y, right.z); - iron_g4_set_float3(pipes_cursor_tint, tint_r, tint_g, tint_b); - iron_g4_set_matrix4(pipes_cursor_vp, scene_camera.vp); + _iron_g4_set_float3(pipes_cursor_camera_right, right.x, right.y, right.z); + _iron_g4_set_float3(pipes_cursor_tint, tint_r, tint_g, tint_b); + _iron_g4_set_matrix4(pipes_cursor_vp, scene_camera.vp); let help_mat: mat4_t = mat4_identity(); help_mat = mat4_inv(scene_camera.vp); - iron_g4_set_matrix4(pipes_cursor_inv_vp, help_mat); + _iron_g4_set_matrix4(pipes_cursor_inv_vp, help_mat); ///if (arm_metal || arm_vulkan) let vs: vertex_element_t[] = [ { @@ -460,14 +460,14 @@ function render_path_paint_draw_cursor(mx: f32, my: f32, radius: f32, tint_r: f3 data: "short2norm" } ]; - kinc_g4_set_vertex_buffer(mesh_data_get(geom, vs)); + iron_g4_set_vertex_buffer(mesh_data_get(geom, vs)); ///else - kinc_g4_set_vertex_buffer(geom._.vertex_buffer); + iron_g4_set_vertex_buffer(geom._.vertex_buffer); ///end - kinc_g4_set_index_buffer(geom._.index_buffers[0]); + iron_g4_set_index_buffer(geom._.index_buffers[0]); iron_g4_draw_indexed_vertices(); - kinc_g4_disable_scissor(); + iron_g4_disable_scissor(); render_path_end(); } diff --git a/armorpaint/sources/ui_header_ext.ts b/armorpaint/sources/ui_header_ext.ts index 1620c049..fed302f5 100644 --- a/armorpaint/sources/ui_header_ext.ts +++ b/armorpaint/sources/ui_header_ext.ts @@ -52,15 +52,15 @@ function ui_header_draw_tool_properties(ui: ui_t) { } let m: slot_layer_t = layers_new_mask(false, context_raw.layer); app_notify_on_next_frame(function (m: slot_layer_t) { - iron_g4_begin(m.texpaint); - kinc_g5_set_pipeline(pipes_colorid_to_mask); + _iron_g4_begin(m.texpaint); + iron_g5_set_pipeline(pipes_colorid_to_mask); let rt: render_target_t = map_get(render_path_render_targets, "texpaint_colorid"); - iron_g4_set_texture(pipes_texpaint_colorid, rt._image); - iron_g4_set_texture(pipes_tex_colorid, project_get_image(project_assets[context_raw.colorid_handle.position])); - kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); - kinc_g4_set_index_buffer(const_data_screen_aligned_ib); + _iron_g4_set_texture(pipes_texpaint_colorid, rt._image); + _iron_g4_set_texture(pipes_tex_colorid, project_get_image(project_assets[context_raw.colorid_handle.position])); + iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); + iron_g4_set_index_buffer(const_data_screen_aligned_ib); iron_g4_draw_indexed_vertices(); - iron_g4_end(); + _iron_g4_end(); context_raw.colorid_picked = false; ui_toolbar_handle.redraws = 1; ui_header_handle.redraws = 1; @@ -178,7 +178,7 @@ function ui_header_draw_tool_properties(ui: ui_t) { tr("Object ID"), tr("Vertex Color"), ]; - if (kinc_g5_raytrace_supported()) { + if (iron_g5_raytrace_supported()) { array_push(bakes, tr("Lightmap")); array_push(bakes, tr("Bent Normal")); array_push(bakes, tr("Thickness")); @@ -189,7 +189,7 @@ function ui_header_draw_tool_properties(ui: ui_t) { context_raw.bake_type = ui_combo(bake_handle, bakes, tr("Bake")); - if (!kinc_g5_raytrace_supported()) { + if (!iron_g5_raytrace_supported()) { context_raw.bake_type += 1; // Offset for removed AO } @@ -338,7 +338,7 @@ function ui_header_draw_tool_properties(ui: ui_t) { context_raw.brush_scale = ui_slider(brush_scale_handle, tr("UV Scale"), 0.01, 5.0, true); if (brush_scale_handle.changed) { if (context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT) { - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; g2_end(); util_render_make_decal_preview(); g2_begin(current); @@ -423,7 +423,7 @@ function ui_header_draw_tool_properties(ui: ui_t) { ui._w = w; if (h.changed) { - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; g2_end(); util_render_make_text_preview(); util_render_make_decal_preview(); @@ -436,7 +436,7 @@ function ui_header_draw_tool_properties(ui: ui_t) { ui_combo(context_raw.fill_type_handle, fill_mode_combo, tr("Fill Mode")); if (context_raw.fill_type_handle.changed) { if (context_raw.fill_type_handle.position == fill_type_t.FACE) { - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; g2_end(); // cache_uv_map(); util_uv_cache_triangle_map(); diff --git a/armorpaint/sources/ui_toolbar_ext.ts b/armorpaint/sources/ui_toolbar_ext.ts index da5b5554..2dac0279 100644 --- a/armorpaint/sources/ui_toolbar_ext.ts +++ b/armorpaint/sources/ui_toolbar_ext.ts @@ -1,5 +1,5 @@ -function ui_toolbar_ext_draw_tools(ui: ui_t, img: kinc_g5_texture_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_ext_draw_tools(ui: ui_t, img: iron_g5_texture_t, icon_accent: i32, keys: string[]) { ui_toolbar_draw_tool(workspace_tool_t.BRUSH, ui, img, icon_accent, keys); ui_toolbar_draw_tool(workspace_tool_t.ERASER, ui, img, icon_accent, keys); diff --git a/armorsculpt/sources/export_obj.ts b/armorsculpt/sources/export_obj.ts index fcbc366d..96befa01 100644 --- a/armorsculpt/sources/export_obj.ts +++ b/armorsculpt/sources/export_obj.ts @@ -9,7 +9,7 @@ function export_obj_run(path: string, paint_objects: mesh_object_t[], apply_disp let o: u8[] = []; export_obj_write_string(o, "# armorsculpt.org\n"); - let texpaint: kinc_g5_texture_t = project_layers[0].texpaint; + let texpaint: iron_g5_texture_t = project_layers[0].texpaint; let pixels: buffer_t = iron_g4_get_texture_pixels(texpaint); let mesh: mesh_data_t = paint_objects[0].data; let inda: u32_array_t = mesh.index_arrays[0].values; diff --git a/armorsculpt/sources/import_mesh.ts b/armorsculpt/sources/import_mesh.ts index 2c5bc095..361fd9c9 100644 --- a/armorsculpt/sources/import_mesh.ts +++ b/armorsculpt/sources/import_mesh.ts @@ -230,8 +230,8 @@ function import_mesh_pack_to_texture(mesh: raw_mesh_t) { buffer_set_f32(b, 4 * i * 4 + 3 * 4, 1.0); } - let imgmesh: kinc_g5_texture_t = iron_g4_create_texture_from_bytes(b, config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.RGBA128); - let texpaint: kinc_g5_texture_t = project_layers[0].texpaint; + let imgmesh: iron_g5_texture_t = iron_g4_create_texture_from_bytes(b, config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.RGBA128); + let texpaint: iron_g5_texture_t = project_layers[0].texpaint; g2_begin(texpaint); draw_set_pipeline(pipes_copy128); draw_scaled_image(imgmesh, 0, 0, config_get_texture_res_x(), config_get_texture_res_y()); diff --git a/armorsculpt/sources/make_material.ts b/armorsculpt/sources/make_material.ts index d55d7846..55e1ed34 100644 --- a/armorsculpt/sources/make_material.ts +++ b/armorsculpt/sources/make_material.ts @@ -156,7 +156,7 @@ function make_material_parse_paint_material(bake_previews: bool = true) { } if (bake_previews) { - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); make_material_bake_node_previews(); @@ -232,8 +232,8 @@ function make_material_bake_node_previews() { for (let i: i32 = 0; i < keys.length; ++i) { let key: string = keys[i]; if (array_index_of(context_raw.node_previews_used, key) == -1) { - let image: kinc_g5_texture_t = map_get(context_raw.node_previews, key); - app_notify_on_next_frame(function (image: kinc_g5_texture_t) { + let image: iron_g5_texture_t = map_get(context_raw.node_previews, key); + app_notify_on_next_frame(function (image: iron_g5_texture_t) { iron_unload_image(image); }, image); map_delete(context_raw.node_previews, key); @@ -263,7 +263,7 @@ function make_material_traverse_nodes(nodes: ui_node_t[], group: ui_node_canvas_ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_t, parents: ui_node_t[]) { if (node.type == "BLUR") { let id: string = parser_material_node_name(node, parents); - let image: kinc_g5_texture_t = map_get(context_raw.node_previews, id); + let image: iron_g5_texture_t = map_get(context_raw.node_previews, id); array_push(context_raw.node_previews_used, id); let res_x: i32 = math_floor(config_get_texture_res_x() / 4); let res_y: i32 = math_floor(config_get_texture_res_y() / 4); @@ -281,7 +281,7 @@ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_ } else if (node.type == "DIRECT_WARP") { let id: string = parser_material_node_name(node, parents); - let image: kinc_g5_texture_t = map_get(context_raw.node_previews, id); + let image: iron_g5_texture_t = map_get(context_raw.node_previews, id); array_push(context_raw.node_previews_used, id); let res_x: i32 = math_floor(config_get_texture_res_x()); let res_y: i32 = math_floor(config_get_texture_res_y()); diff --git a/armorsculpt/sources/nodes/brush_output_node_ext.ts b/armorsculpt/sources/nodes/brush_output_node_ext.ts index 20949cc1..8b6128c2 100644 --- a/armorsculpt/sources/nodes/brush_output_node_ext.ts +++ b/armorsculpt/sources/nodes/brush_output_node_ext.ts @@ -10,8 +10,8 @@ function brush_output_node_create_ext(n: brush_output_node_t) { function brush_output_node_parse_inputs(self: brush_output_node_t) { - let last_mask: kinc_g5_texture_t = context_raw.brush_mask_image; - let last_stencil: kinc_g5_texture_t = context_raw.brush_stencil_image; + let last_mask: iron_g5_texture_t = context_raw.brush_mask_image; + let last_stencil: iron_g5_texture_t = context_raw.brush_stencil_image; let input0: logic_node_value_t = logic_node_input_get(self.base.inputs[0]); let input1: logic_node_value_t = logic_node_input_get(self.base.inputs[1]); diff --git a/armorsculpt/sources/render_path_sculpt.ts b/armorsculpt/sources/render_path_sculpt.ts index 5f09156f..3ebd46a0 100644 --- a/armorsculpt/sources/render_path_sculpt.ts +++ b/armorsculpt/sources/render_path_sculpt.ts @@ -29,12 +29,12 @@ function render_path_sculpt_commands() { mesh_object_get_contexts(project_paint_objects[0], "paint", mats, material_contexts, shader_contexts); let cc_context: shader_context_t = shader_contexts[0]; - kinc_g5_set_pipeline(cc_context._.pipe_state); + iron_g5_set_pipeline(cc_context._.pipe_state); uniforms_set_context_consts(cc_context,_render_path_bind_params); uniforms_set_obj_consts(cc_context, project_paint_objects[0].base); uniforms_set_material_consts(cc_context, material_contexts[0]); - kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); - kinc_g4_set_index_buffer(const_data_screen_aligned_ib); + iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); + iron_g4_set_index_buffer(const_data_screen_aligned_ib); iron_g4_draw_indexed_vertices(); render_path_end(); } diff --git a/armorsculpt/sources/tab_layers.ts b/armorsculpt/sources/tab_layers.ts index 972af346..67638637 100644 --- a/armorsculpt/sources/tab_layers.ts +++ b/armorsculpt/sources/tab_layers.ts @@ -223,7 +223,7 @@ function tab_layers_draw_layer_slot_full(l: slot_layer_t, i: i32) { } // Draw eye icon - let icons: kinc_g5_texture_t = resource_get("icons.k"); + let icons: iron_g5_texture_t = resource_get("icons.k"); let r: rect_t = resource_tile18(icons, l.visible ? 0 : 1, 0); let center: i32 = (step / 2) * ui_SCALE(ui); ui._x += 2; diff --git a/armorsculpt/sources/ui_toolbar_ext.ts b/armorsculpt/sources/ui_toolbar_ext.ts index d6677e44..7592d93a 100644 --- a/armorsculpt/sources/ui_toolbar_ext.ts +++ b/armorsculpt/sources/ui_toolbar_ext.ts @@ -1,5 +1,5 @@ -function ui_toolbar_ext_draw_tools(ui: ui_t, img: kinc_g5_texture_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_ext_draw_tools(ui: ui_t, img: iron_g5_texture_t, icon_accent: i32, keys: string[]) { ui_toolbar_draw_tool(workspace_tool_t.BRUSH, ui, img, icon_accent, keys); } diff --git a/base/make b/base/make index d9e6a489..aeb5e334 100755 --- a/base/make +++ b/base/make @@ -1,5 +1,5 @@ #!/usr/bin/env bash . `dirname "$0"`/tools/platform.sh -MAKE="`dirname "$0"`/tools/bin/$KINC_PLATFORM/amake" +MAKE="`dirname "$0"`/tools/bin/$IRON_PLATFORM/amake" exec $MAKE `dirname "$0"`/tools/make.js "$@" diff --git a/base/project.js b/base/project.js index 912e557e..b033340e 100644 --- a/base/project.js +++ b/base/project.js @@ -162,7 +162,7 @@ if (!flags.lite) { add_gpu_backend("direct3d12"); project.add_define("_CRT_SECURE_NO_WARNINGS"); project.add_define("_WINSOCK_DEPRECATED_NO_WARNINGS"); - project.add_define("KINC_DIRECT3D12"); + project.add_define("IRON_DIRECT3D12"); project.add_lib("dxguid"); project.add_lib("dsound"); project.add_lib("dinput8"); @@ -178,7 +178,7 @@ if (!flags.lite) { add_thread_backend("apple"); add_gpu_backend("metal"); project.add_cfiles("sources/backends/data/mac.plist"); - project.add_define("KINC_METAL"); + project.add_define("IRON_METAL"); project.add_lib("Metal"); project.add_lib("MetalKit"); project.add_lib("IOKit"); @@ -198,7 +198,7 @@ if (!flags.lite) { add_gpu_backend("metal"); project.add_cfiles("sources/backends/data/ios.plist"); project.add_cfiles("sources/backends/data/LaunchScreen.storyboard"); - project.add_define("KINC_METAL"); + project.add_define("IRON_METAL"); project.add_lib("Metal"); project.add_lib("UIKit"); project.add_lib("Foundation"); @@ -217,9 +217,9 @@ if (!flags.lite) { add_net_backend("posix"); add_thread_backend("posix"); add_gpu_backend("vulkan"); - project.add_define("KINC_ANDROID"); - project.add_define("KINC_VULKAN"); - project.add_define("KINC_ANDROID_API=24"); + project.add_define("IRON_ANDROID"); + project.add_define("IRON_VULKAN"); + project.add_define("IRON_ANDROID_API=24"); project.add_define("VK_USE_PLATFORM_ANDROID_KHR"); project.add_lib("vulkan"); project.add_lib("log"); @@ -234,15 +234,15 @@ if (!flags.lite) { add_thread_backend("wasm"); add_gpu_backend("webgpu"); project.add_cfiles("sources/libs/miniclib/**"); - project.add_define("KINC_WASM"); - project.add_define("KINC_WEBGPU"); + project.add_define("IRON_WASM"); + project.add_define("IRON_WEBGPU"); project.add_include_dir("miniclib"); } else if (platform === "linux") { add_sys_backend("linux"); add_thread_backend("posix"); add_gpu_backend("vulkan"); - project.add_define("KINC_VULKAN"); + project.add_define("IRON_VULKAN"); project.add_define("_POSIX_C_SOURCE=200112L"); project.add_define("_XOPEN_SOURCE=600"); project.add_lib("asound"); @@ -268,8 +268,8 @@ project.add_define("IRON_C_PATH=\"" + os_cwd() + "/build/iron.c" + "\""); project.add_define("EMBED_H_PATH=\"" + os_cwd() + "/build/embed.h" + "\""); if (flags.with_audio) { - project.add_define("KINC_A1"); - project.add_define("KINC_A2"); + project.add_define("IRON_A1"); + project.add_define("IRON_A2"); project.add_define("WITH_AUDIO"); project.add_define("arm_audio"); project.add_cfiles("sources/libs/stb_vorbis.c"); diff --git a/base/sources/backends/KincActivity.kt b/base/sources/backends/KincActivity.kt index 499fcbe6..8d87416f 100644 --- a/base/sources/backends/KincActivity.kt +++ b/base/sources/backends/KincActivity.kt @@ -1,4 +1,4 @@ -package tech.kinc +package org.armory3d import android.app.NativeActivity import android.content.Context @@ -34,9 +34,9 @@ import java.io.InputStream; import java.io.OutputStream; import kotlin.math.log -class KincActivity: NativeActivity(), KeyEvent.Callback { +class IronActivity: NativeActivity(), KeyEvent.Callback { companion object { - var instance: KincActivity? = null + var instance: IronActivity? = null @JvmStatic fun showKeyboard() { @@ -111,9 +111,9 @@ class KincActivity: NativeActivity(), KeyEvent.Callback { } } - class MyHandler(private val kincActivity: KincActivity) : Handler() { + class MyHandler(private val ironActivity: IronActivity) : Handler() { override fun handleMessage(msg: Message) { - kincActivity.hideSystemUI() + ironActivity.hideSystemUI() } } @@ -181,11 +181,11 @@ class KincActivity: NativeActivity(), KeyEvent.Callback { } override fun onKeyMultiple(keyCode: Int, count: Int, event: KeyEvent): Boolean { - this.nativeKincKeyPress(event.characters) + this.nativeIronKeyPress(event.characters) return false } - private external fun nativeKincKeyPress(chars: String) + private external fun nativeIronKeyPress(chars: String) private external fun onAndroidFilePicked(pickedPath: String) private external fun getMobileTitle(): String diff --git a/base/sources/backends/KincMoviePlayer.kt b/base/sources/backends/KincMoviePlayer.kt index 724f52b5..3f991693 100644 --- a/base/sources/backends/KincMoviePlayer.kt +++ b/base/sources/backends/KincMoviePlayer.kt @@ -1,16 +1,16 @@ -package tech.kinc +package org.armory3d import java.util.ArrayList import android.view.Surface -class KincMoviePlayer(var path: String) { +class IronMoviePlayer(var path: String) { companion object { - var players = ArrayList() + var players = ArrayList() @JvmStatic fun updateAll() { - for (player in KincMoviePlayer.players) { + for (player in IronMoviePlayer.players) { player!!.update() } } @@ -20,28 +20,28 @@ class KincMoviePlayer(var path: String) { } } - private var movieTexture: KincMovieTexture? = null + private var movieTexture: IronMovieTexture? = null var id: Int = players.size init { players.add(this) } - + fun init() { - movieTexture = KincMovieTexture() + movieTexture = IronMovieTexture() val surface = Surface(movieTexture!!.surfaceTexture) nativeCreate(path, surface, id) surface.release() } - fun getMovieTexture(): KincMovieTexture? { + fun getMovieTexture(): IronMovieTexture? { return movieTexture } fun update(): Boolean { return movieTexture!!.update() } - + fun getTextureId(): Int { return movieTexture!!.textureId } diff --git a/base/sources/backends/KincMovieTexture.kt b/base/sources/backends/KincMovieTexture.kt index ed058b8f..897e9181 100644 --- a/base/sources/backends/KincMovieTexture.kt +++ b/base/sources/backends/KincMovieTexture.kt @@ -1,10 +1,10 @@ -package tech.kinc +package org.armory3d import android.graphics.SurfaceTexture import android.graphics.SurfaceTexture.OnFrameAvailableListener import android.opengl.GLES20 -class KincMovieTexture: OnFrameAvailableListener { +class IronMovieTexture: OnFrameAvailableListener { private val GL_TEXTURE_EXTERNAL_OES: Int = 0x8D65 var textureId: Int = 0 @@ -53,7 +53,7 @@ class KincMovieTexture: OnFrameAvailableListener { } return ret } - + override fun onFrameAvailable(surface: SurfaceTexture) { if (surfaceTexture == surface) { updateTexture = true diff --git a/base/sources/backends/android_audio.c b/base/sources/backends/android_audio.c index 1fda5740..ca25f2c1 100644 --- a/base/sources/backends/android_audio.c +++ b/base/sources/backends/android_audio.c @@ -1,7 +1,7 @@ -#ifdef KINC_A2 +#ifdef IRON_A2 -#include +#include #include #include @@ -9,7 +9,7 @@ #include #include -static kinc_a2_buffer_t a2_buffer; +static iron_a2_buffer_t a2_buffer; static SLObjectItf engineObject; static SLEngineItf engineEngine; @@ -32,7 +32,7 @@ static void copySample(void *buffer) { } static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf caller, void *context) { - if (kinc_a2_internal_callback(&a2_buffer, AUDIO_BUFFER_SIZE / 2)) { + if (iron_a2_internal_callback(&a2_buffer, AUDIO_BUFFER_SIZE / 2)) { for (int i = 0; i < AUDIO_BUFFER_SIZE; i += 2) { copySample(&tempBuffer[i]); } @@ -45,12 +45,12 @@ static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf caller, void *context static bool initialized = false; -void kinc_a2_init() { +void iron_a2_init() { if (initialized) { return; } - kinc_a2_internal_init(); + iron_a2_internal_init(); initialized = true; a2_buffer.read_location = 0; @@ -111,9 +111,9 @@ void resumeAudio() { SLresult result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_PLAYING); } -void kinc_a2_update() {} +void iron_a2_update() {} -void kinc_a2_shutdown() { +void iron_a2_shutdown() { if (bqPlayerObject != NULL) { (*bqPlayerObject)->Destroy(bqPlayerObject); bqPlayerObject = NULL; @@ -131,7 +131,7 @@ void kinc_a2_shutdown() { } } -uint32_t kinc_a2_samples_per_second(void) { +uint32_t iron_a2_samples_per_second(void) { return 44100; } diff --git a/base/sources/backends/android_file_dialog.c b/base/sources/backends/android_file_dialog.c index 0c522911..238a788b 100644 --- a/base/sources/backends/android_file_dialog.c +++ b/base/sources/backends/android_file_dialog.c @@ -9,10 +9,10 @@ extern char mobile_title[1024]; -ANativeActivity *kinc_android_get_activity(void); -jclass kinc_android_find_class(JNIEnv *env, const char *name); +ANativeActivity *iron_android_get_activity(void); +jclass iron_android_find_class(JNIEnv *env, const char *name); -JNIEXPORT void JNICALL Java_tech_kinc_KincActivity_onAndroidFilePicked(JNIEnv *env, jobject jobj, jstring jstr) { +JNIEXPORT void JNICALL Java_org_armory3d_IronActivity_onAndroidFilePicked(JNIEnv *env, jobject jobj, jstring jstr) { if (jstr == NULL) return; const char *str = (*env)->GetStringUTFChars(env, jstr, 0); size_t len = strlen(str); @@ -20,27 +20,27 @@ JNIEXPORT void JNICALL Java_tech_kinc_KincActivity_onAndroidFilePicked(JNIEnv *e mbstowcs(filePath, (char *)str, len); filePath[len] = 0; - kinc_internal_drop_files_callback(filePath); + iron_internal_drop_files_callback(filePath); (*env)->ReleaseStringUTFChars(env, jstr, str); } -JNIEXPORT jstring JNICALL Java_tech_kinc_KincActivity_getMobileTitle(JNIEnv *env, jobject jobj) { +JNIEXPORT jstring JNICALL Java_org_armory3d_IronActivity_getMobileTitle(JNIEnv *env, jobject jobj) { jstring result = (*env)->NewStringUTF(env, mobile_title); return result; } void AndroidFileDialogOpen() { - ANativeActivity *activity = kinc_android_get_activity(); + ANativeActivity *activity = iron_android_get_activity(); JNIEnv *env; - JavaVM *vm = kinc_android_get_activity()->vm; + JavaVM *vm = iron_android_get_activity()->vm; (*vm)->AttachCurrentThread(vm, &env, NULL); - jclass kincActivityClass = kinc_android_find_class(env, "tech.kinc.KincActivity"); - (*env)->CallStaticVoidMethod(env, kincActivityClass, (*env)->GetStaticMethodID(env, kincActivityClass, "pickFile", "()V")); + jclass ironActivityClass = iron_android_find_class(env, "org.armory3d.IronActivity"); + (*env)->CallStaticVoidMethod(env, ironActivityClass, (*env)->GetStaticMethodID(env, ironActivityClass, "pickFile", "()V")); (*vm)->DetachCurrentThread(vm); } wchar_t *AndroidFileDialogSave() { - // kinc_android_get_activity()->externalDataPath; // /storage/emulated/0/Android/data/org.armorpaint/files + // iron_android_get_activity()->externalDataPath; // /storage/emulated/0/Android/data/org.armorpaint/files mkdir("/storage/emulated/0/Pictures/ArmorPaint", 0777); return L"/storage/emulated/0/Pictures/ArmorPaint/untitled"; } @@ -53,9 +53,9 @@ jstring android_permission_name(JNIEnv *env, const char *perm_name) { } bool android_has_permission(struct android_app *app, const char *perm_name) { - ANativeActivity *activity = kinc_android_get_activity(); + ANativeActivity *activity = iron_android_get_activity(); JNIEnv *env; - JavaVM *vm = kinc_android_get_activity()->vm; + JavaVM *vm = iron_android_get_activity()->vm; (*vm)->AttachCurrentThread(vm, &env, NULL); bool result = false; jstring ls_PERM = android_permission_name(env, perm_name); @@ -77,9 +77,9 @@ bool android_has_permission(struct android_app *app, const char *perm_name) { } void android_request_file_permissions(struct android_app *app) { - ANativeActivity *activity = kinc_android_get_activity(); + ANativeActivity *activity = iron_android_get_activity(); JNIEnv *env; - JavaVM *vm = kinc_android_get_activity()->vm; + JavaVM *vm = iron_android_get_activity()->vm; (*vm)->AttachCurrentThread(vm, &env, NULL); jobjectArray perm_array = (*env)->NewObjectArray(env, 2, (*env)->FindClass(env, "java/lang/String"), (*env)->NewStringUTF(env, "")); (*env)->SetObjectArrayElement(env, perm_array, 0, android_permission_name(env, "READ_EXTERNAL_STORAGE")); @@ -92,20 +92,20 @@ void android_request_file_permissions(struct android_app *app) { } void android_check_permissions() { - ANativeActivity *activity = kinc_android_get_activity(); + ANativeActivity *activity = iron_android_get_activity(); struct android_app *app = (struct android_app *)activity->instance; bool hasPermissions = android_has_permission(app, "READ_EXTERNAL_STORAGE") && android_has_permission(app, "WRITE_EXTERNAL_STORAGE"); if (!hasPermissions) android_request_file_permissions(app); JNIEnv *env; - JavaVM *vm = kinc_android_get_activity()->vm; + JavaVM *vm = iron_android_get_activity()->vm; (*vm)->AttachCurrentThread(vm, &env, NULL); - jclass kincActivityClass = kinc_android_find_class(env, "tech.kinc.KincActivity"); + jclass ironActivityClass = iron_android_find_class(env, "org.armory3d.IronActivity"); JNINativeMethod methodTable[] = { - {"onAndroidFilePicked", "(Ljava/lang/String;)V", (void *)Java_tech_kinc_KincActivity_onAndroidFilePicked}, - {"getMobileTitle", "()Ljava/lang/String;", (void *)Java_tech_kinc_KincActivity_getMobileTitle} + {"onAndroidFilePicked", "(Ljava/lang/String;)V", (void *)Java_org_armory3d_IronActivity_onAndroidFilePicked}, + {"getMobileTitle", "()Ljava/lang/String;", (void *)Java_org_armory3d_IronActivity_getMobileTitle} }; int methodTableSize = sizeof(methodTable) / sizeof(methodTable[0]); - (*env)->RegisterNatives(env, kincActivityClass, methodTable, methodTableSize); + (*env)->RegisterNatives(env, ironActivityClass, methodTable, methodTableSize); (*vm)->DetachCurrentThread(vm); } diff --git a/base/sources/backends/android_http_request.c b/base/sources/backends/android_http_request.c index 0a61f104..78e80610 100644 --- a/base/sources/backends/android_http_request.c +++ b/base/sources/backends/android_http_request.c @@ -4,16 +4,16 @@ #include #include -ANativeActivity *kinc_android_get_activity(void); -jclass kinc_android_find_class(JNIEnv *env, const char *name); +ANativeActivity *iron_android_get_activity(void); +jclass iron_android_find_class(JNIEnv *env, const char *name); void android_http_request(const char *url, const char *path, const char *data, int port, bool secure, int method, const char *header, - kinc_http_callback_t callback, void *callbackdata) { - ANativeActivity *activity = kinc_android_get_activity(); + iron_http_callback_t callback, void *callbackdata) { + ANativeActivity *activity = iron_android_get_activity(); JNIEnv *env; - JavaVM *vm = kinc_android_get_activity()->vm; + JavaVM *vm = iron_android_get_activity()->vm; (*vm)->AttachCurrentThread(vm, &env, NULL); - jclass activityClass = kinc_android_find_class(env, "arm.AndroidHttpRequest"); + jclass activityClass = iron_android_find_class(env, "arm.AndroidHttpRequest"); jstring jstr = (*env)->NewStringUTF(env, url); jbyteArray bytes_array = (jbyteArray)((*env)->CallStaticObjectMethod(env, activityClass, (*env)->GetStaticMethodID(env, activityClass, "androidHttpRequest", "(Ljava/lang/String;)[B"), jstr)); diff --git a/base/sources/backends/android_http_request.h b/base/sources/backends/android_http_request.h index 4a65bbe3..f4a1044a 100644 --- a/base/sources/backends/android_http_request.h +++ b/base/sources/backends/android_http_request.h @@ -2,8 +2,8 @@ #include -typedef void (*kinc_http_callback_t)(int error, int response, const char *body, void *callbackdata); +typedef void (*iron_http_callback_t)(int error, int response, const char *body, void *callbackdata); void android_http_request(const char *url, const char *path, const char *data, int port, bool secure, int method, const char *header, - kinc_http_callback_t callback, void *callbackdata); + iron_http_callback_t callback, void *callbackdata); diff --git a/base/sources/backends/android_system.c b/base/sources/backends/android_system.c index 385918c9..7cd4ad6f 100644 --- a/base/sources/backends/android_system.c +++ b/base/sources/backends/android_system.c @@ -25,66 +25,66 @@ typedef struct { int height; bool primary; int number; -} kinc_display_t; +} iron_display_t; -static kinc_display_t display; +static iron_display_t display; -int kinc_count_displays(void) { +int iron_count_displays(void) { return 1; } -int kinc_primary_display(void) { +int iron_primary_display(void) { return 0; } static int width() { JNIEnv *env; - JavaVM *vm = kinc_android_get_activity()->vm; + JavaVM *vm = iron_android_get_activity()->vm; (*vm)->AttachCurrentThread(vm, &env, NULL); - jclass koreActivityClass = kinc_android_find_class(env, "tech.kinc.KincActivity"); - jmethodID koreActivityGetScreenDpi = (*env)->GetStaticMethodID(env, koreActivityClass, "getDisplayWidth", "()I"); - int width = (*env)->CallStaticIntMethod(env, koreActivityClass, koreActivityGetScreenDpi); + jclass ironActivityClass = iron_android_find_class(env, "org.armory3d.IronActivity"); + jmethodID ironActivityGetScreenDpi = (*env)->GetStaticMethodID(env, ironActivityClass, "getDisplayWidth", "()I"); + int width = (*env)->CallStaticIntMethod(env, ironActivityClass, ironActivityGetScreenDpi); (*vm)->DetachCurrentThread(vm); return width; } static int height() { JNIEnv *env; - JavaVM *vm = kinc_android_get_activity()->vm; + JavaVM *vm = iron_android_get_activity()->vm; (*vm)->AttachCurrentThread(vm, &env, NULL); - jclass koreActivityClass = kinc_android_find_class(env, "tech.kinc.KincActivity"); - jmethodID koreActivityGetScreenDpi = (*env)->GetStaticMethodID(env, koreActivityClass, "getDisplayHeight", "()I"); - int height = (*env)->CallStaticIntMethod(env, koreActivityClass, koreActivityGetScreenDpi); + jclass ironActivityClass = iron_android_find_class(env, "org.armory3d.IronActivity"); + jmethodID ironActivityGetScreenDpi = (*env)->GetStaticMethodID(env, ironActivityClass, "getDisplayHeight", "()I"); + int height = (*env)->CallStaticIntMethod(env, ironActivityClass, ironActivityGetScreenDpi); (*vm)->DetachCurrentThread(vm); return height; } static int pixelsPerInch() { JNIEnv *env; - JavaVM *vm = kinc_android_get_activity()->vm; + JavaVM *vm = iron_android_get_activity()->vm; (*vm)->AttachCurrentThread(vm, &env, NULL); - jclass koreActivityClass = kinc_android_find_class(env, "tech.kinc.KincActivity"); - jmethodID koreActivityGetScreenDpi = (*env)->GetStaticMethodID(env, koreActivityClass, "getScreenDpi", "()I"); - int dpi = (*env)->CallStaticIntMethod(env, koreActivityClass, koreActivityGetScreenDpi); + jclass ironActivityClass = iron_android_find_class(env, "org.armory3d.IronActivity"); + jmethodID ironActivityGetScreenDpi = (*env)->GetStaticMethodID(env, ironActivityClass, "getScreenDpi", "()I"); + int dpi = (*env)->CallStaticIntMethod(env, ironActivityClass, ironActivityGetScreenDpi); (*vm)->DetachCurrentThread(vm); return dpi; } static int refreshRate() { JNIEnv *env; - JavaVM *vm = kinc_android_get_activity()->vm; + JavaVM *vm = iron_android_get_activity()->vm; (*vm)->AttachCurrentThread(vm, &env, NULL); - jclass koreActivityClass = kinc_android_find_class(env, "tech.kinc.KincActivity"); - jmethodID koreActivityGetScreenDpi = (*env)->GetStaticMethodID(env, koreActivityClass, "getRefreshRate", "()I"); - int dpi = (*env)->CallStaticIntMethod(env, koreActivityClass, koreActivityGetScreenDpi); + jclass ironActivityClass = iron_android_find_class(env, "org.armory3d.IronActivity"); + jmethodID ironActivityGetScreenDpi = (*env)->GetStaticMethodID(env, ironActivityClass, "getRefreshRate", "()I"); + int dpi = (*env)->CallStaticIntMethod(env, ironActivityClass, ironActivityGetScreenDpi); (*vm)->DetachCurrentThread(vm); return dpi; } -void kinc_display_init() {} +void iron_display_init() {} -kinc_display_mode_t kinc_display_available_mode(int display_index, int mode_index) { - kinc_display_mode_t mode; +iron_display_mode_t iron_display_available_mode(int display_index, int mode_index) { + iron_display_mode_t mode; mode.x = 0; mode.y = 0; mode.width = width(); @@ -95,12 +95,12 @@ kinc_display_mode_t kinc_display_available_mode(int display_index, int mode_inde return mode; } -int kinc_display_count_available_modes(int display_index) { +int iron_display_count_available_modes(int display_index) { return 1; } -kinc_display_mode_t kinc_display_current_mode(int display) { - kinc_display_mode_t mode; +iron_display_mode_t iron_display_current_mode(int display) { + iron_display_mode_t mode; mode.x = 0; mode.y = 0; mode.width = width(); @@ -111,11 +111,11 @@ kinc_display_mode_t kinc_display_current_mode(int display) { return mode; } -const char *kinc_display_name(int display) { +const char *iron_display_name(int display) { return "Display"; } -bool kinc_display_available(int display) { +bool iron_display_available(int display) { return display == 0; } @@ -135,7 +135,7 @@ static bool displayIsInitialized = false; static bool appIsForeground = false; static bool activityJustResized = false; -VkResult kinc_vulkan_create_surface(VkInstance instance, VkSurfaceKHR *surface) { +VkResult iron_vulkan_create_surface(VkInstance instance, VkSurfaceKHR *surface) { assert(app->window != NULL); VkAndroidSurfaceCreateInfoKHR createInfo = {}; createInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR; @@ -145,12 +145,12 @@ VkResult kinc_vulkan_create_surface(VkInstance instance, VkSurfaceKHR *surface) return vkCreateAndroidSurfaceKHR(instance, &createInfo, NULL, surface); } -void kinc_vulkan_get_instance_extensions(const char **names, int *index, int max) { +void iron_vulkan_get_instance_extensions(const char **names, int *index, int max) { assert(*index + 1 < max); names[(*index)++] = VK_KHR_ANDROID_SURFACE_EXTENSION_NAME; } -VkBool32 kinc_vulkan_get_physical_device_presentation_support(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex) { +VkBool32 iron_vulkan_get_physical_device_presentation_support(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex) { // https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_android_surface.html#_issues // // 1) Does Android need a way to query for compatibility between a particular physical device (and queue family?) @@ -160,10 +160,10 @@ VkBool32 kinc_vulkan_get_physical_device_presentation_support(VkPhysicalDevice p return true; } -void kinc_vulkan_init_window(); +void iron_vulkan_init_window(); static void initDisplay() { - kinc_vulkan_init_window(0); + iron_vulkan_init_window(0); } static void termDisplay() { @@ -176,10 +176,10 @@ static void updateAppForegroundStatus(bool displayIsInitializedValue, bool appIs bool newStatus = displayIsInitialized && appIsForeground; if (oldStatus != newStatus) { if (newStatus) { - kinc_internal_foreground_callback(); + iron_internal_foreground_callback(); } else { - kinc_internal_background_callback(); + iron_internal_background_callback(); } } } @@ -204,12 +204,12 @@ static void touchInput(AInputEvent *event) { case AMOTION_EVENT_ACTION_DOWN: case AMOTION_EVENT_ACTION_POINTER_DOWN: if (id == 0) { - kinc_internal_mouse_trigger_press(0, 0, x, y); + iron_internal_mouse_trigger_press(0, 0, x, y); } if (isPenEvent(event)) { - kinc_internal_pen_trigger_press(0, x, y, AMotionEvent_getPressure(event, index)); + iron_internal_pen_trigger_press(0, x, y, AMotionEvent_getPressure(event, index)); } - kinc_internal_surface_trigger_touch_start(id, x, y); + iron_internal_surface_trigger_touch_start(id, x, y); break; case AMOTION_EVENT_ACTION_MOVE: case AMOTION_EVENT_ACTION_HOVER_MOVE: { @@ -219,29 +219,29 @@ static void touchInput(AInputEvent *event) { x = AMotionEvent_getX(event, i); y = AMotionEvent_getY(event, i); if (id == 0) { - kinc_internal_mouse_trigger_move(0, x, y); + iron_internal_mouse_trigger_move(0, x, y); } if (isPenEvent(event)) { - kinc_internal_pen_trigger_move(0, x, y, AMotionEvent_getPressure(event, index)); + iron_internal_pen_trigger_move(0, x, y, AMotionEvent_getPressure(event, index)); } - kinc_internal_surface_trigger_move(id, x, y); + iron_internal_surface_trigger_move(id, x, y); } } break; case AMOTION_EVENT_ACTION_UP: case AMOTION_EVENT_ACTION_CANCEL: case AMOTION_EVENT_ACTION_POINTER_UP: if (id == 0) { - kinc_internal_mouse_trigger_release(0, 0, x, y); + iron_internal_mouse_trigger_release(0, 0, x, y); } if (isPenEvent(event)) { - kinc_internal_pen_trigger_release(0, x, y, AMotionEvent_getPressure(event, index)); + iron_internal_pen_trigger_release(0, x, y, AMotionEvent_getPressure(event, index)); } - kinc_internal_surface_trigger_touch_end(id, x, y); + iron_internal_surface_trigger_touch_end(id, x, y); break; case AMOTION_EVENT_ACTION_SCROLL: if (id == 0) { float scroll = AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_VSCROLL, 0); - kinc_internal_mouse_trigger_scroll(0, -(int)scroll); + iron_internal_mouse_trigger_scroll(0, -(int)scroll); } break; } @@ -268,25 +268,25 @@ static int32_t input(struct android_app *app, AInputEvent *event) { float x = AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_X, 0); if (x != last_x) { - kinc_internal_gamepad_trigger_axis(0, 0, x); + iron_internal_gamepad_trigger_axis(0, 0, x); last_x = x; } float y = -AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_Y, 0); if (y != last_y) { - kinc_internal_gamepad_trigger_axis(0, 1, y); + iron_internal_gamepad_trigger_axis(0, 1, y); last_y = y; } float l = AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_LTRIGGER, 0); if (l != last_l) { - kinc_internal_gamepad_trigger_button(0, 6, l); + iron_internal_gamepad_trigger_button(0, 6, l); last_l = l; } float r = AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_RTRIGGER, 0); if (r != last_r) { - kinc_internal_gamepad_trigger_button(0, 7, r); + iron_internal_gamepad_trigger_button(0, 7, r); last_r = r; } @@ -313,22 +313,22 @@ static int32_t input(struct android_app *app, AInputEvent *event) { } if (hat_left != last_hat_left) { - kinc_internal_gamepad_trigger_button(0, 14, hat_left ? 1.0f : 0.0f); + iron_internal_gamepad_trigger_button(0, 14, hat_left ? 1.0f : 0.0f); last_hat_left = hat_left; } if (hat_right != last_hat_right) { - kinc_internal_gamepad_trigger_button(0, 15, hat_right ? 1.0f : 0.0f); + iron_internal_gamepad_trigger_button(0, 15, hat_right ? 1.0f : 0.0f); last_hat_right = hat_right; } if (hat_up != last_hat_up) { - kinc_internal_gamepad_trigger_button(0, 12, hat_up ? 1.0f : 0.0f); + iron_internal_gamepad_trigger_button(0, 12, hat_up ? 1.0f : 0.0f); last_hat_up = hat_up; } if (hat_down != last_hat_down) { - kinc_internal_gamepad_trigger_button(0, 13, hat_down ? 1.0f : 0.0f); + iron_internal_gamepad_trigger_button(0, 13, hat_down ? 1.0f : 0.0f); last_hat_down = hat_down; } @@ -343,262 +343,262 @@ static int32_t input(struct android_app *app, AInputEvent *event) { if (shift) { switch (code) { case AKEYCODE_1: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_EXCLAMATION); - kinc_internal_keyboard_trigger_key_press('!'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_EXCLAMATION); + iron_internal_keyboard_trigger_key_press('!'); return 1; case AKEYCODE_4: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_DOLLAR); - kinc_internal_keyboard_trigger_key_press('$'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_DOLLAR); + iron_internal_keyboard_trigger_key_press('$'); return 1; case AKEYCODE_5: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_PERCENT); - kinc_internal_keyboard_trigger_key_press('%'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_PERCENT); + iron_internal_keyboard_trigger_key_press('%'); return 1; case AKEYCODE_6: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_CIRCUMFLEX); - kinc_internal_keyboard_trigger_key_press('^'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_CIRCUMFLEX); + iron_internal_keyboard_trigger_key_press('^'); return 1; case AKEYCODE_7: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_AMPERSAND); - kinc_internal_keyboard_trigger_key_press('&'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_AMPERSAND); + iron_internal_keyboard_trigger_key_press('&'); return 1; case AKEYCODE_9: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_OPEN_PAREN); - kinc_internal_keyboard_trigger_key_press('('); + iron_internal_keyboard_trigger_key_down(IRON_KEY_OPEN_PAREN); + iron_internal_keyboard_trigger_key_press('('); return 1; case AKEYCODE_0: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_CLOSE_PAREN); - kinc_internal_keyboard_trigger_key_press(')'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_CLOSE_PAREN); + iron_internal_keyboard_trigger_key_press(')'); return 1; case AKEYCODE_COMMA: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_LESS_THAN); - kinc_internal_keyboard_trigger_key_press('<'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_LESS_THAN); + iron_internal_keyboard_trigger_key_press('<'); return 1; case AKEYCODE_PERIOD: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_GREATER_THAN); - kinc_internal_keyboard_trigger_key_press('>'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_GREATER_THAN); + iron_internal_keyboard_trigger_key_press('>'); return 1; case AKEYCODE_MINUS: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_UNDERSCORE); - kinc_internal_keyboard_trigger_key_press('_'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_UNDERSCORE); + iron_internal_keyboard_trigger_key_press('_'); return 1; case AKEYCODE_SLASH: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_QUESTIONMARK); - kinc_internal_keyboard_trigger_key_press('?'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_QUESTIONMARK); + iron_internal_keyboard_trigger_key_press('?'); return 1; case AKEYCODE_BACKSLASH: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_PIPE); - kinc_internal_keyboard_trigger_key_press('|'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_PIPE); + iron_internal_keyboard_trigger_key_press('|'); return 1; case AKEYCODE_LEFT_BRACKET: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_OPEN_CURLY_BRACKET); - kinc_internal_keyboard_trigger_key_press('{'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_OPEN_CURLY_BRACKET); + iron_internal_keyboard_trigger_key_press('{'); return 1; case AKEYCODE_RIGHT_BRACKET: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_CLOSE_CURLY_BRACKET); - kinc_internal_keyboard_trigger_key_press('}'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_CLOSE_CURLY_BRACKET); + iron_internal_keyboard_trigger_key_press('}'); return 1; case AKEYCODE_SEMICOLON: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_COLON); - kinc_internal_keyboard_trigger_key_press(':'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_COLON); + iron_internal_keyboard_trigger_key_press(':'); return 1; case AKEYCODE_APOSTROPHE: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_DOUBLE_QUOTE); - kinc_internal_keyboard_trigger_key_press('"'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_DOUBLE_QUOTE); + iron_internal_keyboard_trigger_key_press('"'); return 1; case AKEYCODE_GRAVE: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_TILDE); - kinc_internal_keyboard_trigger_key_press('~'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_TILDE); + iron_internal_keyboard_trigger_key_press('~'); return 1; } } switch (code) { case AKEYCODE_SHIFT_LEFT: case AKEYCODE_SHIFT_RIGHT: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_SHIFT); + iron_internal_keyboard_trigger_key_down(IRON_KEY_SHIFT); return 1; case AKEYCODE_DEL: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_BACKSPACE); + iron_internal_keyboard_trigger_key_down(IRON_KEY_BACKSPACE); return 1; case AKEYCODE_ENTER: case AKEYCODE_NUMPAD_ENTER: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_RETURN); + iron_internal_keyboard_trigger_key_down(IRON_KEY_RETURN); return 1; case AKEYCODE_DPAD_CENTER: case AKEYCODE_BUTTON_B: - kinc_internal_gamepad_trigger_button(0, 1, 1); + iron_internal_gamepad_trigger_button(0, 1, 1); return 1; case AKEYCODE_BACK: if (AKeyEvent_getMetaState(event) & AMETA_ALT_ON) { // Xperia Play - kinc_internal_gamepad_trigger_button(0, 1, 1); + iron_internal_gamepad_trigger_button(0, 1, 1); return 1; } else { - kinc_internal_keyboard_trigger_key_down(KINC_KEY_BACK); + iron_internal_keyboard_trigger_key_down(IRON_KEY_BACK); return 1; } case AKEYCODE_BUTTON_A: - kinc_internal_gamepad_trigger_button(0, 0, 1); + iron_internal_gamepad_trigger_button(0, 0, 1); return 1; case AKEYCODE_BUTTON_Y: - kinc_internal_gamepad_trigger_button(0, 3, 1); + iron_internal_gamepad_trigger_button(0, 3, 1); return 1; case AKEYCODE_BUTTON_X: - kinc_internal_gamepad_trigger_button(0, 2, 1); + iron_internal_gamepad_trigger_button(0, 2, 1); return 1; case AKEYCODE_BUTTON_L1: - kinc_internal_gamepad_trigger_button(0, 4, 1); + iron_internal_gamepad_trigger_button(0, 4, 1); return 1; case AKEYCODE_BUTTON_R1: - kinc_internal_gamepad_trigger_button(0, 5, 1); + iron_internal_gamepad_trigger_button(0, 5, 1); return 1; case AKEYCODE_BUTTON_L2: - kinc_internal_gamepad_trigger_button(0, 6, 1); + iron_internal_gamepad_trigger_button(0, 6, 1); return 1; case AKEYCODE_BUTTON_R2: - kinc_internal_gamepad_trigger_button(0, 7, 1); + iron_internal_gamepad_trigger_button(0, 7, 1); return 1; case AKEYCODE_BUTTON_SELECT: - kinc_internal_gamepad_trigger_button(0, 8, 1); + iron_internal_gamepad_trigger_button(0, 8, 1); return 1; case AKEYCODE_BUTTON_START: - kinc_internal_gamepad_trigger_button(0, 9, 1); + iron_internal_gamepad_trigger_button(0, 9, 1); return 1; case AKEYCODE_BUTTON_THUMBL: - kinc_internal_gamepad_trigger_button(0, 10, 1); + iron_internal_gamepad_trigger_button(0, 10, 1); return 1; case AKEYCODE_BUTTON_THUMBR: - kinc_internal_gamepad_trigger_button(0, 11, 1); + iron_internal_gamepad_trigger_button(0, 11, 1); return 1; case AKEYCODE_DPAD_UP: if (isGamepadEvent(event)) - kinc_internal_gamepad_trigger_button(0, 12, 1); + iron_internal_gamepad_trigger_button(0, 12, 1); else - kinc_internal_keyboard_trigger_key_down(KINC_KEY_UP); + iron_internal_keyboard_trigger_key_down(IRON_KEY_UP); return 1; case AKEYCODE_DPAD_DOWN: if (isGamepadEvent(event)) - kinc_internal_gamepad_trigger_button(0, 13, 1); + iron_internal_gamepad_trigger_button(0, 13, 1); else - kinc_internal_keyboard_trigger_key_down(KINC_KEY_DOWN); + iron_internal_keyboard_trigger_key_down(IRON_KEY_DOWN); return 1; case AKEYCODE_DPAD_LEFT: if (isGamepadEvent(event)) - kinc_internal_gamepad_trigger_button(0, 14, 1); + iron_internal_gamepad_trigger_button(0, 14, 1); else - kinc_internal_keyboard_trigger_key_down(KINC_KEY_LEFT); + iron_internal_keyboard_trigger_key_down(IRON_KEY_LEFT); return 1; case AKEYCODE_DPAD_RIGHT: if (isGamepadEvent(event)) - kinc_internal_gamepad_trigger_button(0, 15, 1); + iron_internal_gamepad_trigger_button(0, 15, 1); else - kinc_internal_keyboard_trigger_key_down(KINC_KEY_RIGHT); + iron_internal_keyboard_trigger_key_down(IRON_KEY_RIGHT); return 1; case AKEYCODE_BUTTON_MODE: - kinc_internal_gamepad_trigger_button(0, 16, 1); + iron_internal_gamepad_trigger_button(0, 16, 1); return 1; case AKEYCODE_STAR: case AKEYCODE_NUMPAD_MULTIPLY: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_MULTIPLY); - kinc_internal_keyboard_trigger_key_press('*'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_MULTIPLY); + iron_internal_keyboard_trigger_key_press('*'); return 1; case AKEYCODE_POUND: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_HASH); - kinc_internal_keyboard_trigger_key_press('#'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_HASH); + iron_internal_keyboard_trigger_key_press('#'); return 1; case AKEYCODE_COMMA: case AKEYCODE_NUMPAD_COMMA: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_COMMA); - kinc_internal_keyboard_trigger_key_press(','); + iron_internal_keyboard_trigger_key_down(IRON_KEY_COMMA); + iron_internal_keyboard_trigger_key_press(','); return 1; case AKEYCODE_PERIOD: case AKEYCODE_NUMPAD_DOT: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_PERIOD); - kinc_internal_keyboard_trigger_key_press('.'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_PERIOD); + iron_internal_keyboard_trigger_key_press('.'); return 1; case AKEYCODE_SPACE: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_SPACE); - kinc_internal_keyboard_trigger_key_press(' '); + iron_internal_keyboard_trigger_key_down(IRON_KEY_SPACE); + iron_internal_keyboard_trigger_key_press(' '); return 1; case AKEYCODE_MINUS: case AKEYCODE_NUMPAD_SUBTRACT: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_HYPHEN_MINUS); - kinc_internal_keyboard_trigger_key_press('-'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_HYPHEN_MINUS); + iron_internal_keyboard_trigger_key_press('-'); return 1; case AKEYCODE_EQUALS: case AKEYCODE_NUMPAD_EQUALS: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_EQUALS); - kinc_internal_keyboard_trigger_key_press('='); + iron_internal_keyboard_trigger_key_down(IRON_KEY_EQUALS); + iron_internal_keyboard_trigger_key_press('='); return 1; case AKEYCODE_LEFT_BRACKET: case AKEYCODE_NUMPAD_LEFT_PAREN: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_OPEN_BRACKET); - kinc_internal_keyboard_trigger_key_press('['); + iron_internal_keyboard_trigger_key_down(IRON_KEY_OPEN_BRACKET); + iron_internal_keyboard_trigger_key_press('['); return 1; case AKEYCODE_RIGHT_BRACKET: case AKEYCODE_NUMPAD_RIGHT_PAREN: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_CLOSE_BRACKET); - kinc_internal_keyboard_trigger_key_press(']'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_CLOSE_BRACKET); + iron_internal_keyboard_trigger_key_press(']'); return 1; case AKEYCODE_BACKSLASH: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_BACK_SLASH); - kinc_internal_keyboard_trigger_key_press('\\'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_BACK_SLASH); + iron_internal_keyboard_trigger_key_press('\\'); return 1; case AKEYCODE_SEMICOLON: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_SEMICOLON); - kinc_internal_keyboard_trigger_key_press(';'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_SEMICOLON); + iron_internal_keyboard_trigger_key_press(';'); return 1; case AKEYCODE_APOSTROPHE: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_QUOTE); - kinc_internal_keyboard_trigger_key_press('\''); + iron_internal_keyboard_trigger_key_down(IRON_KEY_QUOTE); + iron_internal_keyboard_trigger_key_press('\''); return 1; case AKEYCODE_GRAVE: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_BACK_QUOTE); - kinc_internal_keyboard_trigger_key_press('`'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_BACK_QUOTE); + iron_internal_keyboard_trigger_key_press('`'); return 1; case AKEYCODE_SLASH: case AKEYCODE_NUMPAD_DIVIDE: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_SLASH); - kinc_internal_keyboard_trigger_key_press('/'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_SLASH); + iron_internal_keyboard_trigger_key_press('/'); return 1; case AKEYCODE_AT: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_AT); - kinc_internal_keyboard_trigger_key_press('@'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_AT); + iron_internal_keyboard_trigger_key_press('@'); return 1; case AKEYCODE_PLUS: case AKEYCODE_NUMPAD_ADD: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_PLUS); - kinc_internal_keyboard_trigger_key_press('+'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_PLUS); + iron_internal_keyboard_trigger_key_press('+'); return 1; // (DK) Amazon FireTV remote/controller mappings // (DK) TODO handle multiple pads (up to 4 possible) case AKEYCODE_MENU: - kinc_internal_gamepad_trigger_button(0, 9, 1); + iron_internal_gamepad_trigger_button(0, 9, 1); return 1; case AKEYCODE_MEDIA_REWIND: - kinc_internal_gamepad_trigger_button(0, 10, 1); + iron_internal_gamepad_trigger_button(0, 10, 1); return 1; case AKEYCODE_MEDIA_FAST_FORWARD: - kinc_internal_gamepad_trigger_button(0, 11, 1); + iron_internal_gamepad_trigger_button(0, 11, 1); return 1; case AKEYCODE_MEDIA_PLAY_PAUSE: - kinc_internal_gamepad_trigger_button(0, 12, 1); + iron_internal_gamepad_trigger_button(0, 12, 1); return 1; // (DK) /Amazon FireTV remote/controller mappings default: if (code >= AKEYCODE_NUMPAD_0 && code <= AKEYCODE_NUMPAD_9) { - kinc_internal_keyboard_trigger_key_down(code + KINC_KEY_NUMPAD_0 - AKEYCODE_NUMPAD_0); - kinc_internal_keyboard_trigger_key_press(code + KINC_KEY_NUMPAD_0 - AKEYCODE_NUMPAD_0); + iron_internal_keyboard_trigger_key_down(code + IRON_KEY_NUMPAD_0 - AKEYCODE_NUMPAD_0); + iron_internal_keyboard_trigger_key_press(code + IRON_KEY_NUMPAD_0 - AKEYCODE_NUMPAD_0); return 1; } else if (code >= AKEYCODE_0 && code <= AKEYCODE_9) { - kinc_internal_keyboard_trigger_key_down(code + KINC_KEY_0 - AKEYCODE_0); - kinc_internal_keyboard_trigger_key_press(code + KINC_KEY_0 - AKEYCODE_0); + iron_internal_keyboard_trigger_key_down(code + IRON_KEY_0 - AKEYCODE_0); + iron_internal_keyboard_trigger_key_press(code + IRON_KEY_0 - AKEYCODE_0); return 1; } else if (code >= AKEYCODE_A && code <= AKEYCODE_Z) { - kinc_internal_keyboard_trigger_key_down(code + KINC_KEY_A - AKEYCODE_A); - kinc_internal_keyboard_trigger_key_press(code + (shift ? 'A' : 'a') - AKEYCODE_A); + iron_internal_keyboard_trigger_key_down(code + IRON_KEY_A - AKEYCODE_A); + iron_internal_keyboard_trigger_key_press(code + (shift ? 'A' : 'a') - AKEYCODE_A); return 1; } } @@ -608,225 +608,225 @@ static int32_t input(struct android_app *app, AInputEvent *event) { if (shift) { switch (code) { case AKEYCODE_1: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_EXCLAMATION); + iron_internal_keyboard_trigger_key_up(IRON_KEY_EXCLAMATION); return 1; case AKEYCODE_4: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_DOLLAR); + iron_internal_keyboard_trigger_key_up(IRON_KEY_DOLLAR); return 1; case AKEYCODE_5: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_PERCENT); + iron_internal_keyboard_trigger_key_up(IRON_KEY_PERCENT); return 1; case AKEYCODE_6: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_CIRCUMFLEX); + iron_internal_keyboard_trigger_key_up(IRON_KEY_CIRCUMFLEX); return 1; case AKEYCODE_7: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_AMPERSAND); + iron_internal_keyboard_trigger_key_up(IRON_KEY_AMPERSAND); return 1; case AKEYCODE_9: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_OPEN_PAREN); + iron_internal_keyboard_trigger_key_up(IRON_KEY_OPEN_PAREN); return 1; case AKEYCODE_0: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_CLOSE_PAREN); + iron_internal_keyboard_trigger_key_up(IRON_KEY_CLOSE_PAREN); return 1; case AKEYCODE_COMMA: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_LESS_THAN); + iron_internal_keyboard_trigger_key_up(IRON_KEY_LESS_THAN); return 1; case AKEYCODE_PERIOD: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_GREATER_THAN); + iron_internal_keyboard_trigger_key_up(IRON_KEY_GREATER_THAN); return 1; case AKEYCODE_MINUS: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_UNDERSCORE); + iron_internal_keyboard_trigger_key_up(IRON_KEY_UNDERSCORE); return 1; case AKEYCODE_SLASH: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_QUESTIONMARK); + iron_internal_keyboard_trigger_key_up(IRON_KEY_QUESTIONMARK); return 1; case AKEYCODE_BACKSLASH: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_PIPE); + iron_internal_keyboard_trigger_key_up(IRON_KEY_PIPE); return 1; case AKEYCODE_LEFT_BRACKET: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_OPEN_CURLY_BRACKET); + iron_internal_keyboard_trigger_key_up(IRON_KEY_OPEN_CURLY_BRACKET); return 1; case AKEYCODE_RIGHT_BRACKET: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_CLOSE_CURLY_BRACKET); + iron_internal_keyboard_trigger_key_up(IRON_KEY_CLOSE_CURLY_BRACKET); return 1; case AKEYCODE_SEMICOLON: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_COLON); + iron_internal_keyboard_trigger_key_up(IRON_KEY_COLON); return 1; case AKEYCODE_APOSTROPHE: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_DOUBLE_QUOTE); + iron_internal_keyboard_trigger_key_up(IRON_KEY_DOUBLE_QUOTE); return 1; case AKEYCODE_GRAVE: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_TILDE); + iron_internal_keyboard_trigger_key_up(IRON_KEY_TILDE); return 1; } } switch (code) { case AKEYCODE_SHIFT_LEFT: case AKEYCODE_SHIFT_RIGHT: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_SHIFT); + iron_internal_keyboard_trigger_key_up(IRON_KEY_SHIFT); return 1; case AKEYCODE_DEL: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_BACKSPACE); + iron_internal_keyboard_trigger_key_up(IRON_KEY_BACKSPACE); return 1; case AKEYCODE_ENTER: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_RETURN); + iron_internal_keyboard_trigger_key_up(IRON_KEY_RETURN); return 1; case AKEYCODE_DPAD_CENTER: case AKEYCODE_BUTTON_B: - kinc_internal_gamepad_trigger_button(0, 1, 0); + iron_internal_gamepad_trigger_button(0, 1, 0); return 1; case AKEYCODE_BACK: if (AKeyEvent_getMetaState(event) & AMETA_ALT_ON) { // Xperia Play - kinc_internal_gamepad_trigger_button(0, 1, 0); + iron_internal_gamepad_trigger_button(0, 1, 0); return 1; } else { - kinc_internal_keyboard_trigger_key_up(KINC_KEY_BACK); + iron_internal_keyboard_trigger_key_up(IRON_KEY_BACK); return 1; } case AKEYCODE_BUTTON_A: - kinc_internal_gamepad_trigger_button(0, 0, 0); + iron_internal_gamepad_trigger_button(0, 0, 0); return 1; case AKEYCODE_BUTTON_Y: - kinc_internal_gamepad_trigger_button(0, 3, 0); + iron_internal_gamepad_trigger_button(0, 3, 0); return 1; case AKEYCODE_BUTTON_X: - kinc_internal_gamepad_trigger_button(0, 2, 0); + iron_internal_gamepad_trigger_button(0, 2, 0); return 1; case AKEYCODE_BUTTON_L1: - kinc_internal_gamepad_trigger_button(0, 4, 0); + iron_internal_gamepad_trigger_button(0, 4, 0); return 1; case AKEYCODE_BUTTON_R1: - kinc_internal_gamepad_trigger_button(0, 5, 0); + iron_internal_gamepad_trigger_button(0, 5, 0); return 1; case AKEYCODE_BUTTON_L2: - kinc_internal_gamepad_trigger_button(0, 6, 0); + iron_internal_gamepad_trigger_button(0, 6, 0); return 1; case AKEYCODE_BUTTON_R2: - kinc_internal_gamepad_trigger_button(0, 7, 0); + iron_internal_gamepad_trigger_button(0, 7, 0); return 1; case AKEYCODE_BUTTON_SELECT: - kinc_internal_gamepad_trigger_button(0, 8, 0); + iron_internal_gamepad_trigger_button(0, 8, 0); return 1; case AKEYCODE_BUTTON_START: - kinc_internal_gamepad_trigger_button(0, 9, 0); + iron_internal_gamepad_trigger_button(0, 9, 0); return 1; case AKEYCODE_BUTTON_THUMBL: - kinc_internal_gamepad_trigger_button(0, 10, 0); + iron_internal_gamepad_trigger_button(0, 10, 0); return 1; case AKEYCODE_BUTTON_THUMBR: - kinc_internal_gamepad_trigger_button(0, 11, 0); + iron_internal_gamepad_trigger_button(0, 11, 0); return 1; case AKEYCODE_DPAD_UP: if (isGamepadEvent(event)) - kinc_internal_gamepad_trigger_button(0, 12, 0); + iron_internal_gamepad_trigger_button(0, 12, 0); else - kinc_internal_keyboard_trigger_key_up(KINC_KEY_UP); + iron_internal_keyboard_trigger_key_up(IRON_KEY_UP); return 1; case AKEYCODE_DPAD_DOWN: if (isGamepadEvent(event)) - kinc_internal_gamepad_trigger_button(0, 13, 0); + iron_internal_gamepad_trigger_button(0, 13, 0); else - kinc_internal_keyboard_trigger_key_up(KINC_KEY_DOWN); + iron_internal_keyboard_trigger_key_up(IRON_KEY_DOWN); return 1; case AKEYCODE_DPAD_LEFT: if (isGamepadEvent(event)) - kinc_internal_gamepad_trigger_button(0, 14, 0); + iron_internal_gamepad_trigger_button(0, 14, 0); else - kinc_internal_keyboard_trigger_key_up(KINC_KEY_LEFT); + iron_internal_keyboard_trigger_key_up(IRON_KEY_LEFT); return 1; case AKEYCODE_DPAD_RIGHT: if (isGamepadEvent(event)) - kinc_internal_gamepad_trigger_button(0, 15, 0); + iron_internal_gamepad_trigger_button(0, 15, 0); else - kinc_internal_keyboard_trigger_key_up(KINC_KEY_RIGHT); + iron_internal_keyboard_trigger_key_up(IRON_KEY_RIGHT); return 1; case AKEYCODE_BUTTON_MODE: - kinc_internal_gamepad_trigger_button(0, 16, 0); + iron_internal_gamepad_trigger_button(0, 16, 0); return 1; case AKEYCODE_STAR: case AKEYCODE_NUMPAD_MULTIPLY: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_MULTIPLY); + iron_internal_keyboard_trigger_key_up(IRON_KEY_MULTIPLY); return 1; case AKEYCODE_POUND: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_HASH); + iron_internal_keyboard_trigger_key_up(IRON_KEY_HASH); return 1; case AKEYCODE_COMMA: case AKEYCODE_NUMPAD_COMMA: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_COMMA); + iron_internal_keyboard_trigger_key_up(IRON_KEY_COMMA); return 1; case AKEYCODE_PERIOD: case AKEYCODE_NUMPAD_DOT: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_PERIOD); + iron_internal_keyboard_trigger_key_up(IRON_KEY_PERIOD); return 1; case AKEYCODE_SPACE: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_SPACE); + iron_internal_keyboard_trigger_key_up(IRON_KEY_SPACE); return 1; case AKEYCODE_MINUS: case AKEYCODE_NUMPAD_SUBTRACT: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_HYPHEN_MINUS); + iron_internal_keyboard_trigger_key_up(IRON_KEY_HYPHEN_MINUS); return 1; case AKEYCODE_EQUALS: case AKEYCODE_NUMPAD_EQUALS: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_EQUALS); + iron_internal_keyboard_trigger_key_up(IRON_KEY_EQUALS); return 1; case AKEYCODE_LEFT_BRACKET: case AKEYCODE_NUMPAD_LEFT_PAREN: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_OPEN_BRACKET); + iron_internal_keyboard_trigger_key_up(IRON_KEY_OPEN_BRACKET); return 1; case AKEYCODE_RIGHT_BRACKET: case AKEYCODE_NUMPAD_RIGHT_PAREN: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_CLOSE_BRACKET); + iron_internal_keyboard_trigger_key_up(IRON_KEY_CLOSE_BRACKET); return 1; case AKEYCODE_BACKSLASH: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_BACK_SLASH); + iron_internal_keyboard_trigger_key_up(IRON_KEY_BACK_SLASH); return 1; case AKEYCODE_SEMICOLON: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_SEMICOLON); + iron_internal_keyboard_trigger_key_up(IRON_KEY_SEMICOLON); return 1; case AKEYCODE_APOSTROPHE: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_QUOTE); + iron_internal_keyboard_trigger_key_up(IRON_KEY_QUOTE); return 1; case AKEYCODE_GRAVE: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_BACK_QUOTE); + iron_internal_keyboard_trigger_key_up(IRON_KEY_BACK_QUOTE); return 1; case AKEYCODE_SLASH: case AKEYCODE_NUMPAD_DIVIDE: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_SLASH); + iron_internal_keyboard_trigger_key_up(IRON_KEY_SLASH); return 1; case AKEYCODE_AT: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_AT); + iron_internal_keyboard_trigger_key_up(IRON_KEY_AT); return 1; case AKEYCODE_PLUS: case AKEYCODE_NUMPAD_ADD: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_PLUS); + iron_internal_keyboard_trigger_key_up(IRON_KEY_PLUS); return 1; // (DK) Amazon FireTV remote/controller mappings // (DK) TODO handle multiple pads (up to 4 possible) case AKEYCODE_MENU: - kinc_internal_gamepad_trigger_button(0, 9, 0); + iron_internal_gamepad_trigger_button(0, 9, 0); return 1; case AKEYCODE_MEDIA_REWIND: - kinc_internal_gamepad_trigger_button(0, 10, 0); + iron_internal_gamepad_trigger_button(0, 10, 0); return 1; case AKEYCODE_MEDIA_FAST_FORWARD: - kinc_internal_gamepad_trigger_button(0, 11, 0); + iron_internal_gamepad_trigger_button(0, 11, 0); return 1; case AKEYCODE_MEDIA_PLAY_PAUSE: - kinc_internal_gamepad_trigger_button(0, 12, 0); + iron_internal_gamepad_trigger_button(0, 12, 0); return 1; // (DK) /Amazon FireTV remote/controller mappings default: if (code >= AKEYCODE_NUMPAD_0 && code <= AKEYCODE_NUMPAD_9) { - kinc_internal_keyboard_trigger_key_up(code + KINC_KEY_NUMPAD_0 - AKEYCODE_NUMPAD_0); + iron_internal_keyboard_trigger_key_up(code + IRON_KEY_NUMPAD_0 - AKEYCODE_NUMPAD_0); return 1; } else if (code >= AKEYCODE_0 && code <= AKEYCODE_9) { - kinc_internal_keyboard_trigger_key_up(code + KINC_KEY_0 - AKEYCODE_0); + iron_internal_keyboard_trigger_key_up(code + IRON_KEY_0 - AKEYCODE_0); return 1; } else if (code >= AKEYCODE_A && code <= AKEYCODE_Z) { - kinc_internal_keyboard_trigger_key_up(code + KINC_KEY_A - AKEYCODE_A); + iron_internal_keyboard_trigger_key_up(code + IRON_KEY_A - AKEYCODE_A); return 1; } } @@ -846,7 +846,7 @@ static void cmd(struct android_app *app, int32_t cmd) { } else { initDisplay(); - kinc_g5_swap_buffers(); + iron_g5_swap_buffers(); } updateAppForegroundStatus(true, appIsForeground); @@ -878,12 +878,12 @@ static void cmd(struct android_app *app, int32_t cmd) { updateAppForegroundStatus(displayIsInitialized, true); break; case APP_CMD_RESUME: - kinc_internal_resume_callback(); + iron_internal_resume_callback(); resumeAudio(); paused = false; break; case APP_CMD_PAUSE: - kinc_internal_pause_callback(); + iron_internal_pause_callback(); pauseAudio(); paused = true; break; @@ -891,7 +891,7 @@ static void cmd(struct android_app *app, int32_t cmd) { updateAppForegroundStatus(displayIsInitialized, false); break; case APP_CMD_DESTROY: - kinc_internal_shutdown_callback(); + iron_internal_shutdown_callback(); break; case APP_CMD_CONFIG_CHANGED: { @@ -904,15 +904,15 @@ static void resize(ANativeActivity *activity, ANativeWindow *window) { activityJustResized = true; } -ANativeActivity *kinc_android_get_activity(void) { +ANativeActivity *iron_android_get_activity(void) { return activity; } -AAssetManager *kinc_android_get_asset_manager(void) { +AAssetManager *iron_android_get_asset_manager(void) { return activity->assetManager; } -jclass kinc_android_find_class(JNIEnv *env, const char *name) { +jclass iron_android_find_class(JNIEnv *env, const char *name) { jobject nativeActivity = activity->clazz; jclass acl = (*env)->GetObjectClass(env, nativeActivity); jmethodID getClassLoader = (*env)->GetMethodID(env, acl, "getClassLoader", "()Ljava/lang/ClassLoader;"); @@ -928,35 +928,35 @@ jclass kinc_android_find_class(JNIEnv *env, const char *name) { #define UNICODE_STACK_SIZE 256 static uint16_t unicode_stack[UNICODE_STACK_SIZE]; static int unicode_stack_index = 0; -static kinc_mutex_t unicode_mutex; +static iron_mutex_t unicode_mutex; -JNIEXPORT void JNICALL Java_tech_kinc_KincActivity_nativeKincKeyPress(JNIEnv *env, jobject jobj, jstring chars) { +JNIEXPORT void JNICALL Java_org_armory3d_IronActivity_nativeIronKeyPress(JNIEnv *env, jobject jobj, jstring chars) { const jchar *text = (*env)->GetStringChars(env, chars, NULL); const jsize length = (*env)->GetStringLength(env, chars); - kinc_mutex_lock(&unicode_mutex); + iron_mutex_lock(&unicode_mutex); for (jsize i = 0; i < length && unicode_stack_index < UNICODE_STACK_SIZE; ++i) { unicode_stack[unicode_stack_index++] = text[i]; } - kinc_mutex_unlock(&unicode_mutex); + iron_mutex_unlock(&unicode_mutex); (*env)->ReleaseStringChars(env, chars, text); } -void KincAndroidKeyboardInit() { +void IronAndroidKeyboardInit() { JNIEnv *env; (*activity->vm)->AttachCurrentThread(activity->vm, &env, NULL); - jclass clazz = kinc_android_find_class(env, "tech.kinc.KincActivity"); + jclass clazz = iron_android_find_class(env, "org.armory3d.IronActivity"); // String chars - JNINativeMethod methodTable[] = {{"nativeKincKeyPress", "(Ljava/lang/String;)V", (void *)Java_tech_kinc_KincActivity_nativeKincKeyPress}}; + JNINativeMethod methodTable[] = {{"nativeIronKeyPress", "(Ljava/lang/String;)V", (void *)Java_org_armory3d_IronActivity_nativeIronKeyPress}}; int methodTableSize = sizeof(methodTable) / sizeof(methodTable[0]); int failure = (*env)->RegisterNatives(env, clazz, methodTable, methodTableSize); if (failure != 0) { - kinc_log("Failed to register KincActivity.nativeKincKeyPress"); + iron_log("Failed to register IronActivity.nativeIronKeyPress"); } (*activity->vm)->DetachCurrentThread(activity->vm); @@ -964,53 +964,53 @@ void KincAndroidKeyboardInit() { static bool keyboard_active = false; -void kinc_keyboard_show() { +void iron_keyboard_show() { keyboard_active = true; JNIEnv *env; (*activity->vm)->AttachCurrentThread(activity->vm, &env, NULL); - jclass koreActivityClass = kinc_android_find_class(env, "tech.kinc.KincActivity"); - (*env)->CallStaticVoidMethod(env, koreActivityClass, (*env)->GetStaticMethodID(env, koreActivityClass, "showKeyboard", "()V")); + jclass ironActivityClass = iron_android_find_class(env, "org.armory3d.IronActivity"); + (*env)->CallStaticVoidMethod(env, ironActivityClass, (*env)->GetStaticMethodID(env, ironActivityClass, "showKeyboard", "()V")); (*activity->vm)->DetachCurrentThread(activity->vm); } -void kinc_keyboard_hide() { +void iron_keyboard_hide() { keyboard_active = false; JNIEnv *env; (*activity->vm)->AttachCurrentThread(activity->vm, &env, NULL); - jclass koreActivityClass = kinc_android_find_class(env, "tech.kinc.KincActivity"); - (*env)->CallStaticVoidMethod(env, koreActivityClass, (*env)->GetStaticMethodID(env, koreActivityClass, "hideKeyboard", "()V")); + jclass ironActivityClass = iron_android_find_class(env, "org.armory3d.IronActivity"); + (*env)->CallStaticVoidMethod(env, ironActivityClass, (*env)->GetStaticMethodID(env, ironActivityClass, "hideKeyboard", "()V")); (*activity->vm)->DetachCurrentThread(activity->vm); } -bool kinc_keyboard_active() { +bool iron_keyboard_active() { return keyboard_active; } -void kinc_load_url(const char *url) { +void iron_load_url(const char *url) { JNIEnv *env; (*activity->vm)->AttachCurrentThread(activity->vm, &env, NULL); - jclass koreActivityClass = kinc_android_find_class(env, "tech.kinc.KincActivity"); + jclass ironActivityClass = iron_android_find_class(env, "org.armory3d.IronActivity"); jstring jurl = (*env)->NewStringUTF(env, url); - (*env)->CallStaticVoidMethod(env, koreActivityClass, (*env)->GetStaticMethodID(env, koreActivityClass, "loadURL", "(Ljava/lang/String;)V"), jurl); + (*env)->CallStaticVoidMethod(env, ironActivityClass, (*env)->GetStaticMethodID(env, ironActivityClass, "loadURL", "(Ljava/lang/String;)V"), jurl); (*activity->vm)->DetachCurrentThread(activity->vm); } -const char *kinc_language() { +const char *iron_language() { JNIEnv *env; (*activity->vm)->AttachCurrentThread(activity->vm, &env, NULL); - jclass koreActivityClass = kinc_android_find_class(env, "tech.kinc.KincActivity"); - jstring s = (jstring)(*env)->CallStaticObjectMethod(env, koreActivityClass, - (*env)->GetStaticMethodID(env, koreActivityClass, "getLanguage", "()Ljava/lang/String;")); + jclass ironActivityClass = iron_android_find_class(env, "org.armory3d.IronActivity"); + jstring s = (jstring)(*env)->CallStaticObjectMethod(env, ironActivityClass, + (*env)->GetStaticMethodID(env, ironActivityClass, "getLanguage", "()Ljava/lang/String;")); const char *str = (*env)->GetStringUTFChars(env, s, 0); (*activity->vm)->DetachCurrentThread(activity->vm); return str; } -bool kinc_vulkan_internal_get_size(int *width, int *height); +bool iron_vulkan_internal_get_size(int *width, int *height); -int kinc_android_width() { +int iron_android_width() { int width, height; - if (kinc_vulkan_internal_get_size(&width, &height)) { + if (iron_vulkan_internal_get_size(&width, &height)) { return width; } else { @@ -1018,9 +1018,9 @@ int kinc_android_width() { } } -int kinc_android_height() { +int iron_android_height() { int width, height; - if (kinc_vulkan_internal_get_size(&width, &height)) { + if (iron_vulkan_internal_get_size(&width, &height)) { return height; } else { @@ -1028,21 +1028,21 @@ int kinc_android_height() { } } -const char *kinc_internal_save_path() { - return kinc_android_get_activity()->internalDataPath; +const char *iron_internal_save_path() { + return iron_android_get_activity()->internalDataPath; } -const char *kinc_system_id() { +const char *iron_system_id() { return "Android"; } static const char *videoFormats[] = {"ts", NULL}; -const char **kinc_video_formats() { +const char **iron_video_formats() { return videoFormats; } -void kinc_set_keep_screen_on(bool on) { +void iron_set_keep_screen_on(bool on) { if (on) { ANativeActivity_setWindowFlags(activity, AWINDOW_FLAG_KEEP_SCREEN_ON, 0); } @@ -1053,31 +1053,31 @@ void kinc_set_keep_screen_on(bool on) { static __kernel_time_t start_sec = 0; -double kinc_frequency() { +double iron_frequency() { return 1000000.0; } -kinc_ticks_t kinc_timestamp() { +iron_ticks_t iron_timestamp() { struct timeval now; gettimeofday(&now, NULL); - return (kinc_ticks_t)(now.tv_sec - start_sec) * 1000000 + (kinc_ticks_t)(now.tv_usec); + return (iron_ticks_t)(now.tv_sec - start_sec) * 1000000 + (iron_ticks_t)(now.tv_usec); } -double kinc_time() { +double iron_time() { struct timeval now; gettimeofday(&now, NULL); return (double)(now.tv_sec - start_sec) + (now.tv_usec / 1000000.0); } -void kinc_internal_resize(int width, int height); +void iron_internal_resize(int width, int height); -bool kinc_internal_handle_messages(void) { - kinc_mutex_lock(&unicode_mutex); +bool iron_internal_handle_messages(void) { + iron_mutex_lock(&unicode_mutex); for (int i = 0; i < unicode_stack_index; ++i) { - kinc_internal_keyboard_trigger_key_press(unicode_stack[i]); + iron_internal_keyboard_trigger_key_press(unicode_stack[i]); } unicode_stack_index = 0; - kinc_mutex_unlock(&unicode_mutex); + iron_mutex_unlock(&unicode_mutex); int ident; int events; @@ -1093,10 +1093,10 @@ bool kinc_internal_handle_messages(void) { ASensorEvent event; while (ASensorEventQueue_getEvents(sensorEventQueue, &event, 1) > 0) { if (event.type == ASENSOR_TYPE_ACCELEROMETER) { - // kinc_internal_on_acceleration(event.acceleration.x, event.acceleration.y, event.acceleration.z); + // iron_internal_on_acceleration(event.acceleration.x, event.acceleration.y, event.acceleration.z); } else if (event.type == ASENSOR_TYPE_GYROSCOPE) { - // kinc_internal_on_rotation(event.vector.x, event.vector.y, event.vector.z); + // iron_internal_on_rotation(event.vector.x, event.vector.y, event.vector.z); } } } @@ -1104,63 +1104,63 @@ bool kinc_internal_handle_messages(void) { if (app->destroyRequested != 0) { termDisplay(); - kinc_stop(); + iron_stop(); return true; } } if (activityJustResized && app->window != NULL) { activityJustResized = false; - int32_t width = kinc_android_width(); - int32_t height = kinc_android_height(); -#ifdef KINC_VULKAN - kinc_internal_resize(0, width, height); + int32_t width = iron_android_width(); + int32_t height = iron_android_height(); +#ifdef IRON_VULKAN + iron_internal_resize(0, width, height); #endif - kinc_internal_call_resize_callback(width, height); + iron_internal_call_resize_callback(width, height); } // Get screen rotation /* JNIEnv* env; (*activity->vm)->AttachCurrentThread(&env, NULL); - jclass koreActivityClass = KoreAndroid::findClass(env, "tech.kode.kore.KoreActivity"); - jmethodID koreActivityGetRotation = (*env)->GetStaticMethodID(koreActivityClass, "getRotation", "()I"); - screenRotation = (*env)->CallStaticIntMethod(koreActivityClass, koreActivityGetRotation); + jclass ironActivityClass = IronAndroid::findClass(env, "org.armory3d.IronActivity"); + jmethodID ironActivityGetRotation = (*env)->GetStaticMethodID(ironActivityClass, "getRotation", "()I"); + screenRotation = (*env)->CallStaticIntMethod(ironActivityClass, ironActivityGetRotation); (*activity->vm)->DetachCurrentThread(); */ return true; } -bool kinc_mouse_can_lock(void) { +bool iron_mouse_can_lock(void) { return false; } -void kinc_mouse_show() {} +void iron_mouse_show() {} -void kinc_mouse_hide() {} +void iron_mouse_hide() {} -void kinc_mouse_set_position(int x, int y) {} +void iron_mouse_set_position(int x, int y) {} -void kinc_internal_mouse_lock() {} +void iron_internal_mouse_lock() {} -void kinc_internal_mouse_unlock(void) {} +void iron_internal_mouse_unlock(void) {} -void kinc_mouse_get_position(int *x, int *y) { +void iron_mouse_get_position(int *x, int *y) { x = 0; y = 0; } -void kinc_mouse_set_cursor(int cursor_index) {} +void iron_mouse_set_cursor(int cursor_index) {} -bool kinc_gamepad_connected(int num) { +bool iron_gamepad_connected(int num) { return num == 0; } -void kinc_gamepad_rumble(int gamepad, float left, float right) {} +void iron_gamepad_rumble(int gamepad, float left, float right) {} void initAndroidFileReader(); -void KoreAndroidVideoInit(); +void IronAndroidVideoInit(); void android_main(struct android_app *application) { app_dummy(); @@ -1172,8 +1172,8 @@ void android_main(struct android_app *application) { app = application; activity = application->activity; initAndroidFileReader(); - KoreAndroidVideoInit(); - KincAndroidKeyboardInit(); + IronAndroidVideoInit(); + IronAndroidKeyboardInit(); application->onAppCmd = cmd; application->onInputEvent = input; activity->callbacks->onNativeWindowResized = resize; @@ -1183,57 +1183,57 @@ void android_main(struct android_app *application) { sensorEventQueue = ASensorManager_createEventQueue(sensorManager, application->looper, LOOPER_ID_USER, NULL, NULL); JNIEnv *env = NULL; - (*kinc_android_get_activity()->vm)->AttachCurrentThread(kinc_android_get_activity()->vm, &env, NULL); + (*iron_android_get_activity()->vm)->AttachCurrentThread(iron_android_get_activity()->vm, &env, NULL); - jclass koreMoviePlayerClass = kinc_android_find_class(env, "tech.kinc.KincMoviePlayer"); - jmethodID updateAll = (*env)->GetStaticMethodID(env, koreMoviePlayerClass, "updateAll", "()V"); + jclass ironMoviePlayerClass = iron_android_find_class(env, "org.armory3d.IronMoviePlayer"); + jmethodID updateAll = (*env)->GetStaticMethodID(env, ironMoviePlayerClass, "updateAll", "()V"); while (!started) { - kinc_internal_handle_messages(); - (*env)->CallStaticVoidMethod(env, koreMoviePlayerClass, updateAll); + iron_internal_handle_messages(); + (*env)->CallStaticVoidMethod(env, ironMoviePlayerClass, updateAll); } - (*kinc_android_get_activity()->vm)->DetachCurrentThread(kinc_android_get_activity()->vm); + (*iron_android_get_activity()->vm)->DetachCurrentThread(iron_android_get_activity()->vm); kickstart(0, NULL); (*activity->vm)->AttachCurrentThread(activity->vm, &env, NULL); - jclass koreActivityClass = kinc_android_find_class(env, "tech.kinc.KincActivity"); - jmethodID FinishHim = (*env)->GetStaticMethodID(env, koreActivityClass, "stop", "()V"); - (*env)->CallStaticVoidMethod(env, koreActivityClass, FinishHim); + jclass ironActivityClass = iron_android_find_class(env, "org.armory3d.IronActivity"); + jmethodID FinishHim = (*env)->GetStaticMethodID(env, ironActivityClass, "stop", "()V"); + (*env)->CallStaticVoidMethod(env, ironActivityClass, FinishHim); (*activity->vm)->DetachCurrentThread(activity->vm); } -void kinc_init(const char *name, int width, int height, struct kinc_window_options *win) { - kinc_mutex_init(&unicode_mutex); +void iron_init(const char *name, int width, int height, struct iron_window_options *win) { + iron_mutex_init(&unicode_mutex); - kinc_window_options_t default_win; + iron_window_options_t default_win; if (win == NULL) { - kinc_window_options_set_defaults(&default_win); + iron_window_options_set_defaults(&default_win); win = &default_win; } win->width = width; win->height = height; - kinc_g5_internal_init(); - kinc_g4_internal_init_window(win->depth_bits, true); + iron_g5_internal_init(); + iron_g4_internal_init_window(win->depth_bits, true); - kinc_internal_gamepad_trigger_connect(0); + iron_internal_gamepad_trigger_connect(0); } -void kinc_internal_shutdown(void) { - kinc_internal_gamepad_trigger_disconnect(0); +void iron_internal_shutdown(void) { + iron_internal_gamepad_trigger_disconnect(0); } -const char *kinc_gamepad_vendor(int gamepad) { +const char *iron_gamepad_vendor(int gamepad) { return "Google"; } -const char *kinc_gamepad_product_name(int gamepad) { +const char *iron_gamepad_product_name(int gamepad) { return "gamepad"; } void initAndroidFileReader(void) { if (activity == NULL) { - kinc_error("Android activity is NULL"); + iron_error("Android activity is NULL"); return; } @@ -1251,118 +1251,118 @@ void initAndroidFileReader(void) { const char *path = (*env)->GetStringUTFChars(env, jPath, NULL); char *externalFilesDir = malloc(strlen(path) + 1); strcpy(externalFilesDir, path); - kinc_internal_set_files_location(externalFilesDir); + iron_internal_set_files_location(externalFilesDir); (*env)->ReleaseStringUTFChars(env, jPath, path); (*env)->DeleteLocalRef(env, jPath); (*activity->vm)->DetachCurrentThread(activity->vm); } -static bool kinc_aasset_reader_close(kinc_file_reader_t *reader) { +static bool iron_aasset_reader_close(iron_file_reader_t *reader) { AAsset_close((struct AAsset *)reader->data); return true; } -static size_t kinc_aasset_reader_read(kinc_file_reader_t *reader, void *data, size_t size) { +static size_t iron_aasset_reader_read(iron_file_reader_t *reader, void *data, size_t size) { return AAsset_read((struct AAsset *)reader->data, data, size); } -static size_t kinc_aasset_reader_pos(kinc_file_reader_t *reader) { +static size_t iron_aasset_reader_pos(iron_file_reader_t *reader) { return (size_t)AAsset_seek((struct AAsset *)reader->data, 0, SEEK_CUR); } -static bool kinc_aasset_reader_seek(kinc_file_reader_t *reader, size_t pos) { +static bool iron_aasset_reader_seek(iron_file_reader_t *reader, size_t pos) { AAsset_seek((struct AAsset *)reader->data, pos, SEEK_SET); return true; } -static bool kinc_aasset_reader_open(kinc_file_reader_t *reader, const char *filename, int type) { - if (type != KINC_FILE_TYPE_ASSET) +static bool iron_aasset_reader_open(iron_file_reader_t *reader, const char *filename, int type) { + if (type != IRON_FILE_TYPE_ASSET) return false; - reader->data = AAssetManager_open(kinc_android_get_asset_manager(), filename, AASSET_MODE_RANDOM); + reader->data = AAssetManager_open(iron_android_get_asset_manager(), filename, AASSET_MODE_RANDOM); if (reader->data == NULL) return false; reader->size = AAsset_getLength((struct AAsset *)reader->data); - reader->close = kinc_aasset_reader_close; - reader->read = kinc_aasset_reader_read; - reader->pos = kinc_aasset_reader_pos; - reader->seek = kinc_aasset_reader_seek; + reader->close = iron_aasset_reader_close; + reader->read = iron_aasset_reader_read; + reader->pos = iron_aasset_reader_pos; + reader->seek = iron_aasset_reader_seek; return true; } -bool kinc_file_reader_open(kinc_file_reader_t *reader, const char *filename, int type) { +bool iron_file_reader_open(iron_file_reader_t *reader, const char *filename, int type) { memset(reader, 0, sizeof(*reader)); - return kinc_internal_file_reader_callback(reader, filename, type) || - kinc_internal_file_reader_open(reader, filename, type) || - kinc_aasset_reader_open(reader, filename, type); + return iron_internal_file_reader_callback(reader, filename, type) || + iron_internal_file_reader_open(reader, filename, type) || + iron_aasset_reader_open(reader, filename, type); } -int kinc_cpu_cores(void) { - return kinc_hardware_threads(); +int iron_cpu_cores(void) { + return iron_hardware_threads(); } -int kinc_hardware_threads(void) { +int iron_hardware_threads(void) { return sysconf(_SC_NPROCESSORS_ONLN); } static void (*resizeCallback)(int x, int y, void *data) = NULL; static void *resizeCallbackData = NULL; -int kinc_window_x() { +int iron_window_x() { return 0; } -int kinc_window_y() { +int iron_window_y() { return 0; } -int kinc_android_width(); +int iron_android_width(); -int kinc_window_width() { - return kinc_android_width(); +int iron_window_width() { + return iron_android_width(); } -int kinc_android_height(); +int iron_android_height(); -int kinc_window_height() { - return kinc_android_height(); +int iron_window_height() { + return iron_android_height(); } -void kinc_window_resize(int width, int height) {} +void iron_window_resize(int width, int height) {} -void kinc_window_move(int x, int y) {} +void iron_window_move(int x, int y) {} -void kinc_window_change_features(int features) {} +void iron_window_change_features(int features) {} -void kinc_window_change_mode(kinc_window_mode_t mode) {} +void iron_window_change_mode(iron_window_mode_t mode) {} -void kinc_window_destroy() {} +void iron_window_destroy() {} -void kinc_window_show() {} +void iron_window_show() {} -void kinc_window_hide() {} +void iron_window_hide() {} -void kinc_window_set_title(const char *title) {} +void iron_window_set_title(const char *title) {} -void kinc_window_create(kinc_window_options_t *win) {} +void iron_window_create(iron_window_options_t *win) {} -void kinc_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) { +void iron_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) { resizeCallback = callback; resizeCallbackData = data; } -void kinc_internal_call_resize_callback(int width, int height) { +void iron_internal_call_resize_callback(int width, int height) { if (resizeCallback != NULL) { resizeCallback(width, height, resizeCallbackData); } } -void kinc_window_set_close_callback(bool (*callback)(void *), void *data) {} +void iron_window_set_close_callback(bool (*callback)(void *), void *data) {} -kinc_window_mode_t kinc_window_get_mode() { - return KINC_WINDOW_MODE_FULLSCREEN; +iron_window_mode_t iron_window_get_mode() { + return IRON_WINDOW_MODE_FULLSCREEN; } -int kinc_window_display() { +int iron_window_display() { return 0; } diff --git a/base/sources/backends/android_system.h b/base/sources/backends/android_system.h index cf2e43b3..2b280aa1 100644 --- a/base/sources/backends/android_system.h +++ b/base/sources/backends/android_system.h @@ -3,6 +3,6 @@ #include // name in usual Java syntax (points, no slashes) -jclass kinc_android_find_class(JNIEnv *env, const char *name); -ANativeActivity *kinc_android_get_activity(void); -AAssetManager *kinc_android_get_asset_manager(void); +jclass iron_android_find_class(JNIEnv *env, const char *name); +ANativeActivity *iron_android_get_activity(void); +AAssetManager *iron_android_get_asset_manager(void); diff --git a/base/sources/backends/android_video.c b/base/sources/backends/android_video.c index 2712a306..a5296084 100644 --- a/base/sources/backends/android_video.c +++ b/base/sources/backends/android_video.c @@ -1,6 +1,6 @@ // #include -// #include +// #include // #include // #include // #include @@ -14,7 +14,7 @@ // #include // #include -// void kinc_video_sound_stream_impl_init(kinc_internal_video_sound_stream_t *stream, int channel_count, int frequency) { +// void iron_video_sound_stream_impl_init(iron_internal_video_sound_stream_t *stream, int channel_count, int frequency) { // stream->bufferSize = 1; // stream->bufferReadPosition = 0; // stream->bufferWritePosition = 0; @@ -22,85 +22,85 @@ // stream->written = 0; // } -// void kinc_video_sound_stream_impl_destroy(kinc_internal_video_sound_stream_t *stream) {} +// void iron_video_sound_stream_impl_destroy(iron_internal_video_sound_stream_t *stream) {} -// void kinc_video_sound_stream_impl_insert_data(kinc_internal_video_sound_stream_t *stream, float *data, int sample_count) {} +// void iron_video_sound_stream_impl_insert_data(iron_internal_video_sound_stream_t *stream, float *data, int sample_count) {} // static float samples[2] = {0}; -// float *kinc_internal_video_sound_stream_next_frame(kinc_internal_video_sound_stream_t *stream) { +// float *iron_internal_video_sound_stream_next_frame(iron_internal_video_sound_stream_t *stream) { // return samples; // } -// bool kinc_internal_video_sound_stream_ended(kinc_internal_video_sound_stream_t *stream) { +// bool iron_internal_video_sound_stream_ended(iron_internal_video_sound_stream_t *stream) { // return false; // } -// JNIEXPORT void JNICALL Java_tech_kinc_KincMoviePlayer_nativeCreate(JNIEnv *env, jobject jobj, jstring jpath, jobject surface, jint id) { +// JNIEXPORT void JNICALL Java_org_armory3d_IronMoviePlayer_nativeCreate(JNIEnv *env, jobject jobj, jstring jpath, jobject surface, jint id) { // } -// void KoreAndroidVideoInit() { +// void IronAndroidVideoInit() { // JNIEnv *env; -// (*kinc_android_get_activity()->vm)->AttachCurrentThread(kinc_android_get_activity()->vm, &env, NULL); +// (*iron_android_get_activity()->vm)->AttachCurrentThread(iron_android_get_activity()->vm, &env, NULL); -// jclass clazz = kinc_android_find_class(env, "tech.kinc.KincMoviePlayer"); +// jclass clazz = iron_android_find_class(env, "org.armory3d.IronMoviePlayer"); // // String path, Surface surface, int id -// JNINativeMethod methodTable[] = {{"nativeCreate", "(Ljava/lang/String;Landroid/view/Surface;I)V", (void *)Java_tech_kinc_KincMoviePlayer_nativeCreate}}; +// JNINativeMethod methodTable[] = {{"nativeCreate", "(Ljava/lang/String;Landroid/view/Surface;I)V", (void *)Java_org_armory3d_IronMoviePlayer_nativeCreate}}; // int methodTableSize = sizeof(methodTable) / sizeof(methodTable[0]); // int failure = (*env)->RegisterNatives(env, clazz, methodTable, methodTableSize); // if (failure != 0) { -// kinc_log("Failed to register KincMoviePlayer.nativeCreate"); +// iron_log("Failed to register IronMoviePlayer.nativeCreate"); // } -// (*kinc_android_get_activity()->vm)->DetachCurrentThread(kinc_android_get_activity()->vm); +// (*iron_android_get_activity()->vm)->DetachCurrentThread(iron_android_get_activity()->vm); // } -// void kinc_video_init(kinc_video_t *video, const char *filename) { +// void iron_video_init(iron_video_t *video, const char *filename) { // video->impl.playing = false; // video->impl.sound = NULL; // } -// void kinc_video_destroy(kinc_video_t *video) { +// void iron_video_destroy(iron_video_t *video) { // } -// void kinc_video_play(kinc_video_t *video, bool loop) { +// void iron_video_play(iron_video_t *video, bool loop) { // } -// void kinc_video_pause(kinc_video_t *video) { +// void iron_video_pause(iron_video_t *video) { // } -// void kinc_video_stop(kinc_video_t *video) { +// void iron_video_stop(iron_video_t *video) { // } -// void kinc_video_update(kinc_video_t *video, double time) {} +// void iron_video_update(iron_video_t *video, double time) {} -// int kinc_video_width(kinc_video_t *video) { +// int iron_video_width(iron_video_t *video) { // return 512; // } -// int kinc_video_height(kinc_video_t *video) { +// int iron_video_height(iron_video_t *video) { // return 512; // } -// kinc_g5_texture_t *kinc_video_current_image(kinc_video_t *video) { +// iron_g5_texture_t *iron_video_current_image(iron_video_t *video) { // return NULL; // } -// double kinc_video_duration(kinc_video_t *video) { +// double iron_video_duration(iron_video_t *video) { // return 0.0; // } -// double kinc_video_position(kinc_video_t *video) { +// double iron_video_position(iron_video_t *video) { // return 0.0; // } -// bool kinc_video_finished(kinc_video_t *video) { +// bool iron_video_finished(iron_video_t *video) { // return false; // } -// bool kinc_video_paused(kinc_video_t *video) { +// bool iron_video_paused(iron_video_t *video) { // return !video->impl.playing; // } diff --git a/base/sources/backends/android_video.h b/base/sources/backends/android_video.h index 80fb3684..b6bc25bc 100644 --- a/base/sources/backends/android_video.h +++ b/base/sources/backends/android_video.h @@ -13,13 +13,13 @@ // void *sound; // void *androidVideo; // int id; -// kinc_g5_texture_t image; +// iron_g5_texture_t image; // double lastTime; // int myWidth; // int myHeight; -// } kinc_video_impl_t; +// } iron_video_impl_t; -// typedef struct kinc_internal_video_sound_stream { +// typedef struct iron_internal_video_sound_stream { // void *audioTrackOutput; // float *buffer; // int bufferSize; @@ -27,10 +27,10 @@ // int bufferReadPosition; // uint64_t read; // uint64_t written; -// } kinc_internal_video_sound_stream_t; +// } iron_internal_video_sound_stream_t; -// void kinc_internal_video_sound_stream_init(kinc_internal_video_sound_stream_t *stream, int channel_count, int frequency); -// void kinc_internal_video_sound_stream_destroy(kinc_internal_video_sound_stream_t *stream); -// void kinc_internal_video_sound_stream_insert_data(kinc_internal_video_sound_stream_t *stream, float *data, int sample_count); -// float *kinc_internal_video_sound_stream_next_frame(kinc_internal_video_sound_stream_t *stream); -// bool kinc_internal_video_sound_stream_ended(kinc_internal_video_sound_stream_t *stream); +// void iron_internal_video_sound_stream_init(iron_internal_video_sound_stream_t *stream, int channel_count, int frequency); +// void iron_internal_video_sound_stream_destroy(iron_internal_video_sound_stream_t *stream); +// void iron_internal_video_sound_stream_insert_data(iron_internal_video_sound_stream_t *stream, float *data, int sample_count); +// float *iron_internal_video_sound_stream_next_frame(iron_internal_video_sound_stream_t *stream); +// bool iron_internal_video_sound_stream_ended(iron_internal_video_sound_stream_t *stream); diff --git a/base/sources/backends/apple_net.m b/base/sources/backends/apple_net.m index f0ee93d4..032891e2 100644 --- a/base/sources/backends/apple_net.m +++ b/base/sources/backends/apple_net.m @@ -2,8 +2,8 @@ #import -void kinc_http_request(const char *url, const char *path, const char *data, int port, bool secure, int method, const char *header, - kinc_http_callback_t callback, void *callbackdata) { +void iron_http_request(const char *url, const char *path, const char *data, int port, bool secure, int method, const char *header, + iron_http_callback_t callback, void *callbackdata) { NSString *urlstring = secure ? @"https://" : @"http://"; urlstring = [urlstring stringByAppendingString:[NSString stringWithUTF8String:url]]; urlstring = [urlstring stringByAppendingString:@":"]; @@ -24,16 +24,16 @@ void kinc_http_request(const char *url, const char *path, const char *data, int } switch (method) { - case KINC_HTTP_GET: + case IRON_HTTP_GET: request.HTTPMethod = @"GET"; break; - case KINC_HTTP_POST: + case IRON_HTTP_POST: request.HTTPMethod = @"POST"; break; - case KINC_HTTP_PUT: + case IRON_HTTP_PUT: request.HTTPMethod = @"PUT"; break; - case KINC_HTTP_DELETE: + case IRON_HTTP_DELETE: request.HTTPMethod = @"DELETE"; break; } diff --git a/base/sources/backends/apple_thread.m b/base/sources/backends/apple_thread.m index f45bd687..2a9bd6ac 100644 --- a/base/sources/backends/apple_thread.m +++ b/base/sources/backends/apple_thread.m @@ -9,14 +9,14 @@ static void *ThreadProc(void *arg) { @autoreleasepool { - kinc_thread_t *t = (kinc_thread_t *)arg; + iron_thread_t *t = (iron_thread_t *)arg; t->impl.thread(t->impl.param); pthread_exit(NULL); return NULL; } } -void kinc_thread_init(kinc_thread_t *t, void (*thread)(void *param), void *param) { +void iron_thread_init(iron_thread_t *t, void (*thread)(void *param), void *param) { t->impl.param = param; t->impl.thread = thread; pthread_attr_t attr; @@ -30,25 +30,25 @@ void kinc_thread_init(kinc_thread_t *t, void (*thread)(void *param), void *param pthread_attr_destroy(&attr); } -void kinc_thread_wait_and_destroy(kinc_thread_t *thread) { +void iron_thread_wait_and_destroy(iron_thread_t *thread) { int ret; do { ret = pthread_join(thread->impl.pthread, NULL); } while (ret != 0); } -bool kinc_thread_try_to_destroy(kinc_thread_t *thread) { +bool iron_thread_try_to_destroy(iron_thread_t *thread) { return pthread_join(thread->impl.pthread, NULL) == 0; } -void kinc_threads_init(void) {} +void iron_threads_init(void) {} -void kinc_threads_quit(void) {} +void iron_threads_quit(void) {} -int kinc_hardware_threads(void) { +int iron_hardware_threads(void) { return (int)[[NSProcessInfo processInfo] processorCount]; } -int kinc_cpu_cores(void) { - return kinc_hardware_threads(); +int iron_cpu_cores(void) { + return iron_hardware_threads(); } diff --git a/base/sources/backends/apple_video.h b/base/sources/backends/apple_video.h index 1fa9931d..59448777 100644 --- a/base/sources/backends/apple_video.h +++ b/base/sources/backends/apple_video.h @@ -12,7 +12,7 @@ // bool loop; // void *sound; // bool image_initialized; -// kinc_g5_texture_t image; +// iron_g5_texture_t image; // double lastTime; // float duration; // bool finished; @@ -24,19 +24,19 @@ // id videoTrackOutput; // id audioTrackOutput; // id url; -// } kinc_video_impl_t; +// } iron_video_impl_t; -// typedef struct kinc_internal_video_sound_stream { +// typedef struct iron_internal_video_sound_stream { // float *buffer; // int bufferSize; // int bufferWritePosition; // int bufferReadPosition; // uint64_t read; // uint64_t written; -// } kinc_internal_video_sound_stream_t; +// } iron_internal_video_sound_stream_t; -// void kinc_internal_video_sound_stream_init(kinc_internal_video_sound_stream_t *stream, int channel_count, int frequency); -// void kinc_internal_video_sound_stream_destroy(kinc_internal_video_sound_stream_t *stream); -// void kinc_internal_video_sound_stream_insert_data(kinc_internal_video_sound_stream_t *stream, float *data, int sample_count); -// float *kinc_internal_video_sound_stream_next_frame(kinc_internal_video_sound_stream_t *stream); -// bool kinc_internal_video_sound_stream_ended(kinc_internal_video_sound_stream_t *stream); +// void iron_internal_video_sound_stream_init(iron_internal_video_sound_stream_t *stream, int channel_count, int frequency); +// void iron_internal_video_sound_stream_destroy(iron_internal_video_sound_stream_t *stream); +// void iron_internal_video_sound_stream_insert_data(iron_internal_video_sound_stream_t *stream, float *data, int sample_count); +// float *iron_internal_video_sound_stream_next_frame(iron_internal_video_sound_stream_t *stream); +// bool iron_internal_video_sound_stream_ended(iron_internal_video_sound_stream_t *stream); diff --git a/base/sources/backends/apple_video.m b/base/sources/backends/apple_video.m index a09abf52..102ab7f0 100644 --- a/base/sources/backends/apple_video.m +++ b/base/sources/backends/apple_video.m @@ -12,7 +12,7 @@ // extern const char *iphonegetresourcepath(void); // extern const char *macgetresourcepath(void); -// void kinc_internal_video_sound_stream_init(kinc_internal_video_sound_stream_t *stream, int channel_count, int frequency) { +// void iron_internal_video_sound_stream_init(iron_internal_video_sound_stream_t *stream, int channel_count, int frequency) { // stream->bufferSize = 1024 * 100; // stream->bufferReadPosition = 0; // stream->bufferWritePosition = 0; @@ -21,11 +21,11 @@ // stream->buffer = (float *)malloc(stream->bufferSize * sizeof(float)); // } -// void kinc_internal_video_sound_stream_destroy(kinc_internal_video_sound_stream_t *stream) { +// void iron_internal_video_sound_stream_destroy(iron_internal_video_sound_stream_t *stream) { // free(stream->buffer); // } -// void kinc_internal_video_sound_stream_insert_data(kinc_internal_video_sound_stream_t *stream, float *data, int sample_count) { +// void iron_internal_video_sound_stream_insert_data(iron_internal_video_sound_stream_t *stream, float *data, int sample_count) { // for (int i = 0; i < sample_count; ++i) { // float value = data[i]; // / 32767.0; // stream->buffer[stream->bufferWritePosition++] = value; @@ -38,33 +38,33 @@ // static float samples[2] = {0}; -// float *kinc_internal_video_sound_stream_next_frame(kinc_internal_video_sound_stream_t *stream) { +// float *iron_internal_video_sound_stream_next_frame(iron_internal_video_sound_stream_t *stream) { // ++stream->read; // if (stream->written <= stream->read) { -// kinc_log("Out of audio\n"); +// iron_log("Out of audio\n"); // return 0; // } // if (stream->bufferReadPosition >= stream->bufferSize) { // stream->bufferReadPosition = 0; -// kinc_log("buffer read back - %i\n", (int)(stream->written - stream->read)); +// iron_log("buffer read back - %i\n", (int)(stream->written - stream->read)); // } // samples[0] = stream->buffer[stream->bufferReadPosition++]; // if (stream->bufferReadPosition >= stream->bufferSize) { // stream->bufferReadPosition = 0; -// kinc_log("buffer read back - %i\n", (int)(stream->written - stream->read)); +// iron_log("buffer read back - %i\n", (int)(stream->written - stream->read)); // } // samples[1] = stream->buffer[stream->bufferReadPosition++]; // return samples; // } -// bool kinc_internal_video_sound_stream_ended(kinc_internal_video_sound_stream_t *stream) { +// bool iron_internal_video_sound_stream_ended(iron_internal_video_sound_stream_t *stream) { // return false; // } -// static void load(kinc_video_t *video, double startTime) { +// static void load(iron_video_t *video, double startTime) { // video->impl.videoStart = startTime; // AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:video->impl.url options:nil]; // video->impl.videoAsset = asset; @@ -115,23 +115,23 @@ // if (video->impl.myHeight < 0) // video->impl.myHeight = [videoTrack naturalSize].height; // int framerate = [videoTrack nominalFrameRate]; -// kinc_log("Framerate: %i\n", framerate); +// iron_log("Framerate: %i\n", framerate); // video->impl.next = video->impl.videoStart; // video->impl.audioTime = video->impl.videoStart * 44100; // } -// void kinc_video_init(kinc_video_t *video, const char *filename) { +// void iron_video_init(iron_video_t *video, const char *filename) { // video->impl.playing = false; // video->impl.sound = NULL; // video->impl.image_initialized = false; // char name[2048]; -// #ifdef KINC_IOS +// #ifdef IRON_IOS // strcpy(name, iphonegetresourcepath()); // #else // strcpy(name, macgetresourcepath()); // #endif // strcat(name, "/"); -// strcat(name, KINC_OUTDIR); +// strcat(name, IRON_OUTDIR); // strcat(name, "/"); // strcat(name, filename); // video->impl.url = [NSURL fileURLWithPath:[NSString stringWithUTF8String:name]]; @@ -142,57 +142,57 @@ // load(video, 0); // } -// void kinc_video_destroy(kinc_video_t *video) { -// kinc_video_stop(video); +// void iron_video_destroy(iron_video_t *video) { +// iron_video_stop(video); // } -// #ifdef KINC_IOS -// void iosPlayVideoSoundStream(kinc_internal_video_sound_stream_t *video); +// #ifdef IRON_IOS +// void iosPlayVideoSoundStream(iron_internal_video_sound_stream_t *video); // void iosStopVideoSoundStream(void); // #else -// void macPlayVideoSoundStream(kinc_internal_video_sound_stream_t *video); +// void macPlayVideoSoundStream(iron_internal_video_sound_stream_t *video); // void macStopVideoSoundStream(void); // #endif -// void kinc_video_play(kinc_video_t *video, bool loop) { +// void iron_video_play(iron_video_t *video, bool loop) { // AVAssetReader *reader = video->impl.assetReader; // [reader startReading]; -// kinc_internal_video_sound_stream_t *stream = (kinc_internal_video_sound_stream_t *)malloc(sizeof(kinc_internal_video_sound_stream_t)); -// kinc_internal_video_sound_stream_init(stream, 2, 44100); +// iron_internal_video_sound_stream_t *stream = (iron_internal_video_sound_stream_t *)malloc(sizeof(iron_internal_video_sound_stream_t)); +// iron_internal_video_sound_stream_init(stream, 2, 44100); // video->impl.sound = stream; -// #ifdef KINC_IOS -// iosPlayVideoSoundStream((kinc_internal_video_sound_stream_t *)video->impl.sound); +// #ifdef IRON_IOS +// iosPlayVideoSoundStream((iron_internal_video_sound_stream_t *)video->impl.sound); // #else -// macPlayVideoSoundStream((kinc_internal_video_sound_stream_t *)video->impl.sound); +// macPlayVideoSoundStream((iron_internal_video_sound_stream_t *)video->impl.sound); // #endif // video->impl.playing = true; -// video->impl.start = kinc_time() - video->impl.videoStart; +// video->impl.start = iron_time() - video->impl.videoStart; // video->impl.loop = loop; // } -// void kinc_video_pause(kinc_video_t *video) { +// void iron_video_pause(iron_video_t *video) { // video->impl.playing = false; // if (video->impl.sound != NULL) { // // Mixer::stop(sound); -// #ifdef KINC_IOS +// #ifdef IRON_IOS // iosStopVideoSoundStream(); // #else // macStopVideoSoundStream(); // #endif -// kinc_internal_video_sound_stream_destroy((kinc_internal_video_sound_stream_t *)video->impl.sound); +// iron_internal_video_sound_stream_destroy((iron_internal_video_sound_stream_t *)video->impl.sound); // free(video->impl.sound); // video->impl.sound = NULL; // } // } -// void kinc_video_stop(kinc_video_t *video) { -// kinc_video_pause(video); +// void iron_video_stop(iron_video_t *video) { +// iron_video_pause(video); // video->impl.finished = true; // } -// static void updateImage(kinc_video_t *video) { +// static void updateImage(iron_video_t *video) { // if (!video->impl.playing) // return; @@ -213,10 +213,10 @@ // buffer = [videoOutput copyNextSampleBuffer]; -// video->impl.start = kinc_time() - video->impl.videoStart; +// video->impl.start = iron_time() - video->impl.videoStart; // } // else { -// kinc_video_stop(video); +// iron_video_stop(video); // return; // } // } @@ -228,13 +228,13 @@ // CGSize size = CVImageBufferGetDisplaySize(pixelBuffer); // video->impl.myWidth = size.width; // video->impl.myHeight = size.height; -// kinc_g5_texture_init(&video->impl.image, kinc_video_width(video), kinc_video_height(video), KINC_IMAGE_FORMAT_BGRA32); +// iron_g5_texture_init(&video->impl.image, iron_video_width(video), iron_video_height(video), IRON_IMAGE_FORMAT_BGRA32); // video->impl.image_initialized = true; // } // if (pixelBuffer != NULL) { // CVPixelBufferLockBaseAddress(pixelBuffer, 0); -// // kinc_g4_texture_upload(&video->impl.image, (uint8_t *)CVPixelBufferGetBaseAddress(pixelBuffer), (int)(CVPixelBufferGetBytesPerRow(pixelBuffer))); +// // iron_g4_texture_upload(&video->impl.image, (uint8_t *)CVPixelBufferGetBaseAddress(pixelBuffer), (int)(CVPixelBufferGetBytesPerRow(pixelBuffer))); // CVPixelBufferUnlockBaseAddress(pixelBuffer, 0); // } // CFRelease(buffer); @@ -253,13 +253,13 @@ // kCMSampleBufferFlag_AudioBufferList_Assure16ByteAlignment, &blockBufferOut); // for (int bufferCount = 0; bufferCount < audioBufferList.mNumberBuffers; ++bufferCount) { // float *samples = (float *)audioBufferList.mBuffers[bufferCount].mData; -// kinc_internal_video_sound_stream_t *sound = (kinc_internal_video_sound_stream_t *)video->impl.sound; +// iron_internal_video_sound_stream_t *sound = (iron_internal_video_sound_stream_t *)video->impl.sound; // if (video->impl.audioTime / 44100.0 > video->impl.next - 0.1) { -// kinc_internal_video_sound_stream_insert_data(sound, samples, (int)numSamplesInBuffer * 2); +// iron_internal_video_sound_stream_insert_data(sound, samples, (int)numSamplesInBuffer * 2); // } // else { // // Send some data anyway because the buffers are huge -// kinc_internal_video_sound_stream_insert_data(sound, samples, (int)numSamplesInBuffer); +// iron_internal_video_sound_stream_insert_data(sound, samples, (int)numSamplesInBuffer); // } // video->impl.audioTime += numSamplesInBuffer; // } @@ -269,37 +269,37 @@ // } // } -// void kinc_video_update(kinc_video_t *video, double time) { +// void iron_video_update(iron_video_t *video, double time) { // if (video->impl.playing && time >= video->impl.start + video->impl.next) { // updateImage(video); // } // } -// int kinc_video_width(kinc_video_t *video) { +// int iron_video_width(iron_video_t *video) { // return video->impl.myWidth; // } -// int kinc_video_height(kinc_video_t *video) { +// int iron_video_height(iron_video_t *video) { // return video->impl.myHeight; // } -// kinc_g5_texture_t *kinc_video_current_image(kinc_video_t *video) { -// kinc_video_update(video, kinc_time()); +// iron_g5_texture_t *iron_video_current_image(iron_video_t *video) { +// iron_video_update(video, iron_time()); // return &video->impl.image; // } -// double kinc_video_duration(kinc_video_t *video) { +// double iron_video_duration(iron_video_t *video) { // return video->impl.duration; // } -// bool kinc_video_finished(kinc_video_t *video) { +// bool iron_video_finished(iron_video_t *video) { // return video->impl.finished; // } -// bool kinc_video_paused(kinc_video_t *video) { +// bool iron_video_paused(iron_video_t *video) { // return !video->impl.playing; // } -// double kinc_video_position(kinc_video_t *video) { +// double iron_video_position(iron_video_t *video) { // return video->impl.next - video->impl.start; // } diff --git a/base/sources/backends/data/android/app/CMakeLists.txt b/base/sources/backends/data/android/app/CMakeLists.txt index 3dc1a283..973f5afe 100644 --- a/base/sources/backends/data/android/app/CMakeLists.txt +++ b/base/sources/backends/data/android/app/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.22.1) -project("Kinc") +project("Iron") set(CMAKE_CXX_STANDARD 17) set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}{debug_defines}") @@ -12,11 +12,11 @@ include_directories( {includes}) add_library( - kinc + iron SHARED {files}) {libraries1} target_link_libraries( - kinc + iron {libraries2}) diff --git a/base/sources/backends/data/android/app/proguard-rules.pro b/base/sources/backends/data/android/app/proguard-rules.pro index 5206dd13..a35b51b8 100644 --- a/base/sources/backends/data/android/app/proguard-rules.pro +++ b/base/sources/backends/data/android/app/proguard-rules.pro @@ -20,13 +20,13 @@ # hide the original source file name. #-renamesourcefileattribute SourceFile --keep public class tech.kinc.KincActivity { +-keep public class org.armory3d.IronActivity { public ; } --keep public class tech.kinc.KincMoviePlayer { +-keep public class org.armory3d.IronMoviePlayer { public ; } --keep public class tech.kinc.KincMovieTexture { +-keep public class org.armory3d.IronMovieTexture { public ; } -keepclasseswithmembernames,includedescriptorclasses class * { diff --git a/base/sources/backends/data/android/main/AndroidManifest.xml b/base/sources/backends/data/android/main/AndroidManifest.xml index 3e1b7466..04b0fc3a 100644 --- a/base/sources/backends/data/android/main/AndroidManifest.xml +++ b/base/sources/backends/data/android/main/AndroidManifest.xml @@ -10,11 +10,11 @@ android:supportsRtl="true" tools:targetApi="{targetSdkVersion}"> - + diff --git a/base/sources/backends/data/mac.plist b/base/sources/backends/data/mac.plist index 56c0fe3d..27b98d35 100644 --- a/base/sources/backends/data/mac.plist +++ b/base/sources/backends/data/mac.plist @@ -25,7 +25,7 @@ LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSHumanReadableCopyright - Copyright © 2018 the Kore Development Team. All rights reserved. + Copyright © 2025 the Iron Development Team. All rights reserved. NSMainNibFile MainMenu NSPrincipalClass diff --git a/base/sources/backends/direct3d12_gpu.c b/base/sources/backends/direct3d12_gpu.c index 7543a600..23ca6c10 100644 --- a/base/sources/backends/direct3d12_gpu.c +++ b/base/sources/backends/direct3d12_gpu.c @@ -75,7 +75,7 @@ struct dx_ctx { static struct dx_ctx dx_ctx = {0}; -inline struct dx_window *kinc_dx_current_window() { +inline struct dx_window *iron_dx_current_window() { return &dx_ctx.windows[0]; } @@ -97,26 +97,26 @@ static ID3D12CommandAllocator *initCommandAllocator; struct RenderEnvironment createDeviceAndSwapChainHelper(D3D_FEATURE_LEVEL minimumFeatureLevel, const struct DXGI_SWAP_CHAIN_DESC *swapChainDesc) { struct RenderEnvironment result = {0}; - kinc_microsoft_affirm(D3D12CreateDevice(NULL, minimumFeatureLevel, &IID_ID3D12Device, &result.device)); + iron_microsoft_affirm(D3D12CreateDevice(NULL, minimumFeatureLevel, &IID_ID3D12Device, &result.device)); D3D12_COMMAND_QUEUE_DESC queueDesc = {}; queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; - kinc_microsoft_affirm(result.device->lpVtbl->CreateCommandQueue(result.device, &queueDesc, &IID_ID3D12CommandQueue, &result.queue)); + iron_microsoft_affirm(result.device->lpVtbl->CreateCommandQueue(result.device, &queueDesc, &IID_ID3D12CommandQueue, &result.queue)); IDXGIFactory4 *dxgiFactory; - kinc_microsoft_affirm(CreateDXGIFactory1(&IID_IDXGIFactory4, &dxgiFactory)); + iron_microsoft_affirm(CreateDXGIFactory1(&IID_IDXGIFactory4, &dxgiFactory)); DXGI_SWAP_CHAIN_DESC swapChainDescCopy = *swapChainDesc; - kinc_microsoft_affirm(dxgiFactory->lpVtbl->CreateSwapChain(dxgiFactory, (IUnknown *)result.queue, &swapChainDescCopy, &result.swapChain)); + iron_microsoft_affirm(dxgiFactory->lpVtbl->CreateSwapChain(dxgiFactory, (IUnknown *)result.queue, &swapChainDescCopy, &result.swapChain)); return result; } static void waitForFence(ID3D12Fence *fence, UINT64 completionValue, HANDLE waitEvent) { if (fence->lpVtbl->GetCompletedValue(fence) < completionValue) { - kinc_microsoft_affirm(fence->lpVtbl->SetEventOnCompletion(fence, completionValue, waitEvent)); + iron_microsoft_affirm(fence->lpVtbl->SetEventOnCompletion(fence, completionValue, waitEvent)); WaitForSingleObject(waitEvent, INFINITE); } } @@ -171,7 +171,7 @@ static void createDeviceAndSwapChain(struct dx_window *window) { swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swapChainDesc.BufferDesc.Width = window->width; swapChainDesc.BufferDesc.Height = window->height; - swapChainDesc.OutputWindow = kinc_windows_window_handle(); + swapChainDesc.OutputWindow = iron_windows_window_handle(); swapChainDesc.SampleDesc.Count = 1; swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; swapChainDesc.Windowed = true; @@ -192,7 +192,7 @@ static void createRootSignature() { D3D12_DESCRIPTOR_RANGE range; range.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; - range.NumDescriptors = (UINT)KINC_INTERNAL_G5_TEXTURE_COUNT; + range.NumDescriptors = (UINT)IRON_INTERNAL_G5_TEXTURE_COUNT; range.BaseShaderRegister = 0; range.RegisterSpace = 0; range.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; @@ -203,7 +203,7 @@ static void createRootSignature() { D3D12_DESCRIPTOR_RANGE range2; range2.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER; - range2.NumDescriptors = (UINT)KINC_INTERNAL_G5_TEXTURE_COUNT; + range2.NumDescriptors = (UINT)IRON_INTERNAL_G5_TEXTURE_COUNT; range2.BaseShaderRegister = 0; range2.RegisterSpace = 0; range2.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; @@ -222,8 +222,8 @@ static void createRootSignature() { parameters[3].Descriptor.ShaderRegister = 0; parameters[3].Descriptor.RegisterSpace = 0; - D3D12_STATIC_SAMPLER_DESC samplers[KINC_INTERNAL_G5_TEXTURE_COUNT * 2]; - for (int i = 0; i < KINC_INTERNAL_G5_TEXTURE_COUNT; ++i) { + D3D12_STATIC_SAMPLER_DESC samplers[IRON_INTERNAL_G5_TEXTURE_COUNT * 2]; + for (int i = 0; i < IRON_INTERNAL_G5_TEXTURE_COUNT; ++i) { samplers[i].ShaderRegister = i; samplers[i].Filter = D3D12_FILTER_MIN_MAG_MIP_POINT; samplers[i].AddressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP; @@ -238,7 +238,7 @@ static void createRootSignature() { samplers[i].ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; samplers[i].RegisterSpace = 0; } - for (int i = KINC_INTERNAL_G5_TEXTURE_COUNT; i < KINC_INTERNAL_G5_TEXTURE_COUNT * 2; ++i) { + for (int i = IRON_INTERNAL_G5_TEXTURE_COUNT; i < IRON_INTERNAL_G5_TEXTURE_COUNT * 2; ++i) { samplers[i].ShaderRegister = i; samplers[i].Filter = D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT; samplers[i].AddressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP; @@ -261,7 +261,7 @@ static void createRootSignature() { descRootSignature.pStaticSamplers = NULL; descRootSignature.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; - kinc_microsoft_affirm(D3D12SerializeRootSignature(&descRootSignature, D3D_ROOT_SIGNATURE_VERSION_1, &rootBlob, &errorBlob)); + iron_microsoft_affirm(D3D12SerializeRootSignature(&descRootSignature, D3D_ROOT_SIGNATURE_VERSION_1, &rootBlob, &errorBlob)); device->lpVtbl->CreateRootSignature(device, 0, rootBlob->lpVtbl->GetBufferPointer(rootBlob), rootBlob->lpVtbl->GetBufferSize(rootBlob), &IID_ID3D12RootSignature, &globalRootSignature); } @@ -274,7 +274,7 @@ static void createComputeRootSignature() { D3D12_DESCRIPTOR_RANGE range; range.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; - range.NumDescriptors = (UINT)KINC_INTERNAL_G5_TEXTURE_COUNT; + range.NumDescriptors = (UINT)IRON_INTERNAL_G5_TEXTURE_COUNT; range.BaseShaderRegister = 0; range.RegisterSpace = 0; range.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; @@ -285,7 +285,7 @@ static void createComputeRootSignature() { D3D12_DESCRIPTOR_RANGE uav_range; uav_range.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_UAV; - uav_range.NumDescriptors = (UINT)KINC_INTERNAL_G5_TEXTURE_COUNT; + uav_range.NumDescriptors = (UINT)IRON_INTERNAL_G5_TEXTURE_COUNT; uav_range.BaseShaderRegister = 0; uav_range.RegisterSpace = 0; uav_range.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; @@ -296,7 +296,7 @@ static void createComputeRootSignature() { D3D12_DESCRIPTOR_RANGE range2; range2.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER; - range2.NumDescriptors = (UINT)KINC_INTERNAL_G5_TEXTURE_COUNT; + range2.NumDescriptors = (UINT)IRON_INTERNAL_G5_TEXTURE_COUNT; range2.BaseShaderRegister = 0; range2.RegisterSpace = 0; range2.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; @@ -310,8 +310,8 @@ static void createComputeRootSignature() { parameters[3].Descriptor.ShaderRegister = 0; parameters[3].Descriptor.RegisterSpace = 0; - D3D12_STATIC_SAMPLER_DESC samplers[KINC_INTERNAL_G5_TEXTURE_COUNT * 2]; - for (int i = 0; i < KINC_INTERNAL_G5_TEXTURE_COUNT; ++i) { + D3D12_STATIC_SAMPLER_DESC samplers[IRON_INTERNAL_G5_TEXTURE_COUNT * 2]; + for (int i = 0; i < IRON_INTERNAL_G5_TEXTURE_COUNT; ++i) { samplers[i].ShaderRegister = i; samplers[i].Filter = D3D12_FILTER_MIN_MAG_MIP_POINT; samplers[i].AddressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP; @@ -326,7 +326,7 @@ static void createComputeRootSignature() { samplers[i].ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; samplers[i].RegisterSpace = 0; } - for (int i = KINC_INTERNAL_G5_TEXTURE_COUNT; i < KINC_INTERNAL_G5_TEXTURE_COUNT * 2; ++i) { + for (int i = IRON_INTERNAL_G5_TEXTURE_COUNT; i < IRON_INTERNAL_G5_TEXTURE_COUNT * 2; ++i) { samplers[i].ShaderRegister = i; samplers[i].Filter = D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT; samplers[i].AddressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP; @@ -349,7 +349,7 @@ static void createComputeRootSignature() { descRootSignature.pStaticSamplers = NULL; descRootSignature.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; - kinc_microsoft_affirm(D3D12SerializeRootSignature(&descRootSignature, D3D_ROOT_SIGNATURE_VERSION_1, &rootBlob, &errorBlob)); + iron_microsoft_affirm(D3D12SerializeRootSignature(&descRootSignature, D3D_ROOT_SIGNATURE_VERSION_1, &rootBlob, &errorBlob)); device->lpVtbl->CreateRootSignature(device, 0, rootBlob->lpVtbl->GetBufferPointer(rootBlob), rootBlob->lpVtbl->GetBufferSize(rootBlob), &IID_ID3D12RootSignature, &globalComputeRootSignature); @@ -393,7 +393,7 @@ static void shutdown() { } static void initWindow(struct dx_window *window) { - HWND hwnd = kinc_windows_window_handle(); + HWND hwnd = iron_windows_window_handle(); DXGI_SWAP_CHAIN_DESC swapChainDesc; ZeroMemory(&swapChainDesc, sizeof(swapChainDesc)); @@ -401,38 +401,38 @@ static void initWindow(struct dx_window *window) { swapChainDesc.BufferCount = QUEUE_SLOT_COUNT; swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - swapChainDesc.BufferDesc.Width = kinc_window_width(); - swapChainDesc.BufferDesc.Height = kinc_window_height(); + swapChainDesc.BufferDesc.Width = iron_window_width(); + swapChainDesc.BufferDesc.Height = iron_window_height(); swapChainDesc.OutputWindow = hwnd; swapChainDesc.SampleDesc.Count = 1; swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; swapChainDesc.Windowed = true; IDXGIFactory4 *dxgiFactory = NULL; - kinc_microsoft_affirm(CreateDXGIFactory1(&IID_IDXGIFactory4, &dxgiFactory)); + iron_microsoft_affirm(CreateDXGIFactory1(&IID_IDXGIFactory4, &dxgiFactory)); - kinc_microsoft_affirm(dxgiFactory->lpVtbl->CreateSwapChain(dxgiFactory, (IUnknown *)commandQueue, &swapChainDesc, &window->swapChain)); + iron_microsoft_affirm(dxgiFactory->lpVtbl->CreateSwapChain(dxgiFactory, (IUnknown *)commandQueue, &swapChainDesc, &window->swapChain)); setupSwapChain(window); } -void kinc_g5_internal_destroy_window() {} +void iron_g5_internal_destroy_window() {} -void kinc_g5_internal_destroy() { +void iron_g5_internal_destroy() { if (device) { device->lpVtbl->Release(device); device = NULL; } } -void kinc_g5_internal_init() { +void iron_g5_internal_init() { #ifdef _DEBUG ID3D12Debug *debugController = NULL; if (D3D12GetDebugInterface(&IID_ID3D12Debug, &debugController) == S_OK) { debugController->lpVtbl->EnableDebugLayer(debugController); } #endif - kinc_microsoft_affirm(D3D12CreateDevice(NULL, D3D_FEATURE_LEVEL_11_0, &IID_ID3D12Device, &device)); + iron_microsoft_affirm(D3D12CreateDevice(NULL, D3D_FEATURE_LEVEL_11_0, &IID_ID3D12Device, &device)); createRootSignature(); createComputeRootSignature(); @@ -441,7 +441,7 @@ void kinc_g5_internal_init() { queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; - kinc_microsoft_affirm(device->lpVtbl->CreateCommandQueue(device, &queueDesc, &IID_ID3D12CommandQueue, &commandQueue)); + iron_microsoft_affirm(device->lpVtbl->CreateCommandQueue(device, &queueDesc, &IID_ID3D12CommandQueue, &commandQueue)); device->lpVtbl->CreateFence(device, 0, D3D12_FENCE_FLAG_NONE, &IID_ID3D12Fence, &uploadFence); @@ -464,21 +464,21 @@ void kinc_g5_internal_init() { CloseHandle(waitEvent); } -void kinc_g5_internal_init_window(int depthBufferBits, bool verticalSync) { +void iron_g5_internal_init_window(int depthBufferBits, bool verticalSync) { struct dx_window *window = &dx_ctx.windows[0]; window->vsync = verticalSync; - window->width = window->new_width = kinc_window_width(); - window->height = window->new_height = kinc_window_height(); + window->width = window->new_width = iron_window_width(); + window->height = window->new_height = iron_window_height(); initWindow(window); } -int kinc_g5_max_bound_textures(void) { +int iron_g5_max_bound_textures(void) { return D3D12_COMMONSHADER_SAMPLER_SLOT_COUNT; } static bool began = false; -void kinc_g5_begin(kinc_g5_texture_t *renderTarget) { +void iron_g5_begin(iron_g5_texture_t *renderTarget) { if (began) return; began = true; @@ -489,7 +489,7 @@ void kinc_g5_begin(kinc_g5_texture_t *renderTarget) { if (window->new_width != window->width || window->new_height != window->height) { - kinc_microsoft_affirm(window->swapChain->lpVtbl->ResizeBuffers(window->swapChain, QUEUE_SLOT_COUNT, window->new_width, window->new_height, DXGI_FORMAT_R8G8B8A8_UNORM, 0)); + iron_microsoft_affirm(window->swapChain->lpVtbl->ResizeBuffers(window->swapChain, QUEUE_SLOT_COUNT, window->new_width, window->new_height, DXGI_FORMAT_R8G8B8A8_UNORM, 0)); setupSwapChain(window); window->width = window->new_width; @@ -512,34 +512,34 @@ void kinc_g5_begin(kinc_g5_texture_t *renderTarget) { // commandList->ClearDepthStencilView(GetCPUDescriptorHandle(depthStencilDescriptorHeap), D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, nullptr); } -void kinc_g5_end() { +void iron_g5_end() { began = false; } -void kinc_g5_internal_resize(int, int); +void iron_g5_internal_resize(int, int); -void kinc_internal_resize(int width, int height) { +void iron_internal_resize(int width, int height) { if (width == 0 || height == 0) return; struct dx_window *window = &dx_ctx.windows[0]; window->new_width = width; window->new_height = height; - kinc_g5_internal_resize(width, height); + iron_g5_internal_resize(width, height); } -bool kinc_g5_swap_buffers() { +bool iron_g5_swap_buffers() { for (int i = 0; i < MAXIMUM_WINDOWS; i++) { struct dx_window *window = &dx_ctx.windows[i]; if (window->swapChain) { - kinc_microsoft_affirm(window->swapChain->lpVtbl->Present(window->swapChain, window->vsync, 0)); + iron_microsoft_affirm(window->swapChain->lpVtbl->Present(window->swapChain, window->vsync, 0)); } } return true; } -void kinc_g5_flush() {} +void iron_g5_flush() {} -bool kinc_g5_raytrace_supported() { +bool iron_g5_raytrace_supported() { D3D12_FEATURE_DATA_D3D12_OPTIONS5 options; if (device->lpVtbl->CheckFeatureSupport(device, D3D12_FEATURE_D3D12_OPTIONS5, &options, sizeof(options)) == S_OK) { return options.RaytracingTier >= D3D12_RAYTRACING_TIER_1_0; @@ -547,7 +547,7 @@ bool kinc_g5_raytrace_supported() { return false; } -void createHeaps(kinc_g5_command_list_t *list); +void createHeaps(iron_g5_command_list_t *list); static int formatSize(DXGI_FORMAT format) { switch (format) { @@ -564,7 +564,7 @@ static int formatSize(DXGI_FORMAT format) { } } -void kinc_g5_command_list_init(struct kinc_g5_command_list *list) { +void iron_g5_command_list_init(struct iron_g5_command_list *list) { #ifndef NDEBUG list->impl.open = false; #endif @@ -580,7 +580,7 @@ void kinc_g5_command_list_init(struct kinc_g5_command_list *list) { list->impl.current_full_scissor.left = -1; - for (int i = 0; i < KINC_INTERNAL_G5_TEXTURE_COUNT; ++i) { + for (int i = 0; i < IRON_INTERNAL_G5_TEXTURE_COUNT; ++i) { list->impl.currentTextures[i] = NULL; list->impl.current_samplers[i] = NULL; } @@ -588,11 +588,11 @@ void kinc_g5_command_list_init(struct kinc_g5_command_list *list) { createHeaps(list); } -void kinc_g5_command_list_destroy(struct kinc_g5_command_list *list) {} +void iron_g5_command_list_destroy(struct iron_g5_command_list *list) {} -void kinc_g5_internal_reset_textures(struct kinc_g5_command_list *list); +void iron_g5_internal_reset_textures(struct iron_g5_command_list *list); -void kinc_g5_command_list_begin(struct kinc_g5_command_list *list) { +void iron_g5_command_list_begin(struct iron_g5_command_list *list) { assert(!list->impl.open); compute_pipeline_set = false; @@ -603,14 +603,14 @@ void kinc_g5_command_list_begin(struct kinc_g5_command_list *list) { list->impl._commandList->lpVtbl->Reset(list->impl._commandList, list->impl._commandAllocator, NULL); } - kinc_g5_internal_reset_textures(list); + iron_g5_internal_reset_textures(list); #ifndef NDEBUG list->impl.open = true; #endif } -void kinc_g5_command_list_end(struct kinc_g5_command_list *list) { +void iron_g5_command_list_end(struct iron_g5_command_list *list) { assert(list->impl.open); list->impl._commandList->lpVtbl->Close(list->impl._commandList); @@ -620,10 +620,10 @@ void kinc_g5_command_list_end(struct kinc_g5_command_list *list) { #endif } -void kinc_g5_command_list_clear(struct kinc_g5_command_list *list, kinc_g5_texture_t *renderTarget, unsigned flags, unsigned color, float depth) { +void iron_g5_command_list_clear(struct iron_g5_command_list *list, iron_g5_texture_t *renderTarget, unsigned flags, unsigned color, float depth) { assert(list->impl.open); - if (flags & KINC_G5_CLEAR_COLOR) { + if (flags & IRON_G5_CLEAR_COLOR) { float clearColor[] = {((color & 0x00ff0000) >> 16) / 255.0f, ((color & 0x0000ff00) >> 8) / 255.0f, (color & 0x000000ff) / 255.0f, ((color & 0xff000000) >> 24) / 255.0f}; @@ -637,7 +637,7 @@ void kinc_g5_command_list_clear(struct kinc_g5_command_list *list, kinc_g5_textu 0, NULL); } - if (flags & KINC_G5_CLEAR_DEPTH) { + if (flags & IRON_G5_CLEAR_DEPTH) { D3D12_CLEAR_FLAGS d3dflags = D3D12_CLEAR_FLAG_DEPTH; if (renderTarget->impl.depthStencilDescriptorHeap != NULL) { @@ -652,7 +652,7 @@ void kinc_g5_command_list_clear(struct kinc_g5_command_list *list, kinc_g5_textu } } -void kinc_g5_command_list_render_target_to_framebuffer_barrier(struct kinc_g5_command_list *list, kinc_g5_texture_t *renderTarget) { +void iron_g5_command_list_render_target_to_framebuffer_barrier(struct iron_g5_command_list *list, iron_g5_texture_t *renderTarget) { assert(list->impl.open); D3D12_RESOURCE_BARRIER barrier; @@ -666,7 +666,7 @@ void kinc_g5_command_list_render_target_to_framebuffer_barrier(struct kinc_g5_co list->impl._commandList->lpVtbl->ResourceBarrier(list->impl._commandList, 1, &barrier); } -void kinc_g5_command_list_framebuffer_to_render_target_barrier(struct kinc_g5_command_list *list, kinc_g5_texture_t *renderTarget) { +void iron_g5_command_list_framebuffer_to_render_target_barrier(struct iron_g5_command_list *list, iron_g5_texture_t *renderTarget) { assert(list->impl.open); D3D12_RESOURCE_BARRIER barrier; @@ -680,7 +680,7 @@ void kinc_g5_command_list_framebuffer_to_render_target_barrier(struct kinc_g5_co list->impl._commandList->lpVtbl->ResourceBarrier(list->impl._commandList, 1, &barrier); } -void kinc_g5_command_list_texture_to_render_target_barrier(struct kinc_g5_command_list *list, kinc_g5_texture_t *renderTarget) { +void iron_g5_command_list_texture_to_render_target_barrier(struct iron_g5_command_list *list, iron_g5_texture_t *renderTarget) { assert(list->impl.open); D3D12_RESOURCE_BARRIER barrier; @@ -694,7 +694,7 @@ void kinc_g5_command_list_texture_to_render_target_barrier(struct kinc_g5_comman list->impl._commandList->lpVtbl->ResourceBarrier(list->impl._commandList, 1, &barrier); } -void kinc_g5_command_list_render_target_to_texture_barrier(struct kinc_g5_command_list *list, kinc_g5_texture_t *renderTarget) { +void iron_g5_command_list_render_target_to_texture_barrier(struct iron_g5_command_list *list, iron_g5_texture_t *renderTarget) { assert(list->impl.open); D3D12_RESOURCE_BARRIER barrier; @@ -708,32 +708,32 @@ void kinc_g5_command_list_render_target_to_texture_barrier(struct kinc_g5_comman list->impl._commandList->lpVtbl->ResourceBarrier(list->impl._commandList, 1, &barrier); } -void kinc_g5_command_list_set_vertex_constant_buffer(struct kinc_g5_command_list *list, kinc_g5_constant_buffer_t *buffer, int offset, size_t size) { +void iron_g5_command_list_set_vertex_constant_buffer(struct iron_g5_command_list *list, iron_g5_constant_buffer_t *buffer, int offset, size_t size) { assert(list->impl.open); list->impl._commandList->lpVtbl->SetGraphicsRootConstantBufferView(list->impl._commandList, 2, buffer->impl.constant_buffer->lpVtbl->GetGPUVirtualAddress(buffer->impl.constant_buffer) + offset); } -void kinc_g5_command_list_set_fragment_constant_buffer(struct kinc_g5_command_list *list, kinc_g5_constant_buffer_t *buffer, int offset, size_t size) { +void iron_g5_command_list_set_fragment_constant_buffer(struct iron_g5_command_list *list, iron_g5_constant_buffer_t *buffer, int offset, size_t size) { assert(list->impl.open); list->impl._commandList->lpVtbl->SetGraphicsRootConstantBufferView(list->impl._commandList, 3, buffer->impl.constant_buffer->lpVtbl->GetGPUVirtualAddress(buffer->impl.constant_buffer) + offset); } -void kinc_g5_command_list_set_compute_constant_buffer(struct kinc_g5_command_list *list, kinc_g5_constant_buffer_t *buffer, int offset, size_t size) { +void iron_g5_command_list_set_compute_constant_buffer(struct iron_g5_command_list *list, iron_g5_constant_buffer_t *buffer, int offset, size_t size) { assert(list->impl.open); list->impl._commandList->lpVtbl->SetComputeRootConstantBufferView(list->impl._commandList, 3, buffer->impl.constant_buffer->lpVtbl->GetGPUVirtualAddress(buffer->impl.constant_buffer) + offset); } -void kinc_g5_command_list_draw_indexed_vertices(struct kinc_g5_command_list *list) { - kinc_g5_command_list_draw_indexed_vertices_from_to(list, 0, list->impl._indexCount); +void iron_g5_command_list_draw_indexed_vertices(struct iron_g5_command_list *list) { + iron_g5_command_list_draw_indexed_vertices_from_to(list, 0, list->impl._indexCount); } -void kinc_g5_command_list_draw_indexed_vertices_from_to(struct kinc_g5_command_list *list, int start, int count) { +void iron_g5_command_list_draw_indexed_vertices_from_to(struct iron_g5_command_list *list, int start, int count) { assert(list->impl.open); list->impl._commandList->lpVtbl->IASetPrimitiveTopology(list->impl._commandList, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); list->impl._commandList->lpVtbl->DrawIndexedInstanced(list->impl._commandList, count, 1, start, 0, 0); } -void kinc_g5_command_list_execute(kinc_g5_command_list_t *list) { +void iron_g5_command_list_execute(iron_g5_command_list_t *list) { assert(!list->impl.open); ID3D12CommandList *commandLists[] = {(ID3D12CommandList *)list->impl._commandList}; @@ -742,15 +742,15 @@ void kinc_g5_command_list_execute(kinc_g5_command_list_t *list) { commandQueue->lpVtbl->Signal(commandQueue, list->impl.fence, ++list->impl.fence_value); } -void kinc_g5_command_list_wait_for_execution_to_finish(kinc_g5_command_list_t *list) { +void iron_g5_command_list_wait_for_execution_to_finish(iron_g5_command_list_t *list) { waitForFence(list->impl.fence, list->impl.fence_value, list->impl.fence_event); } -bool kinc_g5_non_pow2_textures_supported(void) { +bool iron_g5_non_pow2_textures_supported(void) { return true; } -void kinc_g5_command_list_viewport(struct kinc_g5_command_list *list, int x, int y, int width, int height) { +void iron_g5_command_list_viewport(struct iron_g5_command_list *list, int x, int y, int width, int height) { assert(list->impl.open); D3D12_VIEWPORT viewport; @@ -763,7 +763,7 @@ void kinc_g5_command_list_viewport(struct kinc_g5_command_list *list, int x, int list->impl._commandList->lpVtbl->RSSetViewports(list->impl._commandList, 1, &viewport); } -void kinc_g5_command_list_scissor(struct kinc_g5_command_list *list, int x, int y, int width, int height) { +void iron_g5_command_list_scissor(struct iron_g5_command_list *list, int x, int y, int width, int height) { assert(list->impl.open); D3D12_RECT scissor; @@ -774,7 +774,7 @@ void kinc_g5_command_list_scissor(struct kinc_g5_command_list *list, int x, int list->impl._commandList->lpVtbl->RSSetScissorRects(list->impl._commandList, 1, &scissor); } -void kinc_g5_command_list_disable_scissor(struct kinc_g5_command_list *list) { +void iron_g5_command_list_disable_scissor(struct iron_g5_command_list *list) { assert(list->impl.open); if (list->impl.current_full_scissor.left >= 0) { @@ -784,49 +784,49 @@ void kinc_g5_command_list_disable_scissor(struct kinc_g5_command_list *list) { D3D12_RECT scissor; scissor.left = 0; scissor.top = 0; - scissor.right = kinc_window_width(); - scissor.bottom = kinc_window_height(); + scissor.right = iron_window_width(); + scissor.bottom = iron_window_height(); list->impl._commandList->lpVtbl->RSSetScissorRects(list->impl._commandList, 1, &scissor); } } -void kinc_g5_command_list_set_pipeline(struct kinc_g5_command_list *list, kinc_g5_pipeline_t *pipeline) { +void iron_g5_command_list_set_pipeline(struct iron_g5_command_list *list, iron_g5_pipeline_t *pipeline) { assert(list->impl.open); list->impl._currentPipeline = pipeline; list->impl._commandList->lpVtbl->SetPipelineState(list->impl._commandList, pipeline->impl.pso); compute_pipeline_set = false; - for (int i = 0; i < KINC_INTERNAL_G5_TEXTURE_COUNT; ++i) { + for (int i = 0; i < IRON_INTERNAL_G5_TEXTURE_COUNT; ++i) { list->impl.currentTextures[i] = NULL; } - kinc_g5_internal_setConstants(list, list->impl._currentPipeline); + iron_g5_internal_setConstants(list, list->impl._currentPipeline); } -void kinc_g5_command_list_set_vertex_buffer(struct kinc_g5_command_list *list, kinc_g5_vertex_buffer_t *buffer) { +void iron_g5_command_list_set_vertex_buffer(struct iron_g5_command_list *list, iron_g5_vertex_buffer_t *buffer) { assert(list->impl.open); D3D12_VERTEX_BUFFER_VIEW *views = (D3D12_VERTEX_BUFFER_VIEW *)alloca(sizeof(D3D12_VERTEX_BUFFER_VIEW) * 1); ZeroMemory(views, sizeof(D3D12_VERTEX_BUFFER_VIEW) * 1); views[0].BufferLocation = buffer->impl.uploadBuffer->lpVtbl->GetGPUVirtualAddress(buffer->impl.uploadBuffer); - views[0].SizeInBytes = (kinc_g5_vertex_buffer_count(buffer)) * kinc_g5_vertex_buffer_stride(buffer); - views[0].StrideInBytes = kinc_g5_vertex_buffer_stride(buffer); + views[0].SizeInBytes = (iron_g5_vertex_buffer_count(buffer)) * iron_g5_vertex_buffer_stride(buffer); + views[0].StrideInBytes = iron_g5_vertex_buffer_stride(buffer); list->impl._commandList->lpVtbl->IASetVertexBuffers(list->impl._commandList, 0, 1, views); } -void kinc_g5_command_list_set_index_buffer(struct kinc_g5_command_list *list, kinc_g5_index_buffer_t *buffer) { +void iron_g5_command_list_set_index_buffer(struct iron_g5_command_list *list, iron_g5_index_buffer_t *buffer) { assert(list->impl.open); - list->impl._indexCount = kinc_g5_index_buffer_count(buffer); + list->impl._indexCount = iron_g5_index_buffer_count(buffer); list->impl._commandList->lpVtbl->IASetIndexBuffer(list->impl._commandList, (D3D12_INDEX_BUFFER_VIEW *) & buffer->impl.index_buffer_view); } -void kinc_g5_command_list_set_render_targets(struct kinc_g5_command_list *list, kinc_g5_texture_t **targets, int count) { +void iron_g5_command_list_set_render_targets(struct iron_g5_command_list *list, iron_g5_texture_t **targets, int count) { assert(list->impl.open); - kinc_g5_texture_t *render_target = targets[0]; + iron_g5_texture_t *render_target = targets[0]; D3D12_CPU_DESCRIPTOR_HANDLE target_descriptors[16]; for (int i = 0; i < count; ++i) { @@ -851,14 +851,14 @@ void kinc_g5_command_list_set_render_targets(struct kinc_g5_command_list *list, list->impl.current_full_scissor = render_target->impl.scissor; } -void kinc_g5_command_list_upload_vertex_buffer(kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer *buffer) {} +void iron_g5_command_list_upload_vertex_buffer(iron_g5_command_list_t *list, struct iron_g5_vertex_buffer *buffer) {} -void kinc_g5_command_list_upload_index_buffer(kinc_g5_command_list_t *list, kinc_g5_index_buffer_t *buffer) { +void iron_g5_command_list_upload_index_buffer(iron_g5_command_list_t *list, iron_g5_index_buffer_t *buffer) { assert(list->impl.open); - kinc_g5_internal_index_buffer_upload(buffer, list->impl._commandList); + iron_g5_internal_index_buffer_upload(buffer, list->impl._commandList); } -void kinc_g5_command_list_upload_texture(kinc_g5_command_list_t *list, kinc_g5_texture_t *texture) { +void iron_g5_command_list_upload_texture(iron_g5_command_list_t *list, iron_g5_texture_t *texture) { assert(list->impl.open); { @@ -910,7 +910,7 @@ static int d3d12_textureAlignment() { return D3D12_TEXTURE_DATA_PITCH_ALIGNMENT; } -void kinc_g5_command_list_get_render_target_pixels(kinc_g5_command_list_t *list, kinc_g5_texture_t *render_target, uint8_t *data) { +void iron_g5_command_list_get_render_target_pixels(iron_g5_command_list_t *list, iron_g5_texture_t *render_target, uint8_t *data) { assert(list->impl.open); D3D12_RESOURCE_DESC desc; @@ -990,10 +990,10 @@ void kinc_g5_command_list_get_render_target_pixels(kinc_g5_command_list_t *list, list->impl._commandList->lpVtbl->ResourceBarrier(list->impl._commandList, 1, &barrier); } - kinc_g5_command_list_end(list); - kinc_g5_command_list_execute(list); - kinc_g5_command_list_wait_for_execution_to_finish(list); - kinc_g5_command_list_begin(list); + iron_g5_command_list_end(list); + iron_g5_command_list_execute(list); + iron_g5_command_list_wait_for_execution_to_finish(list); + iron_g5_command_list_begin(list); // Read buffer void *p; @@ -1002,60 +1002,60 @@ void kinc_g5_command_list_get_render_target_pixels(kinc_g5_command_list_t *list, render_target->impl.renderTargetReadback->lpVtbl->Unmap(render_target->impl.renderTargetReadback, 0, NULL); } -void kinc_g5_internal_set_compute_constants(kinc_g5_command_list_t *commandList); +void iron_g5_internal_set_compute_constants(iron_g5_command_list_t *commandList); -void kinc_g5_command_list_set_compute_shader(kinc_g5_command_list_t *list, kinc_g5_compute_shader *shader) { +void iron_g5_command_list_set_compute_shader(iron_g5_command_list_t *list, iron_g5_compute_shader *shader) { list->impl._commandList->lpVtbl->SetPipelineState(list->impl._commandList, shader->impl.pso); compute_pipeline_set = true; - for (int i = 0; i < KINC_INTERNAL_G5_TEXTURE_COUNT; ++i) { + for (int i = 0; i < IRON_INTERNAL_G5_TEXTURE_COUNT; ++i) { list->impl.currentTextures[i] = NULL; } - kinc_g5_internal_set_compute_constants(list); + iron_g5_internal_set_compute_constants(list); } -void kinc_g5_command_list_compute(kinc_g5_command_list_t *list, int x, int y, int z) { +void iron_g5_command_list_compute(iron_g5_command_list_t *list, int x, int y, int z) { assert(list->impl.open); list->impl._commandList->lpVtbl->Dispatch(list->impl._commandList, x, y, z); } -void kinc_g5_internal_sampler_set(kinc_g5_command_list_t *list, kinc_g5_sampler_t *sampler, int unit); +void iron_g5_internal_sampler_set(iron_g5_command_list_t *list, iron_g5_sampler_t *sampler, int unit); -void kinc_g5_command_list_set_sampler(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_sampler_t *sampler) { - if (unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT] >= 0) { - kinc_g5_internal_sampler_set(list, sampler, unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT]); +void iron_g5_command_list_set_sampler(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_sampler_t *sampler) { + if (unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] >= 0) { + iron_g5_internal_sampler_set(list, sampler, unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]); } - else if (unit.stages[KINC_G5_SHADER_TYPE_VERTEX] >= 0) { - kinc_g5_internal_sampler_set(list, sampler, unit.stages[KINC_G5_SHADER_TYPE_VERTEX]); + else if (unit.stages[IRON_G5_SHADER_TYPE_VERTEX] >= 0) { + iron_g5_internal_sampler_set(list, sampler, unit.stages[IRON_G5_SHADER_TYPE_VERTEX]); } - kinc_g5_internal_set_textures(list); + iron_g5_internal_set_textures(list); } -void kinc_g5_command_list_set_texture(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_texture_t *texture) { - if (unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT] >= 0) { - texture->impl.stage = unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT]; +void iron_g5_command_list_set_texture(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *texture) { + if (unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] >= 0) { + texture->impl.stage = unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]; } - else if (unit.stages[KINC_G5_SHADER_TYPE_VERTEX] >= 0) { - texture->impl.stage = unit.stages[KINC_G5_SHADER_TYPE_VERTEX]; + else if (unit.stages[IRON_G5_SHADER_TYPE_VERTEX] >= 0) { + texture->impl.stage = unit.stages[IRON_G5_SHADER_TYPE_VERTEX]; } - else if (unit.stages[KINC_G5_SHADER_TYPE_COMPUTE] >= 0) { - texture->impl.stage = unit.stages[KINC_G5_SHADER_TYPE_COMPUTE]; + else if (unit.stages[IRON_G5_SHADER_TYPE_COMPUTE] >= 0) { + texture->impl.stage = unit.stages[IRON_G5_SHADER_TYPE_COMPUTE]; } list->impl.currentTextures[texture->impl.stage] = texture; - kinc_g5_internal_set_textures(list); + iron_g5_internal_set_textures(list); } -void kinc_g5_command_list_set_texture_from_render_target_depth(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_texture_t *texture) { - if (unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT] >= 0) { - texture->impl.stage_depth = unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT]; +void iron_g5_command_list_set_texture_from_render_target_depth(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *texture) { + if (unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] >= 0) { + texture->impl.stage_depth = unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]; } - else if (unit.stages[KINC_G5_SHADER_TYPE_VERTEX] >= 0) { - texture->impl.stage_depth = unit.stages[KINC_G5_SHADER_TYPE_VERTEX]; + else if (unit.stages[IRON_G5_SHADER_TYPE_VERTEX] >= 0) { + texture->impl.stage_depth = unit.stages[IRON_G5_SHADER_TYPE_VERTEX]; } list->impl.currentTextures[texture->impl.stage_depth] = texture; } -void kinc_g5_compute_shader_init(kinc_g5_compute_shader *shader, void *_data, int length) { +void iron_g5_compute_shader_init(iron_g5_compute_shader *shader, void *_data, int length) { unsigned index = 0; uint8_t *data = (uint8_t *)_data; @@ -1068,7 +1068,7 @@ void kinc_g5_compute_shader_init(kinc_g5_compute_shader *shader, void *_data, in if (name[i2] == 0) break; } - shader->impl.attributes[i].hash = kinc_internal_hash_name(name); + shader->impl.attributes[i].hash = iron_internal_hash_name(name); shader->impl.attributes[i].index = data[index++]; } @@ -1081,7 +1081,7 @@ void kinc_g5_compute_shader_init(kinc_g5_compute_shader *shader, void *_data, in if (name[i2] == 0) break; } - shader->impl.textures[i].hash = kinc_internal_hash_name(name); + shader->impl.textures[i].hash = iron_internal_hash_name(name); shader->impl.textures[i].index = data[index++]; } @@ -1095,8 +1095,8 @@ void kinc_g5_compute_shader_init(kinc_g5_compute_shader *shader, void *_data, in if (name[i2] == 0) break; } - kinc_compute_internal_shader_constant_t constant; - constant.hash = kinc_internal_hash_name(name); + iron_compute_internal_shader_constant_t constant; + constant.hash = iron_internal_hash_name(name); memcpy(&constant.offset, &data[index], sizeof(constant.offset)); index += 4; memcpy(&constant.size, &data[index], sizeof(constant.size)); @@ -1122,22 +1122,22 @@ void kinc_g5_compute_shader_init(kinc_g5_compute_shader *shader, void *_data, in HRESULT hr = device->lpVtbl->CreateComputePipelineState(device , &desc, &IID_ID3D12PipelineState, &shader->impl.pso); if (hr != S_OK) { - kinc_log("Could not initialize compute shader."); + iron_log("Could not initialize compute shader."); return; } - // kinc_microsoft_affirm(device->CreateBuffer(&CD3D11_BUFFER_DESC(getMultipleOf16(shader->impl.constantsSize), D3D11_BIND_CONSTANT_BUFFER), nullptr, + // iron_microsoft_affirm(device->CreateBuffer(&CD3D11_BUFFER_DESC(getMultipleOf16(shader->impl.constantsSize), D3D11_BIND_CONSTANT_BUFFER), nullptr, // &shader->impl.constantBuffer)); } -void kinc_g5_compute_shader_destroy(kinc_g5_compute_shader *shader) { +void iron_g5_compute_shader_destroy(iron_g5_compute_shader *shader) { if (shader->impl.pso != NULL) { shader->impl.pso->lpVtbl->Release(shader->impl.pso); shader->impl.pso = NULL; } } -static kinc_compute_internal_shader_constant_t *findComputeConstant(kinc_compute_internal_shader_constant_t *constants, uint32_t hash) { +static iron_compute_internal_shader_constant_t *findComputeConstant(iron_compute_internal_shader_constant_t *constants, uint32_t hash) { for (int i = 0; i < 64; ++i) { if (constants[i].hash == hash) { return &constants[i]; @@ -1146,7 +1146,7 @@ static kinc_compute_internal_shader_constant_t *findComputeConstant(kinc_compute return NULL; } -static kinc_internal_hash_index_t *findComputeTextureUnit(kinc_internal_hash_index_t *units, uint32_t hash) { +static iron_internal_hash_index_t *findComputeTextureUnit(iron_internal_hash_index_t *units, uint32_t hash) { for (int i = 0; i < 64; ++i) { if (units[i].hash == hash) { return &units[i]; @@ -1155,12 +1155,12 @@ static kinc_internal_hash_index_t *findComputeTextureUnit(kinc_internal_hash_ind return NULL; } -kinc_g5_constant_location_t kinc_g5_compute_shader_get_constant_location(kinc_g5_compute_shader *shader, const char *name) { - kinc_g5_constant_location_t location = {0}; +iron_g5_constant_location_t iron_g5_compute_shader_get_constant_location(iron_g5_compute_shader *shader, const char *name) { + iron_g5_constant_location_t location = {0}; - uint32_t hash = kinc_internal_hash_name((unsigned char *)name); + uint32_t hash = iron_internal_hash_name((unsigned char *)name); - kinc_compute_internal_shader_constant_t *constant = findComputeConstant(shader->impl.constants, hash); + iron_compute_internal_shader_constant_t *constant = findComputeConstant(shader->impl.constants, hash); if (constant == NULL) { location.impl.computeOffset = 0; location.impl.computeSize = 0; @@ -1171,13 +1171,13 @@ kinc_g5_constant_location_t kinc_g5_compute_shader_get_constant_location(kinc_g5 } if (location.impl.computeSize == 0) { - kinc_log("Uniform %s not found.", name); + iron_log("Uniform %s not found.", name); } return location; } -kinc_g5_texture_unit_t kinc_g5_compute_shader_get_texture_unit(kinc_g5_compute_shader *shader, const char *name) { +iron_g5_texture_unit_t iron_g5_compute_shader_get_texture_unit(iron_g5_compute_shader *shader, const char *name) { char unitName[64]; int unitOffset = 0; size_t len = strlen(name); @@ -1189,55 +1189,55 @@ kinc_g5_texture_unit_t kinc_g5_compute_shader_get_texture_unit(kinc_g5_compute_s unitName[len - 3] = 0; // Strip array from name } - uint32_t hash = kinc_internal_hash_name((unsigned char *)unitName); + uint32_t hash = iron_internal_hash_name((unsigned char *)unitName); - kinc_g5_texture_unit_t unit; - for (int i = 0; i < KINC_G5_SHADER_TYPE_COUNT; ++i) { + iron_g5_texture_unit_t unit; + for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { unit.stages[i] = -1; } - kinc_internal_hash_index_t *computeUnit = findComputeTextureUnit(shader->impl.textures, hash); + iron_internal_hash_index_t *computeUnit = findComputeTextureUnit(shader->impl.textures, hash); if (computeUnit == NULL) { #ifndef NDEBUG static int notFoundCount = 0; if (notFoundCount < 10) { - kinc_log("Sampler %s not found.", unitName); + iron_log("Sampler %s not found.", unitName); ++notFoundCount; } else if (notFoundCount == 10) { - kinc_log("Giving up on sampler not found messages.", unitName); + iron_log("Giving up on sampler not found messages.", unitName); ++notFoundCount; } #endif } else { - unit.stages[KINC_G5_SHADER_TYPE_COMPUTE] = computeUnit->index + unitOffset; + unit.stages[IRON_G5_SHADER_TYPE_COMPUTE] = computeUnit->index + unitOffset; } return unit; } -void kinc_g5_internal_setConstants(kinc_g5_command_list_t *commandList, kinc_g5_pipeline_t *pipeline) { +void iron_g5_internal_setConstants(iron_g5_command_list_t *commandList, iron_g5_pipeline_t *pipeline) { commandList->impl._commandList->lpVtbl->SetGraphicsRootSignature(commandList->impl._commandList, globalRootSignature); if (pipeline->impl.textures > 0) { - kinc_g5_internal_set_textures(commandList); + iron_g5_internal_set_textures(commandList); } } -void kinc_g5_internal_set_compute_constants(kinc_g5_command_list_t *commandList) { +void iron_g5_internal_set_compute_constants(iron_g5_command_list_t *commandList) { commandList->impl._commandList->lpVtbl->SetComputeRootSignature(commandList->impl._commandList, globalComputeRootSignature); //if (pipeline->impl.textures > 0) { - kinc_g5_internal_set_textures(commandList); + iron_g5_internal_set_textures(commandList); //} } -void kinc_g5_pipeline_init(kinc_g5_pipeline_t *pipe) { - kinc_g5_internal_pipeline_set_defaults(pipe); - kinc_g5_internal_pipeline_init(pipe); +void iron_g5_pipeline_init(iron_g5_pipeline_t *pipe) { + iron_g5_internal_pipeline_set_defaults(pipe); + iron_g5_internal_pipeline_init(pipe); } -void kinc_g5_pipeline_destroy(kinc_g5_pipeline_t *pipe) { +void iron_g5_pipeline_destroy(iron_g5_pipeline_t *pipe) { if (pipe->impl.pso != NULL) { pipe->impl.pso->lpVtbl->Release(pipe->impl.pso); pipe->impl.pso = NULL; @@ -1246,7 +1246,7 @@ void kinc_g5_pipeline_destroy(kinc_g5_pipeline_t *pipe) { #define MAX_SHADER_THING 32 -static ShaderConstant findConstant(kinc_g5_shader_t *shader, const char *name) { +static ShaderConstant findConstant(iron_g5_shader_t *shader, const char *name) { if (shader != NULL) { for (int i = 0; i < MAX_SHADER_THING; ++i) { if (strcmp(shader->impl.constants[i].name, name) == 0) { @@ -1262,7 +1262,7 @@ static ShaderConstant findConstant(kinc_g5_shader_t *shader, const char *name) { return constant; } -static ShaderTexture findTexture(kinc_g5_shader_t *shader, const char *name) { +static ShaderTexture findTexture(iron_g5_shader_t *shader, const char *name) { for (int i = 0; i < MAX_SHADER_THING; ++i) { if (strcmp(shader->impl.textures[i].name, name) == 0) { return shader->impl.textures[i]; @@ -1275,7 +1275,7 @@ static ShaderTexture findTexture(kinc_g5_shader_t *shader, const char *name) { return texture; } -static ShaderAttribute findAttribute(kinc_g5_shader_t *shader, const char *name) { +static ShaderAttribute findAttribute(iron_g5_shader_t *shader, const char *name) { for (int i = 0; i < MAX_SHADER_THING; ++i) { if (strcmp(shader->impl.attributes[i].name, name) == 0) { return shader->impl.attributes[i]; @@ -1288,8 +1288,8 @@ static ShaderAttribute findAttribute(kinc_g5_shader_t *shader, const char *name) return attribute; } -kinc_g5_constant_location_t kinc_g5_pipeline_get_constant_location(struct kinc_g5_pipeline *pipe, const char *name) { - kinc_g5_constant_location_t location; +iron_g5_constant_location_t iron_g5_pipeline_get_constant_location(struct iron_g5_pipeline *pipe, const char *name) { + iron_g5_constant_location_t location; { ShaderConstant constant = findConstant(pipe->vertex_shader, name); @@ -1309,48 +1309,48 @@ kinc_g5_constant_location_t kinc_g5_pipeline_get_constant_location(struct kinc_g return location; } -kinc_g5_texture_unit_t kinc_g5_pipeline_get_texture_unit(kinc_g5_pipeline_t *pipe, const char *name) { - kinc_g5_texture_unit_t unit; - for (int i = 0; i < KINC_G5_SHADER_TYPE_COUNT; ++i) { +iron_g5_texture_unit_t iron_g5_pipeline_get_texture_unit(iron_g5_pipeline_t *pipe, const char *name) { + iron_g5_texture_unit_t unit; + for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { unit.stages[i] = -1; } ShaderTexture vertexTexture = findTexture(pipe->vertex_shader, name); if (vertexTexture.texture != -1) { - unit.stages[KINC_G5_SHADER_TYPE_VERTEX] = vertexTexture.texture; + unit.stages[IRON_G5_SHADER_TYPE_VERTEX] = vertexTexture.texture; } else { ShaderTexture fragmentTexture = findTexture(pipe->fragment_shader, name); - unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT] = fragmentTexture.texture; + unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] = fragmentTexture.texture; } return unit; } -static D3D12_BLEND convert_blend_factor(kinc_g5_blending_factor_t factor) { +static D3D12_BLEND convert_blend_factor(iron_g5_blending_factor_t factor) { switch (factor) { - case KINC_G5_BLEND_ONE: + case IRON_G5_BLEND_ONE: return D3D12_BLEND_ONE; - case KINC_G5_BLEND_ZERO: + case IRON_G5_BLEND_ZERO: return D3D12_BLEND_ZERO; - case KINC_G5_BLEND_SOURCE_ALPHA: + case IRON_G5_BLEND_SOURCE_ALPHA: return D3D12_BLEND_SRC_ALPHA; - case KINC_G5_BLEND_DEST_ALPHA: + case IRON_G5_BLEND_DEST_ALPHA: return D3D12_BLEND_DEST_ALPHA; - case KINC_G5_BLEND_INV_SOURCE_ALPHA: + case IRON_G5_BLEND_INV_SOURCE_ALPHA: return D3D12_BLEND_INV_SRC_ALPHA; - case KINC_G5_BLEND_INV_DEST_ALPHA: + case IRON_G5_BLEND_INV_DEST_ALPHA: return D3D12_BLEND_INV_DEST_ALPHA; - case KINC_G5_BLEND_SOURCE_COLOR: + case IRON_G5_BLEND_SOURCE_COLOR: return D3D12_BLEND_SRC_COLOR; - case KINC_G5_BLEND_DEST_COLOR: + case IRON_G5_BLEND_DEST_COLOR: return D3D12_BLEND_DEST_COLOR; - case KINC_G5_BLEND_INV_SOURCE_COLOR: + case IRON_G5_BLEND_INV_SOURCE_COLOR: return D3D12_BLEND_INV_SRC_COLOR; - case KINC_G5_BLEND_INV_DEST_COLOR: + case IRON_G5_BLEND_INV_DEST_COLOR: return D3D12_BLEND_INV_DEST_COLOR; - case KINC_G5_BLEND_CONSTANT: + case IRON_G5_BLEND_CONSTANT: return D3D12_BLEND_BLEND_FACTOR; - case KINC_G5_BLEND_INV_CONSTANT: + case IRON_G5_BLEND_INV_CONSTANT: return D3D12_BLEND_INV_BLEND_FACTOR; default: assert(false); @@ -1358,17 +1358,17 @@ static D3D12_BLEND convert_blend_factor(kinc_g5_blending_factor_t factor) { } } -static D3D12_BLEND_OP convert_blend_operation(kinc_g5_blending_operation_t op) { +static D3D12_BLEND_OP convert_blend_operation(iron_g5_blending_operation_t op) { switch (op) { - case KINC_G5_BLENDOP_ADD: + case IRON_G5_BLENDOP_ADD: return D3D12_BLEND_OP_ADD; - case KINC_G5_BLENDOP_SUBTRACT: + case IRON_G5_BLENDOP_SUBTRACT: return D3D12_BLEND_OP_SUBTRACT; - case KINC_G5_BLENDOP_REVERSE_SUBTRACT: + case IRON_G5_BLENDOP_REVERSE_SUBTRACT: return D3D12_BLEND_OP_REV_SUBTRACT; - case KINC_G5_BLENDOP_MIN: + case IRON_G5_BLENDOP_MIN: return D3D12_BLEND_OP_MIN; - case KINC_G5_BLENDOP_MAX: + case IRON_G5_BLENDOP_MAX: return D3D12_BLEND_OP_MAX; default: assert(false); @@ -1376,61 +1376,61 @@ static D3D12_BLEND_OP convert_blend_operation(kinc_g5_blending_operation_t op) { } } -static D3D12_CULL_MODE convert_cull_mode(kinc_g5_cull_mode_t cull_mode) { +static D3D12_CULL_MODE convert_cull_mode(iron_g5_cull_mode_t cull_mode) { switch (cull_mode) { - case KINC_G5_CULL_MODE_CLOCKWISE: + case IRON_G5_CULL_MODE_CLOCKWISE: return D3D12_CULL_MODE_FRONT; - case KINC_G5_CULL_MODE_COUNTERCLOCKWISE: + case IRON_G5_CULL_MODE_COUNTERCLOCKWISE: return D3D12_CULL_MODE_BACK; - case KINC_G5_CULL_MODE_NEVER: + case IRON_G5_CULL_MODE_NEVER: default: return D3D12_CULL_MODE_NONE; } } -static D3D12_COMPARISON_FUNC convert_compare_mode(kinc_g5_compare_mode_t compare) { +static D3D12_COMPARISON_FUNC convert_compare_mode(iron_g5_compare_mode_t compare) { switch (compare) { default: - case KINC_G5_COMPARE_MODE_ALWAYS: + case IRON_G5_COMPARE_MODE_ALWAYS: return D3D12_COMPARISON_FUNC_ALWAYS; - case KINC_G5_COMPARE_MODE_NEVER: + case IRON_G5_COMPARE_MODE_NEVER: return D3D12_COMPARISON_FUNC_NEVER; - case KINC_G5_COMPARE_MODE_EQUAL: + case IRON_G5_COMPARE_MODE_EQUAL: return D3D12_COMPARISON_FUNC_EQUAL; - case KINC_G5_COMPARE_MODE_NOT_EQUAL: + case IRON_G5_COMPARE_MODE_NOT_EQUAL: return D3D12_COMPARISON_FUNC_NOT_EQUAL; - case KINC_G5_COMPARE_MODE_LESS: + case IRON_G5_COMPARE_MODE_LESS: return D3D12_COMPARISON_FUNC_LESS; - case KINC_G5_COMPARE_MODE_LESS_EQUAL: + case IRON_G5_COMPARE_MODE_LESS_EQUAL: return D3D12_COMPARISON_FUNC_LESS_EQUAL; - case KINC_G5_COMPARE_MODE_GREATER: + case IRON_G5_COMPARE_MODE_GREATER: return D3D12_COMPARISON_FUNC_GREATER; - case KINC_G5_COMPARE_MODE_GREATER_EQUAL: + case IRON_G5_COMPARE_MODE_GREATER_EQUAL: return D3D12_COMPARISON_FUNC_GREATER_EQUAL; } } -static DXGI_FORMAT convert_format(kinc_image_format_t format) { +static DXGI_FORMAT convert_format(iron_image_format_t format) { switch (format) { - case KINC_IMAGE_FORMAT_RGBA128: + case IRON_IMAGE_FORMAT_RGBA128: return DXGI_FORMAT_R32G32B32A32_FLOAT; - case KINC_IMAGE_FORMAT_RGBA64: + case IRON_IMAGE_FORMAT_RGBA64: return DXGI_FORMAT_R16G16B16A16_FLOAT; - case KINC_IMAGE_FORMAT_R32: + case IRON_IMAGE_FORMAT_R32: return DXGI_FORMAT_R32_FLOAT; - case KINC_IMAGE_FORMAT_R16: + case IRON_IMAGE_FORMAT_R16: return DXGI_FORMAT_R16_FLOAT; - case KINC_IMAGE_FORMAT_R8: + case IRON_IMAGE_FORMAT_R8: return DXGI_FORMAT_R8_UNORM; - case KINC_IMAGE_FORMAT_RGBA32: + case IRON_IMAGE_FORMAT_RGBA32: default: return DXGI_FORMAT_R8G8B8A8_UNORM; } } -static void set_blend_state(D3D12_BLEND_DESC *blend_desc, kinc_g5_pipeline_t *pipe, int target) { - blend_desc->RenderTarget[target].BlendEnable = pipe->blend_source != KINC_G5_BLEND_ONE || pipe->blend_destination != KINC_G5_BLEND_ZERO || - pipe->alpha_blend_source != KINC_G5_BLEND_ONE || pipe->alpha_blend_destination != KINC_G5_BLEND_ZERO; +static void set_blend_state(D3D12_BLEND_DESC *blend_desc, iron_g5_pipeline_t *pipe, int target) { + blend_desc->RenderTarget[target].BlendEnable = pipe->blend_source != IRON_G5_BLEND_ONE || pipe->blend_destination != IRON_G5_BLEND_ZERO || + pipe->alpha_blend_source != IRON_G5_BLEND_ONE || pipe->alpha_blend_destination != IRON_G5_BLEND_ZERO; blend_desc->RenderTarget[target].SrcBlend = convert_blend_factor(pipe->blend_source); blend_desc->RenderTarget[target].DestBlend = convert_blend_factor(pipe->blend_destination); blend_desc->RenderTarget[target].BlendOp = convert_blend_operation(pipe->blend_operation); @@ -1444,7 +1444,7 @@ static void set_blend_state(D3D12_BLEND_DESC *blend_desc, kinc_g5_pipeline_t *pi (pipe->color_write_mask_alpha[target] ? D3D12_COLOR_WRITE_ENABLE_ALPHA : 0); } -void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipe) { +void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipe) { int vertexAttributeCount = pipe->input_layout->size; D3D12_INPUT_ELEMENT_DESC *vertexDesc = (D3D12_INPUT_ELEMENT_DESC *)alloca(sizeof(D3D12_INPUT_ELEMENT_DESC) * vertexAttributeCount); @@ -1459,25 +1459,25 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipe) { vertexDesc[i].InstanceDataStepRate = 0; switch (pipe->input_layout->elements[i].data) { - case KINC_G5_VERTEX_DATA_F32_1X: + case IRON_G5_VERTEX_DATA_F32_1X: vertexDesc[i].Format = DXGI_FORMAT_R32_FLOAT; break; - case KINC_G5_VERTEX_DATA_F32_2X: + case IRON_G5_VERTEX_DATA_F32_2X: vertexDesc[i].Format = DXGI_FORMAT_R32G32_FLOAT; break; - case KINC_G5_VERTEX_DATA_F32_3X: + case IRON_G5_VERTEX_DATA_F32_3X: vertexDesc[i].Format = DXGI_FORMAT_R32G32B32_FLOAT; break; - case KINC_G5_VERTEX_DATA_F32_4X: + case IRON_G5_VERTEX_DATA_F32_4X: vertexDesc[i].Format = DXGI_FORMAT_R32G32B32A32_FLOAT; break; - case KINC_G5_VERTEX_DATA_U8_4X_NORM: + case IRON_G5_VERTEX_DATA_U8_4X_NORM: vertexDesc[i].Format = DXGI_FORMAT_R8G8B8A8_UNORM; break; - case KINC_G5_VERTEX_DATA_I16_2X_NORM: + case IRON_G5_VERTEX_DATA_I16_2X_NORM: vertexDesc[i].Format = DXGI_FORMAT_R16G16_SNORM; break; - case KINC_G5_VERTEX_DATA_I16_4X_NORM: + case IRON_G5_VERTEX_DATA_I16_4X_NORM: vertexDesc[i].Format = DXGI_FORMAT_R16G16B16A16_SNORM; break; default: @@ -1562,7 +1562,7 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipe) { psoDesc.DepthStencilState.FrontFace = defaultStencilOp; psoDesc.DepthStencilState.BackFace = defaultStencilOp; - psoDesc.DepthStencilState.DepthEnable = pipe->depth_mode != KINC_G5_COMPARE_MODE_ALWAYS; + psoDesc.DepthStencilState.DepthEnable = pipe->depth_mode != IRON_G5_COMPARE_MODE_ALWAYS; psoDesc.DepthStencilState.DepthWriteMask = pipe->depth_write ? D3D12_DEPTH_WRITE_MASK_ALL : D3D12_DEPTH_WRITE_MASK_ZERO; psoDesc.DepthStencilState.DepthFunc = convert_compare_mode(pipe->depth_mode); psoDesc.DepthStencilState.StencilEnable = false; @@ -1573,19 +1573,19 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipe) { hr = device->lpVtbl->CreateGraphicsPipelineState(device , &psoDesc, &IID_ID3D12PipelineState, &pipe->impl.pso); if (hr != S_OK) { - kinc_log("Could not create pipeline."); + iron_log("Could not create pipeline."); } } -static D3D12_TEXTURE_ADDRESS_MODE convert_texture_addressing(kinc_g5_texture_addressing_t addressing) { +static D3D12_TEXTURE_ADDRESS_MODE convert_texture_addressing(iron_g5_texture_addressing_t addressing) { switch (addressing) { - case KINC_G5_TEXTURE_ADDRESSING_REPEAT: + case IRON_G5_TEXTURE_ADDRESSING_REPEAT: return D3D12_TEXTURE_ADDRESS_MODE_WRAP; - case KINC_G5_TEXTURE_ADDRESSING_MIRROR: + case IRON_G5_TEXTURE_ADDRESSING_MIRROR: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR; - case KINC_G5_TEXTURE_ADDRESSING_CLAMP: + case IRON_G5_TEXTURE_ADDRESSING_CLAMP: return D3D12_TEXTURE_ADDRESS_MODE_CLAMP; - case KINC_G5_TEXTURE_ADDRESSING_BORDER: + case IRON_G5_TEXTURE_ADDRESSING_BORDER: return D3D12_TEXTURE_ADDRESS_MODE_BORDER; default: assert(false); @@ -1593,51 +1593,51 @@ static D3D12_TEXTURE_ADDRESS_MODE convert_texture_addressing(kinc_g5_texture_add } } -static D3D12_FILTER convert_filter(kinc_g5_texture_filter_t minification, kinc_g5_texture_filter_t magnification, kinc_g5_mipmap_filter_t mipmap) { +static D3D12_FILTER convert_filter(iron_g5_texture_filter_t minification, iron_g5_texture_filter_t magnification, iron_g5_mipmap_filter_t mipmap) { switch (minification) { - case KINC_G5_TEXTURE_FILTER_POINT: + case IRON_G5_TEXTURE_FILTER_POINT: switch (magnification) { - case KINC_G5_TEXTURE_FILTER_POINT: + case IRON_G5_TEXTURE_FILTER_POINT: switch (mipmap) { - case KINC_G5_MIPMAP_FILTER_NONE: - case KINC_G5_MIPMAP_FILTER_POINT: + case IRON_G5_MIPMAP_FILTER_NONE: + case IRON_G5_MIPMAP_FILTER_POINT: return D3D12_FILTER_MIN_MAG_MIP_POINT; - case KINC_G5_MIPMAP_FILTER_LINEAR: + case IRON_G5_MIPMAP_FILTER_LINEAR: return D3D12_FILTER_MIN_MAG_POINT_MIP_LINEAR; } - case KINC_G5_TEXTURE_FILTER_LINEAR: + case IRON_G5_TEXTURE_FILTER_LINEAR: switch (mipmap) { - case KINC_G5_MIPMAP_FILTER_NONE: - case KINC_G5_MIPMAP_FILTER_POINT: + case IRON_G5_MIPMAP_FILTER_NONE: + case IRON_G5_MIPMAP_FILTER_POINT: return D3D12_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT; - case KINC_G5_MIPMAP_FILTER_LINEAR: + case IRON_G5_MIPMAP_FILTER_LINEAR: return D3D12_FILTER_MIN_POINT_MAG_MIP_LINEAR; } - case KINC_G5_TEXTURE_FILTER_ANISOTROPIC: + case IRON_G5_TEXTURE_FILTER_ANISOTROPIC: return D3D12_FILTER_ANISOTROPIC; } - case KINC_G5_TEXTURE_FILTER_LINEAR: + case IRON_G5_TEXTURE_FILTER_LINEAR: switch (magnification) { - case KINC_G5_TEXTURE_FILTER_POINT: + case IRON_G5_TEXTURE_FILTER_POINT: switch (mipmap) { - case KINC_G5_MIPMAP_FILTER_NONE: - case KINC_G5_MIPMAP_FILTER_POINT: + case IRON_G5_MIPMAP_FILTER_NONE: + case IRON_G5_MIPMAP_FILTER_POINT: return D3D12_FILTER_MIN_LINEAR_MAG_MIP_POINT; - case KINC_G5_MIPMAP_FILTER_LINEAR: + case IRON_G5_MIPMAP_FILTER_LINEAR: return D3D12_FILTER_MIN_MAG_MIP_LINEAR; } - case KINC_G5_TEXTURE_FILTER_LINEAR: + case IRON_G5_TEXTURE_FILTER_LINEAR: switch (mipmap) { - case KINC_G5_MIPMAP_FILTER_NONE: - case KINC_G5_MIPMAP_FILTER_POINT: + case IRON_G5_MIPMAP_FILTER_NONE: + case IRON_G5_MIPMAP_FILTER_POINT: return D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT; - case KINC_G5_MIPMAP_FILTER_LINEAR: + case IRON_G5_MIPMAP_FILTER_LINEAR: return D3D12_FILTER_MIN_MAG_MIP_LINEAR; } - case KINC_G5_TEXTURE_FILTER_ANISOTROPIC: + case IRON_G5_TEXTURE_FILTER_ANISOTROPIC: return D3D12_FILTER_ANISOTROPIC; } - case KINC_G5_TEXTURE_FILTER_ANISOTROPIC: + case IRON_G5_TEXTURE_FILTER_ANISOTROPIC: return D3D12_FILTER_ANISOTROPIC; } @@ -1645,7 +1645,7 @@ static D3D12_FILTER convert_filter(kinc_g5_texture_filter_t minification, kinc_g return D3D12_FILTER_MIN_MAG_MIP_POINT; } -void kinc_g5_sampler_init(kinc_g5_sampler_t *sampler, const kinc_g5_sampler_options_t *options) { +void iron_g5_sampler_init(iron_g5_sampler_t *sampler, const iron_g5_sampler_options_t *options) { D3D12_DESCRIPTOR_HEAP_DESC descHeapSampler = {}; descHeapSampler.NumDescriptors = 2; descHeapSampler.Type = D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER; @@ -1668,9 +1668,9 @@ void kinc_g5_sampler_init(kinc_g5_sampler_t *sampler, const kinc_g5_sampler_opti device->lpVtbl->CreateSampler(device, &samplerDesc, handle); } -void kinc_g5_sampler_destroy(kinc_g5_sampler_t *sampler) {} +void iron_g5_sampler_destroy(iron_g5_sampler_t *sampler) {} -void kinc_g5_shader_init(kinc_g5_shader_t *shader, const void *_data, size_t length, kinc_g5_shader_type_t type) { +void iron_g5_shader_init(iron_g5_shader_t *shader, const void *_data, size_t length, iron_g5_shader_type_t type) { memset(shader->impl.constants, 0, sizeof(shader->impl.constants)); memset(shader->impl.attributes, 0, sizeof(shader->impl.attributes)); memset(shader->impl.textures, 0, sizeof(shader->impl.textures)); @@ -1728,12 +1728,12 @@ void kinc_g5_shader_init(kinc_g5_shader_t *shader, const void *_data, size_t len memcpy(shader->impl.data, &data[index], shader->impl.length); } -void kinc_g5_shader_destroy(kinc_g5_shader_t *shader) { +void iron_g5_shader_destroy(iron_g5_shader_t *shader) { free(shader->impl.data); } // djb2 -uint32_t kinc_internal_hash_name(unsigned char *str) { +uint32_t iron_internal_hash_name(unsigned char *str) { unsigned long hash = 5381; int c; while ((c = *str++)) { @@ -1744,8 +1744,8 @@ uint32_t kinc_internal_hash_name(unsigned char *str) { static const int heapSize = 1024; -void kinc_g5_internal_reset_textures(struct kinc_g5_command_list *list) { - for (int i = 0; i < KINC_INTERNAL_G5_TEXTURE_COUNT; ++i) { +void iron_g5_internal_reset_textures(struct iron_g5_command_list *list) { + for (int i = 0; i < IRON_INTERNAL_G5_TEXTURE_COUNT; ++i) { list->impl.currentTextures[i] = NULL; list->impl.current_samplers[i] = NULL; } @@ -1760,48 +1760,48 @@ static inline UINT64 GetRequiredIntermediateSize(ID3D12Resource *destinationReso return requiredSize; } -static DXGI_FORMAT convertImageFormat(kinc_image_format_t format) { +static DXGI_FORMAT convertImageFormat(iron_image_format_t format) { switch (format) { - case KINC_IMAGE_FORMAT_RGBA128: + case IRON_IMAGE_FORMAT_RGBA128: return DXGI_FORMAT_R32G32B32A32_FLOAT; - case KINC_IMAGE_FORMAT_RGBA64: + case IRON_IMAGE_FORMAT_RGBA64: return DXGI_FORMAT_R16G16B16A16_FLOAT; - case KINC_IMAGE_FORMAT_R8: + case IRON_IMAGE_FORMAT_R8: return DXGI_FORMAT_R8_UNORM; - case KINC_IMAGE_FORMAT_BGRA32: + case IRON_IMAGE_FORMAT_BGRA32: return DXGI_FORMAT_B8G8R8A8_UNORM; - case KINC_IMAGE_FORMAT_RGBA32: + case IRON_IMAGE_FORMAT_RGBA32: return DXGI_FORMAT_R8G8B8A8_UNORM; default: return DXGI_FORMAT_R8G8B8A8_UNORM; } } -static int formatByteSize(kinc_image_format_t format) { +static int formatByteSize(iron_image_format_t format) { switch (format) { - case KINC_IMAGE_FORMAT_RGBA128: + case IRON_IMAGE_FORMAT_RGBA128: return 16; - case KINC_IMAGE_FORMAT_RGBA64: + case IRON_IMAGE_FORMAT_RGBA64: return 8; - case KINC_IMAGE_FORMAT_R8: + case IRON_IMAGE_FORMAT_R8: return 1; - case KINC_IMAGE_FORMAT_R16: + case IRON_IMAGE_FORMAT_R16: return 2; - case KINC_IMAGE_FORMAT_BGRA32: - case KINC_IMAGE_FORMAT_RGBA32: - case KINC_IMAGE_FORMAT_R32: + case IRON_IMAGE_FORMAT_BGRA32: + case IRON_IMAGE_FORMAT_RGBA32: + case IRON_IMAGE_FORMAT_R32: return 4; default: return 4; } } -void kinc_g5_internal_set_textures(kinc_g5_command_list_t *list) { +void iron_g5_internal_set_textures(iron_g5_command_list_t *list) { if (list->impl.currentTextures[0] != NULL) { int srvStep = device->lpVtbl->GetDescriptorHandleIncrementSize(device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); int samplerStep = device->lpVtbl->GetDescriptorHandleIncrementSize(device, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); - if (list->impl.heapIndex + KINC_INTERNAL_G5_TEXTURE_COUNT >= heapSize) { + if (list->impl.heapIndex + IRON_INTERNAL_G5_TEXTURE_COUNT >= heapSize) { list->impl.heapIndex = 0; } @@ -1812,7 +1812,7 @@ void kinc_g5_internal_set_textures(kinc_g5_command_list_t *list) { srvGpu.ptr += list->impl.heapIndex * srvStep; samplerGpu.ptr += list->impl.heapIndex * samplerStep; - for (int i = 0; i < KINC_INTERNAL_G5_TEXTURE_COUNT; ++i) { + for (int i = 0; i < IRON_INTERNAL_G5_TEXTURE_COUNT; ++i) { if (list->impl.currentTextures[i] != NULL && list->impl.current_samplers[i] != NULL) { ID3D12DescriptorHeap *samplerDescriptorHeap = list->impl.current_samplers[i]->impl.sampler_heap; @@ -1858,7 +1858,7 @@ void kinc_g5_internal_set_textures(kinc_g5_command_list_t *list) { } } -void createHeaps(kinc_g5_command_list_t *list) { +void createHeaps(iron_g5_command_list_t *list) { D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {}; heapDesc.NumDescriptors = heapSize; heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; @@ -1872,9 +1872,9 @@ void createHeaps(kinc_g5_command_list_t *list) { device->lpVtbl->CreateDescriptorHeap(device, &samplerHeapDesc, &IID_ID3D12DescriptorHeap, &list->impl.samplerHeap); } -void kinc_memory_emergency(); +void iron_memory_emergency(); -void kinc_g5_texture_init_from_bytes(kinc_g5_texture_t *texture, void *data, int width, int height, kinc_image_format_t format) { +void iron_g5_texture_init_from_bytes(iron_g5_texture_t *texture, void *data, int width, int height, iron_image_format_t format) { memset(&texture->impl, 0, sizeof(texture->impl)); texture->impl.stage = 0; texture->impl.stage_depth = -1; @@ -1884,7 +1884,7 @@ void kinc_g5_texture_init_from_bytes(kinc_g5_texture_t *texture, void *data, int texture->_uploaded = false; texture->format = format; texture->data = data; - texture->state = KINC_INTERNAL_RENDER_TARGET_STATE_TEXTURE; + texture->state = IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE; texture->framebuffer_index = -1; texture->impl.renderTarget = NULL; @@ -1916,7 +1916,7 @@ void kinc_g5_texture_init_from_bytes(kinc_g5_texture_t *texture, void *data, int NULL, &IID_ID3D12Resource, &texture->impl.image); if (result != S_OK) { for (int i = 0; i < 10; ++i) { - kinc_memory_emergency(); + iron_memory_emergency(); result = device->lpVtbl->CreateCommittedResource(device, &heapPropertiesDefault, D3D12_HEAP_FLAG_NONE, &resourceDescTex, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, NULL, &IID_ID3D12Resource, &texture->impl.image); @@ -1952,7 +1952,7 @@ void kinc_g5_texture_init_from_bytes(kinc_g5_texture_t *texture, void *data, int &IID_ID3D12Resource, &texture->impl.uploadImage); if (result != S_OK) { for (int i = 0; i < 10; ++i) { - kinc_memory_emergency(); + iron_memory_emergency(); result = device->lpVtbl->CreateCommittedResource(device, &heapPropertiesUpload, D3D12_HEAP_FLAG_NONE, &resourceDescBuffer, D3D12_RESOURCE_STATE_GENERIC_READ, NULL, &IID_ID3D12Resource, &texture->impl.uploadImage); @@ -1966,7 +1966,7 @@ void kinc_g5_texture_init_from_bytes(kinc_g5_texture_t *texture, void *data, int BYTE *pixel; texture->impl.uploadImage->lpVtbl->Map(texture->impl.uploadImage, 0, NULL, (void **)&pixel); - int pitch = kinc_g5_texture_stride(texture); + int pitch = iron_g5_texture_stride(texture); for (int y = 0; y < texture->height; ++y) { memcpy(&pixel[y * pitch], &((uint8_t *)data)[y * texture->width * formatSize], texture->width * formatSize); } @@ -1995,7 +1995,7 @@ void kinc_g5_texture_init_from_bytes(kinc_g5_texture_t *texture, void *data, int device->lpVtbl->CreateShaderResourceView(device, texture->impl.image, &shaderResourceViewDesc, handle); } -void create_texture(struct kinc_g5_texture *texture, int width, int height, kinc_image_format_t format, D3D12_RESOURCE_FLAGS flags) { +void create_texture(struct iron_g5_texture *texture, int width, int height, iron_image_format_t format, D3D12_RESOURCE_FLAGS flags) { memset(&texture->impl, 0, sizeof(texture->impl)); texture->impl.stage = 0; texture->impl.stage_depth = -1; @@ -2033,7 +2033,7 @@ void create_texture(struct kinc_g5_texture *texture, int width, int height, kinc NULL, &IID_ID3D12Resource, &texture->impl.image); if (result != S_OK) { for (int i = 0; i < 10; ++i) { - kinc_memory_emergency(); + iron_memory_emergency(); result = device->lpVtbl->CreateCommittedResource(device, &heapPropertiesDefault, D3D12_HEAP_FLAG_NONE, &resourceDescTex, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, NULL, &IID_ID3D12Resource, &texture->impl.image); @@ -2069,7 +2069,7 @@ void create_texture(struct kinc_g5_texture *texture, int width, int height, kinc &IID_ID3D12Resource, &texture->impl.uploadImage); if (result != S_OK) { for (int i = 0; i < 10; ++i) { - kinc_memory_emergency(); + iron_memory_emergency(); result = device->lpVtbl->CreateCommittedResource(device, &heapPropertiesUpload, D3D12_HEAP_FLAG_NONE, &resourceDescBuffer, D3D12_RESOURCE_STATE_GENERIC_READ, NULL, &IID_ID3D12Resource, &texture->impl.uploadImage); @@ -2105,20 +2105,20 @@ void create_texture(struct kinc_g5_texture *texture, int width, int height, kinc device->lpVtbl->CreateShaderResourceView(device, texture->impl.image, &shaderResourceViewDesc, handle); } -void kinc_g5_texture_init(struct kinc_g5_texture *texture, int width, int height, kinc_image_format_t format) { +void iron_g5_texture_init(struct iron_g5_texture *texture, int width, int height, iron_image_format_t format) { create_texture(texture, width, height, format, D3D12_RESOURCE_FLAG_NONE); texture->_uploaded = true; - texture->state = KINC_INTERNAL_RENDER_TARGET_STATE_TEXTURE; + texture->state = IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE; texture->format = format; } -void kinc_g5_texture_init_non_sampled_access(struct kinc_g5_texture *texture, int width, int height, kinc_image_format_t format) { +void iron_g5_texture_init_non_sampled_access(struct iron_g5_texture *texture, int width, int height, iron_image_format_t format) { create_texture(texture, width, height, format, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS); texture->_uploaded = true; - texture->state = KINC_INTERNAL_RENDER_TARGET_STATE_TEXTURE; + texture->state = IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE; } -void kinc_g5_texture_destroy(kinc_g5_texture_t *render_target) { +void iron_g5_texture_destroy(iron_g5_texture_t *render_target) { if (render_target->impl.framebuffer_index >= 0) { framebuffer_count -= 1; } @@ -2144,24 +2144,24 @@ void kinc_g5_texture_destroy(kinc_g5_texture_t *render_target) { } } -void kinc_g5_internal_texture_unmipmap(struct kinc_g5_texture *texture) { +void iron_g5_internal_texture_unmipmap(struct iron_g5_texture *texture) { texture->impl.mipmap = false; } -void kinc_g5_internal_sampler_set(kinc_g5_command_list_t *list, kinc_g5_sampler_t *sampler, int unit) { +void iron_g5_internal_sampler_set(iron_g5_command_list_t *list, iron_g5_sampler_t *sampler, int unit) { if (unit < 0) return; list->impl.current_samplers[unit] = sampler; } -int kinc_g5_texture_stride(struct kinc_g5_texture *texture) { +int iron_g5_texture_stride(struct iron_g5_texture *texture) { return texture->impl.stride; } -void kinc_g5_texture_generate_mipmaps(struct kinc_g5_texture *texture, int levels) {} +void iron_g5_texture_generate_mipmaps(struct iron_g5_texture *texture, int levels) {} -void kinc_g5_texture_set_mipmap(struct kinc_g5_texture *texture, struct kinc_g5_texture *mipmap, int level) {} +void iron_g5_texture_set_mipmap(struct iron_g5_texture *texture, struct iron_g5_texture *mipmap, int level) {} static void WaitForFence(ID3D12Fence *fence, UINT64 completionValue, HANDLE waitEvent) { if (fence->lpVtbl->GetCompletedValue(fence) < completionValue) { @@ -2183,27 +2183,27 @@ static void createRenderTargetView(ID3D12Resource *renderTarget, ID3D12Descripto device->lpVtbl->CreateRenderTargetView(device, renderTarget, &viewDesc, handle); } -static DXGI_FORMAT convertFormat(kinc_image_format_t format) { +static DXGI_FORMAT convertFormat(iron_image_format_t format) { switch (format) { - case KINC_IMAGE_FORMAT_RGBA128: + case IRON_IMAGE_FORMAT_RGBA128: return DXGI_FORMAT_R32G32B32A32_FLOAT; - case KINC_IMAGE_FORMAT_RGBA64: + case IRON_IMAGE_FORMAT_RGBA64: return DXGI_FORMAT_R16G16B16A16_FLOAT; - case KINC_IMAGE_FORMAT_R32: + case IRON_IMAGE_FORMAT_R32: return DXGI_FORMAT_R32_FLOAT; - case KINC_IMAGE_FORMAT_R16: + case IRON_IMAGE_FORMAT_R16: return DXGI_FORMAT_R16_FLOAT; - case KINC_IMAGE_FORMAT_R8: + case IRON_IMAGE_FORMAT_R8: return DXGI_FORMAT_R8_UNORM; - case KINC_IMAGE_FORMAT_RGBA32: + case IRON_IMAGE_FORMAT_RGBA32: default: return DXGI_FORMAT_R8G8B8A8_UNORM; } } -void kinc_memory_emergency(); +void iron_memory_emergency(); -static void render_target_init(kinc_g5_texture_t *render_target, int width, int height, kinc_image_format_t format, int depthBufferBits, int framebuffer_index) { +static void render_target_init(iron_g5_texture_t *render_target, int width, int height, iron_image_format_t format, int depthBufferBits, int framebuffer_index) { render_target->width = render_target->width = width; render_target->height = render_target->height = height; render_target->impl.stage = 0; @@ -2247,11 +2247,11 @@ static void render_target_init(kinc_g5_texture_t *render_target, int width, int heapDesc.NumDescriptors = 1; heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; - kinc_microsoft_affirm(device->lpVtbl->CreateDescriptorHeap(device , &heapDesc, &IID_ID3D12DescriptorHeap, &render_target->impl.renderTargetDescriptorHeap)); + iron_microsoft_affirm(device->lpVtbl->CreateDescriptorHeap(device , &heapDesc, &IID_ID3D12DescriptorHeap, &render_target->impl.renderTargetDescriptorHeap)); if (framebuffer_index >= 0) { - IDXGISwapChain *swapChain = kinc_dx_current_window()->swapChain; - kinc_microsoft_affirm(swapChain->lpVtbl->GetBuffer(swapChain, framebuffer_index, &IID_ID3D12Resource, &render_target->impl.renderTarget)); + IDXGISwapChain *swapChain = iron_dx_current_window()->swapChain; + iron_microsoft_affirm(swapChain->lpVtbl->GetBuffer(swapChain, framebuffer_index, &IID_ID3D12Resource, &render_target->impl.renderTarget)); wchar_t buffer[128]; wsprintf(buffer, L"Backbuffer (index %i)", framebuffer_index); render_target->impl.renderTarget->lpVtbl->SetName(render_target->impl.renderTarget, buffer); @@ -2263,7 +2263,7 @@ static void render_target_init(kinc_g5_texture_t *render_target, int width, int &clearValue, &IID_ID3D12Resource, &render_target->impl.renderTarget); if (result != S_OK) { for (int i = 0; i < 10; ++i) { - kinc_memory_emergency(); + iron_memory_emergency(); result = device->lpVtbl->CreateCommittedResource(device, &heapProperties, D3D12_HEAP_FLAG_NONE, &texResourceDesc, D3D12_RESOURCE_STATE_RENDER_TARGET, &clearValue, &IID_ID3D12Resource, &render_target->impl.renderTarget); if (result == S_OK) { @@ -2292,7 +2292,7 @@ static void render_target_init(kinc_g5_texture_t *render_target, int width, int descriptorHeapDesc.NodeMask = 0; descriptorHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; - kinc_microsoft_affirm(device->lpVtbl->CreateDescriptorHeap(device, &descriptorHeapDesc, &IID_ID3D12DescriptorHeap, &render_target->impl.srvDescriptorHeap)); + iron_microsoft_affirm(device->lpVtbl->CreateDescriptorHeap(device, &descriptorHeapDesc, &IID_ID3D12DescriptorHeap, &render_target->impl.srvDescriptorHeap)); D3D12_SHADER_RESOURCE_VIEW_DESC shaderResourceViewDesc; ZeroMemory(&shaderResourceViewDesc, sizeof(shaderResourceViewDesc)); @@ -2314,7 +2314,7 @@ static void render_target_init(kinc_g5_texture_t *render_target, int width, int dsvHeapDesc.NumDescriptors = 1; dsvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV; dsvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; - kinc_microsoft_affirm(device->lpVtbl->CreateDescriptorHeap(device, &dsvHeapDesc, &IID_ID3D12DescriptorHeap, &render_target->impl.depthStencilDescriptorHeap)); + iron_microsoft_affirm(device->lpVtbl->CreateDescriptorHeap(device, &dsvHeapDesc, &IID_ID3D12DescriptorHeap, &render_target->impl.depthStencilDescriptorHeap)); D3D12_RESOURCE_DESC depthTexture; depthTexture.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; @@ -2346,7 +2346,7 @@ static void render_target_init(kinc_g5_texture_t *render_target, int width, int &IID_ID3D12Resource, &render_target->impl.depthStencilTexture); if (result != S_OK) { for (int i = 0; i < 10; ++i) { - kinc_memory_emergency(); + iron_memory_emergency(); result = device->lpVtbl->CreateCommittedResource(device, &heapProperties, D3D12_HEAP_FLAG_NONE, &depthTexture, D3D12_RESOURCE_STATE_DEPTH_WRITE, &clearValue, &IID_ID3D12Resource, &render_target->impl.depthStencilTexture); @@ -2367,7 +2367,7 @@ static void render_target_init(kinc_g5_texture_t *render_target, int width, int srvDepthHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; srvDepthHeapDesc.NodeMask = 0; srvDepthHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; - kinc_microsoft_affirm(device->lpVtbl->CreateDescriptorHeap(device, &srvDepthHeapDesc, &IID_ID3D12DescriptorHeap, &render_target->impl.srvDepthDescriptorHeap)); + iron_microsoft_affirm(device->lpVtbl->CreateDescriptorHeap(device, &srvDepthHeapDesc, &IID_ID3D12DescriptorHeap, &render_target->impl.srvDepthDescriptorHeap)); D3D12_SHADER_RESOURCE_VIEW_DESC srvDepthViewDesc; ZeroMemory(&srvDepthViewDesc, sizeof(srvDepthViewDesc)); @@ -2401,33 +2401,33 @@ static void render_target_init(kinc_g5_texture_t *render_target, int width, int render_target->impl.viewport.MaxDepth = 1.0f; } -void kinc_g5_render_target_init(kinc_g5_texture_t *target, int width, int height, kinc_image_format_t format, int depthBufferBits) { +void iron_g5_render_target_init(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { render_target_init(target, width, height, format, depthBufferBits, -1); target->_uploaded = true; - target->state = KINC_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; + target->state = IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; } -void kinc_g5_render_target_init_framebuffer(kinc_g5_texture_t *target, int width, int height, kinc_image_format_t format, int depthBufferBits) { +void iron_g5_render_target_init_framebuffer(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { render_target_init(target, width, height, format, depthBufferBits, framebuffer_count); framebuffer_count += 1; target->_uploaded = true; - target->state = KINC_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; + target->state = IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; } -void kinc_g5_render_target_set_depth_from(kinc_g5_texture_t *render_target, kinc_g5_texture_t *source) { +void iron_g5_render_target_set_depth_from(iron_g5_texture_t *render_target, iron_g5_texture_t *source) { render_target->impl.depthStencilDescriptorHeap = source->impl.depthStencilDescriptorHeap; render_target->impl.srvDepthDescriptorHeap = source->impl.srvDepthDescriptorHeap; render_target->impl.depthStencilTexture = source->impl.depthStencilTexture; } -kinc_g5_vertex_buffer_t *_current_vertex_buffer = NULL; +iron_g5_vertex_buffer_t *_current_vertex_buffer = NULL; -void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int count, kinc_g5_vertex_structure_t *structure, bool gpuMemory) { +void iron_g5_vertex_buffer_init(iron_g5_vertex_buffer_t *buffer, int count, iron_g5_vertex_structure_t *structure, bool gpuMemory) { buffer->impl.myCount = count; buffer->impl.myStride = 0; for (int i = 0; i < structure->size; ++i) { - buffer->impl.myStride += kinc_g5_vertex_data_size(structure->elements[i].data); + buffer->impl.myStride += iron_g5_vertex_data_size(structure->elements[i].data); } int uploadBufferSize = buffer->impl.myStride * buffer->impl.myCount; @@ -2460,19 +2460,19 @@ void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int count, kinc buffer->impl.view.StrideInBytes = buffer->impl.myStride; buffer->impl.lastStart = 0; - buffer->impl.lastCount = kinc_g5_vertex_buffer_count(buffer); + buffer->impl.lastCount = iron_g5_vertex_buffer_count(buffer); } -void kinc_g5_vertex_buffer_destroy(kinc_g5_vertex_buffer_t *buffer) { +void iron_g5_vertex_buffer_destroy(iron_g5_vertex_buffer_t *buffer) { // buffer->impl.vertexBuffer->lpVtbl->Release(); buffer->impl.uploadBuffer->lpVtbl->Release(buffer->impl.uploadBuffer); } -float *kinc_g5_vertex_buffer_lock_all(kinc_g5_vertex_buffer_t *buffer) { - return kinc_g5_vertex_buffer_lock(buffer, 0, kinc_g5_vertex_buffer_count(buffer)); +float *iron_g5_vertex_buffer_lock_all(iron_g5_vertex_buffer_t *buffer) { + return iron_g5_vertex_buffer_lock(buffer, 0, iron_g5_vertex_buffer_count(buffer)); } -float *kinc_g5_vertex_buffer_lock(kinc_g5_vertex_buffer_t *buffer, int start, int count) { +float *iron_g5_vertex_buffer_lock(iron_g5_vertex_buffer_t *buffer, int start, int count) { buffer->impl.lastStart = start; buffer->impl.lastCount = count; @@ -2487,36 +2487,36 @@ float *kinc_g5_vertex_buffer_lock(kinc_g5_vertex_buffer_t *buffer, int start, in return (float *)bytes; } -void kinc_g5_vertex_buffer_unlock_all(kinc_g5_vertex_buffer_t *buffer) { +void iron_g5_vertex_buffer_unlock_all(iron_g5_vertex_buffer_t *buffer) { D3D12_RANGE range; range.Begin = buffer->impl.lastStart * buffer->impl.myStride; range.End = (buffer->impl.lastStart + buffer->impl.lastCount) * buffer->impl.myStride; buffer->impl.uploadBuffer->lpVtbl->Unmap(buffer->impl.uploadBuffer, 0, &range); } -void kinc_g5_vertex_buffer_unlock(kinc_g5_vertex_buffer_t *buffer, int count) { +void iron_g5_vertex_buffer_unlock(iron_g5_vertex_buffer_t *buffer, int count) { D3D12_RANGE range; range.Begin = buffer->impl.lastStart * buffer->impl.myStride; range.End = (buffer->impl.lastStart + count) * buffer->impl.myStride; buffer->impl.uploadBuffer->lpVtbl->Unmap(buffer->impl.uploadBuffer, 0, &range); } -int kinc_g5_internal_vertex_buffer_set(kinc_g5_vertex_buffer_t *buffer) { +int iron_g5_internal_vertex_buffer_set(iron_g5_vertex_buffer_t *buffer) { _current_vertex_buffer = buffer; return 0; } -int kinc_g5_vertex_buffer_count(kinc_g5_vertex_buffer_t *buffer) { +int iron_g5_vertex_buffer_count(iron_g5_vertex_buffer_t *buffer) { return buffer->impl.myCount; } -int kinc_g5_vertex_buffer_stride(kinc_g5_vertex_buffer_t *buffer) { +int iron_g5_vertex_buffer_stride(iron_g5_vertex_buffer_t *buffer) { return buffer->impl.myStride; } -bool kinc_g5_transpose_mat = false; +bool iron_g5_transpose_mat = false; -void kinc_g5_constant_buffer_init(kinc_g5_constant_buffer_t *buffer, int size) { +void iron_g5_constant_buffer_init(iron_g5_constant_buffer_t *buffer, int size) { buffer->impl.mySize = size; buffer->data = NULL; @@ -2540,7 +2540,7 @@ void kinc_g5_constant_buffer_init(kinc_g5_constant_buffer_t *buffer, int size) { resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; resourceDesc.Flags = D3D12_RESOURCE_FLAG_NONE; - kinc_microsoft_affirm(device->lpVtbl->CreateCommittedResource(device , &heapProperties, D3D12_HEAP_FLAG_NONE, &resourceDesc, + iron_microsoft_affirm(device->lpVtbl->CreateCommittedResource(device , &heapProperties, D3D12_HEAP_FLAG_NONE, &resourceDesc, D3D12_RESOURCE_STATE_GENERIC_READ, NULL, &IID_ID3D12Resource, &buffer->impl.constant_buffer)); @@ -2550,15 +2550,15 @@ void kinc_g5_constant_buffer_init(kinc_g5_constant_buffer_t *buffer, int size) { buffer->impl.constant_buffer->lpVtbl->Unmap(buffer->impl.constant_buffer, 0, NULL); } -void kinc_g5_constant_buffer_destroy(kinc_g5_constant_buffer_t *buffer) { +void iron_g5_constant_buffer_destroy(iron_g5_constant_buffer_t *buffer) { buffer->impl.constant_buffer->lpVtbl->Release(buffer->impl.constant_buffer); } -void kinc_g5_constant_buffer_lock_all(kinc_g5_constant_buffer_t *buffer) { - kinc_g5_constant_buffer_lock(buffer, 0, kinc_g5_constant_buffer_size(buffer)); +void iron_g5_constant_buffer_lock_all(iron_g5_constant_buffer_t *buffer) { + iron_g5_constant_buffer_lock(buffer, 0, iron_g5_constant_buffer_size(buffer)); } -void kinc_g5_constant_buffer_lock(kinc_g5_constant_buffer_t *buffer, int start, int count) { +void iron_g5_constant_buffer_lock(iron_g5_constant_buffer_t *buffer, int start, int count) { buffer->impl.lastStart = start; buffer->impl.lastCount = count; D3D12_RANGE range; @@ -2569,7 +2569,7 @@ void kinc_g5_constant_buffer_lock(kinc_g5_constant_buffer_t *buffer, int start, buffer->data = &p[start]; } -void kinc_g5_constant_buffer_unlock(kinc_g5_constant_buffer_t *buffer) { +void iron_g5_constant_buffer_unlock(iron_g5_constant_buffer_t *buffer) { D3D12_RANGE range; range.Begin = buffer->impl.lastStart; range.End = range.Begin + buffer->impl.lastCount; @@ -2577,11 +2577,11 @@ void kinc_g5_constant_buffer_unlock(kinc_g5_constant_buffer_t *buffer) { buffer->data = NULL; } -int kinc_g5_constant_buffer_size(kinc_g5_constant_buffer_t *buffer) { +int iron_g5_constant_buffer_size(iron_g5_constant_buffer_t *buffer) { return buffer->impl.mySize; } -void kinc_g5_index_buffer_init(kinc_g5_index_buffer_t *buffer, int count, bool gpuMemory) { +void iron_g5_index_buffer_init(iron_g5_index_buffer_t *buffer, int count, bool gpuMemory) { buffer->impl.count = count; buffer->impl.gpu_memory = gpuMemory; @@ -2607,7 +2607,7 @@ void kinc_g5_index_buffer_init(kinc_g5_index_buffer_t *buffer, int count, bool g resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; resourceDesc.Flags = D3D12_RESOURCE_FLAG_NONE; - kinc_microsoft_affirm(device->lpVtbl->CreateCommittedResource(device , &heapProperties, D3D12_HEAP_FLAG_NONE, &resourceDesc, + iron_microsoft_affirm(device->lpVtbl->CreateCommittedResource(device , &heapProperties, D3D12_HEAP_FLAG_NONE, &resourceDesc, D3D12_RESOURCE_STATE_GENERIC_READ, NULL, &IID_ID3D12Resource, &buffer->impl.upload_buffer)); @@ -2619,7 +2619,7 @@ void kinc_g5_index_buffer_init(kinc_g5_index_buffer_t *buffer, int count, bool g heapProperties.CreationNodeMask = 1; heapProperties.VisibleNodeMask = 1; - kinc_microsoft_affirm(device->lpVtbl->CreateCommittedResource(device , &heapProperties, D3D12_HEAP_FLAG_NONE, &resourceDesc, + iron_microsoft_affirm(device->lpVtbl->CreateCommittedResource(device , &heapProperties, D3D12_HEAP_FLAG_NONE, &resourceDesc, D3D12_RESOURCE_STATE_COMMON, NULL, &IID_ID3D12Resource, &buffer->impl.index_buffer)); @@ -2632,10 +2632,10 @@ void kinc_g5_index_buffer_init(kinc_g5_index_buffer_t *buffer, int count, bool g buffer->impl.index_buffer_view.Format = DXGI_FORMAT_R32_UINT; buffer->impl.last_start = 0; - buffer->impl.last_count = kinc_g5_index_buffer_count(buffer); + buffer->impl.last_count = iron_g5_index_buffer_count(buffer); } -void kinc_g5_index_buffer_destroy(kinc_g5_index_buffer_t *buffer) { +void iron_g5_index_buffer_destroy(iron_g5_index_buffer_t *buffer) { if (buffer->impl.index_buffer != NULL) { buffer->impl.index_buffer->lpVtbl->Release(buffer->impl.index_buffer); buffer->impl.index_buffer = NULL; @@ -2645,46 +2645,46 @@ void kinc_g5_index_buffer_destroy(kinc_g5_index_buffer_t *buffer) { buffer->impl.upload_buffer = NULL; } -static int kinc_g5_internal_index_buffer_stride(kinc_g5_index_buffer_t *buffer) { +static int iron_g5_internal_index_buffer_stride(iron_g5_index_buffer_t *buffer) { return 4; } -void *kinc_g5_index_buffer_lock_all(kinc_g5_index_buffer_t *buffer) { - return kinc_g5_index_buffer_lock(buffer, 0, kinc_g5_index_buffer_count(buffer)); +void *iron_g5_index_buffer_lock_all(iron_g5_index_buffer_t *buffer) { + return iron_g5_index_buffer_lock(buffer, 0, iron_g5_index_buffer_count(buffer)); } -void *kinc_g5_index_buffer_lock(kinc_g5_index_buffer_t *buffer, int start, int count) { +void *iron_g5_index_buffer_lock(iron_g5_index_buffer_t *buffer, int start, int count) { buffer->impl.last_start = start; buffer->impl.last_count = count; D3D12_RANGE range; - range.Begin = start * kinc_g5_internal_index_buffer_stride(buffer); - range.End = (start + count) * kinc_g5_internal_index_buffer_stride(buffer); + range.Begin = start * iron_g5_internal_index_buffer_stride(buffer); + range.End = (start + count) * iron_g5_internal_index_buffer_stride(buffer); void *p; buffer->impl.upload_buffer->lpVtbl->Map(buffer->impl.upload_buffer, 0, &range, &p); byte *bytes = (byte *)p; - bytes += start * kinc_g5_internal_index_buffer_stride(buffer); + bytes += start * iron_g5_internal_index_buffer_stride(buffer); return bytes; } -void kinc_g5_index_buffer_unlock_all(kinc_g5_index_buffer_t *buffer) { +void iron_g5_index_buffer_unlock_all(iron_g5_index_buffer_t *buffer) { D3D12_RANGE range; - range.Begin = buffer->impl.last_start * kinc_g5_internal_index_buffer_stride(buffer); - range.End = (buffer->impl.last_start + buffer->impl.last_count) * kinc_g5_internal_index_buffer_stride(buffer); + range.Begin = buffer->impl.last_start * iron_g5_internal_index_buffer_stride(buffer); + range.End = (buffer->impl.last_start + buffer->impl.last_count) * iron_g5_internal_index_buffer_stride(buffer); buffer->impl.upload_buffer->lpVtbl->Unmap(buffer->impl.upload_buffer, 0, &range); } -void kinc_g5_index_buffer_unlock(kinc_g5_index_buffer_t *buffer, int count) { +void iron_g5_index_buffer_unlock(iron_g5_index_buffer_t *buffer, int count) { D3D12_RANGE range; - range.Begin = buffer->impl.last_start * kinc_g5_internal_index_buffer_stride(buffer); - range.End = (buffer->impl.last_start + count) * kinc_g5_internal_index_buffer_stride(buffer); + range.Begin = buffer->impl.last_start * iron_g5_internal_index_buffer_stride(buffer); + range.End = (buffer->impl.last_start + count) * iron_g5_internal_index_buffer_stride(buffer); buffer->impl.upload_buffer->lpVtbl->Unmap(buffer->impl.upload_buffer, 0, &range); } -void kinc_g5_internal_index_buffer_upload(kinc_g5_index_buffer_t *buffer, ID3D12GraphicsCommandList *commandList) { +void iron_g5_internal_index_buffer_upload(iron_g5_index_buffer_t *buffer, ID3D12GraphicsCommandList *commandList) { if (!buffer->impl.gpu_memory) return; @@ -2701,7 +2701,7 @@ void kinc_g5_internal_index_buffer_upload(kinc_g5_index_buffer_t *buffer, ID3D12 commandList->lpVtbl->ResourceBarrier(commandList, 1, barriers); } -int kinc_g5_index_buffer_count(kinc_g5_index_buffer_t *buffer) { +int iron_g5_index_buffer_count(iron_g5_index_buffer_t *buffer) { return buffer->impl.count; } @@ -2711,7 +2711,7 @@ static const wchar_t *closesthit_shader_name = L"closesthit"; static const wchar_t *miss_shader_name = L"miss"; typedef struct inst { - kinc_matrix4x4_t m; + iron_matrix4x4_t m; int i; } inst_t; @@ -2719,9 +2719,9 @@ static ID3D12Device5 *dxrDevice = NULL; static ID3D12GraphicsCommandList4 *dxrCommandList = NULL; static ID3D12RootSignature *dxrRootSignature = NULL; static ID3D12DescriptorHeap *descriptorHeap = NULL; -static kinc_g5_raytrace_acceleration_structure_t *accel; -static kinc_g5_raytrace_pipeline_t *pipeline; -static kinc_g5_texture_t *output = NULL; +static iron_g5_raytrace_acceleration_structure_t *accel; +static iron_g5_raytrace_pipeline_t *pipeline; +static iron_g5_texture_t *output = NULL; static D3D12_CPU_DESCRIPTOR_HANDLE outputCpuDescriptor; static D3D12_GPU_DESCRIPTOR_HANDLE outputDescriptorHandle; static D3D12_GPU_DESCRIPTOR_HANDLE vbgpuDescriptorHandle; @@ -2736,16 +2736,16 @@ static D3D12_GPU_DESCRIPTOR_HANDLE texrankgpuDescriptorHandle; static int descriptorsAllocated = 0; static UINT descriptorSize; -static kinc_g5_vertex_buffer_t *vb[16]; -static kinc_g5_vertex_buffer_t *vb_last[16]; -static kinc_g5_index_buffer_t *ib[16]; +static iron_g5_vertex_buffer_t *vb[16]; +static iron_g5_vertex_buffer_t *vb_last[16]; +static iron_g5_index_buffer_t *ib[16]; static int vb_count = 0; static int vb_count_last = 0; static inst_t instances[1024]; static int instances_count = 0; -void kinc_g5_raytrace_pipeline_init(kinc_g5_raytrace_pipeline_t *pipeline, kinc_g5_command_list_t *command_list, void *ray_shader, int ray_shader_size, - kinc_g5_constant_buffer_t *constant_buffer) { +void iron_g5_raytrace_pipeline_init(iron_g5_raytrace_pipeline_t *pipeline, iron_g5_command_list_t *command_list, void *ray_shader, int ray_shader_size, + iron_g5_constant_buffer_t *constant_buffer) { output = NULL; descriptorsAllocated = 0; pipeline->_constant_buffer = constant_buffer; @@ -3061,14 +3061,14 @@ void kinc_g5_raytrace_pipeline_init(kinc_g5_raytrace_pipeline_t *pipeline, kinc_ handle.ptr + (INT64)(descriptorHeapIndex) * (UINT64)(descriptorSize); } -void kinc_g5_raytrace_pipeline_destroy(kinc_g5_raytrace_pipeline_t *pipeline) { +void iron_g5_raytrace_pipeline_destroy(iron_g5_raytrace_pipeline_t *pipeline) { pipeline->impl.dxr_state->lpVtbl->Release(pipeline->impl.dxr_state); pipeline->impl.raygen_shader_table->lpVtbl->Release(pipeline->impl.raygen_shader_table); pipeline->impl.miss_shader_table->lpVtbl->Release(pipeline->impl.miss_shader_table); pipeline->impl.hitgroup_shader_table->lpVtbl->Release(pipeline->impl.hitgroup_shader_table); } -UINT create_srv_vb(kinc_g5_vertex_buffer_t *vb, UINT numElements, UINT elementSize) { +UINT create_srv_vb(iron_g5_vertex_buffer_t *vb, UINT numElements, UINT elementSize) { D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; @@ -3102,7 +3102,7 @@ UINT create_srv_vb(kinc_g5_vertex_buffer_t *vb, UINT numElements, UINT elementSi return descriptorIndex; } -UINT create_srv_ib(kinc_g5_index_buffer_t *ib, UINT numElements, UINT elementSize) { +UINT create_srv_ib(iron_g5_index_buffer_t *ib, UINT numElements, UINT elementSize) { D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; @@ -3135,13 +3135,13 @@ UINT create_srv_ib(kinc_g5_index_buffer_t *ib, UINT numElements, UINT elementSiz return descriptorIndex; } -void kinc_g5_raytrace_acceleration_structure_init(kinc_g5_raytrace_acceleration_structure_t *accel) { +void iron_g5_raytrace_acceleration_structure_init(iron_g5_raytrace_acceleration_structure_t *accel) { vb_count = 0; instances_count = 0; } -void kinc_g5_raytrace_acceleration_structure_add(kinc_g5_raytrace_acceleration_structure_t *accel, kinc_g5_vertex_buffer_t *_vb, kinc_g5_index_buffer_t *_ib, - kinc_matrix4x4_t _transform) { +void iron_g5_raytrace_acceleration_structure_add(iron_g5_raytrace_acceleration_structure_t *accel, iron_g5_vertex_buffer_t *_vb, iron_g5_index_buffer_t *_ib, + iron_matrix4x4_t _transform) { int vb_i = -1; for (int i = 0; i < vb_count; ++i) { @@ -3162,18 +3162,18 @@ void kinc_g5_raytrace_acceleration_structure_add(kinc_g5_raytrace_acceleration_s instances_count++; } -void _kinc_g5_raytrace_acceleration_structure_destroy_bottom(kinc_g5_raytrace_acceleration_structure_t *accel) { +void _iron_g5_raytrace_acceleration_structure_destroy_bottom(iron_g5_raytrace_acceleration_structure_t *accel) { for (int i = 0; i < vb_count_last; ++i) { accel->impl.bottom_level_accel[i]->lpVtbl->Release(accel->impl.bottom_level_accel[i]); } } -void _kinc_g5_raytrace_acceleration_structure_destroy_top(kinc_g5_raytrace_acceleration_structure_t *accel) { +void _iron_g5_raytrace_acceleration_structure_destroy_top(iron_g5_raytrace_acceleration_structure_t *accel) { accel->impl.top_level_accel->lpVtbl->Release(accel->impl.top_level_accel); } -void kinc_g5_raytrace_acceleration_structure_build(kinc_g5_raytrace_acceleration_structure_t *accel, kinc_g5_command_list_t *command_list, - kinc_g5_vertex_buffer_t *_vb_full, kinc_g5_index_buffer_t *_ib_full) { +void iron_g5_raytrace_acceleration_structure_build(iron_g5_raytrace_acceleration_structure_t *accel, iron_g5_command_list_t *command_list, + iron_g5_vertex_buffer_t *_vb_full, iron_g5_index_buffer_t *_ib_full) { bool build_bottom = false; for (int i = 0; i < 16; ++i) { @@ -3185,9 +3185,9 @@ void kinc_g5_raytrace_acceleration_structure_build(kinc_g5_raytrace_acceleration if (vb_count_last > 0) { if (build_bottom) { - _kinc_g5_raytrace_acceleration_structure_destroy_bottom(accel); + _iron_g5_raytrace_acceleration_structure_destroy_bottom(accel); } - _kinc_g5_raytrace_acceleration_structure_destroy_top(accel); + _iron_g5_raytrace_acceleration_structure_destroy_top(accel); } vb_count_last = vb_count; @@ -3196,7 +3196,7 @@ void kinc_g5_raytrace_acceleration_structure_build(kinc_g5_raytrace_acceleration return; } - descriptorsAllocated = 1; // 1 descriptor already allocated in kinc_g5_raytrace_pipeline_init + descriptorsAllocated = 1; // 1 descriptor already allocated in iron_g5_raytrace_pipeline_init #ifdef is_forge create_srv_ib(_ib_full, _ib_full->impl.count, 0); @@ -3409,21 +3409,21 @@ void kinc_g5_raytrace_acceleration_structure_build(kinc_g5_raytrace_acceleration command_list->impl._commandList->lpVtbl->ResourceBarrier(command_list->impl._commandList, 1, &barrier); dxrCommandList->lpVtbl->BuildRaytracingAccelerationStructure(dxrCommandList, &topLevelBuildDesc, 0, NULL); - kinc_g5_command_list_end(command_list); - kinc_g5_command_list_execute(command_list); - kinc_g5_command_list_wait_for_execution_to_finish(command_list); - kinc_g5_command_list_begin(command_list); + iron_g5_command_list_end(command_list); + iron_g5_command_list_execute(command_list); + iron_g5_command_list_wait_for_execution_to_finish(command_list); + iron_g5_command_list_begin(command_list); scratchResource->lpVtbl->Release(scratchResource); instanceDescs->lpVtbl->Release(instanceDescs); } -void kinc_g5_raytrace_acceleration_structure_destroy(kinc_g5_raytrace_acceleration_structure_t *accel) { +void iron_g5_raytrace_acceleration_structure_destroy(iron_g5_raytrace_acceleration_structure_t *accel) { // accel->impl.bottom_level_accel->Release(); // accel->impl.top_level_accel->Release(); } -void kinc_g5_raytrace_set_textures(kinc_g5_texture_t *texpaint0, kinc_g5_texture_t *texpaint1, kinc_g5_texture_t *texpaint2, kinc_g5_texture_t *texenv, kinc_g5_texture_t *texsobol, kinc_g5_texture_t *texscramble, kinc_g5_texture_t *texrank) { +void iron_g5_raytrace_set_textures(iron_g5_texture_t *texpaint0, iron_g5_texture_t *texpaint1, iron_g5_texture_t *texpaint2, iron_g5_texture_t *texenv, iron_g5_texture_t *texsobol, iron_g5_texture_t *texscramble, iron_g5_texture_t *texrank) { D3D12_CPU_DESCRIPTOR_HANDLE handle; descriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(descriptorHeap, &handle); @@ -3481,15 +3481,15 @@ void kinc_g5_raytrace_set_textures(kinc_g5_texture_t *texpaint0, kinc_g5_texture texrankgpuDescriptorHandle.ptr = ghandle.ptr + 11 * (UINT64)(descriptorSize); } -void kinc_g5_raytrace_set_acceleration_structure(kinc_g5_raytrace_acceleration_structure_t *_accel) { +void iron_g5_raytrace_set_acceleration_structure(iron_g5_raytrace_acceleration_structure_t *_accel) { accel = _accel; } -void kinc_g5_raytrace_set_pipeline(kinc_g5_raytrace_pipeline_t *_pipeline) { +void iron_g5_raytrace_set_pipeline(iron_g5_raytrace_pipeline_t *_pipeline) { pipeline = _pipeline; } -void kinc_g5_raytrace_set_target(kinc_g5_texture_t *_output) { +void iron_g5_raytrace_set_target(iron_g5_texture_t *_output) { if (_output != output) { _output->impl.renderTarget->lpVtbl->Release(_output->impl.renderTarget); _output->impl.renderTargetDescriptorHeap->lpVtbl->Release(_output->impl.renderTargetDescriptorHeap); @@ -3560,7 +3560,7 @@ void kinc_g5_raytrace_set_target(kinc_g5_texture_t *_output) { output = _output; } -void kinc_g5_raytrace_dispatch_rays(kinc_g5_command_list_t *command_list) { +void iron_g5_raytrace_dispatch_rays(iron_g5_command_list_t *command_list) { command_list->impl._commandList->lpVtbl->SetComputeRootSignature(command_list->impl._commandList, dxrRootSignature); // Bind the heaps, acceleration structure and dispatch rays diff --git a/base/sources/backends/direct3d12_gpu.h b/base/sources/backends/direct3d12_gpu.h index 042ba5cd..8168bfa2 100644 --- a/base/sources/backends/direct3d12_gpu.h +++ b/base/sources/backends/direct3d12_gpu.h @@ -45,16 +45,16 @@ struct dx_window { bool vsync; }; -struct kinc_g5_pipeline; -struct kinc_g5_texture; -struct kinc_g5_sampler; +struct iron_g5_pipeline; +struct iron_g5_texture; +struct iron_g5_sampler; -#define KINC_INTERNAL_G5_TEXTURE_COUNT 16 +#define IRON_INTERNAL_G5_TEXTURE_COUNT 16 typedef struct { struct ID3D12CommandAllocator *_commandAllocator; struct ID3D12GraphicsCommandList *_commandList; - struct kinc_g5_pipeline *_currentPipeline; + struct iron_g5_pipeline *_currentPipeline; int _indexCount; bool open; @@ -64,8 +64,8 @@ typedef struct { struct ID3D12Fence *fence; HANDLE fence_event; - struct kinc_g5_texture *currentTextures[KINC_INTERNAL_G5_TEXTURE_COUNT]; - struct kinc_g5_sampler *current_samplers[KINC_INTERNAL_G5_TEXTURE_COUNT]; + struct iron_g5_texture *currentTextures[IRON_INTERNAL_G5_TEXTURE_COUNT]; + struct iron_g5_sampler *current_samplers[IRON_INTERNAL_G5_TEXTURE_COUNT]; int heapIndex; struct ID3D12DescriptorHeap *srvHeap; @@ -78,25 +78,25 @@ typedef struct { uint32_t size; uint8_t columns; uint8_t rows; -} kinc_compute_internal_shader_constant_t; +} iron_compute_internal_shader_constant_t; typedef struct { uint32_t hash; uint32_t index; -} kinc_internal_hash_index_t; +} iron_internal_hash_index_t; -typedef struct kinc_g5_compute_shader_impl { - kinc_compute_internal_shader_constant_t constants[64]; +typedef struct iron_g5_compute_shader_impl { + iron_compute_internal_shader_constant_t constants[64]; int constantsSize; - kinc_internal_hash_index_t attributes[64]; - kinc_internal_hash_index_t textures[64]; + iron_internal_hash_index_t attributes[64]; + iron_internal_hash_index_t textures[64]; uint8_t *data; int length; struct ID3D12Buffer *constantBuffer; struct ID3D12PipelineState *pso; -} kinc_g5_compute_shader_impl; +} iron_g5_compute_shader_impl; -struct kinc_g5_shader; +struct iron_g5_shader; struct ID3D12PipelineState; struct ID3D12GraphicsCommandList; @@ -132,14 +132,14 @@ typedef struct { int nothing; } AttributeLocation5Impl; -struct kinc_g5_pipeline; -struct kinc_g5_command_list; +struct iron_g5_pipeline; +struct iron_g5_command_list; -void kinc_g5_internal_setConstants(struct kinc_g5_command_list *commandList, struct kinc_g5_pipeline *pipeline); +void iron_g5_internal_setConstants(struct iron_g5_command_list *commandList, struct iron_g5_pipeline *pipeline); -typedef struct kinc_g5_sampler_impl { +typedef struct iron_g5_sampler_impl { struct ID3D12DescriptorHeap *sampler_heap; -} kinc_g5_sampler_impl_t; +} iron_g5_sampler_impl_t; typedef struct { char name[64]; @@ -168,7 +168,7 @@ typedef struct { int length; } Shader5Impl; -uint32_t kinc_internal_hash_name(unsigned char *str); +uint32_t iron_internal_hash_name(unsigned char *str); struct ID3D12Resource; struct ID3D12DescriptorHeap; @@ -200,11 +200,11 @@ typedef struct { int framebuffer_index; } Texture5Impl; -struct kinc_g5_texture; -struct kinc_g5_command_list; +struct iron_g5_texture; +struct iron_g5_command_list; -void kinc_g5_internal_set_textures(struct kinc_g5_command_list *commandList); -void kinc_g5_internal_texture_set(struct kinc_g5_command_list *commandList, struct kinc_g5_texture *texture, int unit); +void iron_g5_internal_set_textures(struct iron_g5_command_list *commandList); +void iron_g5_internal_texture_set(struct iron_g5_command_list *commandList, struct iron_g5_texture *texture, int unit); struct ID3D12Resource; @@ -247,9 +247,9 @@ typedef struct { int last_count; } IndexBuffer5Impl; -struct kinc_g5_index_buffer; +struct iron_g5_index_buffer; -void kinc_g5_internal_index_buffer_upload(struct kinc_g5_index_buffer *buffer, struct ID3D12GraphicsCommandList *commandList); +void iron_g5_internal_index_buffer_upload(struct iron_g5_index_buffer *buffer, struct ID3D12GraphicsCommandList *commandList); struct ID3D12StateObject; struct ID3D12Resource; @@ -259,9 +259,9 @@ typedef struct { struct ID3D12Resource *raygen_shader_table; struct ID3D12Resource *miss_shader_table; struct ID3D12Resource *hitgroup_shader_table; -} kinc_g5_raytrace_pipeline_impl_t; +} iron_g5_raytrace_pipeline_impl_t; typedef struct { struct ID3D12Resource *bottom_level_accel[16]; struct ID3D12Resource *top_level_accel; -} kinc_g5_raytrace_acceleration_structure_impl_t; +} iron_g5_raytrace_acceleration_structure_impl_t; diff --git a/base/sources/backends/ios_audio.m b/base/sources/backends/ios_audio.m index 199c9d64..65c85162 100644 --- a/base/sources/backends/ios_audio.m +++ b/base/sources/backends/ios_audio.m @@ -1,5 +1,5 @@ -#ifdef KINC_A2 +#ifdef IRON_A2 #import #import @@ -12,9 +12,9 @@ #define kOutputBus 0 -static kinc_internal_video_sound_stream_t *video = NULL; +static iron_internal_video_sound_stream_t *video = NULL; -void iosPlayVideoSoundStream(kinc_internal_video_sound_stream_t *v) { +void iosPlayVideoSoundStream(iron_internal_video_sound_stream_t *v) { video = v; } @@ -35,7 +35,7 @@ static AudioComponentInstance audioUnit; static bool isFloat = false; static bool isInterleaved = true; -static kinc_a2_buffer_t a2_buffer; +static iron_a2_buffer_t a2_buffer; static void copySample(void *buffer, void *secondary_buffer) { float left_value = *(float *)&a2_buffer.channels[0][a2_buffer.read_location]; @@ -46,12 +46,12 @@ static void copySample(void *buffer, void *secondary_buffer) { } if (video != NULL) { - float *frame = kinc_internal_video_sound_stream_next_frame(video); + float *frame = iron_internal_video_sound_stream_next_frame(video); left_value += frame[0]; - left_value = kinc_max(kinc_min(left_value, 1.0f), -1.0f); + left_value = iron_max(iron_min(left_value, 1.0f), -1.0f); right_value += frame[1]; - right_value = kinc_max(kinc_min(right_value, 1.0f), -1.0f); - if (kinc_internal_video_sound_stream_ended(video)) { + right_value = iron_max(iron_min(right_value, 1.0f), -1.0f); + if (iron_internal_video_sound_stream_ended(video)) { video = NULL; } } @@ -80,7 +80,7 @@ static void copySample(void *buffer, void *secondary_buffer) { static OSStatus renderInput(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *outOutputData) { - kinc_a2_internal_callback(&a2_buffer, inNumberFrames); + iron_a2_internal_callback(&a2_buffer, inNumberFrames); if (isInterleaved) { if (isFloat) { float *output = (float *)outOutputData->mBuffers[0].mData; @@ -125,18 +125,18 @@ static void sampleRateListener(void *inRefCon, AudioUnit inUnit, AudioUnitProper if (samples_per_second != (uint32_t)sampleRate) { samples_per_second = (uint32_t)sampleRate; - kinc_a2_internal_sample_rate_callback(); + iron_a2_internal_sample_rate_callback(); } } static bool initialized = false; -void kinc_a2_init(void) { +void iron_a2_init(void) { if (initialized) { return; } - kinc_a2_internal_init(); + iron_a2_internal_init(); initialized = true; a2_buffer.read_location = 0; @@ -197,7 +197,7 @@ void kinc_a2_init(void) { if (samples_per_second != (uint32_t)deviceFormat.mSampleRate) { samples_per_second = (uint32_t)deviceFormat.mSampleRate; - kinc_a2_internal_sample_rate_callback(); + iron_a2_internal_sample_rate_callback(); } AURenderCallbackStruct callbackStruct; @@ -208,9 +208,9 @@ void kinc_a2_init(void) { soundPlaying = true; } -void kinc_a2_update(void) {} +void iron_a2_update(void) {} -void kinc_a2_shutdown(void) { +void iron_a2_shutdown(void) { if (!initialized) return; if (!soundPlaying) @@ -221,7 +221,7 @@ void kinc_a2_shutdown(void) { soundPlaying = false; } -uint32_t kinc_a2_samples_per_second(void) { +uint32_t iron_a2_samples_per_second(void) { return samples_per_second; } diff --git a/base/sources/backends/ios_system.h b/base/sources/backends/ios_system.h index c2bb116b..ce0ac53a 100644 --- a/base/sources/backends/ios_system.h +++ b/base/sources/backends/ios_system.h @@ -4,7 +4,7 @@ #import #import -struct kinc_g5_texture; +struct iron_g5_texture; @interface GLView : UIView { @private @@ -45,7 +45,7 @@ struct kinc_g5_texture; @class GLView; -@interface KoreAppDelegate : NSObject { +@interface IronAppDelegate : NSObject { } @end diff --git a/base/sources/backends/ios_system.m b/base/sources/backends/ios_system.m index ce45ec16..243647e0 100644 --- a/base/sources/backends/ios_system.m +++ b/base/sources/backends/ios_system.m @@ -50,11 +50,11 @@ static int removeTouch(void *touch) { static GLint backingWidth, backingHeight; -int kinc_window_width() { +int iron_window_width() { return backingWidth; } -int kinc_window_height() { +int iron_window_height() { return backingHeight; } @@ -69,7 +69,7 @@ int kinc_window_height() { float x = point.x * self.contentScaleFactor; float y = point.y * self.contentScaleFactor; // Pencil hover - kinc_internal_pen_trigger_move(0, x, y, 0.0); + iron_internal_pen_trigger_move(0, x, y, 0.0); } - (id)initWithFrame:(CGRect)frame { @@ -106,7 +106,7 @@ int kinc_window_height() { - (void)end { } -void kinc_internal_call_resize_callback(int width, int height); +void iron_internal_call_resize_callback(int width, int height); - (void)layoutSubviews { backingWidth = self.frame.size.width * self.contentScaleFactor; @@ -115,7 +115,7 @@ void kinc_internal_call_resize_callback(int width, int height); CAMetalLayer *metalLayer = (CAMetalLayer *)self.layer; metalLayer.drawableSize = CGSizeMake(backingWidth, backingHeight); - kinc_internal_call_resize_callback(backingWidth, backingHeight); + iron_internal_call_resize_callback(backingWidth, backingHeight); } - (void)dealloc { @@ -131,12 +131,12 @@ void kinc_internal_call_resize_callback(int width, int height); float x = point.x * self.contentScaleFactor; float y = point.y * self.contentScaleFactor; if (index == 0) { - kinc_internal_mouse_trigger_press(0, event.buttonMask == UIEventButtonMaskSecondary ? 1 : 0, x, y); + iron_internal_mouse_trigger_press(0, event.buttonMask == UIEventButtonMaskSecondary ? 1 : 0, x, y); } - kinc_internal_surface_trigger_touch_start(index, x, y); + iron_internal_surface_trigger_touch_start(index, x, y); if (touch.type == UITouchTypePencil) { - kinc_internal_pen_trigger_press(0, x, y, 0.0); + iron_internal_pen_trigger_press(0, x, y, 0.0); } } } @@ -150,9 +150,9 @@ void kinc_internal_call_resize_callback(int width, int height); float x = point.x * self.contentScaleFactor; float y = point.y * self.contentScaleFactor; if (index == 0) { - kinc_internal_mouse_trigger_move(0, x, y); + iron_internal_mouse_trigger_move(0, x, y); } - kinc_internal_surface_trigger_move(index, x, y); + iron_internal_surface_trigger_move(index, x, y); } } } @@ -163,7 +163,7 @@ void kinc_internal_call_resize_callback(int width, int height); CGPoint point = [touch locationInView:self]; float x = point.x * self.contentScaleFactor; float y = point.y * self.contentScaleFactor; - kinc_internal_pen_trigger_move(0, x, y, touch.force); + iron_internal_pen_trigger_move(0, x, y, touch.force); } } } @@ -176,12 +176,12 @@ void kinc_internal_call_resize_callback(int width, int height); float x = point.x * self.contentScaleFactor; float y = point.y * self.contentScaleFactor; if (index == 0) { - kinc_internal_mouse_trigger_release(0, event.buttonMask == UIEventButtonMaskSecondary ? 1 : 0, x, y); + iron_internal_mouse_trigger_release(0, event.buttonMask == UIEventButtonMaskSecondary ? 1 : 0, x, y); } - kinc_internal_surface_trigger_touch_end(index, x, y); + iron_internal_surface_trigger_touch_end(index, x, y); if (touch.type == UITouchTypePencil) { - kinc_internal_pen_trigger_release(0, x, y, 0.0); + iron_internal_pen_trigger_release(0, x, y, 0.0); } } } @@ -195,12 +195,12 @@ void kinc_internal_call_resize_callback(int width, int height); float x = point.x * self.contentScaleFactor; float y = point.y * self.contentScaleFactor; if (index == 0) { - kinc_internal_mouse_trigger_release(0, event.buttonMask == UIEventButtonMaskSecondary ? 1 : 0, x, y); + iron_internal_mouse_trigger_release(0, event.buttonMask == UIEventButtonMaskSecondary ? 1 : 0, x, y); } - kinc_internal_surface_trigger_touch_end(index, x, y); + iron_internal_surface_trigger_touch_end(index, x, y); if (touch.type == UITouchTypePencil) { - kinc_internal_pen_trigger_release(0, x, y, 0.0); + iron_internal_pen_trigger_release(0, x, y, 0.0); } } } @@ -228,59 +228,59 @@ static bool shiftDown = false; if (ch == 8212) ch = '_'; if (ch == L'\n') { - kinc_internal_keyboard_trigger_key_down(KINC_KEY_RETURN); - kinc_internal_keyboard_trigger_key_up(KINC_KEY_RETURN); + iron_internal_keyboard_trigger_key_down(IRON_KEY_RETURN); + iron_internal_keyboard_trigger_key_up(IRON_KEY_RETURN); return; } if (ch == L'.') { - kinc_internal_keyboard_trigger_key_down(KINC_KEY_PERIOD); - kinc_internal_keyboard_trigger_key_up(KINC_KEY_PERIOD); + iron_internal_keyboard_trigger_key_down(IRON_KEY_PERIOD); + iron_internal_keyboard_trigger_key_up(IRON_KEY_PERIOD); } else if (ch == L'%') { - kinc_internal_keyboard_trigger_key_down(KINC_KEY_PERCENT); - kinc_internal_keyboard_trigger_key_up(KINC_KEY_PERCENT); + iron_internal_keyboard_trigger_key_down(IRON_KEY_PERCENT); + iron_internal_keyboard_trigger_key_up(IRON_KEY_PERCENT); } else if (ch == L'(') { - kinc_internal_keyboard_trigger_key_down(KINC_KEY_OPEN_PAREN); - kinc_internal_keyboard_trigger_key_up(KINC_KEY_OPEN_PAREN); + iron_internal_keyboard_trigger_key_down(IRON_KEY_OPEN_PAREN); + iron_internal_keyboard_trigger_key_up(IRON_KEY_OPEN_PAREN); } else if (ch == L'&') { - kinc_internal_keyboard_trigger_key_down(KINC_KEY_AMPERSAND); - kinc_internal_keyboard_trigger_key_up(KINC_KEY_AMPERSAND); + iron_internal_keyboard_trigger_key_down(IRON_KEY_AMPERSAND); + iron_internal_keyboard_trigger_key_up(IRON_KEY_AMPERSAND); } else if (ch == L'$') { - kinc_internal_keyboard_trigger_key_down(KINC_KEY_DOLLAR); - kinc_internal_keyboard_trigger_key_up(KINC_KEY_DOLLAR); + iron_internal_keyboard_trigger_key_down(IRON_KEY_DOLLAR); + iron_internal_keyboard_trigger_key_up(IRON_KEY_DOLLAR); } else if (ch == L'#') { - kinc_internal_keyboard_trigger_key_down(KINC_KEY_HASH); - kinc_internal_keyboard_trigger_key_up(KINC_KEY_HASH); + iron_internal_keyboard_trigger_key_down(IRON_KEY_HASH); + iron_internal_keyboard_trigger_key_up(IRON_KEY_HASH); } else if (ch >= L'a' && ch <= L'z') { if (shiftDown) { - kinc_internal_keyboard_trigger_key_up(KINC_KEY_SHIFT); + iron_internal_keyboard_trigger_key_up(IRON_KEY_SHIFT); shiftDown = false; } - kinc_internal_keyboard_trigger_key_down(ch + KINC_KEY_A - L'a'); - kinc_internal_keyboard_trigger_key_up(ch + KINC_KEY_A - L'a'); + iron_internal_keyboard_trigger_key_down(ch + IRON_KEY_A - L'a'); + iron_internal_keyboard_trigger_key_up(ch + IRON_KEY_A - L'a'); } else { if (!shiftDown) { - kinc_internal_keyboard_trigger_key_down(KINC_KEY_SHIFT); + iron_internal_keyboard_trigger_key_down(IRON_KEY_SHIFT); shiftDown = true; } - kinc_internal_keyboard_trigger_key_down(ch + KINC_KEY_A - L'A'); - kinc_internal_keyboard_trigger_key_up(ch + KINC_KEY_A - L'A'); + iron_internal_keyboard_trigger_key_down(ch + IRON_KEY_A - L'A'); + iron_internal_keyboard_trigger_key_up(ch + IRON_KEY_A - L'A'); } - kinc_internal_keyboard_trigger_key_press(ch); + iron_internal_keyboard_trigger_key_press(ch); } } - (void)deleteBackward { - kinc_internal_keyboard_trigger_key_down(KINC_KEY_BACKSPACE); - kinc_internal_keyboard_trigger_key_up(KINC_KEY_BACKSPACE); + iron_internal_keyboard_trigger_key_down(IRON_KEY_BACKSPACE); + iron_internal_keyboard_trigger_key_up(IRON_KEY_BACKSPACE); } - (BOOL)canBecomeFirstResponder { @@ -288,7 +288,7 @@ static bool shiftDown = false; } - (void)onKeyboardHide:(NSNotification *)notification { - kinc_keyboard_hide(); + iron_keyboard_hide(); } - (CAMetalLayer *)metalLayer { @@ -382,14 +382,14 @@ void importFile(NSURL *url) { [[NSFileManager defaultManager] copyItemAtPath:url.path toPath:filePath error:nil]; CFURLStopAccessingSecurityScopedResource(cfurl); wchar_t *wpath = (wchar_t *)[filePath cStringUsingEncoding:NSUTF32LittleEndianStringEncoding]; - kinc_internal_drop_files_callback(wpath); + iron_internal_drop_files_callback(wpath); } - (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url { // wchar_t *filePath = (wchar_t *)[url.path cStringUsingEncoding:NSUTF32LittleEndianStringEncoding]; // CFURLRef cfurl = (__bridge CFURLRef)url; // CFURLStartAccessingSecurityScopedResource(cfurl); - // kinc_internal_drop_files_callback(filePath); + // iron_internal_drop_files_callback(filePath); // CFURLStopAccessingSecurityScopedResource(cfurl); importFile(url); } @@ -398,8 +398,8 @@ void importFile(NSURL *url) { CGPoint point = [session locationInView:self.view]; float x = point.x * glView.contentScaleFactor; float y = point.y * glView.contentScaleFactor; - kinc_internal_mouse_trigger_move(0, x, y); - kinc_internal_surface_trigger_move(0, x, y); + iron_internal_mouse_trigger_move(0, x, y); + iron_internal_surface_trigger_move(0, x, y); for (UIDragItem *item in session.items) { [item.itemProvider loadInPlaceFileRepresentationForTypeIdentifier:item.itemProvider.registeredTypeIdentifiers[0] completionHandler:^(NSURL * _Nullable url, BOOL isInPlace, NSError * _Nullable error) { @@ -419,7 +419,7 @@ void importFile(NSURL *url) { @end -@implementation KoreAppDelegate +@implementation IronAppDelegate static UIWindow *window; static GLViewController *glViewController; @@ -458,69 +458,69 @@ void loadURL(const char *url) { return YES; } -void KoreUpdateKeyboard(void); +void IronUpdateKeyboard(void); - (void)applicationWillEnterForeground:(UIApplication *)application { [glViewController setVisible:YES]; - kinc_internal_foreground_callback(); + iron_internal_foreground_callback(); } - (void)applicationDidBecomeActive:(UIApplication *)application { - kinc_internal_resume_callback(); + iron_internal_resume_callback(); } - (void)applicationWillResignActive:(UIApplication *)application { - kinc_internal_pause_callback(); + iron_internal_pause_callback(); } - (void)applicationDidEnterBackground:(UIApplication *)application { [glViewController setVisible:NO]; - kinc_internal_background_callback(); + iron_internal_background_callback(); } - (void)applicationWillTerminate:(UIApplication *)application { - kinc_internal_shutdown_callback(); + iron_internal_shutdown_callback(); } @end -void kinc_display_init(void) {} +void iron_display_init(void) {} -kinc_display_mode_t kinc_display_available_mode(int display, int mode) { - kinc_display_mode_t dm; - dm.width = kinc_window_width(); - dm.height = kinc_window_height(); +iron_display_mode_t iron_display_available_mode(int display, int mode) { + iron_display_mode_t dm; + dm.width = iron_window_width(); + dm.height = iron_window_height(); dm.frequency = 60; dm.bits_per_pixel = 32; return dm; } -int kinc_display_count_available_modes(int display) { +int iron_display_count_available_modes(int display) { return 1; } -bool kinc_display_available(int display) { +bool iron_display_available(int display) { return true; } -const char *kinc_display_name(int display) { +const char *iron_display_name(int display) { return "Display"; } -kinc_display_mode_t kinc_display_current_mode(int display) { - kinc_display_mode_t dm; - dm.width = kinc_window_width(); - dm.height = kinc_window_height(); +iron_display_mode_t iron_display_current_mode(int display) { + iron_display_mode_t dm; + dm.width = iron_window_width(); + dm.height = iron_window_height(); dm.frequency = (int)[[UIScreen mainScreen] maximumFramesPerSecond]; dm.bits_per_pixel = 32; return dm; } -int kinc_count_displays(void) { +int iron_count_displays(void) { return 1; } -int kinc_primary_display(void) { +int iron_primary_display(void) { return 0; } @@ -528,23 +528,23 @@ int kinc_primary_display(void) { @end -void kinc_internal_mouse_lock(void) {} +void iron_internal_mouse_lock(void) {} -void kinc_internal_mouse_unlock(void) {} +void iron_internal_mouse_unlock(void) {} -bool kinc_mouse_can_lock(void) { +bool iron_mouse_can_lock(void) { return false; } -void kinc_mouse_show(void) {} +void iron_mouse_show(void) {} -void kinc_mouse_hide(void) {} +void iron_mouse_hide(void) {} -void kinc_mouse_set_position(int x, int y) {} +void iron_mouse_set_position(int x, int y) {} -void kinc_mouse_get_position(int *x, int *y) {} +void iron_mouse_get_position(int *x, int *y) {} -void kinc_mouse_set_cursor(int cursor_index) {} +void iron_mouse_set_cursor(int cursor_index) {} bool withAutoreleasepool(bool (*f)(void)) { @autoreleasepool { @@ -558,7 +558,7 @@ const char *iphonegetresourcepath(void) { return [[[NSBundle mainBundle] resourcePath] cStringUsingEncoding:1]; } -bool kinc_internal_handle_messages(void) { +bool iron_internal_handle_messages(void) { SInt32 result; do { result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE); @@ -566,34 +566,34 @@ bool kinc_internal_handle_messages(void) { return true; } -void kinc_set_keep_screen_on(bool on) {} +void iron_set_keep_screen_on(bool on) {} void showKeyboard(void); void hideKeyboard(void); -void kinc_keyboard_show(void) { +void iron_keyboard_show(void) { keyboardshown = true; showKeyboard(); } -void kinc_keyboard_hide(void) { +void iron_keyboard_hide(void) { keyboardshown = false; hideKeyboard(); } -bool kinc_keyboard_active(void) { +bool iron_keyboard_active(void) { return keyboardshown; } void loadURL(const char *url); -void kinc_load_url(const char *url) { +void iron_load_url(const char *url) { loadURL(url); } static char language[3]; -const char *kinc_language(void) { +const char *iron_language(void) { NSString *nsstr = [[NSLocale preferredLanguages] objectAtIndex:0]; const char *lang = [nsstr UTF8String]; language[0] = lang[0]; @@ -602,7 +602,7 @@ const char *kinc_language(void) { return language; } -void KoreUpdateKeyboard(void) { +void IronUpdateKeyboard(void) { if (keyboardshown) { hideKeyboard(); showKeyboard(); @@ -612,16 +612,16 @@ void KoreUpdateKeyboard(void) { } } -void kinc_internal_shutdown(void) {} +void iron_internal_shutdown(void) {} -void kinc_init(const char *name, int width, int height, struct kinc_window_options *win) { - kinc_window_options_t defaultWin; +void iron_init(const char *name, int width, int height, struct iron_window_options *win) { + iron_window_options_t defaultWin; if (win == NULL) { - kinc_window_options_set_defaults(&defaultWin); + iron_window_options_set_defaults(&defaultWin); win = &defaultWin; } - kinc_g5_internal_init(); - kinc_g4_internal_init_window(win->depth_bits, true); + iron_g5_internal_init(); + iron_g4_internal_init_window(win->depth_bits, true); } void endGL(void); @@ -632,7 +632,7 @@ void swapBuffersiOS(void) { static char sysid[512]; -const char *kinc_system_id(void) { +const char *iron_system_id(void) { const char *name = [[[UIDevice currentDevice] name] UTF8String]; const char *vendorId = [[[[UIDevice currentDevice] identifierForVendor] UUIDString] UTF8String]; strcpy(sysid, name); @@ -644,7 +644,7 @@ const char *kinc_system_id(void) { static const char *getSavePath(void) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); NSString *resolvedPath = [paths objectAtIndex:0]; - NSString *appName = [NSString stringWithUTF8String:kinc_application_name()]; + NSString *appName = [NSString stringWithUTF8String:iron_application_name()]; resolvedPath = [resolvedPath stringByAppendingPathComponent:appName]; NSFileManager *fileMgr = [[NSFileManager alloc] init]; @@ -656,46 +656,46 @@ static const char *getSavePath(void) { return [resolvedPath cStringUsingEncoding:1]; } -const char *kinc_internal_save_path(void) { +const char *iron_internal_save_path(void) { return getSavePath(); } static const char *videoFormats[] = {"mp4", NULL}; -const char **kinc_video_formats(void) { +const char **iron_video_formats(void) { return videoFormats; } -double kinc_frequency(void) { +double iron_frequency(void) { mach_timebase_info_data_t info; mach_timebase_info(&info); return (double)info.denom / (double)info.numer / 1e-9; } -kinc_ticks_t kinc_timestamp(void) { - kinc_ticks_t time = mach_absolute_time(); +iron_ticks_t iron_timestamp(void) { + iron_ticks_t time = mach_absolute_time(); return time; } -const char *kinc_gamepad_vendor(int gamepad) { +const char *iron_gamepad_vendor(int gamepad) { return "nobody"; } -const char *kinc_gamepad_product_name(int gamepad) { +const char *iron_gamepad_product_name(int gamepad) { return "none"; } -bool kinc_gamepad_connected(int num) { +bool iron_gamepad_connected(int num) { return true; } -void kinc_gamepad_rumble(int gamepad, float left, float right) {} +void iron_gamepad_rumble(int gamepad, float left, float right) {} int main(int argc, char *argv[]) { int retVal = 0; @autoreleasepool { - [KoreAppDelegate description]; // otherwise removed by the linker - retVal = UIApplicationMain(argc, argv, nil, @"KoreAppDelegate"); + [IronAppDelegate description]; // otherwise removed by the linker + retVal = UIApplicationMain(argc, argv, nil, @"IronAppDelegate"); } return retVal; } @@ -703,49 +703,49 @@ int main(int argc, char *argv[]) { static void (*resizeCallback)(int x, int y, void *data) = NULL; static void *resizeCallbackData = NULL; -int kinc_window_x() { +int iron_window_x() { return 0; } -int kinc_window_y() { +int iron_window_y() { return 0; } -void kinc_window_resize(int width, int height) {} +void iron_window_resize(int width, int height) {} -void kinc_window_move(int x, int y) {} +void iron_window_move(int x, int y) {} -void kinc_window_change_features(int features) {} +void iron_window_change_features(int features) {} -void kinc_window_change_mode(kinc_window_mode_t mode) {} +void iron_window_change_mode(iron_window_mode_t mode) {} -void kinc_window_destroy() {} +void iron_window_destroy() {} -void kinc_window_show() {} +void iron_window_show() {} -void kinc_window_hide() {} +void iron_window_hide() {} -void kinc_window_set_title(const char *title) {} +void iron_window_set_title(const char *title) {} -void kinc_window_create(kinc_window_options_t *win) {} +void iron_window_create(iron_window_options_t *win) {} -void kinc_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) { +void iron_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) { resizeCallback = callback; resizeCallbackData = data; } -void kinc_internal_call_resize_callback(int width, int height) { +void iron_internal_call_resize_callback(int width, int height) { if (resizeCallback != NULL) { resizeCallback(width, height, resizeCallbackData); } } -void kinc_window_set_close_callback(bool (*callback)(void *), void *data) {} +void iron_window_set_close_callback(bool (*callback)(void *), void *data) {} -kinc_window_mode_t kinc_window_get_mode() { - return KINC_WINDOW_MODE_FULLSCREEN; +iron_window_mode_t iron_window_get_mode() { + return IRON_WINDOW_MODE_FULLSCREEN; } -int kinc_window_display() { +int iron_window_display() { return 0; } diff --git a/base/sources/backends/linux_audio.c b/base/sources/backends/linux_audio.c index 26bddfd0..537011fd 100644 --- a/base/sources/backends/linux_audio.c +++ b/base/sources/backends/linux_audio.c @@ -1,5 +1,5 @@ -#ifdef KINC_A2 +#ifdef IRON_A2 #include #include @@ -11,7 +11,7 @@ // apt-get install libasound2-dev -kinc_a2_buffer_t a2_buffer; +iron_a2_buffer_t a2_buffer; pthread_t threadid; bool audioRunning = false; @@ -20,7 +20,7 @@ short buf[4096 * 4]; static unsigned int samples_per_second = 44100; -uint32_t kinc_a2_samples_per_second(void) { +uint32_t iron_a2_samples_per_second(void) { return samples_per_second; } @@ -37,7 +37,7 @@ void copySample(void *buffer) { int playback_callback(snd_pcm_sframes_t nframes) { int err = 0; - if (kinc_a2_internal_callback(&a2_buffer, nframes)) { + if (iron_a2_internal_callback(&a2_buffer, nframes)) { int ni = 0; while (ni < nframes) { int i = 0; @@ -207,12 +207,12 @@ void *doAudio(void *arg) { static bool initialized = false; -void kinc_a2_init() { +void iron_a2_init() { if (initialized) { return; } - kinc_a2_internal_init(); + iron_a2_internal_init(); initialized = true; a2_buffer.read_location = 0; @@ -226,9 +226,9 @@ void kinc_a2_init() { pthread_create(&threadid, NULL, &doAudio, NULL); } -void kinc_a2_update() {} +void iron_a2_update() {} -void kinc_a2_shutdown() { +void iron_a2_shutdown() { audioRunning = false; } diff --git a/base/sources/backends/linux_system.c b/base/sources/backends/linux_system.c index 41ca2955..82943f28 100644 --- a/base/sources/backends/linux_system.c +++ b/base/sources/backends/linux_system.c @@ -25,15 +25,15 @@ #include #include -bool kinc_x11_init(); +bool iron_x11_init(); -void kinc_display_init() { +void iron_display_init() { static bool display_initialized = false; if (display_initialized) { return; } - kinc_x11_init(); + iron_x11_init(); int eventBase; int errorBase; @@ -51,7 +51,7 @@ void kinc_display_init() { for (int i = 0; i < screen_resources->noutput; i++) { if (i >= MAXIMUM_DISPLAYS) { - kinc_error("Too many screens (maximum %i)", MAXIMUM_DISPLAYS); + iron_error("Too many screens (maximum %i)", MAXIMUM_DISPLAYS); break; } @@ -63,7 +63,7 @@ void kinc_display_init() { XRRCrtcInfo *crtc_info = xlib.XRRGetCrtcInfo(x11_ctx.display, screen_resources, output_info->crtc); - struct kinc_x11_display *display = &x11_ctx.displays[x11_ctx.num_displays++]; + struct iron_x11_display *display = &x11_ctx.displays[x11_ctx.num_displays++]; display->index = i; strncpy(display->name, output_info->name, sizeof(display->name)); display->x = crtc_info->x; @@ -86,11 +86,11 @@ void kinc_display_init() { display_initialized = true; } -kinc_display_mode_t kinc_display_available_mode(int display_index, int mode_index) { +iron_display_mode_t iron_display_available_mode(int display_index, int mode_index) { if (display_index >= MAXIMUM_DISPLAYS) display_index = 0; - struct kinc_x11_display *display = &x11_ctx.displays[display_index]; - kinc_display_mode_t mode; + struct iron_x11_display *display = &x11_ctx.displays[display_index]; + iron_display_mode_t mode; mode.x = 0; mode.y = 0; mode.width = display->width; @@ -104,14 +104,14 @@ kinc_display_mode_t kinc_display_available_mode(int display_index, int mode_inde XRROutputInfo *output_info = xlib.XRRGetOutputInfo(x11_ctx.display, screen_resources, screen_resources->outputs[display->index]); if (output_info->connection != RR_Connected || output_info->crtc == None) { - kinc_error("Display %i not connected.", display_index); + iron_error("Display %i not connected.", display_index); xlib.XRRFreeOutputInfo(output_info); xlib.XRRFreeScreenResources(screen_resources); return mode; } if (mode_index >= output_info->nmode) { - kinc_error("Invalid mode index %i.", mode_index); + iron_error("Invalid mode index %i.", mode_index); } RRMode rr_mode = output_info->modes[mode_index]; @@ -144,17 +144,17 @@ kinc_display_mode_t kinc_display_available_mode(int display_index, int mode_inde return mode; } -int kinc_display_count_available_modes(int display_index) { +int iron_display_count_available_modes(int display_index) { if (display_index >= MAXIMUM_DISPLAYS) display_index = 0; - struct kinc_x11_display *display = &x11_ctx.displays[display_index]; + struct iron_x11_display *display = &x11_ctx.displays[display_index]; Window root_window = RootWindow(x11_ctx.display, DefaultScreen(x11_ctx.display)); XRRScreenResources *screen_resources = xlib.XRRGetScreenResourcesCurrent(x11_ctx.display, root_window); XRROutputInfo *output_info = xlib.XRRGetOutputInfo(x11_ctx.display, screen_resources, screen_resources->outputs[display->index]); if (output_info->connection != RR_Connected || output_info->crtc == None) { - kinc_error("Display %i not connected.", display_index); + iron_error("Display %i not connected.", display_index); xlib.XRRFreeOutputInfo(output_info); xlib.XRRFreeScreenResources(screen_resources); return 0; @@ -166,25 +166,25 @@ int kinc_display_count_available_modes(int display_index) { return num_modes; } -bool kinc_display_available(int display_index) { +bool iron_display_available(int display_index) { if (display_index >= MAXIMUM_DISPLAYS) { return false; } return x11_ctx.displays[display_index].output != None; } -const char *kinc_display_name(int display_index) { +const char *iron_display_name(int display_index) { if (display_index >= MAXIMUM_DISPLAYS) { return ""; } return x11_ctx.displays[display_index].name; } -kinc_display_mode_t kinc_display_current_mode(int display_index) { +iron_display_mode_t iron_display_current_mode(int display_index) { if (display_index >= MAXIMUM_DISPLAYS) display_index = 0; - struct kinc_x11_display *display = &x11_ctx.displays[display_index]; - kinc_display_mode_t mode; + struct iron_x11_display *display = &x11_ctx.displays[display_index]; + iron_display_mode_t mode; mode.x = 0; mode.y = 0; mode.width = display->width; @@ -198,7 +198,7 @@ kinc_display_mode_t kinc_display_current_mode(int display_index) { XRROutputInfo *output_info = xlib.XRRGetOutputInfo(x11_ctx.display, screen_resources, screen_resources->outputs[display->index]); if (output_info->connection != RR_Connected || output_info->crtc == None) { - kinc_error("Display %i not connected.", display_index); + iron_error("Display %i not connected.", display_index); xlib.XRRFreeOutputInfo(output_info); xlib.XRRFreeScreenResources(screen_resources); return mode; @@ -237,7 +237,7 @@ kinc_display_mode_t kinc_display_current_mode(int display_index) { return mode; } -int kinc_primary_display(void) { +int iron_primary_display(void) { for (int i = 0; i < x11_ctx.num_displays; i++) { if (x11_ctx.displays[i].primary) { return i; @@ -246,7 +246,7 @@ int kinc_primary_display(void) { return 0; } -int kinc_count_displays(void) { +int iron_count_displays(void) { return x11_ctx.num_displays; } @@ -260,36 +260,36 @@ struct MwmHints { }; #define MWM_HINTS_DECORATIONS (1L << 1) -int kinc_window_x() { +int iron_window_x() { return 0; } -int kinc_window_y() { +int iron_window_y() { return 0; } -int kinc_window_width() { +int iron_window_width() { return x11_ctx.windows[0].width; } -int kinc_window_height() { +int iron_window_height() { return x11_ctx.windows[0].height; } -void kinc_window_resize(int width, int height) { - struct kinc_x11_window *window = &x11_ctx.windows[0]; +void iron_window_resize(int width, int height) { + struct iron_x11_window *window = &x11_ctx.windows[0]; xlib.XResizeWindow(x11_ctx.display, window->window, width, height); } -void kinc_window_move(int x, int y) { - struct kinc_x11_window *window = &x11_ctx.windows[0]; +void iron_window_move(int x, int y) { + struct iron_x11_window *window = &x11_ctx.windows[0]; xlib.XMoveWindow(x11_ctx.display, window->window, x, y); } -void kinc_window_change_features(int features) {} +void iron_window_change_features(int features) {} -void kinc_window_change_mode(kinc_window_mode_t mode) { - struct kinc_x11_window *window = &x11_ctx.windows[0]; +void iron_window_change_mode(iron_window_mode_t mode) { + struct iron_x11_window *window = &x11_ctx.windows[0]; if (mode == window->mode) { return; } @@ -297,18 +297,18 @@ void kinc_window_change_mode(kinc_window_mode_t mode) { bool fullscreen = false; switch (mode) { - case KINC_WINDOW_MODE_WINDOW: - if (window->mode == KINC_WINDOW_MODE_FULLSCREEN) { - window->mode = KINC_WINDOW_MODE_WINDOW; + case IRON_WINDOW_MODE_WINDOW: + if (window->mode == IRON_WINDOW_MODE_FULLSCREEN) { + window->mode = IRON_WINDOW_MODE_WINDOW; fullscreen = false; } else { return; } break; - case KINC_WINDOW_MODE_FULLSCREEN: - if (window->mode == KINC_WINDOW_MODE_WINDOW) { - window->mode = KINC_WINDOW_MODE_FULLSCREEN; + case IRON_WINDOW_MODE_FULLSCREEN: + if (window->mode == IRON_WINDOW_MODE_WINDOW) { + window->mode = IRON_WINDOW_MODE_FULLSCREEN; fullscreen = true; } else { @@ -334,36 +334,36 @@ void kinc_window_change_mode(kinc_window_mode_t mode) { xlib.XFlush(x11_ctx.display); } -int kinc_window_display() { - struct kinc_x11_window *window = &x11_ctx.windows[0]; +int iron_window_display() { + struct iron_x11_window *window = &x11_ctx.windows[0]; return window->display_index; } -void kinc_window_destroy() { - kinc_g5_internal_destroy_window(); +void iron_window_destroy() { + iron_g5_internal_destroy_window(); xlib.XFlush(x11_ctx.display); - struct kinc_x11_window *window = &x11_ctx.windows[0]; + struct iron_x11_window *window = &x11_ctx.windows[0]; xlib.XDestroyIC(window->xInputContext); xlib.XCloseIM(window->xInputMethod); xlib.XDestroyWindow(x11_ctx.display, window->window); xlib.XFlush(x11_ctx.display); - *window = (struct kinc_x11_window){0}; + *window = (struct iron_x11_window){0}; } -void kinc_window_show() { - struct kinc_x11_window *window = &x11_ctx.windows[0]; +void iron_window_show() { + struct iron_x11_window *window = &x11_ctx.windows[0]; xlib.XMapWindow(x11_ctx.display, window->window); } -void kinc_window_hide() { - struct kinc_x11_window *window = &x11_ctx.windows[0]; +void iron_window_hide() { + struct iron_x11_window *window = &x11_ctx.windows[0]; xlib.XUnmapWindow(x11_ctx.display, window->window); } -void kinc_window_set_title(const char *_title) { +void iron_window_set_title(const char *_title) { const char *title = _title == NULL ? "" : _title; - struct kinc_x11_window *window = &x11_ctx.windows[0]; + struct iron_x11_window *window = &x11_ctx.windows[0]; xlib.XChangeProperty(x11_ctx.display, window->window, x11_ctx.atoms.NET_WM_NAME, x11_ctx.atoms.UTF8_STRING, 8, PropModeReplace, (unsigned char *)title, strlen(title)); @@ -373,8 +373,8 @@ void kinc_window_set_title(const char *_title) { xlib.XFlush(x11_ctx.display); } -void kinc_window_create(kinc_window_options_t *win) { - struct kinc_x11_window *window = &x11_ctx.windows[0]; +void iron_window_create(iron_window_options_t *win) { + struct iron_x11_window *window = &x11_ctx.windows[0]; window->width = win->width; window->height = win->height; @@ -392,11 +392,11 @@ void kinc_window_create(kinc_window_options_t *win) { InputOutput, visual, CWBorderPixel | CWColormap | CWEventMask, &set_window_attribs); static char nameClass[256]; - static const char *nameClassAddendum = "_KincApplication"; - strncpy(nameClass, kinc_application_name(), sizeof(nameClass) - strlen(nameClassAddendum) - 1); + static const char *nameClassAddendum = "_IronApplication"; + strncpy(nameClass, iron_application_name(), sizeof(nameClass) - strlen(nameClassAddendum) - 1); strcat(nameClass, nameClassAddendum); char resNameBuffer[256]; - strncpy(resNameBuffer, kinc_application_name(), 256); + strncpy(resNameBuffer, iron_application_name(), 256); XClassHint classHint = {.res_name = resNameBuffer, .res_class = nameClass}; xlib.XSetClassHint(x11_ctx.display, window->window, &classHint); @@ -405,8 +405,8 @@ void kinc_window_create(kinc_window_options_t *win) { window->xInputContext = xlib.XCreateIC(window->xInputMethod, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, window->window, NULL); xlib.XSetICFocus(window->xInputContext); - window->mode = KINC_WINDOW_MODE_WINDOW; - kinc_window_change_mode(win->mode); + window->mode = IRON_WINDOW_MODE_WINDOW; + iron_window_change_mode(win->mode); xlib.XMapWindow(x11_ctx.display, window->window); @@ -414,7 +414,7 @@ void kinc_window_create(kinc_window_options_t *win) { xlib.XChangeProperty(x11_ctx.display, window->window, x11_ctx.atoms.XdndAware, XA_ATOM, 32, PropModeReplace, (unsigned char *)&XdndVersion, 1); xlib.XSetWMProtocols(x11_ctx.display, window->window, &x11_ctx.atoms.WM_DELETE_WINDOW, 1); - kinc_window_set_title(win->title); + iron_window_set_title(win->title); if (x11_ctx.pen.id != -1) { xlib.XSelectExtensionEvent(x11_ctx.display, window->window, &x11_ctx.pen.motionClass, 1); @@ -424,7 +424,7 @@ void kinc_window_create(kinc_window_options_t *win) { xlib.XSelectExtensionEvent(x11_ctx.display, window->window, &x11_ctx.eraser.motionClass, 1); } - kinc_g4_internal_init_window(win->depth_bits, win->vsync); + iron_g4_internal_init_window(win->depth_bits, win->vsync); } static struct { @@ -433,41 +433,41 @@ static struct { void *ppi_data; bool (*close_callback)(void *data); void *close_data; -} kinc_internal_window_callbacks[16]; +} iron_internal_window_callbacks[16]; -void kinc_window_set_resize_callback(void (*callback)(int width, int height, void *data), void *data) { - kinc_internal_window_callbacks[0].resize_callback = callback; - kinc_internal_window_callbacks[0].resize_data = data; +void iron_window_set_resize_callback(void (*callback)(int width, int height, void *data), void *data) { + iron_internal_window_callbacks[0].resize_callback = callback; + iron_internal_window_callbacks[0].resize_data = data; } -void kinc_internal_call_resize_callback(int width, int height) { - if (kinc_internal_window_callbacks[0].resize_callback != NULL) { - kinc_internal_window_callbacks[0].resize_callback(width, height, kinc_internal_window_callbacks[0].resize_data); +void iron_internal_call_resize_callback(int width, int height) { + if (iron_internal_window_callbacks[0].resize_callback != NULL) { + iron_internal_window_callbacks[0].resize_callback(width, height, iron_internal_window_callbacks[0].resize_data); } } -void kinc_window_set_close_callback(bool (*callback)(void *data), void *data) { - kinc_internal_window_callbacks[0].close_callback = callback; - kinc_internal_window_callbacks[0].close_data = data; +void iron_window_set_close_callback(bool (*callback)(void *data), void *data) { + iron_internal_window_callbacks[0].close_callback = callback; + iron_internal_window_callbacks[0].close_data = data; } -bool kinc_internal_call_close_callback() { - if (kinc_internal_window_callbacks[0].close_callback != NULL) { - return kinc_internal_window_callbacks[0].close_callback(kinc_internal_window_callbacks[0].close_data); +bool iron_internal_call_close_callback() { + if (iron_internal_window_callbacks[0].close_callback != NULL) { + return iron_internal_window_callbacks[0].close_callback(iron_internal_window_callbacks[0].close_data); } else { return true; } } -kinc_window_mode_t kinc_window_get_mode() { +iron_window_mode_t iron_window_get_mode() { return x11_ctx.windows[0].mode; } #define Button6 6 #define Button7 7 -struct kinc_x11_procs xlib = {0}; +struct iron_x11_procs xlib = {0}; struct x11_context x11_ctx = {0}; static size_t clipboardStringSize = 1024; @@ -475,7 +475,7 @@ static char *clipboardString = NULL; char buffer[1024]; -void kinc_internal_resize(int width, int height); +void iron_internal_resize(int width, int height); static void init_pen_device(XDeviceInfo *info, struct x11_pen_device *pen, bool eraser); static void load_lib(void **lib, const char *name) { @@ -495,13 +495,13 @@ static void load_lib(void **lib, const char *name) { } } -int kinc_x11_error_handler(Display *display, XErrorEvent *error_event) { +int iron_x11_error_handler(Display *display, XErrorEvent *error_event) { xlib.XGetErrorText(display, error_event->error_code, buffer, 1024); - kinc_error("X Error: %s", buffer); + iron_error("X Error: %s", buffer); return 0; } -bool kinc_x11_init() { +bool iron_x11_init() { #undef LOAD_LIB #undef LOAD_FUN #define LOAD_LIB(name) \ @@ -509,7 +509,7 @@ bool kinc_x11_init() { load_lib(&x11_ctx.libs.name, #name); \ \ if (x11_ctx.libs.name == NULL) { \ - kinc_error("Failed to load lib%s.so", #name); \ + iron_error("Failed to load lib%s.so", #name); \ return false; \ } \ } \ @@ -528,7 +528,7 @@ bool kinc_x11_init() { #define LOAD_FUN(lib, symbol) \ xlib.symbol = dlsym(x11_ctx.libs.lib, #symbol); \ if (xlib.symbol == NULL) { \ - kinc_error("Did not find symbol %s in library %s.", #symbol, #lib); \ + iron_error("Did not find symbol %s in library %s.", #symbol, #lib); \ } LOAD_FUN(X11, XOpenDisplay) LOAD_FUN(X11, XCloseDisplay) @@ -599,7 +599,7 @@ bool kinc_x11_init() { return false; } - xlib.XSetErrorHandler(kinc_x11_error_handler); + xlib.XSetErrorHandler(iron_x11_error_handler); // this should be kept in sync with the x11_atoms struct static char *atom_names[] = { @@ -643,7 +643,7 @@ bool kinc_x11_init() { XI_JOYSTICK, }; - assert((sizeof atom_names / sizeof atom_names[0]) == (sizeof(struct kinc_x11_atoms) / sizeof(Atom))); + assert((sizeof atom_names / sizeof atom_names[0]) == (sizeof(struct iron_x11_atoms) / sizeof(Atom))); xlib.XInternAtoms(x11_ctx.display, atom_names, sizeof atom_names / sizeof atom_names[0], False, (Atom *)&x11_ctx.atoms); clipboardString = (char *)malloc(clipboardStringSize); @@ -686,14 +686,14 @@ static void init_pen_device(XDeviceInfo *info, struct x11_pen_device *pen, bool pen->id = info->id; DeviceMotionNotify(device, pen->motionEvent, pen->motionClass); if (eraser) { - pen->press = kinc_internal_eraser_trigger_press; - pen->move = kinc_internal_eraser_trigger_move; - pen->release = kinc_internal_eraser_trigger_release; + pen->press = iron_internal_eraser_trigger_press; + pen->move = iron_internal_eraser_trigger_move; + pen->release = iron_internal_eraser_trigger_release; } else { - pen->press = kinc_internal_pen_trigger_press; - pen->move = kinc_internal_pen_trigger_move; - pen->release = kinc_internal_pen_trigger_release; + pen->press = iron_internal_pen_trigger_press; + pen->move = iron_internal_pen_trigger_move; + pen->release = iron_internal_pen_trigger_release; } return; } @@ -702,7 +702,7 @@ static void init_pen_device(XDeviceInfo *info, struct x11_pen_device *pen, bool xlib.XCloseDevice(x11_ctx.display, device); } -static void check_pen_device(struct kinc_x11_window *window, XEvent *event, struct x11_pen_device *pen) { +static void check_pen_device(struct iron_x11_window *window, XEvent *event, struct x11_pen_device *pen) { if (event->type == pen->motionEvent) { XDeviceMotionEvent *motion = (XDeviceMotionEvent *)(event); if (motion->deviceid == pen->id) { @@ -721,7 +721,7 @@ static void check_pen_device(struct kinc_x11_window *window, XEvent *event, stru } } -struct kinc_x11_window *window_from_window(Window window) { +struct iron_x11_window *window_from_window(Window window) { for (int i = 0; i < MAXIMUM_WINDOWS; i++) { if (x11_ctx.windows[i].window == window) { return &x11_ctx.windows[i]; @@ -730,16 +730,16 @@ struct kinc_x11_window *window_from_window(Window window) { return NULL; } -void kinc_vulkan_get_instance_extensions(const char **names, int *index, int max) { +void iron_vulkan_get_instance_extensions(const char **names, int *index, int max) { assert(*index + 1 < max); names[(*index)++] = VK_KHR_XLIB_SURFACE_EXTENSION_NAME; } -VkBool32 kinc_vulkan_get_physical_device_presentation_support(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex) { +VkBool32 iron_vulkan_get_physical_device_presentation_support(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex) { return vkGetPhysicalDeviceXlibPresentationSupportKHR(physicalDevice, queueFamilyIndex, x11_ctx.display, DefaultVisual(x11_ctx.display, DefaultScreen(x11_ctx.display))->visualid); } -VkResult kinc_vulkan_create_surface(VkInstance instance, VkSurfaceKHR *surface) { +VkResult iron_vulkan_create_surface(VkInstance instance, VkSurfaceKHR *surface) { VkXlibSurfaceCreateInfoKHR info = {0}; info.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR; info.pNext = NULL; @@ -758,7 +758,7 @@ static bool _handle_messages() { XEvent event; xlib.XNextEvent(x11_ctx.display, &event); Window window = event.xclient.window; - struct kinc_x11_window *k_window = window_from_window(window); + struct iron_x11_window *k_window = window_from_window(window); if (k_window == NULL) { continue; } @@ -781,7 +781,7 @@ static bool _handle_messages() { if (!controlDown && !xlib.XFilterEvent(&event, window) && !isIgnoredKeySym) { if (wcConverted) { - kinc_internal_keyboard_trigger_key_press(wchar); + iron_internal_keyboard_trigger_key_press(wchar); } } @@ -791,9 +791,9 @@ static bool _handle_messages() { continue; } -#define KEY(xkey, korekey) \ +#define KEY(xkey, ironkey) \ case xkey: \ - kinc_internal_keyboard_trigger_key_down(korekey); \ + iron_internal_keyboard_trigger_key_down(ironkey); \ break; KeySym ksKey = xlib.XkbKeycodeToKeysym(x11_ctx.display, event.xkey.keycode, 0, 0); @@ -806,15 +806,15 @@ static bool _handle_messages() { } else if (controlDown && (ksKey == XK_c || ksKey == XK_C)) { xlib.XSetSelectionOwner(x11_ctx.display, x11_ctx.atoms.CLIPBOARD, window, CurrentTime); - char *text = kinc_internal_copy_callback(); + char *text = iron_internal_copy_callback(); if (text != NULL) - kinc_copy_to_clipboard(text); + iron_copy_to_clipboard(text); } else if (controlDown && (ksKey == XK_x || ksKey == XK_X)) { xlib.XSetSelectionOwner(x11_ctx.display, x11_ctx.atoms.CLIPBOARD, window, CurrentTime); - char *text = kinc_internal_cut_callback(); + char *text = iron_internal_cut_callback(); if (text != NULL) - kinc_copy_to_clipboard(text); + iron_copy_to_clipboard(text); } if (event.xkey.keycode == ignoreKeycode) { @@ -829,136 +829,136 @@ static bool _handle_messages() { } switch (ksKey) { - KEY(XK_Right, KINC_KEY_RIGHT) - KEY(XK_Left, KINC_KEY_LEFT) - KEY(XK_Up, KINC_KEY_UP) - KEY(XK_Down, KINC_KEY_DOWN) - KEY(XK_space, KINC_KEY_SPACE) - KEY(XK_BackSpace, KINC_KEY_BACKSPACE) - KEY(XK_Tab, KINC_KEY_TAB) - KEY(XK_Return, KINC_KEY_RETURN) - KEY(XK_Shift_L, KINC_KEY_SHIFT) - KEY(XK_Shift_R, KINC_KEY_SHIFT) - KEY(XK_Control_L, KINC_KEY_CONTROL) - KEY(XK_Control_R, KINC_KEY_CONTROL) - KEY(XK_Alt_L, KINC_KEY_ALT) - KEY(XK_Alt_R, KINC_KEY_ALT) - KEY(XK_Delete, KINC_KEY_DELETE) - KEY(XK_comma, KINC_KEY_COMMA) - KEY(XK_period, KINC_KEY_PERIOD) - KEY(XK_bracketleft, KINC_KEY_OPEN_BRACKET) - KEY(XK_bracketright, KINC_KEY_CLOSE_BRACKET) - KEY(XK_braceleft, KINC_KEY_OPEN_CURLY_BRACKET) - KEY(XK_braceright, KINC_KEY_CLOSE_CURLY_BRACKET) - KEY(XK_parenleft, KINC_KEY_OPEN_PAREN) - KEY(XK_parenright, KINC_KEY_CLOSE_PAREN) - KEY(XK_backslash, KINC_KEY_BACK_SLASH) - KEY(XK_apostrophe, KINC_KEY_QUOTE) - KEY(XK_colon, KINC_KEY_COLON) - KEY(XK_semicolon, KINC_KEY_SEMICOLON) - KEY(XK_minus, KINC_KEY_HYPHEN_MINUS) - KEY(XK_underscore, KINC_KEY_UNDERSCORE) - KEY(XK_slash, KINC_KEY_SLASH) - KEY(XK_bar, KINC_KEY_PIPE) - KEY(XK_question, KINC_KEY_QUESTIONMARK) - KEY(XK_less, KINC_KEY_LESS_THAN) - KEY(XK_greater, KINC_KEY_GREATER_THAN) - KEY(XK_asterisk, KINC_KEY_ASTERISK) - KEY(XK_ampersand, KINC_KEY_AMPERSAND) - KEY(XK_asciicircum, KINC_KEY_CIRCUMFLEX) - KEY(XK_percent, KINC_KEY_PERCENT) - KEY(XK_dollar, KINC_KEY_DOLLAR) - KEY(XK_numbersign, KINC_KEY_HASH) - KEY(XK_at, KINC_KEY_AT) - KEY(XK_exclam, KINC_KEY_EXCLAMATION) - KEY(XK_equal, KINC_KEY_EQUALS) - KEY(XK_plus, KINC_KEY_ADD) - KEY(XK_quoteleft, KINC_KEY_BACK_QUOTE) - KEY(XK_quotedbl, KINC_KEY_DOUBLE_QUOTE) - KEY(XK_asciitilde, KINC_KEY_TILDE) - KEY(XK_Pause, KINC_KEY_PAUSE) - KEY(XK_Scroll_Lock, KINC_KEY_SCROLL_LOCK) - KEY(XK_Home, KINC_KEY_HOME) - KEY(XK_Page_Up, KINC_KEY_PAGE_UP) - KEY(XK_Page_Down, KINC_KEY_PAGE_DOWN) - KEY(XK_End, KINC_KEY_END) - KEY(XK_Insert, KINC_KEY_INSERT) - KEY(XK_KP_Enter, KINC_KEY_RETURN) - KEY(XK_KP_Multiply, KINC_KEY_MULTIPLY) - KEY(XK_KP_Add, KINC_KEY_ADD) - KEY(XK_KP_Subtract, KINC_KEY_SUBTRACT) - KEY(XK_KP_Decimal, KINC_KEY_DECIMAL) - KEY(XK_KP_Divide, KINC_KEY_DIVIDE) - KEY(XK_KP_0, KINC_KEY_NUMPAD_0) - KEY(XK_KP_1, KINC_KEY_NUMPAD_1) - KEY(XK_KP_2, KINC_KEY_NUMPAD_2) - KEY(XK_KP_3, KINC_KEY_NUMPAD_3) - KEY(XK_KP_4, KINC_KEY_NUMPAD_4) - KEY(XK_KP_5, KINC_KEY_NUMPAD_5) - KEY(XK_KP_6, KINC_KEY_NUMPAD_6) - KEY(XK_KP_7, KINC_KEY_NUMPAD_7) - KEY(XK_KP_8, KINC_KEY_NUMPAD_8) - KEY(XK_KP_9, KINC_KEY_NUMPAD_9) - KEY(XK_KP_Insert, KINC_KEY_INSERT) - KEY(XK_KP_Delete, KINC_KEY_DELETE) - KEY(XK_KP_End, KINC_KEY_END) - KEY(XK_KP_Home, KINC_KEY_HOME) - KEY(XK_KP_Left, KINC_KEY_LEFT) - KEY(XK_KP_Up, KINC_KEY_UP) - KEY(XK_KP_Right, KINC_KEY_RIGHT) - KEY(XK_KP_Down, KINC_KEY_DOWN) - KEY(XK_KP_Page_Up, KINC_KEY_PAGE_UP) - KEY(XK_KP_Page_Down, KINC_KEY_PAGE_DOWN) - KEY(XK_Menu, KINC_KEY_CONTEXT_MENU) - KEY(XK_a, KINC_KEY_A) - KEY(XK_b, KINC_KEY_B) - KEY(XK_c, KINC_KEY_C) - KEY(XK_d, KINC_KEY_D) - KEY(XK_e, KINC_KEY_E) - KEY(XK_f, KINC_KEY_F) - KEY(XK_g, KINC_KEY_G) - KEY(XK_h, KINC_KEY_H) - KEY(XK_i, KINC_KEY_I) - KEY(XK_j, KINC_KEY_J) - KEY(XK_k, KINC_KEY_K) - KEY(XK_l, KINC_KEY_L) - KEY(XK_m, KINC_KEY_M) - KEY(XK_n, KINC_KEY_N) - KEY(XK_o, KINC_KEY_O) - KEY(XK_p, KINC_KEY_P) - KEY(XK_q, KINC_KEY_Q) - KEY(XK_r, KINC_KEY_R) - KEY(XK_s, KINC_KEY_S) - KEY(XK_t, KINC_KEY_T) - KEY(XK_u, KINC_KEY_U) - KEY(XK_v, KINC_KEY_V) - KEY(XK_w, KINC_KEY_W) - KEY(XK_x, KINC_KEY_X) - KEY(XK_y, KINC_KEY_Y) - KEY(XK_z, KINC_KEY_Z) - KEY(XK_1, KINC_KEY_1) - KEY(XK_2, KINC_KEY_2) - KEY(XK_3, KINC_KEY_3) - KEY(XK_4, KINC_KEY_4) - KEY(XK_5, KINC_KEY_5) - KEY(XK_6, KINC_KEY_6) - KEY(XK_7, KINC_KEY_7) - KEY(XK_8, KINC_KEY_8) - KEY(XK_9, KINC_KEY_9) - KEY(XK_0, KINC_KEY_0) - KEY(XK_Escape, KINC_KEY_ESCAPE) - KEY(XK_F1, KINC_KEY_F1) - KEY(XK_F2, KINC_KEY_F2) - KEY(XK_F3, KINC_KEY_F3) - KEY(XK_F4, KINC_KEY_F4) - KEY(XK_F5, KINC_KEY_F5) - KEY(XK_F6, KINC_KEY_F6) - KEY(XK_F7, KINC_KEY_F7) - KEY(XK_F8, KINC_KEY_F8) - KEY(XK_F9, KINC_KEY_F9) - KEY(XK_F10, KINC_KEY_F10) - KEY(XK_F11, KINC_KEY_F11) - KEY(XK_F12, KINC_KEY_F12) + KEY(XK_Right, IRON_KEY_RIGHT) + KEY(XK_Left, IRON_KEY_LEFT) + KEY(XK_Up, IRON_KEY_UP) + KEY(XK_Down, IRON_KEY_DOWN) + KEY(XK_space, IRON_KEY_SPACE) + KEY(XK_BackSpace, IRON_KEY_BACKSPACE) + KEY(XK_Tab, IRON_KEY_TAB) + KEY(XK_Return, IRON_KEY_RETURN) + KEY(XK_Shift_L, IRON_KEY_SHIFT) + KEY(XK_Shift_R, IRON_KEY_SHIFT) + KEY(XK_Control_L, IRON_KEY_CONTROL) + KEY(XK_Control_R, IRON_KEY_CONTROL) + KEY(XK_Alt_L, IRON_KEY_ALT) + KEY(XK_Alt_R, IRON_KEY_ALT) + KEY(XK_Delete, IRON_KEY_DELETE) + KEY(XK_comma, IRON_KEY_COMMA) + KEY(XK_period, IRON_KEY_PERIOD) + KEY(XK_bracketleft, IRON_KEY_OPEN_BRACKET) + KEY(XK_bracketright, IRON_KEY_CLOSE_BRACKET) + KEY(XK_braceleft, IRON_KEY_OPEN_CURLY_BRACKET) + KEY(XK_braceright, IRON_KEY_CLOSE_CURLY_BRACKET) + KEY(XK_parenleft, IRON_KEY_OPEN_PAREN) + KEY(XK_parenright, IRON_KEY_CLOSE_PAREN) + KEY(XK_backslash, IRON_KEY_BACK_SLASH) + KEY(XK_apostrophe, IRON_KEY_QUOTE) + KEY(XK_colon, IRON_KEY_COLON) + KEY(XK_semicolon, IRON_KEY_SEMICOLON) + KEY(XK_minus, IRON_KEY_HYPHEN_MINUS) + KEY(XK_underscore, IRON_KEY_UNDERSCORE) + KEY(XK_slash, IRON_KEY_SLASH) + KEY(XK_bar, IRON_KEY_PIPE) + KEY(XK_question, IRON_KEY_QUESTIONMARK) + KEY(XK_less, IRON_KEY_LESS_THAN) + KEY(XK_greater, IRON_KEY_GREATER_THAN) + KEY(XK_asterisk, IRON_KEY_ASTERISK) + KEY(XK_ampersand, IRON_KEY_AMPERSAND) + KEY(XK_asciicircum, IRON_KEY_CIRCUMFLEX) + KEY(XK_percent, IRON_KEY_PERCENT) + KEY(XK_dollar, IRON_KEY_DOLLAR) + KEY(XK_numbersign, IRON_KEY_HASH) + KEY(XK_at, IRON_KEY_AT) + KEY(XK_exclam, IRON_KEY_EXCLAMATION) + KEY(XK_equal, IRON_KEY_EQUALS) + KEY(XK_plus, IRON_KEY_ADD) + KEY(XK_quoteleft, IRON_KEY_BACK_QUOTE) + KEY(XK_quotedbl, IRON_KEY_DOUBLE_QUOTE) + KEY(XK_asciitilde, IRON_KEY_TILDE) + KEY(XK_Pause, IRON_KEY_PAUSE) + KEY(XK_Scroll_Lock, IRON_KEY_SCROLL_LOCK) + KEY(XK_Home, IRON_KEY_HOME) + KEY(XK_Page_Up, IRON_KEY_PAGE_UP) + KEY(XK_Page_Down, IRON_KEY_PAGE_DOWN) + KEY(XK_End, IRON_KEY_END) + KEY(XK_Insert, IRON_KEY_INSERT) + KEY(XK_KP_Enter, IRON_KEY_RETURN) + KEY(XK_KP_Multiply, IRON_KEY_MULTIPLY) + KEY(XK_KP_Add, IRON_KEY_ADD) + KEY(XK_KP_Subtract, IRON_KEY_SUBTRACT) + KEY(XK_KP_Decimal, IRON_KEY_DECIMAL) + KEY(XK_KP_Divide, IRON_KEY_DIVIDE) + KEY(XK_KP_0, IRON_KEY_NUMPAD_0) + KEY(XK_KP_1, IRON_KEY_NUMPAD_1) + KEY(XK_KP_2, IRON_KEY_NUMPAD_2) + KEY(XK_KP_3, IRON_KEY_NUMPAD_3) + KEY(XK_KP_4, IRON_KEY_NUMPAD_4) + KEY(XK_KP_5, IRON_KEY_NUMPAD_5) + KEY(XK_KP_6, IRON_KEY_NUMPAD_6) + KEY(XK_KP_7, IRON_KEY_NUMPAD_7) + KEY(XK_KP_8, IRON_KEY_NUMPAD_8) + KEY(XK_KP_9, IRON_KEY_NUMPAD_9) + KEY(XK_KP_Insert, IRON_KEY_INSERT) + KEY(XK_KP_Delete, IRON_KEY_DELETE) + KEY(XK_KP_End, IRON_KEY_END) + KEY(XK_KP_Home, IRON_KEY_HOME) + KEY(XK_KP_Left, IRON_KEY_LEFT) + KEY(XK_KP_Up, IRON_KEY_UP) + KEY(XK_KP_Right, IRON_KEY_RIGHT) + KEY(XK_KP_Down, IRON_KEY_DOWN) + KEY(XK_KP_Page_Up, IRON_KEY_PAGE_UP) + KEY(XK_KP_Page_Down, IRON_KEY_PAGE_DOWN) + KEY(XK_Menu, IRON_KEY_CONTEXT_MENU) + KEY(XK_a, IRON_KEY_A) + KEY(XK_b, IRON_KEY_B) + KEY(XK_c, IRON_KEY_C) + KEY(XK_d, IRON_KEY_D) + KEY(XK_e, IRON_KEY_E) + KEY(XK_f, IRON_KEY_F) + KEY(XK_g, IRON_KEY_G) + KEY(XK_h, IRON_KEY_H) + KEY(XK_i, IRON_KEY_I) + KEY(XK_j, IRON_KEY_J) + KEY(XK_k, IRON_KEY_K) + KEY(XK_l, IRON_KEY_L) + KEY(XK_m, IRON_KEY_M) + KEY(XK_n, IRON_KEY_N) + KEY(XK_o, IRON_KEY_O) + KEY(XK_p, IRON_KEY_P) + KEY(XK_q, IRON_KEY_Q) + KEY(XK_r, IRON_KEY_R) + KEY(XK_s, IRON_KEY_S) + KEY(XK_t, IRON_KEY_T) + KEY(XK_u, IRON_KEY_U) + KEY(XK_v, IRON_KEY_V) + KEY(XK_w, IRON_KEY_W) + KEY(XK_x, IRON_KEY_X) + KEY(XK_y, IRON_KEY_Y) + KEY(XK_z, IRON_KEY_Z) + KEY(XK_1, IRON_KEY_1) + KEY(XK_2, IRON_KEY_2) + KEY(XK_3, IRON_KEY_3) + KEY(XK_4, IRON_KEY_4) + KEY(XK_5, IRON_KEY_5) + KEY(XK_6, IRON_KEY_6) + KEY(XK_7, IRON_KEY_7) + KEY(XK_8, IRON_KEY_8) + KEY(XK_9, IRON_KEY_9) + KEY(XK_0, IRON_KEY_0) + KEY(XK_Escape, IRON_KEY_ESCAPE) + KEY(XK_F1, IRON_KEY_F1) + KEY(XK_F2, IRON_KEY_F2) + KEY(XK_F3, IRON_KEY_F3) + KEY(XK_F4, IRON_KEY_F4) + KEY(XK_F5, IRON_KEY_F5) + KEY(XK_F6, IRON_KEY_F6) + KEY(XK_F7, IRON_KEY_F7) + KEY(XK_F8, IRON_KEY_F8) + KEY(XK_F9, IRON_KEY_F9) + KEY(XK_F10, IRON_KEY_F10) + KEY(XK_F11, IRON_KEY_F11) + KEY(XK_F12, IRON_KEY_F12) } break; #undef KEY @@ -982,9 +982,9 @@ static bool _handle_messages() { char c; xlib.XLookupString(key, &c, 1, &keysym, NULL); -#define KEY(xkey, korekey) \ +#define KEY(xkey, ironkey) \ case xkey: \ - kinc_internal_keyboard_trigger_key_up(korekey); \ + iron_internal_keyboard_trigger_key_up(ironkey); \ break; KeySym ksKey = xlib.XkbKeycodeToKeysym(x11_ctx.display, event.xkey.keycode, 0, 0); @@ -1002,137 +1002,137 @@ static bool _handle_messages() { } switch (ksKey) { - KEY(XK_Right, KINC_KEY_RIGHT) - KEY(XK_Left, KINC_KEY_LEFT) - KEY(XK_Up, KINC_KEY_UP) - KEY(XK_Down, KINC_KEY_DOWN) - KEY(XK_space, KINC_KEY_SPACE) - KEY(XK_BackSpace, KINC_KEY_BACKSPACE) - KEY(XK_Tab, KINC_KEY_TAB) - KEY(XK_Return, KINC_KEY_RETURN) - KEY(XK_Shift_L, KINC_KEY_SHIFT) - KEY(XK_Shift_R, KINC_KEY_SHIFT) - KEY(XK_Control_L, KINC_KEY_CONTROL) - KEY(XK_Control_R, KINC_KEY_CONTROL) - KEY(XK_Alt_L, KINC_KEY_ALT) - KEY(XK_ISO_Prev_Group, KINC_KEY_ALT) //// XK_ISO_Prev_Group received instead of XK_Alt_L? - KEY(XK_Alt_R, KINC_KEY_ALT) - KEY(XK_Delete, KINC_KEY_DELETE) - KEY(XK_comma, KINC_KEY_COMMA) - KEY(XK_period, KINC_KEY_PERIOD) - KEY(XK_bracketleft, KINC_KEY_OPEN_BRACKET) - KEY(XK_bracketright, KINC_KEY_CLOSE_BRACKET) - KEY(XK_braceleft, KINC_KEY_OPEN_CURLY_BRACKET) - KEY(XK_braceright, KINC_KEY_CLOSE_CURLY_BRACKET) - KEY(XK_parenleft, KINC_KEY_OPEN_PAREN) - KEY(XK_parenright, KINC_KEY_CLOSE_PAREN) - KEY(XK_backslash, KINC_KEY_BACK_SLASH) - KEY(XK_apostrophe, KINC_KEY_QUOTE) - KEY(XK_colon, KINC_KEY_COLON) - KEY(XK_semicolon, KINC_KEY_SEMICOLON) - KEY(XK_minus, KINC_KEY_HYPHEN_MINUS) - KEY(XK_underscore, KINC_KEY_UNDERSCORE) - KEY(XK_slash, KINC_KEY_SLASH) - KEY(XK_bar, KINC_KEY_PIPE) - KEY(XK_question, KINC_KEY_QUESTIONMARK) - KEY(XK_less, KINC_KEY_LESS_THAN) - KEY(XK_greater, KINC_KEY_GREATER_THAN) - KEY(XK_asterisk, KINC_KEY_ASTERISK) - KEY(XK_ampersand, KINC_KEY_AMPERSAND) - KEY(XK_asciicircum, KINC_KEY_CIRCUMFLEX) - KEY(XK_percent, KINC_KEY_PERCENT) - KEY(XK_dollar, KINC_KEY_DOLLAR) - KEY(XK_numbersign, KINC_KEY_HASH) - KEY(XK_at, KINC_KEY_AT) - KEY(XK_exclam, KINC_KEY_EXCLAMATION) - KEY(XK_equal, KINC_KEY_EQUALS) - KEY(XK_plus, KINC_KEY_ADD) - KEY(XK_quoteleft, KINC_KEY_BACK_QUOTE) - KEY(XK_quotedbl, KINC_KEY_DOUBLE_QUOTE) - KEY(XK_asciitilde, KINC_KEY_TILDE) - KEY(XK_Pause, KINC_KEY_PAUSE) - KEY(XK_Scroll_Lock, KINC_KEY_SCROLL_LOCK) - KEY(XK_Home, KINC_KEY_HOME) - KEY(XK_Page_Up, KINC_KEY_PAGE_UP) - KEY(XK_Page_Down, KINC_KEY_PAGE_DOWN) - KEY(XK_End, KINC_KEY_END) - KEY(XK_Insert, KINC_KEY_INSERT) - KEY(XK_KP_Enter, KINC_KEY_RETURN) - KEY(XK_KP_Multiply, KINC_KEY_MULTIPLY) - KEY(XK_KP_Add, KINC_KEY_ADD) - KEY(XK_KP_Subtract, KINC_KEY_SUBTRACT) - KEY(XK_KP_Decimal, KINC_KEY_DECIMAL) - KEY(XK_KP_Divide, KINC_KEY_DIVIDE) - KEY(XK_KP_0, KINC_KEY_NUMPAD_0) - KEY(XK_KP_1, KINC_KEY_NUMPAD_1) - KEY(XK_KP_2, KINC_KEY_NUMPAD_2) - KEY(XK_KP_3, KINC_KEY_NUMPAD_3) - KEY(XK_KP_4, KINC_KEY_NUMPAD_4) - KEY(XK_KP_5, KINC_KEY_NUMPAD_5) - KEY(XK_KP_6, KINC_KEY_NUMPAD_6) - KEY(XK_KP_7, KINC_KEY_NUMPAD_7) - KEY(XK_KP_8, KINC_KEY_NUMPAD_8) - KEY(XK_KP_9, KINC_KEY_NUMPAD_9) - KEY(XK_KP_Insert, KINC_KEY_INSERT) - KEY(XK_KP_Delete, KINC_KEY_DELETE) - KEY(XK_KP_End, KINC_KEY_END) - KEY(XK_KP_Home, KINC_KEY_HOME) - KEY(XK_KP_Left, KINC_KEY_LEFT) - KEY(XK_KP_Up, KINC_KEY_UP) - KEY(XK_KP_Right, KINC_KEY_RIGHT) - KEY(XK_KP_Down, KINC_KEY_DOWN) - KEY(XK_KP_Page_Up, KINC_KEY_PAGE_UP) - KEY(XK_KP_Page_Down, KINC_KEY_PAGE_DOWN) - KEY(XK_Menu, KINC_KEY_CONTEXT_MENU) - KEY(XK_a, KINC_KEY_A) - KEY(XK_b, KINC_KEY_B) - KEY(XK_c, KINC_KEY_C) - KEY(XK_d, KINC_KEY_D) - KEY(XK_e, KINC_KEY_E) - KEY(XK_f, KINC_KEY_F) - KEY(XK_g, KINC_KEY_G) - KEY(XK_h, KINC_KEY_H) - KEY(XK_i, KINC_KEY_I) - KEY(XK_j, KINC_KEY_J) - KEY(XK_k, KINC_KEY_K) - KEY(XK_l, KINC_KEY_L) - KEY(XK_m, KINC_KEY_M) - KEY(XK_n, KINC_KEY_N) - KEY(XK_o, KINC_KEY_O) - KEY(XK_p, KINC_KEY_P) - KEY(XK_q, KINC_KEY_Q) - KEY(XK_r, KINC_KEY_R) - KEY(XK_s, KINC_KEY_S) - KEY(XK_t, KINC_KEY_T) - KEY(XK_u, KINC_KEY_U) - KEY(XK_v, KINC_KEY_V) - KEY(XK_w, KINC_KEY_W) - KEY(XK_x, KINC_KEY_X) - KEY(XK_y, KINC_KEY_Y) - KEY(XK_z, KINC_KEY_Z) - KEY(XK_1, KINC_KEY_1) - KEY(XK_2, KINC_KEY_2) - KEY(XK_3, KINC_KEY_3) - KEY(XK_4, KINC_KEY_4) - KEY(XK_5, KINC_KEY_5) - KEY(XK_6, KINC_KEY_6) - KEY(XK_7, KINC_KEY_7) - KEY(XK_8, KINC_KEY_8) - KEY(XK_9, KINC_KEY_9) - KEY(XK_0, KINC_KEY_0) - KEY(XK_Escape, KINC_KEY_ESCAPE) - KEY(XK_F1, KINC_KEY_F1) - KEY(XK_F2, KINC_KEY_F2) - KEY(XK_F3, KINC_KEY_F3) - KEY(XK_F4, KINC_KEY_F4) - KEY(XK_F5, KINC_KEY_F5) - KEY(XK_F6, KINC_KEY_F6) - KEY(XK_F7, KINC_KEY_F7) - KEY(XK_F8, KINC_KEY_F8) - KEY(XK_F9, KINC_KEY_F9) - KEY(XK_F10, KINC_KEY_F10) - KEY(XK_F11, KINC_KEY_F11) - KEY(XK_F12, KINC_KEY_F12) + KEY(XK_Right, IRON_KEY_RIGHT) + KEY(XK_Left, IRON_KEY_LEFT) + KEY(XK_Up, IRON_KEY_UP) + KEY(XK_Down, IRON_KEY_DOWN) + KEY(XK_space, IRON_KEY_SPACE) + KEY(XK_BackSpace, IRON_KEY_BACKSPACE) + KEY(XK_Tab, IRON_KEY_TAB) + KEY(XK_Return, IRON_KEY_RETURN) + KEY(XK_Shift_L, IRON_KEY_SHIFT) + KEY(XK_Shift_R, IRON_KEY_SHIFT) + KEY(XK_Control_L, IRON_KEY_CONTROL) + KEY(XK_Control_R, IRON_KEY_CONTROL) + KEY(XK_Alt_L, IRON_KEY_ALT) + KEY(XK_ISO_Prev_Group, IRON_KEY_ALT) //// XK_ISO_Prev_Group received instead of XK_Alt_L? + KEY(XK_Alt_R, IRON_KEY_ALT) + KEY(XK_Delete, IRON_KEY_DELETE) + KEY(XK_comma, IRON_KEY_COMMA) + KEY(XK_period, IRON_KEY_PERIOD) + KEY(XK_bracketleft, IRON_KEY_OPEN_BRACKET) + KEY(XK_bracketright, IRON_KEY_CLOSE_BRACKET) + KEY(XK_braceleft, IRON_KEY_OPEN_CURLY_BRACKET) + KEY(XK_braceright, IRON_KEY_CLOSE_CURLY_BRACKET) + KEY(XK_parenleft, IRON_KEY_OPEN_PAREN) + KEY(XK_parenright, IRON_KEY_CLOSE_PAREN) + KEY(XK_backslash, IRON_KEY_BACK_SLASH) + KEY(XK_apostrophe, IRON_KEY_QUOTE) + KEY(XK_colon, IRON_KEY_COLON) + KEY(XK_semicolon, IRON_KEY_SEMICOLON) + KEY(XK_minus, IRON_KEY_HYPHEN_MINUS) + KEY(XK_underscore, IRON_KEY_UNDERSCORE) + KEY(XK_slash, IRON_KEY_SLASH) + KEY(XK_bar, IRON_KEY_PIPE) + KEY(XK_question, IRON_KEY_QUESTIONMARK) + KEY(XK_less, IRON_KEY_LESS_THAN) + KEY(XK_greater, IRON_KEY_GREATER_THAN) + KEY(XK_asterisk, IRON_KEY_ASTERISK) + KEY(XK_ampersand, IRON_KEY_AMPERSAND) + KEY(XK_asciicircum, IRON_KEY_CIRCUMFLEX) + KEY(XK_percent, IRON_KEY_PERCENT) + KEY(XK_dollar, IRON_KEY_DOLLAR) + KEY(XK_numbersign, IRON_KEY_HASH) + KEY(XK_at, IRON_KEY_AT) + KEY(XK_exclam, IRON_KEY_EXCLAMATION) + KEY(XK_equal, IRON_KEY_EQUALS) + KEY(XK_plus, IRON_KEY_ADD) + KEY(XK_quoteleft, IRON_KEY_BACK_QUOTE) + KEY(XK_quotedbl, IRON_KEY_DOUBLE_QUOTE) + KEY(XK_asciitilde, IRON_KEY_TILDE) + KEY(XK_Pause, IRON_KEY_PAUSE) + KEY(XK_Scroll_Lock, IRON_KEY_SCROLL_LOCK) + KEY(XK_Home, IRON_KEY_HOME) + KEY(XK_Page_Up, IRON_KEY_PAGE_UP) + KEY(XK_Page_Down, IRON_KEY_PAGE_DOWN) + KEY(XK_End, IRON_KEY_END) + KEY(XK_Insert, IRON_KEY_INSERT) + KEY(XK_KP_Enter, IRON_KEY_RETURN) + KEY(XK_KP_Multiply, IRON_KEY_MULTIPLY) + KEY(XK_KP_Add, IRON_KEY_ADD) + KEY(XK_KP_Subtract, IRON_KEY_SUBTRACT) + KEY(XK_KP_Decimal, IRON_KEY_DECIMAL) + KEY(XK_KP_Divide, IRON_KEY_DIVIDE) + KEY(XK_KP_0, IRON_KEY_NUMPAD_0) + KEY(XK_KP_1, IRON_KEY_NUMPAD_1) + KEY(XK_KP_2, IRON_KEY_NUMPAD_2) + KEY(XK_KP_3, IRON_KEY_NUMPAD_3) + KEY(XK_KP_4, IRON_KEY_NUMPAD_4) + KEY(XK_KP_5, IRON_KEY_NUMPAD_5) + KEY(XK_KP_6, IRON_KEY_NUMPAD_6) + KEY(XK_KP_7, IRON_KEY_NUMPAD_7) + KEY(XK_KP_8, IRON_KEY_NUMPAD_8) + KEY(XK_KP_9, IRON_KEY_NUMPAD_9) + KEY(XK_KP_Insert, IRON_KEY_INSERT) + KEY(XK_KP_Delete, IRON_KEY_DELETE) + KEY(XK_KP_End, IRON_KEY_END) + KEY(XK_KP_Home, IRON_KEY_HOME) + KEY(XK_KP_Left, IRON_KEY_LEFT) + KEY(XK_KP_Up, IRON_KEY_UP) + KEY(XK_KP_Right, IRON_KEY_RIGHT) + KEY(XK_KP_Down, IRON_KEY_DOWN) + KEY(XK_KP_Page_Up, IRON_KEY_PAGE_UP) + KEY(XK_KP_Page_Down, IRON_KEY_PAGE_DOWN) + KEY(XK_Menu, IRON_KEY_CONTEXT_MENU) + KEY(XK_a, IRON_KEY_A) + KEY(XK_b, IRON_KEY_B) + KEY(XK_c, IRON_KEY_C) + KEY(XK_d, IRON_KEY_D) + KEY(XK_e, IRON_KEY_E) + KEY(XK_f, IRON_KEY_F) + KEY(XK_g, IRON_KEY_G) + KEY(XK_h, IRON_KEY_H) + KEY(XK_i, IRON_KEY_I) + KEY(XK_j, IRON_KEY_J) + KEY(XK_k, IRON_KEY_K) + KEY(XK_l, IRON_KEY_L) + KEY(XK_m, IRON_KEY_M) + KEY(XK_n, IRON_KEY_N) + KEY(XK_o, IRON_KEY_O) + KEY(XK_p, IRON_KEY_P) + KEY(XK_q, IRON_KEY_Q) + KEY(XK_r, IRON_KEY_R) + KEY(XK_s, IRON_KEY_S) + KEY(XK_t, IRON_KEY_T) + KEY(XK_u, IRON_KEY_U) + KEY(XK_v, IRON_KEY_V) + KEY(XK_w, IRON_KEY_W) + KEY(XK_x, IRON_KEY_X) + KEY(XK_y, IRON_KEY_Y) + KEY(XK_z, IRON_KEY_Z) + KEY(XK_1, IRON_KEY_1) + KEY(XK_2, IRON_KEY_2) + KEY(XK_3, IRON_KEY_3) + KEY(XK_4, IRON_KEY_4) + KEY(XK_5, IRON_KEY_5) + KEY(XK_6, IRON_KEY_6) + KEY(XK_7, IRON_KEY_7) + KEY(XK_8, IRON_KEY_8) + KEY(XK_9, IRON_KEY_9) + KEY(XK_0, IRON_KEY_0) + KEY(XK_Escape, IRON_KEY_ESCAPE) + KEY(XK_F1, IRON_KEY_F1) + KEY(XK_F2, IRON_KEY_F2) + KEY(XK_F3, IRON_KEY_F3) + KEY(XK_F4, IRON_KEY_F4) + KEY(XK_F5, IRON_KEY_F5) + KEY(XK_F6, IRON_KEY_F6) + KEY(XK_F7, IRON_KEY_F7) + KEY(XK_F8, IRON_KEY_F8) + KEY(XK_F9, IRON_KEY_F9) + KEY(XK_F10, IRON_KEY_F10) + KEY(XK_F11, IRON_KEY_F11) + KEY(XK_F12, IRON_KEY_F12) } break; #undef KEY @@ -1142,13 +1142,13 @@ static bool _handle_messages() { switch (button->button) { case Button1: - kinc_internal_mouse_trigger_press(0, button->x, button->y); + iron_internal_mouse_trigger_press(0, button->x, button->y); break; case Button2: - kinc_internal_mouse_trigger_press(2, button->x, button->y); + iron_internal_mouse_trigger_press(2, button->x, button->y); break; case Button3: - kinc_internal_mouse_trigger_press(1, button->x, button->y); + iron_internal_mouse_trigger_press(1, button->x, button->y); break; // buttons 4-7 are for mouse wheel events because why not case Button4: @@ -1157,7 +1157,7 @@ static bool _handle_messages() { case Button7: break; default: - kinc_internal_mouse_trigger_press(button->button - Button1 - 4, button->x, button->y); + iron_internal_mouse_trigger_press(button->button - Button1 - 4, button->x, button->y); break; } break; @@ -1167,42 +1167,42 @@ static bool _handle_messages() { switch (button->button) { case Button1: - kinc_internal_mouse_trigger_release(0, button->x, button->y); + iron_internal_mouse_trigger_release(0, button->x, button->y); break; case Button2: - kinc_internal_mouse_trigger_release(2, button->x, button->y); + iron_internal_mouse_trigger_release(2, button->x, button->y); break; case Button3: - kinc_internal_mouse_trigger_release(1, button->x, button->y); + iron_internal_mouse_trigger_release(1, button->x, button->y); break; // Button4 and Button5 provide mouse wheel events because why not case Button4: - kinc_internal_mouse_trigger_scroll(-1); + iron_internal_mouse_trigger_scroll(-1); break; case Button5: - kinc_internal_mouse_trigger_scroll(1); + iron_internal_mouse_trigger_scroll(1); break; - // button 6 and 7 seem to be horizontal scrolling, which is not exposed in Kinc's api at the moment + // button 6 and 7 seem to be horizontal scrolling, which is not exposed in Iron's api at the moment case Button6: case Button7: break; default: - kinc_internal_mouse_trigger_release(button->button - Button1 - 4, button->x, button->y); + iron_internal_mouse_trigger_release(button->button - Button1 - 4, button->x, button->y); break; } break; } case MotionNotify: { XMotionEvent *motion = (XMotionEvent *)&event; - kinc_internal_mouse_trigger_move(motion->x, motion->y); + iron_internal_mouse_trigger_move(motion->x, motion->y); break; } case ConfigureNotify: { if (event.xconfigure.width != k_window->width || event.xconfigure.height != k_window->height) { k_window->width = event.xconfigure.width; k_window->height = event.xconfigure.height; - kinc_internal_resize(event.xconfigure.width, event.xconfigure.height); - kinc_internal_call_resize_callback(event.xconfigure.width, event.xconfigure.height); + iron_internal_resize(event.xconfigure.width, event.xconfigure.height); + iron_internal_call_resize_callback(event.xconfigure.width, event.xconfigure.height); } break; } @@ -1228,9 +1228,9 @@ static bool _handle_messages() { event.xclient.data.l[2]); } else if (event.xclient.data.l[0] == x11_ctx.atoms.WM_DELETE_WINDOW) { - if (kinc_internal_call_close_callback()) { - kinc_window_destroy(); - kinc_stop(); + if (iron_internal_call_close_callback()) { + iron_window_destroy(); + iron_stop(); } } }; break; @@ -1241,7 +1241,7 @@ static bool _handle_messages() { int resbits; xlib.XGetWindowProperty(x11_ctx.display, window, x11_ctx.atoms.XSEL_DATA, 0, LONG_MAX / 4, False, AnyPropertyType, &x11_ctx.atoms.UTF8_STRING, &resbits, &ressize, &restail, (unsigned char **)&result); - kinc_internal_paste_callback(result); + iron_internal_paste_callback(result); xlib.XFree(result); } else if (event.xselection.property == x11_ctx.atoms.XdndSelection) { @@ -1259,7 +1259,7 @@ static bool _handle_messages() { wchar_t filePath[len + 1]; mbstowcs(filePath, buffer, len); filePath[len] = 0; - kinc_internal_drop_files_callback(filePath + 7); // Strip file:// + iron_internal_drop_files_callback(filePath + 7); // Strip file:// pos += 2; // Avoid \n len = 0; } @@ -1300,13 +1300,13 @@ static bool _handle_messages() { case Expose: break; case FocusIn: { - kinc_internal_foreground_callback(); + iron_internal_foreground_callback(); break; } case FocusOut: { controlDown = false; ignoreKeycode = 0; - kinc_internal_background_callback(); + iron_internal_background_callback(); break; } case LeaveNotify: @@ -1319,31 +1319,31 @@ static bool _handle_messages() { return true; } -bool kinc_internal_handle_messages() { +bool iron_internal_handle_messages() { if (!_handle_messages()) { return false; } - kinc_linux_updateHIDGamepads(); + iron_linux_updateHIDGamepads(); return true; } -const char *kinc_system_id() { +const char *iron_system_id() { return "Linux"; } -void kinc_set_keep_screen_on(bool on) {} +void iron_set_keep_screen_on(bool on) {} -void kinc_keyboard_show() {} +void iron_keyboard_show() {} -void kinc_keyboard_hide() {} +void iron_keyboard_hide() {} -bool kinc_keyboard_active() { +bool iron_keyboard_active() { return true; } -void kinc_load_url(const char *url) { +void iron_load_url(const char *url) { #define MAX_COMMAND_BUFFER_SIZE 256 #define HTTP "http://" #define HTTPS "https://" @@ -1352,7 +1352,7 @@ void kinc_load_url(const char *url) { snprintf(openUrlCommand, MAX_COMMAND_BUFFER_SIZE, "xdg-open %s", url); int err = system(openUrlCommand); if (err != 0) { - kinc_log("Error opening url %s", url); + iron_log("Error opening url %s", url); } } #undef HTTPS @@ -1360,14 +1360,14 @@ void kinc_load_url(const char *url) { #undef MAX_COMMAND_BUFFER_SIZE } -const char *kinc_language() { +const char *iron_language() { return "en"; } static char save[2000]; static bool saveInitialized = false; -const char *kinc_internal_save_path() { +const char *iron_internal_save_path() { // first check for an existing directory in $HOME // if one exists, use it, else create one in $XDG_DATA_HOME // See: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html @@ -1380,7 +1380,7 @@ const char *kinc_internal_save_path() { strcpy(save, homedir); strcat(save, "/."); - strcat(save, kinc_application_name()); + strcat(save, iron_application_name()); strcat(save, "/"); struct stat st; if (stat(save, &st) == 0) { @@ -1401,11 +1401,11 @@ const char *kinc_internal_save_path() { strcat(save, "/"); } } - strcat(save, kinc_application_name()); + strcat(save, iron_application_name()); strcat(save, "/"); int res = mkdir(save, 0700); if (res != 0 && errno != EEXIST) { - kinc_error("Could not create save directory '%s'. Error %d", save, errno); + iron_error("Could not create save directory '%s'. Error %d", save, errno); } } @@ -1416,38 +1416,38 @@ const char *kinc_internal_save_path() { static const char *videoFormats[] = {"ogv", NULL}; -const char **kinc_video_formats() { +const char **iron_video_formats() { return videoFormats; } -double kinc_frequency(void) { +double iron_frequency(void) { return 1000000.0; } static struct timeval start; -kinc_ticks_t kinc_timestamp(void) { +iron_ticks_t iron_timestamp(void) { struct timeval now; gettimeofday(&now, NULL); now.tv_sec -= start.tv_sec; now.tv_usec -= start.tv_usec; - return (kinc_ticks_t)now.tv_sec * 1000000 + (kinc_ticks_t)now.tv_usec; + return (iron_ticks_t)now.tv_sec * 1000000 + (iron_ticks_t)now.tv_usec; } -void kinc_init(const char *name, int width, int height, kinc_window_options_t *win) { - kinc_linux_initHIDGamepads(); +void iron_init(const char *name, int width, int height, iron_window_options_t *win) { + iron_linux_initHIDGamepads(); gettimeofday(&start, NULL); - kinc_x11_init(); - kinc_display_init(); + iron_x11_init(); + iron_display_init(); - kinc_set_app_name(name); + iron_set_app_name(name); - kinc_g5_internal_init(); + iron_g5_internal_init(); - kinc_window_options_t defaultWin; + iron_window_options_t defaultWin; if (win == NULL) { - kinc_window_options_set_defaults(&defaultWin); + iron_window_options_set_defaults(&defaultWin); win = &defaultWin; } win->width = width; @@ -1456,24 +1456,24 @@ void kinc_init(const char *name, int width, int height, kinc_window_options_t *w win->title = name; } - kinc_window_create(win); + iron_window_create(win); } -void kinc_internal_shutdown() { - kinc_g5_internal_destroy(); - kinc_linux_closeHIDGamepads(); +void iron_internal_shutdown() { + iron_g5_internal_destroy(); + iron_linux_closeHIDGamepads(); free(clipboardString); xlib.XCloseDisplay(x11_ctx.display); - kinc_internal_shutdown_callback(); + iron_internal_shutdown_callback(); } -#ifndef KINC_NO_MAIN +#ifndef IRON_NO_MAIN int main(int argc, char **argv) { return kickstart(argc, argv); } #endif -void kinc_copy_to_clipboard(const char *text) { +void iron_copy_to_clipboard(const char *text) { size_t textLength = strlen(text); if (textLength >= clipboardStringSize) { free(clipboardString); @@ -1495,7 +1495,7 @@ static int parse_number_at_end_of_line(char *line) { return num; } -int kinc_cpu_cores(void) { +int iron_cpu_cores(void) { char line[1024]; FILE *file = fopen("/proc/cpuinfo", "r"); @@ -1553,160 +1553,160 @@ int kinc_cpu_cores(void) { }; } -int kinc_hardware_threads(void) { +int iron_hardware_threads(void) { return sysconf(_SC_NPROCESSORS_ONLN); } -int xkb_to_kinc(xkb_keysym_t symbol) { -#define KEY(xkb, kinc) \ +int xkb_to_iron(xkb_keysym_t symbol) { +#define KEY(xkb, iron) \ case xkb: \ - return kinc; + return iron; switch (symbol) { - KEY(XKB_KEY_Right, KINC_KEY_RIGHT) - KEY(XKB_KEY_Left, KINC_KEY_LEFT) - KEY(XKB_KEY_Up, KINC_KEY_UP) - KEY(XKB_KEY_Down, KINC_KEY_DOWN) - KEY(XKB_KEY_space, KINC_KEY_SPACE) - KEY(XKB_KEY_BackSpace, KINC_KEY_BACKSPACE) - KEY(XKB_KEY_Tab, KINC_KEY_TAB) - KEY(XKB_KEY_Return, KINC_KEY_RETURN) - KEY(XKB_KEY_Shift_L, KINC_KEY_SHIFT) - KEY(XKB_KEY_Shift_R, KINC_KEY_SHIFT) - KEY(XKB_KEY_Control_L, KINC_KEY_CONTROL) - KEY(XKB_KEY_Control_R, KINC_KEY_CONTROL) - KEY(XKB_KEY_Alt_L, KINC_KEY_ALT) - KEY(XKB_KEY_Alt_R, KINC_KEY_ALT) - KEY(XKB_KEY_Delete, KINC_KEY_DELETE) - KEY(XKB_KEY_comma, KINC_KEY_COMMA) - KEY(XKB_KEY_period, KINC_KEY_PERIOD) - KEY(XKB_KEY_bracketleft, KINC_KEY_OPEN_BRACKET) - KEY(XKB_KEY_bracketright, KINC_KEY_CLOSE_BRACKET) - KEY(XKB_KEY_braceleft, KINC_KEY_OPEN_CURLY_BRACKET) - KEY(XKB_KEY_braceright, KINC_KEY_CLOSE_CURLY_BRACKET) - KEY(XKB_KEY_parenleft, KINC_KEY_OPEN_PAREN) - KEY(XKB_KEY_parenright, KINC_KEY_CLOSE_PAREN) - KEY(XKB_KEY_backslash, KINC_KEY_BACK_SLASH) - KEY(XKB_KEY_apostrophe, KINC_KEY_QUOTE) - KEY(XKB_KEY_colon, KINC_KEY_COLON) - KEY(XKB_KEY_semicolon, KINC_KEY_SEMICOLON) - KEY(XKB_KEY_minus, KINC_KEY_HYPHEN_MINUS) - KEY(XKB_KEY_underscore, KINC_KEY_UNDERSCORE) - KEY(XKB_KEY_slash, KINC_KEY_SLASH) - KEY(XKB_KEY_bar, KINC_KEY_PIPE) - KEY(XKB_KEY_question, KINC_KEY_QUESTIONMARK) - KEY(XKB_KEY_less, KINC_KEY_LESS_THAN) - KEY(XKB_KEY_greater, KINC_KEY_GREATER_THAN) - KEY(XKB_KEY_asterisk, KINC_KEY_ASTERISK) - KEY(XKB_KEY_ampersand, KINC_KEY_AMPERSAND) - KEY(XKB_KEY_asciicircum, KINC_KEY_CIRCUMFLEX) - KEY(XKB_KEY_percent, KINC_KEY_PERCENT) - KEY(XKB_KEY_dollar, KINC_KEY_DOLLAR) - KEY(XKB_KEY_numbersign, KINC_KEY_HASH) - KEY(XKB_KEY_at, KINC_KEY_AT) - KEY(XKB_KEY_exclam, KINC_KEY_EXCLAMATION) - KEY(XKB_KEY_equal, KINC_KEY_EQUALS) - KEY(XKB_KEY_plus, KINC_KEY_ADD) - KEY(XKB_KEY_quoteleft, KINC_KEY_BACK_QUOTE) - KEY(XKB_KEY_quotedbl, KINC_KEY_DOUBLE_QUOTE) - KEY(XKB_KEY_asciitilde, KINC_KEY_TILDE) - KEY(XKB_KEY_Pause, KINC_KEY_PAUSE) - KEY(XKB_KEY_Scroll_Lock, KINC_KEY_SCROLL_LOCK) - KEY(XKB_KEY_Home, KINC_KEY_HOME) - KEY(XKB_KEY_Page_Up, KINC_KEY_PAGE_UP) - KEY(XKB_KEY_Page_Down, KINC_KEY_PAGE_DOWN) - KEY(XKB_KEY_End, KINC_KEY_END) - KEY(XKB_KEY_Insert, KINC_KEY_INSERT) - KEY(XKB_KEY_KP_Enter, KINC_KEY_RETURN) - KEY(XKB_KEY_KP_Multiply, KINC_KEY_MULTIPLY) - KEY(XKB_KEY_KP_Add, KINC_KEY_ADD) - KEY(XKB_KEY_KP_Subtract, KINC_KEY_SUBTRACT) - KEY(XKB_KEY_KP_Decimal, KINC_KEY_DECIMAL) - KEY(XKB_KEY_KP_Divide, KINC_KEY_DIVIDE) - KEY(XKB_KEY_KP_0, KINC_KEY_NUMPAD_0) - KEY(XKB_KEY_KP_1, KINC_KEY_NUMPAD_1) - KEY(XKB_KEY_KP_2, KINC_KEY_NUMPAD_2) - KEY(XKB_KEY_KP_3, KINC_KEY_NUMPAD_3) - KEY(XKB_KEY_KP_4, KINC_KEY_NUMPAD_4) - KEY(XKB_KEY_KP_5, KINC_KEY_NUMPAD_5) - KEY(XKB_KEY_KP_6, KINC_KEY_NUMPAD_6) - KEY(XKB_KEY_KP_7, KINC_KEY_NUMPAD_7) - KEY(XKB_KEY_KP_8, KINC_KEY_NUMPAD_8) - KEY(XKB_KEY_KP_9, KINC_KEY_NUMPAD_9) - KEY(XKB_KEY_KP_Insert, KINC_KEY_INSERT) - KEY(XKB_KEY_KP_Delete, KINC_KEY_DELETE) - KEY(XKB_KEY_KP_End, KINC_KEY_END) - KEY(XKB_KEY_KP_Home, KINC_KEY_HOME) - KEY(XKB_KEY_KP_Left, KINC_KEY_LEFT) - KEY(XKB_KEY_KP_Up, KINC_KEY_UP) - KEY(XKB_KEY_KP_Right, KINC_KEY_RIGHT) - KEY(XKB_KEY_KP_Down, KINC_KEY_DOWN) - KEY(XKB_KEY_KP_Page_Up, KINC_KEY_PAGE_UP) - KEY(XKB_KEY_KP_Page_Down, KINC_KEY_PAGE_DOWN) - KEY(XKB_KEY_Menu, KINC_KEY_CONTEXT_MENU) - KEY(XKB_KEY_a, KINC_KEY_A) - KEY(XKB_KEY_b, KINC_KEY_B) - KEY(XKB_KEY_c, KINC_KEY_C) - KEY(XKB_KEY_d, KINC_KEY_D) - KEY(XKB_KEY_e, KINC_KEY_E) - KEY(XKB_KEY_f, KINC_KEY_F) - KEY(XKB_KEY_g, KINC_KEY_G) - KEY(XKB_KEY_h, KINC_KEY_H) - KEY(XKB_KEY_i, KINC_KEY_I) - KEY(XKB_KEY_j, KINC_KEY_J) - KEY(XKB_KEY_k, KINC_KEY_K) - KEY(XKB_KEY_l, KINC_KEY_L) - KEY(XKB_KEY_m, KINC_KEY_M) - KEY(XKB_KEY_n, KINC_KEY_N) - KEY(XKB_KEY_o, KINC_KEY_O) - KEY(XKB_KEY_p, KINC_KEY_P) - KEY(XKB_KEY_q, KINC_KEY_Q) - KEY(XKB_KEY_r, KINC_KEY_R) - KEY(XKB_KEY_s, KINC_KEY_S) - KEY(XKB_KEY_t, KINC_KEY_T) - KEY(XKB_KEY_u, KINC_KEY_U) - KEY(XKB_KEY_v, KINC_KEY_V) - KEY(XKB_KEY_w, KINC_KEY_W) - KEY(XKB_KEY_x, KINC_KEY_X) - KEY(XKB_KEY_y, KINC_KEY_Y) - KEY(XKB_KEY_z, KINC_KEY_Z) - KEY(XKB_KEY_1, KINC_KEY_1) - KEY(XKB_KEY_2, KINC_KEY_2) - KEY(XKB_KEY_3, KINC_KEY_3) - KEY(XKB_KEY_4, KINC_KEY_4) - KEY(XKB_KEY_5, KINC_KEY_5) - KEY(XKB_KEY_6, KINC_KEY_6) - KEY(XKB_KEY_7, KINC_KEY_7) - KEY(XKB_KEY_8, KINC_KEY_8) - KEY(XKB_KEY_9, KINC_KEY_9) - KEY(XKB_KEY_0, KINC_KEY_0) - KEY(XKB_KEY_Escape, KINC_KEY_ESCAPE) - KEY(XKB_KEY_F1, KINC_KEY_F1) - KEY(XKB_KEY_F2, KINC_KEY_F2) - KEY(XKB_KEY_F3, KINC_KEY_F3) - KEY(XKB_KEY_F4, KINC_KEY_F4) - KEY(XKB_KEY_F5, KINC_KEY_F5) - KEY(XKB_KEY_F6, KINC_KEY_F6) - KEY(XKB_KEY_F7, KINC_KEY_F7) - KEY(XKB_KEY_F8, KINC_KEY_F8) - KEY(XKB_KEY_F9, KINC_KEY_F9) - KEY(XKB_KEY_F10, KINC_KEY_F10) - KEY(XKB_KEY_F11, KINC_KEY_F11) - KEY(XKB_KEY_F12, KINC_KEY_F12) + KEY(XKB_KEY_Right, IRON_KEY_RIGHT) + KEY(XKB_KEY_Left, IRON_KEY_LEFT) + KEY(XKB_KEY_Up, IRON_KEY_UP) + KEY(XKB_KEY_Down, IRON_KEY_DOWN) + KEY(XKB_KEY_space, IRON_KEY_SPACE) + KEY(XKB_KEY_BackSpace, IRON_KEY_BACKSPACE) + KEY(XKB_KEY_Tab, IRON_KEY_TAB) + KEY(XKB_KEY_Return, IRON_KEY_RETURN) + KEY(XKB_KEY_Shift_L, IRON_KEY_SHIFT) + KEY(XKB_KEY_Shift_R, IRON_KEY_SHIFT) + KEY(XKB_KEY_Control_L, IRON_KEY_CONTROL) + KEY(XKB_KEY_Control_R, IRON_KEY_CONTROL) + KEY(XKB_KEY_Alt_L, IRON_KEY_ALT) + KEY(XKB_KEY_Alt_R, IRON_KEY_ALT) + KEY(XKB_KEY_Delete, IRON_KEY_DELETE) + KEY(XKB_KEY_comma, IRON_KEY_COMMA) + KEY(XKB_KEY_period, IRON_KEY_PERIOD) + KEY(XKB_KEY_bracketleft, IRON_KEY_OPEN_BRACKET) + KEY(XKB_KEY_bracketright, IRON_KEY_CLOSE_BRACKET) + KEY(XKB_KEY_braceleft, IRON_KEY_OPEN_CURLY_BRACKET) + KEY(XKB_KEY_braceright, IRON_KEY_CLOSE_CURLY_BRACKET) + KEY(XKB_KEY_parenleft, IRON_KEY_OPEN_PAREN) + KEY(XKB_KEY_parenright, IRON_KEY_CLOSE_PAREN) + KEY(XKB_KEY_backslash, IRON_KEY_BACK_SLASH) + KEY(XKB_KEY_apostrophe, IRON_KEY_QUOTE) + KEY(XKB_KEY_colon, IRON_KEY_COLON) + KEY(XKB_KEY_semicolon, IRON_KEY_SEMICOLON) + KEY(XKB_KEY_minus, IRON_KEY_HYPHEN_MINUS) + KEY(XKB_KEY_underscore, IRON_KEY_UNDERSCORE) + KEY(XKB_KEY_slash, IRON_KEY_SLASH) + KEY(XKB_KEY_bar, IRON_KEY_PIPE) + KEY(XKB_KEY_question, IRON_KEY_QUESTIONMARK) + KEY(XKB_KEY_less, IRON_KEY_LESS_THAN) + KEY(XKB_KEY_greater, IRON_KEY_GREATER_THAN) + KEY(XKB_KEY_asterisk, IRON_KEY_ASTERISK) + KEY(XKB_KEY_ampersand, IRON_KEY_AMPERSAND) + KEY(XKB_KEY_asciicircum, IRON_KEY_CIRCUMFLEX) + KEY(XKB_KEY_percent, IRON_KEY_PERCENT) + KEY(XKB_KEY_dollar, IRON_KEY_DOLLAR) + KEY(XKB_KEY_numbersign, IRON_KEY_HASH) + KEY(XKB_KEY_at, IRON_KEY_AT) + KEY(XKB_KEY_exclam, IRON_KEY_EXCLAMATION) + KEY(XKB_KEY_equal, IRON_KEY_EQUALS) + KEY(XKB_KEY_plus, IRON_KEY_ADD) + KEY(XKB_KEY_quoteleft, IRON_KEY_BACK_QUOTE) + KEY(XKB_KEY_quotedbl, IRON_KEY_DOUBLE_QUOTE) + KEY(XKB_KEY_asciitilde, IRON_KEY_TILDE) + KEY(XKB_KEY_Pause, IRON_KEY_PAUSE) + KEY(XKB_KEY_Scroll_Lock, IRON_KEY_SCROLL_LOCK) + KEY(XKB_KEY_Home, IRON_KEY_HOME) + KEY(XKB_KEY_Page_Up, IRON_KEY_PAGE_UP) + KEY(XKB_KEY_Page_Down, IRON_KEY_PAGE_DOWN) + KEY(XKB_KEY_End, IRON_KEY_END) + KEY(XKB_KEY_Insert, IRON_KEY_INSERT) + KEY(XKB_KEY_KP_Enter, IRON_KEY_RETURN) + KEY(XKB_KEY_KP_Multiply, IRON_KEY_MULTIPLY) + KEY(XKB_KEY_KP_Add, IRON_KEY_ADD) + KEY(XKB_KEY_KP_Subtract, IRON_KEY_SUBTRACT) + KEY(XKB_KEY_KP_Decimal, IRON_KEY_DECIMAL) + KEY(XKB_KEY_KP_Divide, IRON_KEY_DIVIDE) + KEY(XKB_KEY_KP_0, IRON_KEY_NUMPAD_0) + KEY(XKB_KEY_KP_1, IRON_KEY_NUMPAD_1) + KEY(XKB_KEY_KP_2, IRON_KEY_NUMPAD_2) + KEY(XKB_KEY_KP_3, IRON_KEY_NUMPAD_3) + KEY(XKB_KEY_KP_4, IRON_KEY_NUMPAD_4) + KEY(XKB_KEY_KP_5, IRON_KEY_NUMPAD_5) + KEY(XKB_KEY_KP_6, IRON_KEY_NUMPAD_6) + KEY(XKB_KEY_KP_7, IRON_KEY_NUMPAD_7) + KEY(XKB_KEY_KP_8, IRON_KEY_NUMPAD_8) + KEY(XKB_KEY_KP_9, IRON_KEY_NUMPAD_9) + KEY(XKB_KEY_KP_Insert, IRON_KEY_INSERT) + KEY(XKB_KEY_KP_Delete, IRON_KEY_DELETE) + KEY(XKB_KEY_KP_End, IRON_KEY_END) + KEY(XKB_KEY_KP_Home, IRON_KEY_HOME) + KEY(XKB_KEY_KP_Left, IRON_KEY_LEFT) + KEY(XKB_KEY_KP_Up, IRON_KEY_UP) + KEY(XKB_KEY_KP_Right, IRON_KEY_RIGHT) + KEY(XKB_KEY_KP_Down, IRON_KEY_DOWN) + KEY(XKB_KEY_KP_Page_Up, IRON_KEY_PAGE_UP) + KEY(XKB_KEY_KP_Page_Down, IRON_KEY_PAGE_DOWN) + KEY(XKB_KEY_Menu, IRON_KEY_CONTEXT_MENU) + KEY(XKB_KEY_a, IRON_KEY_A) + KEY(XKB_KEY_b, IRON_KEY_B) + KEY(XKB_KEY_c, IRON_KEY_C) + KEY(XKB_KEY_d, IRON_KEY_D) + KEY(XKB_KEY_e, IRON_KEY_E) + KEY(XKB_KEY_f, IRON_KEY_F) + KEY(XKB_KEY_g, IRON_KEY_G) + KEY(XKB_KEY_h, IRON_KEY_H) + KEY(XKB_KEY_i, IRON_KEY_I) + KEY(XKB_KEY_j, IRON_KEY_J) + KEY(XKB_KEY_k, IRON_KEY_K) + KEY(XKB_KEY_l, IRON_KEY_L) + KEY(XKB_KEY_m, IRON_KEY_M) + KEY(XKB_KEY_n, IRON_KEY_N) + KEY(XKB_KEY_o, IRON_KEY_O) + KEY(XKB_KEY_p, IRON_KEY_P) + KEY(XKB_KEY_q, IRON_KEY_Q) + KEY(XKB_KEY_r, IRON_KEY_R) + KEY(XKB_KEY_s, IRON_KEY_S) + KEY(XKB_KEY_t, IRON_KEY_T) + KEY(XKB_KEY_u, IRON_KEY_U) + KEY(XKB_KEY_v, IRON_KEY_V) + KEY(XKB_KEY_w, IRON_KEY_W) + KEY(XKB_KEY_x, IRON_KEY_X) + KEY(XKB_KEY_y, IRON_KEY_Y) + KEY(XKB_KEY_z, IRON_KEY_Z) + KEY(XKB_KEY_1, IRON_KEY_1) + KEY(XKB_KEY_2, IRON_KEY_2) + KEY(XKB_KEY_3, IRON_KEY_3) + KEY(XKB_KEY_4, IRON_KEY_4) + KEY(XKB_KEY_5, IRON_KEY_5) + KEY(XKB_KEY_6, IRON_KEY_6) + KEY(XKB_KEY_7, IRON_KEY_7) + KEY(XKB_KEY_8, IRON_KEY_8) + KEY(XKB_KEY_9, IRON_KEY_9) + KEY(XKB_KEY_0, IRON_KEY_0) + KEY(XKB_KEY_Escape, IRON_KEY_ESCAPE) + KEY(XKB_KEY_F1, IRON_KEY_F1) + KEY(XKB_KEY_F2, IRON_KEY_F2) + KEY(XKB_KEY_F3, IRON_KEY_F3) + KEY(XKB_KEY_F4, IRON_KEY_F4) + KEY(XKB_KEY_F5, IRON_KEY_F5) + KEY(XKB_KEY_F6, IRON_KEY_F6) + KEY(XKB_KEY_F7, IRON_KEY_F7) + KEY(XKB_KEY_F8, IRON_KEY_F8) + KEY(XKB_KEY_F9, IRON_KEY_F9) + KEY(XKB_KEY_F10, IRON_KEY_F10) + KEY(XKB_KEY_F11, IRON_KEY_F11) + KEY(XKB_KEY_F12, IRON_KEY_F12) default: - return KINC_KEY_UNKNOWN; + return IRON_KEY_UNKNOWN; } #undef KEY } static bool mouse_hidden = false; -void kinc_internal_mouse_lock() { - kinc_mouse_hide(); - int width = kinc_window_width(); - int height = kinc_window_height(); +void iron_internal_mouse_lock() { + iron_mouse_hide(); + int width = iron_window_width(); + int height = iron_window_height(); int x, y; - kinc_mouse_get_position(&x, &y); + iron_mouse_get_position(&x, &y); // Guess the new position of X and Y int newX = x; @@ -1731,27 +1731,27 @@ void kinc_internal_mouse_lock() { } // Force the mouse to stay inside the window - kinc_mouse_set_position(newX, newY); + iron_mouse_set_position(newX, newY); } -void kinc_internal_mouse_unlock() { - kinc_mouse_show(); +void iron_internal_mouse_unlock() { + iron_mouse_show(); } -bool kinc_mouse_can_lock(void) { +bool iron_mouse_can_lock(void) { return true; } -void kinc_mouse_show() { - struct kinc_x11_window *window = &x11_ctx.windows[0]; +void iron_mouse_show() { + struct iron_x11_window *window = &x11_ctx.windows[0]; if (mouse_hidden) { xlib.XUndefineCursor(x11_ctx.display, window->window); mouse_hidden = false; } } -void kinc_mouse_hide() { - struct kinc_x11_window *window = &x11_ctx.windows[0]; +void iron_mouse_hide() { + struct iron_x11_window *window = &x11_ctx.windows[0]; if (!mouse_hidden) { XColor col; col.pixel = 0; @@ -1769,8 +1769,8 @@ void kinc_mouse_hide() { } } -void kinc_mouse_set_cursor(int cursor_index) { - struct kinc_x11_window *window = &x11_ctx.windows[0]; +void iron_mouse_set_cursor(int cursor_index) { + struct iron_x11_window *window = &x11_ctx.windows[0]; if (!mouse_hidden) { Cursor cursor; switch (cursor_index) { @@ -1840,15 +1840,15 @@ void kinc_mouse_set_cursor(int cursor_index) { } } -void kinc_mouse_set_position(int x, int y) { - struct kinc_x11_window *window = &x11_ctx.windows[0]; +void iron_mouse_set_position(int x, int y) { + struct iron_x11_window *window = &x11_ctx.windows[0]; xlib.XWarpPointer(x11_ctx.display, None, window->window, 0, 0, 0, 0, x, y); xlib.XFlush(x11_ctx.display); // Flushes the output buffer, therefore updates the cursor's position. } -void kinc_mouse_get_position(int *x, int *y) { - struct kinc_x11_window *window = &x11_ctx.windows[0]; +void iron_mouse_get_position(int *x, int *y) { + struct iron_x11_window *window = &x11_ctx.windows[0]; Window inwin; Window inchildwin; int rootx, rooty; @@ -1880,7 +1880,7 @@ static void HIDGamepad_open(struct HIDGamepad *pad) { } pad->name[0] = 0; // snprintf(pad->name, sizeof(pad->name), "%s(%s)", buf, pad->gamepad_dev_name); // TODO: valgrind error - kinc_internal_gamepad_trigger_connect(pad->idx); + iron_internal_gamepad_trigger_connect(pad->idx); } } @@ -1897,7 +1897,7 @@ static void HIDGamepad_init(struct HIDGamepad *pad, int index) { static void HIDGamepad_close(struct HIDGamepad *pad) { if (pad->connected) { - kinc_internal_gamepad_trigger_disconnect(pad->idx); + iron_internal_gamepad_trigger_disconnect(pad->idx); close(pad->file_descriptor); pad->file_descriptor = -1; pad->connected = false; @@ -1907,11 +1907,11 @@ static void HIDGamepad_close(struct HIDGamepad *pad) { void HIDGamepad_processEvent(struct HIDGamepad *pad, struct js_event e) { switch (e.type) { case JS_EVENT_BUTTON: - kinc_internal_gamepad_trigger_button(pad->idx, e.number, e.value); + iron_internal_gamepad_trigger_button(pad->idx, e.number, e.value); break; case JS_EVENT_AXIS: { float value = e.number % 2 == 0 ? e.value : -e.value; - kinc_internal_gamepad_trigger_axis(pad->idx, e.number, value / 32767.0f); + iron_internal_gamepad_trigger_axis(pad->idx, e.number, value / 32767.0f); break; } default: @@ -1935,7 +1935,7 @@ struct HIDGamepadUdevHelper { static struct HIDGamepadUdevHelper udev_helper; -static struct HIDGamepad gamepads[KINC_GAMEPAD_MAX_COUNT]; +static struct HIDGamepad gamepads[IRON_GAMEPAD_MAX_COUNT]; static void HIDGamepadUdevHelper_openOrCloseGamepad(struct HIDGamepadUdevHelper *helper, struct udev_device *dev) { const char *action = udev_device_get_action(dev); @@ -2013,34 +2013,34 @@ static void HIDGamepadUdevHelper_close(struct HIDGamepadUdevHelper *helper) { udev_unref(helper->udevPtr); } -void kinc_linux_initHIDGamepads() { - for (int i = 0; i < KINC_GAMEPAD_MAX_COUNT; ++i) { +void iron_linux_initHIDGamepads() { + for (int i = 0; i < IRON_GAMEPAD_MAX_COUNT; ++i) { HIDGamepad_init(&gamepads[i], i); } HIDGamepadUdevHelper_init(&udev_helper); } -void kinc_linux_updateHIDGamepads() { +void iron_linux_updateHIDGamepads() { HIDGamepadUdevHelper_update(&udev_helper); - for (int i = 0; i < KINC_GAMEPAD_MAX_COUNT; ++i) { + for (int i = 0; i < IRON_GAMEPAD_MAX_COUNT; ++i) { HIDGamepad_update(&gamepads[i]); } } -void kinc_linux_closeHIDGamepads() { +void iron_linux_closeHIDGamepads() { HIDGamepadUdevHelper_close(&udev_helper); } -const char *kinc_gamepad_vendor(int gamepad) { +const char *iron_gamepad_vendor(int gamepad) { return "Linux gamepad"; } -const char *kinc_gamepad_product_name(int gamepad) { - return gamepad >= 0 && gamepad < KINC_GAMEPAD_MAX_COUNT ? gamepads[gamepad].name : ""; +const char *iron_gamepad_product_name(int gamepad) { + return gamepad >= 0 && gamepad < IRON_GAMEPAD_MAX_COUNT ? gamepads[gamepad].name : ""; } -bool kinc_gamepad_connected(int gamepad) { - return gamepad >= 0 && gamepad < KINC_GAMEPAD_MAX_COUNT && gamepads[gamepad].connected; +bool iron_gamepad_connected(int gamepad) { + return gamepad >= 0 && gamepad < IRON_GAMEPAD_MAX_COUNT && gamepads[gamepad].connected; } -void kinc_gamepad_rumble(int gamepad, float left, float right) {} +void iron_gamepad_rumble(int gamepad, float left, float right) {} diff --git a/base/sources/backends/linux_system.h b/base/sources/backends/linux_system.h index 1df22fcd..8d290103 100644 --- a/base/sources/backends/linux_system.h +++ b/base/sources/backends/linux_system.h @@ -11,17 +11,17 @@ #define MAXIMUM_WINDOWS 1 #define MAXIMUM_DISPLAYS 16 -struct kinc_x11_window { +struct iron_x11_window { int display_index; int width; int height; - kinc_window_mode_t mode; + iron_window_mode_t mode; Window window; XIM xInputMethod; XIC xInputContext; }; -struct kinc_x11_display { +struct iron_x11_display { int index; int current_mode; int num_modes; @@ -36,12 +36,12 @@ struct kinc_x11_display { RRCrtc crtc; }; -struct kinc_x11_mouse { +struct iron_x11_mouse { int x; int y; }; -struct kinc_x11_atoms { +struct iron_x11_atoms { Atom XdndAware; Atom XdndDrop; Atom XdndEnter; @@ -83,7 +83,7 @@ struct kinc_x11_atoms { Atom JOYSTICK; }; -struct kinc_x11_libs { +struct iron_x11_libs { void *X11; void *Xcursor; void *Xi; @@ -91,7 +91,7 @@ struct kinc_x11_libs { void *Xrandr; }; -struct kinc_x11_procs { +struct iron_x11_procs { Display *(*XOpenDisplay)(const char *name); Status (*XInternAtoms)(Display *display, char **names, int count, Bool only_if_exists, Atom *atoms_return); int (*XCloseDisplay)(Display *display); @@ -170,23 +170,23 @@ struct x11_pen_device { struct x11_context { Display *display; - struct kinc_x11_libs libs; - struct kinc_x11_atoms atoms; - struct kinc_x11_mouse mouse; + struct iron_x11_libs libs; + struct iron_x11_atoms atoms; + struct iron_x11_mouse mouse; struct x11_pen_device pen; struct x11_pen_device eraser; - struct kinc_x11_window windows[MAXIMUM_WINDOWS]; + struct iron_x11_window windows[MAXIMUM_WINDOWS]; int num_displays; - struct kinc_x11_display displays[MAXIMUM_DISPLAYS]; + struct iron_x11_display displays[MAXIMUM_DISPLAYS]; }; -struct kinc_x11_procs xlib; +struct iron_x11_procs xlib; struct x11_context x11_ctx; -void kinc_copy_to_clipboard(const char *text); +void iron_copy_to_clipboard(const char *text); -void kinc_linux_initHIDGamepads(); -void kinc_linux_updateHIDGamepads(); -void kinc_linux_closeHIDGamepads(); +void iron_linux_initHIDGamepads(); +void iron_linux_updateHIDGamepads(); +void iron_linux_closeHIDGamepads(); diff --git a/base/sources/backends/linux_video.c b/base/sources/backends/linux_video.c index 4991d4b5..0137c6be 100644 --- a/base/sources/backends/linux_video.c +++ b/base/sources/backends/linux_video.c @@ -1,57 +1,57 @@ // #include -// void kinc_video_init(kinc_video_t *video, const char *filename) {} +// void iron_video_init(iron_video_t *video, const char *filename) {} -// void kinc_video_destroy(kinc_video_t *video) {} +// void iron_video_destroy(iron_video_t *video) {} -// void kinc_video_play(kinc_video_t *video, bool loop) {} +// void iron_video_play(iron_video_t *video, bool loop) {} -// void kinc_video_pause(kinc_video_t *video) {} +// void iron_video_pause(iron_video_t *video) {} -// void kinc_video_stop(kinc_video_t *video) {} +// void iron_video_stop(iron_video_t *video) {} -// int kinc_video_width(kinc_video_t *video) { +// int iron_video_width(iron_video_t *video) { // return 256; // } -// int kinc_video_height(kinc_video_t *video) { +// int iron_video_height(iron_video_t *video) { // return 256; // } -// kinc_g5_texture_t *kinc_video_current_image(kinc_video_t *video) { +// iron_g5_texture_t *iron_video_current_image(iron_video_t *video) { // return NULL; // } -// double kinc_video_duration(kinc_video_t *video) { +// double iron_video_duration(iron_video_t *video) { // return 0.0; // } -// double kinc_video_position(kinc_video_t *video) { +// double iron_video_position(iron_video_t *video) { // return 0.0; // } -// bool kinc_video_finished(kinc_video_t *video) { +// bool iron_video_finished(iron_video_t *video) { // return false; // } -// bool kinc_video_paused(kinc_video_t *video) { +// bool iron_video_paused(iron_video_t *video) { // return false; // } -// void kinc_video_update(kinc_video_t *video, double time) {} +// void iron_video_update(iron_video_t *video, double time) {} -// void kinc_internal_video_sound_stream_init(kinc_internal_video_sound_stream_t *stream, int channel_count, int frequency) {} +// void iron_internal_video_sound_stream_init(iron_internal_video_sound_stream_t *stream, int channel_count, int frequency) {} -// void kinc_internal_video_sound_stream_destroy(kinc_internal_video_sound_stream_t *stream) {} +// void iron_internal_video_sound_stream_destroy(iron_internal_video_sound_stream_t *stream) {} -// void kinc_internal_video_sound_stream_insert_data(kinc_internal_video_sound_stream_t *stream, float *data, int sample_count) {} +// void iron_internal_video_sound_stream_insert_data(iron_internal_video_sound_stream_t *stream, float *data, int sample_count) {} // static float samples[2] = {0}; -// float *kinc_internal_video_sound_stream_next_frame(kinc_internal_video_sound_stream_t *stream) { +// float *iron_internal_video_sound_stream_next_frame(iron_internal_video_sound_stream_t *stream) { // return samples; // } -// bool kinc_internal_video_sound_stream_ended(kinc_internal_video_sound_stream_t *stream) { +// bool iron_internal_video_sound_stream_ended(iron_internal_video_sound_stream_t *stream) { // return true; // } diff --git a/base/sources/backends/linux_video.h b/base/sources/backends/linux_video.h index 1dd13625..3290b704 100644 --- a/base/sources/backends/linux_video.h +++ b/base/sources/backends/linux_video.h @@ -2,18 +2,18 @@ // typedef struct { // int nothing; -// } kinc_video_impl_t; +// } iron_video_impl_t; -// typedef struct kinc_internal_video_sound_stream { +// typedef struct iron_internal_video_sound_stream { // int nothing; -// } kinc_internal_video_sound_stream_t; +// } iron_internal_video_sound_stream_t; -// void kinc_internal_video_sound_stream_init(kinc_internal_video_sound_stream_t *stream, int channel_count, int frequency); +// void iron_internal_video_sound_stream_init(iron_internal_video_sound_stream_t *stream, int channel_count, int frequency); -// void kinc_internal_video_sound_stream_destroy(kinc_internal_video_sound_stream_t *stream); +// void iron_internal_video_sound_stream_destroy(iron_internal_video_sound_stream_t *stream); -// void kinc_internal_video_sound_stream_insert_data(kinc_internal_video_sound_stream_t *stream, float *data, int sample_count); +// void iron_internal_video_sound_stream_insert_data(iron_internal_video_sound_stream_t *stream, float *data, int sample_count); -// float *kinc_internal_video_sound_stream_next_frame(kinc_internal_video_sound_stream_t *stream); +// float *iron_internal_video_sound_stream_next_frame(iron_internal_video_sound_stream_t *stream); -// bool kinc_internal_video_sound_stream_ended(kinc_internal_video_sound_stream_t *stream); +// bool iron_internal_video_sound_stream_ended(iron_internal_video_sound_stream_t *stream); diff --git a/base/sources/backends/macos_audio.c b/base/sources/backends/macos_audio.c index d739a0a4..068b84e4 100644 --- a/base/sources/backends/macos_audio.c +++ b/base/sources/backends/macos_audio.c @@ -1,5 +1,5 @@ -#ifdef KINC_A2 +#ifdef IRON_A2 #include #include @@ -8,9 +8,9 @@ #include #include -static kinc_internal_video_sound_stream_t *video = NULL; +static iron_internal_video_sound_stream_t *video = NULL; -void macPlayVideoSoundStream(kinc_internal_video_sound_stream_t *v) { +void macPlayVideoSoundStream(iron_internal_video_sound_stream_t *v) { video = v; } @@ -20,7 +20,7 @@ void macStopVideoSoundStream(void) { static void affirm(OSStatus err) { if (err != kAudioHardwareNoError) { - kinc_error("Error: %i\n", err); + iron_error("Error: %i\n", err); } } @@ -34,11 +34,11 @@ static AudioObjectPropertyAddress address; static AudioDeviceIOProcID theIOProcID = NULL; -static kinc_a2_buffer_t a2_buffer; +static iron_a2_buffer_t a2_buffer; static uint32_t samples_per_second = 44100; -uint32_t kinc_a2_samples_per_second(void) { +uint32_t iron_a2_samples_per_second(void) { return samples_per_second; } @@ -58,10 +58,10 @@ static OSStatus appIOProc(AudioDeviceID inDevice, const AudioTimeStamp *inNow, c affirm(AudioObjectGetPropertyData(device, &address, 0, NULL, &size, &deviceFormat)); if (samples_per_second != (int)deviceFormat.mSampleRate) { samples_per_second = (int)deviceFormat.mSampleRate; - kinc_a2_internal_sample_rate_callback(); + iron_a2_internal_sample_rate_callback(); } int num_frames = deviceBufferSize / deviceFormat.mBytesPerFrame; - kinc_a2_internal_callback(&a2_buffer, num_frames); + iron_a2_internal_callback(&a2_buffer, num_frames); float *output = (float *)outOutputData->mBuffers[0].mData; for (int i = 0; i < num_frames; ++i) { copySample(output); @@ -72,12 +72,12 @@ static OSStatus appIOProc(AudioDeviceID inDevice, const AudioTimeStamp *inNow, c static bool initialized = false; -void kinc_a2_init(void) { +void iron_a2_init(void) { if (initialized) { return; } - kinc_a2_internal_init(); + iron_a2_internal_init(); initialized = true; a2_buffer.read_location = 0; @@ -102,7 +102,7 @@ void kinc_a2_init(void) { address.mScope = kAudioDevicePropertyScopeOutput; affirm(AudioObjectGetPropertyData(device, &address, 0, NULL, &size, &deviceBufferSize)); - kinc_log("deviceBufferSize = %i\n", deviceBufferSize); + iron_log("deviceBufferSize = %i\n", deviceBufferSize); size = sizeof(AudioStreamBasicDescription); address.mSelector = kAudioDevicePropertyStreamFormat; @@ -111,29 +111,29 @@ void kinc_a2_init(void) { affirm(AudioObjectGetPropertyData(device, &address, 0, NULL, &size, &deviceFormat)); if (deviceFormat.mFormatID != kAudioFormatLinearPCM) { - kinc_error("mFormatID != kAudioFormatLinearPCM\n"); + iron_error("mFormatID != kAudioFormatLinearPCM\n"); return; } if (!(deviceFormat.mFormatFlags & kLinearPCMFormatFlagIsFloat)) { - kinc_error("Only works with float format.\n"); + iron_error("Only works with float format.\n"); return; } if (samples_per_second != (int)deviceFormat.mSampleRate) { samples_per_second = (int)deviceFormat.mSampleRate; - kinc_a2_internal_sample_rate_callback(); + iron_a2_internal_sample_rate_callback(); } initialized = true; - kinc_log("mSampleRate = %g\n", deviceFormat.mSampleRate); - kinc_log("mFormatFlags = %08X\n", (unsigned int)deviceFormat.mFormatFlags); - kinc_log("mBytesPerPacket = %d\n", (unsigned int)deviceFormat.mBytesPerPacket); - kinc_log("mFramesPerPacket = %d\n", (unsigned int)deviceFormat.mFramesPerPacket); - kinc_log("mChannelsPerFrame = %d\n", (unsigned int)deviceFormat.mChannelsPerFrame); - kinc_log("mBytesPerFrame = %d\n", (unsigned int)deviceFormat.mBytesPerFrame); - kinc_log("mBitsPerChannel = %d\n", (unsigned int)deviceFormat.mBitsPerChannel); + iron_log("mSampleRate = %g\n", deviceFormat.mSampleRate); + iron_log("mFormatFlags = %08X\n", (unsigned int)deviceFormat.mFormatFlags); + iron_log("mBytesPerPacket = %d\n", (unsigned int)deviceFormat.mBytesPerPacket); + iron_log("mFramesPerPacket = %d\n", (unsigned int)deviceFormat.mFramesPerPacket); + iron_log("mChannelsPerFrame = %d\n", (unsigned int)deviceFormat.mChannelsPerFrame); + iron_log("mBytesPerFrame = %d\n", (unsigned int)deviceFormat.mBytesPerFrame); + iron_log("mBitsPerChannel = %d\n", (unsigned int)deviceFormat.mBitsPerChannel); if (soundPlaying) return; @@ -144,9 +144,9 @@ void kinc_a2_init(void) { soundPlaying = true; } -void kinc_a2_update(void) {} +void iron_a2_update(void) {} -void kinc_a2_shutdown(void) { +void iron_a2_shutdown(void) { if (!initialized) return; if (!soundPlaying) diff --git a/base/sources/backends/macos_system.h b/base/sources/backends/macos_system.h index 029b5da4..8bc4b1d3 100644 --- a/base/sources/backends/macos_system.h +++ b/base/sources/backends/macos_system.h @@ -8,7 +8,7 @@ #include #include -struct kinc_g5_texture; +struct iron_g5_texture; @interface BasicOpenGLView : MTKView { @private @@ -65,9 +65,7 @@ void HIDGamepad_destroy(struct HIDGamepad *gamepad); void HIDGamepad_bind(struct HIDGamepad *gamepad, IOHIDDeviceRef deviceRef, int padIndex); void HIDGamepad_unbind(struct HIDGamepad *gamepad); -// Maximum number of devices supported -// Corresponds to size of Kore::Gamepad array -static const int KINC_MAX_HID_DEVICES = 12; +static const int IRON_MAX_HID_DEVICES = 12; // Slots to hold details on connected devices struct HIDManagerDeviceRecord { @@ -78,7 +76,7 @@ struct HIDManagerDeviceRecord { struct HIDManager { IOHIDManagerRef managerRef; - struct HIDManagerDeviceRecord devices[KINC_MAX_HID_DEVICES]; + struct HIDManagerDeviceRecord devices[IRON_MAX_HID_DEVICES]; }; void HIDManager_init(struct HIDManager *manager); diff --git a/base/sources/backends/macos_system.m b/base/sources/backends/macos_system.m index dbaf9587..06190372 100644 --- a/base/sources/backends/macos_system.m +++ b/base/sources/backends/macos_system.m @@ -28,36 +28,36 @@ static bool cmd = false; - (void)flagsChanged:(NSEvent *)theEvent { if (shift) { - kinc_internal_keyboard_trigger_key_up(KINC_KEY_SHIFT); + iron_internal_keyboard_trigger_key_up(IRON_KEY_SHIFT); shift = false; } if (ctrl) { - kinc_internal_keyboard_trigger_key_up(KINC_KEY_CONTROL); + iron_internal_keyboard_trigger_key_up(IRON_KEY_CONTROL); ctrl = false; } if (alt) { - kinc_internal_keyboard_trigger_key_up(KINC_KEY_ALT); + iron_internal_keyboard_trigger_key_up(IRON_KEY_ALT); alt = false; } if (cmd) { - kinc_internal_keyboard_trigger_key_up(KINC_KEY_META); + iron_internal_keyboard_trigger_key_up(IRON_KEY_META); cmd = false; } if ([theEvent modifierFlags] & NSShiftKeyMask) { - kinc_internal_keyboard_trigger_key_down(KINC_KEY_SHIFT); + iron_internal_keyboard_trigger_key_down(IRON_KEY_SHIFT); shift = true; } if ([theEvent modifierFlags] & NSControlKeyMask) { - kinc_internal_keyboard_trigger_key_down(KINC_KEY_CONTROL); + iron_internal_keyboard_trigger_key_down(IRON_KEY_CONTROL); ctrl = true; } if ([theEvent modifierFlags] & NSAlternateKeyMask) { - kinc_internal_keyboard_trigger_key_down(KINC_KEY_ALT); + iron_internal_keyboard_trigger_key_down(IRON_KEY_ALT); alt = true; } if ([theEvent modifierFlags] & NSCommandKeyMask) { - kinc_internal_keyboard_trigger_key_down(KINC_KEY_META); + iron_internal_keyboard_trigger_key_down(IRON_KEY_META); cmd = true; } } @@ -70,75 +70,75 @@ static bool cmd = false; unichar ch = [characters characterAtIndex:0]; switch (ch) { // keys that exist in keydown and keypress events case 59: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_SEMICOLON); + iron_internal_keyboard_trigger_key_down(IRON_KEY_SEMICOLON); break; case 91: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_OPEN_BRACKET); + iron_internal_keyboard_trigger_key_down(IRON_KEY_OPEN_BRACKET); break; case 93: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_CLOSE_BRACKET); + iron_internal_keyboard_trigger_key_down(IRON_KEY_CLOSE_BRACKET); break; case 39: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_QUOTE); + iron_internal_keyboard_trigger_key_down(IRON_KEY_QUOTE); break; case 92: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_BACK_SLASH); + iron_internal_keyboard_trigger_key_down(IRON_KEY_BACK_SLASH); break; case 44: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_COMMA); + iron_internal_keyboard_trigger_key_down(IRON_KEY_COMMA); break; case 46: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_PERIOD); + iron_internal_keyboard_trigger_key_down(IRON_KEY_PERIOD); break; case 47: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_SLASH); + iron_internal_keyboard_trigger_key_down(IRON_KEY_SLASH); break; case 96: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_BACK_QUOTE); + iron_internal_keyboard_trigger_key_down(IRON_KEY_BACK_QUOTE); break; case 32: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_SPACE); + iron_internal_keyboard_trigger_key_down(IRON_KEY_SPACE); break; case 45: // we need breaks because EQUALS triggered too for some reason - kinc_internal_keyboard_trigger_key_down(KINC_KEY_HYPHEN_MINUS); + iron_internal_keyboard_trigger_key_down(IRON_KEY_HYPHEN_MINUS); break; case 61: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_EQUALS); + iron_internal_keyboard_trigger_key_down(IRON_KEY_EQUALS); break; } switch (ch) { case NSRightArrowFunctionKey: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_RIGHT); + iron_internal_keyboard_trigger_key_down(IRON_KEY_RIGHT); break; case NSLeftArrowFunctionKey: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_LEFT); + iron_internal_keyboard_trigger_key_down(IRON_KEY_LEFT); break; case NSUpArrowFunctionKey: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_UP); + iron_internal_keyboard_trigger_key_down(IRON_KEY_UP); break; case NSDownArrowFunctionKey: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_DOWN); + iron_internal_keyboard_trigger_key_down(IRON_KEY_DOWN); break; case 27: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_ESCAPE); + iron_internal_keyboard_trigger_key_down(IRON_KEY_ESCAPE); break; case NSEnterCharacter: case NSNewlineCharacter: case NSCarriageReturnCharacter: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_RETURN); - kinc_internal_keyboard_trigger_key_press('\n'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_RETURN); + iron_internal_keyboard_trigger_key_press('\n'); break; case 0x7f: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_BACKSPACE); - kinc_internal_keyboard_trigger_key_press('\x08'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_BACKSPACE); + iron_internal_keyboard_trigger_key_press('\x08'); break; case 9: - kinc_internal_keyboard_trigger_key_down(KINC_KEY_TAB); - kinc_internal_keyboard_trigger_key_press('\t'); + iron_internal_keyboard_trigger_key_down(IRON_KEY_TAB); + iron_internal_keyboard_trigger_key_press('\t'); break; default: if (ch == 'x' && [theEvent modifierFlags] & NSCommandKeyMask) { - char *text = kinc_internal_cut_callback(); + char *text = iron_internal_cut_callback(); if (text != NULL) { NSPasteboard *board = [NSPasteboard generalPasteboard]; [board clearContents]; @@ -146,7 +146,7 @@ static bool cmd = false; } } if (ch == 'c' && [theEvent modifierFlags] & NSCommandKeyMask) { - char *text = kinc_internal_copy_callback(); + char *text = iron_internal_copy_callback(); if (text != NULL) { NSPasteboard *board = [NSPasteboard generalPasteboard]; [board clearContents]; @@ -159,19 +159,19 @@ static bool cmd = false; if (data != nil) { char charData[4096]; strcpy(charData, [data UTF8String]); - kinc_internal_paste_callback(charData); + iron_internal_paste_callback(charData); } } if (ch >= L'a' && ch <= L'z') { - kinc_internal_keyboard_trigger_key_down(ch - L'a' + KINC_KEY_A); + iron_internal_keyboard_trigger_key_down(ch - L'a' + IRON_KEY_A); } else if (ch >= L'A' && ch <= L'Z') { - kinc_internal_keyboard_trigger_key_down(ch - L'A' + KINC_KEY_A); + iron_internal_keyboard_trigger_key_down(ch - L'A' + IRON_KEY_A); } else if (ch >= L'0' && ch <= L'9') { - kinc_internal_keyboard_trigger_key_down(ch - L'0' + KINC_KEY_0); + iron_internal_keyboard_trigger_key_down(ch - L'0' + IRON_KEY_0); } - kinc_internal_keyboard_trigger_key_press(ch); + iron_internal_keyboard_trigger_key_press(ch); break; } } @@ -183,76 +183,76 @@ static bool cmd = false; unichar ch = [characters characterAtIndex:0]; switch (ch) { case 59: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_SEMICOLON); + iron_internal_keyboard_trigger_key_up(IRON_KEY_SEMICOLON); break; case 91: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_OPEN_BRACKET); + iron_internal_keyboard_trigger_key_up(IRON_KEY_OPEN_BRACKET); break; case 93: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_CLOSE_BRACKET); + iron_internal_keyboard_trigger_key_up(IRON_KEY_CLOSE_BRACKET); break; case 39: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_QUOTE); + iron_internal_keyboard_trigger_key_up(IRON_KEY_QUOTE); break; case 92: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_BACK_SLASH); + iron_internal_keyboard_trigger_key_up(IRON_KEY_BACK_SLASH); break; case 44: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_COMMA); + iron_internal_keyboard_trigger_key_up(IRON_KEY_COMMA); break; case 46: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_PERIOD); + iron_internal_keyboard_trigger_key_up(IRON_KEY_PERIOD); break; case 47: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_SLASH); + iron_internal_keyboard_trigger_key_up(IRON_KEY_SLASH); break; case 96: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_BACK_QUOTE); + iron_internal_keyboard_trigger_key_up(IRON_KEY_BACK_QUOTE); break; case 45: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_HYPHEN_MINUS); + iron_internal_keyboard_trigger_key_up(IRON_KEY_HYPHEN_MINUS); break; case 61: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_EQUALS); + iron_internal_keyboard_trigger_key_up(IRON_KEY_EQUALS); break; case NSRightArrowFunctionKey: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_RIGHT); + iron_internal_keyboard_trigger_key_up(IRON_KEY_RIGHT); break; case NSLeftArrowFunctionKey: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_LEFT); + iron_internal_keyboard_trigger_key_up(IRON_KEY_LEFT); break; case NSUpArrowFunctionKey: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_UP); + iron_internal_keyboard_trigger_key_up(IRON_KEY_UP); break; case NSDownArrowFunctionKey: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_DOWN); + iron_internal_keyboard_trigger_key_up(IRON_KEY_DOWN); break; case 27: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_ESCAPE); + iron_internal_keyboard_trigger_key_up(IRON_KEY_ESCAPE); break; case NSEnterCharacter: case NSNewlineCharacter: case NSCarriageReturnCharacter: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_RETURN); + iron_internal_keyboard_trigger_key_up(IRON_KEY_RETURN); break; case 0x7f: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_BACKSPACE); + iron_internal_keyboard_trigger_key_up(IRON_KEY_BACKSPACE); break; case 9: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_TAB); + iron_internal_keyboard_trigger_key_up(IRON_KEY_TAB); break; case 32: - kinc_internal_keyboard_trigger_key_up(KINC_KEY_SPACE); + iron_internal_keyboard_trigger_key_up(IRON_KEY_SPACE); break; default: if (ch >= L'a' && ch <= L'z') { - kinc_internal_keyboard_trigger_key_up(ch - L'a' + KINC_KEY_A); + iron_internal_keyboard_trigger_key_up(ch - L'a' + IRON_KEY_A); } else if (ch >= L'A' && ch <= L'Z') { - kinc_internal_keyboard_trigger_key_up(ch - L'A' + KINC_KEY_A); + iron_internal_keyboard_trigger_key_up(ch - L'A' + IRON_KEY_A); } else if (ch >= L'0' && ch <= L'9') { - kinc_internal_keyboard_trigger_key_up(ch - L'0' + KINC_KEY_0); + iron_internal_keyboard_trigger_key_up(ch - L'0' + IRON_KEY_0); } break; } @@ -268,7 +268,7 @@ static int getMouseX(NSEvent *event) { static int getMouseY(NSEvent *event) { NSWindow *window = [[NSApplication sharedApplication] mainWindow]; float scale = [window backingScaleFactor]; - return (int)(kinc_height() - [event locationInWindow].y * scale); + return (int)(iron_height() - [event locationInWindow].y * scale); } static bool controlKeyMouseButton = false; @@ -276,71 +276,71 @@ static bool controlKeyMouseButton = false; - (void)mouseDown:(NSEvent *)theEvent { if ([theEvent modifierFlags] & NSControlKeyMask) { controlKeyMouseButton = true; - kinc_internal_mouse_trigger_press(1, getMouseX(theEvent), getMouseY(theEvent)); + iron_internal_mouse_trigger_press(1, getMouseX(theEvent), getMouseY(theEvent)); } else { controlKeyMouseButton = false; - kinc_internal_mouse_trigger_press(0, getMouseX(theEvent), getMouseY(theEvent)); + iron_internal_mouse_trigger_press(0, getMouseX(theEvent), getMouseY(theEvent)); } if ([theEvent subtype] == NSTabletPointEventSubtype) { - kinc_internal_pen_trigger_press(getMouseX(theEvent), getMouseY(theEvent), theEvent.pressure); + iron_internal_pen_trigger_press(getMouseX(theEvent), getMouseY(theEvent), theEvent.pressure); } } - (void)mouseUp:(NSEvent *)theEvent { if (controlKeyMouseButton) { - kinc_internal_mouse_trigger_release(1, getMouseX(theEvent), getMouseY(theEvent)); + iron_internal_mouse_trigger_release(1, getMouseX(theEvent), getMouseY(theEvent)); } else { - kinc_internal_mouse_trigger_release(0, getMouseX(theEvent), getMouseY(theEvent)); + iron_internal_mouse_trigger_release(0, getMouseX(theEvent), getMouseY(theEvent)); } controlKeyMouseButton = false; if ([theEvent subtype] == NSTabletPointEventSubtype) { - kinc_internal_pen_trigger_release(getMouseX(theEvent), getMouseY(theEvent), theEvent.pressure); + iron_internal_pen_trigger_release(getMouseX(theEvent), getMouseY(theEvent), theEvent.pressure); } } - (void)mouseMoved:(NSEvent *)theEvent { - kinc_internal_mouse_trigger_move(getMouseX(theEvent), getMouseY(theEvent)); + iron_internal_mouse_trigger_move(getMouseX(theEvent), getMouseY(theEvent)); } - (void)mouseDragged:(NSEvent *)theEvent { - kinc_internal_mouse_trigger_move(getMouseX(theEvent), getMouseY(theEvent)); + iron_internal_mouse_trigger_move(getMouseX(theEvent), getMouseY(theEvent)); if ([theEvent subtype] == NSTabletPointEventSubtype) { - kinc_internal_pen_trigger_move(getMouseX(theEvent), getMouseY(theEvent), theEvent.pressure); + iron_internal_pen_trigger_move(getMouseX(theEvent), getMouseY(theEvent), theEvent.pressure); } } - (void)rightMouseDown:(NSEvent *)theEvent { - kinc_internal_mouse_trigger_press(1, getMouseX(theEvent), getMouseY(theEvent)); + iron_internal_mouse_trigger_press(1, getMouseX(theEvent), getMouseY(theEvent)); } - (void)rightMouseUp:(NSEvent *)theEvent { - kinc_internal_mouse_trigger_release(1, getMouseX(theEvent), getMouseY(theEvent)); + iron_internal_mouse_trigger_release(1, getMouseX(theEvent), getMouseY(theEvent)); } - (void)rightMouseDragged:(NSEvent *)theEvent { - kinc_internal_mouse_trigger_move(getMouseX(theEvent), getMouseY(theEvent)); + iron_internal_mouse_trigger_move(getMouseX(theEvent), getMouseY(theEvent)); } - (void)otherMouseDown:(NSEvent *)theEvent { - kinc_internal_mouse_trigger_press(2, getMouseX(theEvent), getMouseY(theEvent)); + iron_internal_mouse_trigger_press(2, getMouseX(theEvent), getMouseY(theEvent)); } - (void)otherMouseUp:(NSEvent *)theEvent { - kinc_internal_mouse_trigger_release(2, getMouseX(theEvent), getMouseY(theEvent)); + iron_internal_mouse_trigger_release(2, getMouseX(theEvent), getMouseY(theEvent)); } - (void)otherMouseDragged:(NSEvent *)theEvent { - kinc_internal_mouse_trigger_move(getMouseX(theEvent), getMouseY(theEvent)); + iron_internal_mouse_trigger_move(getMouseX(theEvent), getMouseY(theEvent)); } - (void)scrollWheel:(NSEvent *)theEvent { int delta = [theEvent deltaY]; - kinc_internal_mouse_trigger_scroll(-delta); + iron_internal_mouse_trigger_scroll(-delta); } - (NSDragOperation)draggingEntered:(id)sender { @@ -360,7 +360,7 @@ static bool controlKeyMouseButton = false; if ([[pboard types] containsObject:NSURLPboardType]) { NSURL *fileURL = [NSURL URLFromPasteboard:pboard]; wchar_t *filePath = (wchar_t *)[fileURL.path cStringUsingEncoding:NSUTF32LittleEndianStringEncoding]; - kinc_internal_drop_files_callback(filePath); + iron_internal_drop_files_callback(filePath); } return YES; } @@ -422,7 +422,7 @@ static bool controlKeyMouseButton = false; @end -void kinc_copy_to_clipboard(const char *text) { +void iron_copy_to_clipboard(const char *text) { NSPasteboard *board = [NSPasteboard generalPasteboard]; [board clearContents]; [board setString:[NSString stringWithUTF8String:text] forType:NSStringPboardType]; @@ -443,63 +443,63 @@ static bool debugButtonInput = false; static void logButton(int buttonIndex, bool pressed) { switch (buttonIndex) { case 0: - kinc_log("A Pressed %i", pressed); + iron_log("A Pressed %i", pressed); break; case 1: - kinc_log("B Pressed %i", pressed); + iron_log("B Pressed %i", pressed); break; case 2: - kinc_log("X Pressed %i", pressed); + iron_log("X Pressed %i", pressed); break; case 3: - kinc_log("Y Pressed %i", pressed); + iron_log("Y Pressed %i", pressed); break; case 4: - kinc_log("Lb Pressed %i", pressed); + iron_log("Lb Pressed %i", pressed); break; case 5: - kinc_log("Rb Pressed %i", pressed); + iron_log("Rb Pressed %i", pressed); break; case 6: - kinc_log("Left Stick Pressed %i", pressed); + iron_log("Left Stick Pressed %i", pressed); break; case 7: - kinc_log("Right Stick Pressed %i", pressed); + iron_log("Right Stick Pressed %i", pressed); break; case 8: - kinc_log("Start Pressed %i", pressed); + iron_log("Start Pressed %i", pressed); break; case 9: - kinc_log("Back Pressed %i", pressed); + iron_log("Back Pressed %i", pressed); break; case 10: - kinc_log("Home Pressed %i", pressed); + iron_log("Home Pressed %i", pressed); break; case 11: - kinc_log("Up Pressed %i", pressed); + iron_log("Up Pressed %i", pressed); break; case 12: - kinc_log("Down Pressed %i", pressed); + iron_log("Down Pressed %i", pressed); break; case 13: - kinc_log("Left Pressed %i", pressed); + iron_log("Left Pressed %i", pressed); break; case 14: - kinc_log("Right Pressed %i", pressed); + iron_log("Right Pressed %i", pressed); break; default: @@ -512,27 +512,27 @@ static bool debugAxisInput = false; static void logAxis(int axisIndex) { switch (axisIndex) { case 0: - kinc_log("Left stick X"); + iron_log("Left stick X"); break; case 1: - kinc_log("Left stick Y"); + iron_log("Left stick Y"); break; case 2: - kinc_log("Right stick X"); + iron_log("Right stick X"); break; case 3: - kinc_log("Right stick Y"); + iron_log("Right stick Y"); break; case 4: - kinc_log("Left trigger"); + iron_log("Left trigger"); break; case 5: - kinc_log("Right trigger"); + iron_log("Right trigger"); break; default: @@ -549,7 +549,7 @@ static void cstringFromCFStringRef(CFStringRef string, char *cstr, size_t clen) if (string != NULL) { char temp[256]; if (CFStringGetCString(string, temp, 256, kCFStringEncodingUTF8)) { - temp[kinc_mini(255, (int)(clen - 1))] = '\0'; + temp[iron_mini(255, (int)(clen - 1))] = '\0'; strncpy(cstr, temp, clen); } } @@ -603,7 +603,7 @@ void HIDGamepad_bind(struct HIDGamepad *gamepad, IOHIDDeviceRef inDeviceRef, int cstringFromCFStringRef(productRef, gamepad->hidDeviceProduct, sizeof(gamepad->hidDeviceProduct)); } - kinc_log("HIDGamepad.bind: <%p> idx:%d [0x%x:0x%x] [%s] [%s]", inDeviceRef, gamepad->padIndex, gamepad->hidDeviceVendorID, + iron_log("HIDGamepad.bind: <%p> idx:%d [0x%x:0x%x] [%s] [%s]", inDeviceRef, gamepad->padIndex, gamepad->hidDeviceVendorID, gamepad->hidDeviceProductID, gamepad->hidDeviceVendor, gamepad->hidDeviceProduct); } @@ -664,7 +664,7 @@ static void initDeviceElements(struct HIDGamepad *gamepad, CFArrayRef elements) } void HIDGamepad_unbind(struct HIDGamepad *gamepad) { - kinc_log("HIDGamepad.unbind: idx:%d [0x%x:0x%x] [%s] [%s]", gamepad->padIndex, gamepad->hidDeviceVendorID, gamepad->hidDeviceProductID, + iron_log("HIDGamepad.unbind: idx:%d [0x%x:0x%x] [%s] [%s]", gamepad->padIndex, gamepad->hidDeviceVendorID, gamepad->hidDeviceProductID, gamepad->hidDeviceVendor, gamepad->hidDeviceProduct); if (gamepad->hidQueueRef) { @@ -705,7 +705,7 @@ static void buttonChanged(struct HIDGamepad *gamepad, IOHIDElementRef elementRef double max = IOHIDElementGetLogicalMax(elementRef); double normalize = (rawValue - min) / (max - min); - kinc_internal_gamepad_trigger_button(gamepad->padIndex, buttonIndex, normalize); + iron_internal_gamepad_trigger_button(gamepad->padIndex, buttonIndex, normalize); if (debugButtonInput) logButton(buttonIndex, (normalize != 0)); @@ -724,7 +724,7 @@ static void axisChanged(struct HIDGamepad *gamepad, IOHIDElementRef elementRef, if (axisIndex % 2 == 1) normalize = -normalize; - kinc_internal_gamepad_trigger_axis(gamepad->padIndex, axisIndex, normalize); + iron_internal_gamepad_trigger_axis(gamepad->padIndex, axisIndex, normalize); if (debugAxisInput) logAxis(axisIndex); @@ -764,11 +764,11 @@ static void valueAvailableCallback(void *inContext, IOReturn inResult, void *inS } while (1); } -const char *kinc_gamepad_vendor(int gamepad) { +const char *iron_gamepad_vendor(int gamepad) { return "unknown"; } -const char *kinc_gamepad_product_name(int gamepad) { +const char *iron_gamepad_product_name(int gamepad) { return "unknown"; } @@ -808,7 +808,7 @@ static int initHIDManager(struct HIDManager *manager) { addMatchingArray(manager, matchingCFArrayRef, matchingCFDictRef); } else { - kinc_error("%s: CFArrayCreateMutable failed.", __PRETTY_FUNCTION__); + iron_error("%s: CFArrayCreateMutable failed.", __PRETTY_FUNCTION__); return -1; } @@ -859,17 +859,17 @@ CFMutableDictionaryRef createDeviceMatchingDictionary(struct HIDManager *manager CFRelease(usageCFNumberRef); } else { - kinc_error("%s: CFNumberCreate(usage) failed.", __PRETTY_FUNCTION__); + iron_error("%s: CFNumberCreate(usage) failed.", __PRETTY_FUNCTION__); } } } else { - kinc_error("%s: CFNumberCreate(usage page) failed.", __PRETTY_FUNCTION__); + iron_error("%s: CFNumberCreate(usage page) failed.", __PRETTY_FUNCTION__); } } } else { - kinc_error("%s: CFDictionaryCreateMutable failed.", __PRETTY_FUNCTION__); + iron_error("%s: CFDictionaryCreateMutable failed.", __PRETTY_FUNCTION__); } return result; } @@ -882,7 +882,7 @@ void deviceConnected(void *inContext, IOReturn inResult, void *inSender, IOHIDDe // Find an empty slot in the devices list and add the new device there // TODO: does this need to be made thread safe? struct HIDManagerDeviceRecord *device = &manager->devices[0]; - for (int i = 0; i < KINC_MAX_HID_DEVICES; ++i, ++device) { + for (int i = 0; i < IRON_MAX_HID_DEVICES; ++i, ++device) { if (!device->connected) { device->connected = true; device->device = inIOHIDDeviceRef; @@ -899,7 +899,7 @@ void deviceRemoved(void *inContext, IOReturn inResult, void *inSender, IOHIDDevi // TODO: does this need to be made thread safe? struct HIDManagerDeviceRecord *device = &manager->devices[0]; - for (int i = 0; i < KINC_MAX_HID_DEVICES; ++i, ++device) { + for (int i = 0; i < IRON_MAX_HID_DEVICES; ++i, ++device) { // TODO: is comparing IOHIDDeviceRef to match devices safe? Is there a better way? if (device->connected && device->device == inIOHIDDeviceRef) { device->connected = false; @@ -912,12 +912,12 @@ void deviceRemoved(void *inContext, IOReturn inResult, void *inSender, IOHIDDevi #define maxDisplays 10 -int kinc_count_displays(void) { +int iron_count_displays(void) { NSArray *screens = [NSScreen screens]; return (int)[screens count]; } -int kinc_primary_display(void) { +int iron_primary_display(void) { NSArray *screens = [NSScreen screens]; NSScreen *mainScreen = [NSScreen mainScreen]; for (int i = 0; i < maxDisplays; ++i) { @@ -928,10 +928,10 @@ int kinc_primary_display(void) { return -1; } -void kinc_display_init(void) {} +void iron_display_init(void) {} -kinc_display_mode_t kinc_display_available_mode(int display, int mode) { - kinc_display_mode_t dm; +iron_display_mode_t iron_display_available_mode(int display, int mode) { + iron_display_mode_t dm; dm.width = 800; dm.height = 600; dm.frequency = 60; @@ -939,23 +939,23 @@ kinc_display_mode_t kinc_display_available_mode(int display, int mode) { return dm; } -int kinc_display_count_available_modes(int display) { +int iron_display_count_available_modes(int display) { return 1; } -bool kinc_display_available(int display) { +bool iron_display_available(int display) { return true; } -const char *kinc_display_name(int display) { +const char *iron_display_name(int display) { return "Display"; } -kinc_display_mode_t kinc_display_current_mode(int display) { +iron_display_mode_t iron_display_current_mode(int display) { NSArray *screens = [NSScreen screens]; NSScreen *screen = screens[display]; NSRect screenRect = [screen frame]; - kinc_display_mode_t dm; + iron_display_mode_t dm; dm.width = screenRect.size.width; dm.height = screenRect.size.height; dm.frequency = 60; @@ -971,31 +971,31 @@ kinc_display_mode_t kinc_display_current_mode(int display) { return dm; } -NSWindow *kinc_get_mac_window_handle(); +NSWindow *iron_get_mac_window_handle(); -void kinc_internal_mouse_lock() { - kinc_mouse_hide(); +void iron_internal_mouse_lock() { + iron_mouse_hide(); } -void kinc_internal_mouse_unlock(void) { - kinc_mouse_show(); +void iron_internal_mouse_unlock(void) { + iron_mouse_show(); } -bool kinc_mouse_can_lock(void) { +bool iron_mouse_can_lock(void) { return true; } -void kinc_mouse_show(void) { +void iron_mouse_show(void) { CGDisplayShowCursor(kCGDirectMainDisplay); } -void kinc_mouse_hide(void) { +void iron_mouse_hide(void) { CGDisplayHideCursor(kCGDirectMainDisplay); } -void kinc_mouse_set_position(int x, int y) { +void iron_mouse_set_position(int x, int y) { - NSWindow *window = kinc_get_mac_window_handle(); + NSWindow *window = iron_get_mac_window_handle(); float scale = [window backingScaleFactor]; NSRect rect = [[NSScreen mainScreen] frame]; @@ -1007,64 +1007,64 @@ void kinc_mouse_set_position(int x, int y) { CGAssociateMouseAndMouseCursorPosition(true); } -void kinc_mouse_get_position(int *x, int *y) { - NSWindow *window = kinc_get_mac_window_handle(); +void iron_mouse_get_position(int *x, int *y) { + NSWindow *window = iron_get_mac_window_handle(); NSPoint point = [window mouseLocationOutsideOfEventStream]; *x = (int)point.x; *y = (int)point.y; } -void kinc_mouse_set_cursor(int cursor_index) {} +void iron_mouse_set_cursor(int cursor_index) {} static int mouseX, mouseY; static bool keyboardShown = false; -void Kinc_Mouse_GetPosition(int *x, int *y) { +void Iron_Mouse_GetPosition(int *x, int *y) { *x = mouseX; *y = mouseY; } -void kinc_keyboard_show(void) { +void iron_keyboard_show(void) { keyboardShown = true; } -void kinc_keyboard_hide(void) { +void iron_keyboard_hide(void) { keyboardShown = false; } -bool kinc_keyboard_active(void) { +bool iron_keyboard_active(void) { return keyboardShown; } -const char *kinc_system_id(void) { +const char *iron_system_id(void) { return "macOS"; } static const char *videoFormats[] = {"ogv", NULL}; -const char **kinc_video_formats(void) { +const char **iron_video_formats(void) { return videoFormats; } -void kinc_set_keep_screen_on(bool on) {} +void iron_set_keep_screen_on(bool on) {} #include -double kinc_frequency(void) { +double iron_frequency(void) { mach_timebase_info_data_t info; mach_timebase_info(&info); return (double)info.denom / (double)info.numer / 1e-9; } -kinc_ticks_t kinc_timestamp(void) { +iron_ticks_t iron_timestamp(void) { return mach_absolute_time(); } -bool kinc_gamepad_connected(int num) { +bool iron_gamepad_connected(int num) { return true; } -void kinc_gamepad_rumble(int gamepad, float left, float right) {} +void iron_gamepad_rumble(int gamepad, float left, float right) {} bool withAutoreleasepool(bool (*f)(void)) { @autoreleasepool { @@ -1078,12 +1078,12 @@ const char *macgetresourcepath(void) { return [[[NSBundle mainBundle] resourcePath] cStringUsingEncoding:NSUTF8StringEncoding]; } -@interface KincApplication : NSApplication { +@interface IronApplication : NSApplication { } - (void)terminate:(id)sender; @end -@interface KincAppDelegate : NSObject { +@interface IronAppDelegate : NSObject { } - (void)windowWillClose:(NSNotification *)notification; - (void)windowDidResize:(NSNotification *)notification; @@ -1096,7 +1096,7 @@ const char *macgetresourcepath(void) { static NSApplication *myapp; static NSWindow *window; static BasicOpenGLView *view; -static KincAppDelegate *delegate; +static IronAppDelegate *delegate; static struct HIDManager *hidManager; CAMetalLayer *getMetalLayer(void) { @@ -1115,7 +1115,7 @@ id getMetalQueue(void) { return [view metalQueue]; } -bool kinc_internal_handle_messages(void) { +bool iron_internal_handle_messages(void) { NSEvent *event = [myapp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode @@ -1135,21 +1135,21 @@ bool kinc_internal_handle_messages(void) { void swapBuffersMac() { } -static void createWindow(kinc_window_options_t *options) { +static void createWindow(iron_window_options_t *options) { int width = options->width / [[NSScreen mainScreen] backingScaleFactor]; int height = options->height / [[NSScreen mainScreen] backingScaleFactor]; int styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable; - if ((options->features & KINC_WINDOW_FEATURE_RESIZEABLE) || (options->features & KINC_WINDOW_FEATURE_MAXIMIZABLE)) { + if ((options->features & IRON_WINDOW_FEATURE_RESIZEABLE) || (options->features & IRON_WINDOW_FEATURE_MAXIMIZABLE)) { styleMask |= NSWindowStyleMaskResizable; } - if (options->features & KINC_WINDOW_FEATURE_MINIMIZABLE) { + if (options->features & IRON_WINDOW_FEATURE_MINIMIZABLE) { styleMask |= NSWindowStyleMaskMiniaturizable; } view = [[BasicOpenGLView alloc] initWithFrame:NSMakeRect(0, 0, width, height)]; [view registerForDraggedTypes:[NSArray arrayWithObjects:NSURLPboardType, nil]]; window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, width, height) styleMask:styleMask backing:NSBackingStoreBuffered defer:TRUE]; - delegate = [KincAppDelegate alloc]; + delegate = [IronAppDelegate alloc]; [window setDelegate:delegate]; [window setTitle:[NSString stringWithCString:options->title encoding:NSUTF8StringEncoding]]; [window setAcceptsMouseMovedEvents:YES]; @@ -1161,21 +1161,21 @@ static void createWindow(kinc_window_options_t *options) { [window makeKeyAndOrderFront:nil]; - if (options->mode == KINC_WINDOW_MODE_FULLSCREEN) { + if (options->mode == IRON_WINDOW_MODE_FULLSCREEN) { [window toggleFullScreen:nil]; windows[0].fullscreen = true; } } -void kinc_window_change_window_mode(kinc_window_mode_t mode) { +void iron_window_change_window_mode(iron_window_mode_t mode) { switch (mode) { - case KINC_WINDOW_MODE_WINDOW: + case IRON_WINDOW_MODE_WINDOW: if (windows[0].fullscreen) { [window toggleFullScreen:nil]; windows[0].fullscreen = false; } break; - case KINC_WINDOW_MODE_FULLSCREEN: + case IRON_WINDOW_MODE_FULLSCREEN: if (!windows[0].fullscreen) { [window toggleFullScreen:nil]; windows[0].fullscreen = true; @@ -1184,7 +1184,7 @@ void kinc_window_change_window_mode(kinc_window_mode_t mode) { } } -void kinc_window_set_close_callback(bool (*callback)(void *), void *data) { +void iron_window_set_close_callback(bool (*callback)(void *), void *data) { windows[0].closeCallback = callback; windows[0].closeCallbackData = data; } @@ -1205,9 +1205,9 @@ static void addMenubar(void) { [NSApp setMainMenu:menubar]; } -void kinc_init(const char *name, int width, int height, kinc_window_options_t *win) { +void iron_init(const char *name, int width, int height, iron_window_options_t *win) { @autoreleasepool { - myapp = [KincApplication sharedApplication]; + myapp = [IronApplication sharedApplication]; [myapp finishLaunching]; [[NSRunningApplication currentApplication] activateWithOptions:(NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)]; NSApp.activationPolicy = NSApplicationActivationPolicyRegular; @@ -1217,9 +1217,9 @@ void kinc_init(const char *name, int width, int height, kinc_window_options_t *w addMenubar(); } - kinc_window_options_t defaultWindowOptions; + iron_window_options_t defaultWindowOptions; if (win == NULL) { - kinc_window_options_set_defaults(&defaultWindowOptions); + iron_window_options_set_defaults(&defaultWindowOptions); win = &defaultWindowOptions; } @@ -1230,33 +1230,33 @@ void kinc_init(const char *name, int width, int height, kinc_window_options_t *w } createWindow(win); - kinc_g5_internal_init(); - kinc_g4_internal_init_window(win->depth_bits, true); + iron_g5_internal_init(); + iron_g4_internal_init_window(win->depth_bits, true); } -int kinc_window_width() { +int iron_window_width() { NSWindow *window = windows[0].handle; float scale = [window backingScaleFactor]; return [[window contentView] frame].size.width * scale; } -int kinc_window_height() { +int iron_window_height() { NSWindow *window = windows[0].handle; float scale = [window backingScaleFactor]; return [[window contentView] frame].size.height * scale; } -NSWindow *kinc_get_mac_window_handle() { +NSWindow *iron_get_mac_window_handle() { return windows[0].handle; } -void kinc_load_url(const char *url) { +void iron_load_url(const char *url) { [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[NSString stringWithUTF8String:url]]]; } static char language[3]; -const char *kinc_language(void) { +const char *iron_language(void) { NSString *nsstr = [[NSLocale preferredLanguages] objectAtIndex:0]; const char *lang = [nsstr UTF8String]; language[0] = lang[0]; @@ -1265,12 +1265,12 @@ const char *kinc_language(void) { return language; } -void kinc_internal_shutdown(void) {} +void iron_internal_shutdown(void) {} static const char *getSavePath(void) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); NSString *resolvedPath = [paths objectAtIndex:0]; - NSString *appName = [NSString stringWithUTF8String:kinc_application_name()]; + NSString *appName = [NSString stringWithUTF8String:iron_application_name()]; resolvedPath = [resolvedPath stringByAppendingPathComponent:appName]; NSFileManager *fileMgr = [[NSFileManager alloc] init]; @@ -1282,25 +1282,25 @@ static const char *getSavePath(void) { return [resolvedPath cStringUsingEncoding:NSUTF8StringEncoding]; } -const char *kinc_internal_save_path(void) { +const char *iron_internal_save_path(void) { return getSavePath(); } -#ifndef KINC_NO_MAIN +#ifndef IRON_NO_MAIN int main(int argc, char **argv) { return kickstart(argc, argv); } #endif -@implementation KincApplication +@implementation IronApplication - (void)terminate:(id)sender { - kinc_stop(); + iron_stop(); } @end -@implementation KincAppDelegate +@implementation IronAppDelegate - (BOOL)windowShouldClose:(NSWindow *)sender { if (windows[0].closeCallback != NULL) { if (windows[0].closeCallback(windows[0].closeCallbackData)) { @@ -1314,7 +1314,7 @@ int main(int argc, char **argv) { } - (void)windowWillClose:(NSNotification *)notification { - kinc_stop(); + iron_stop(); } - (void)windowDidResize:(NSNotification *)notification { @@ -1327,59 +1327,59 @@ int main(int argc, char **argv) { } - (void)windowWillMiniaturize:(NSNotification *)notification { - kinc_internal_background_callback(); + iron_internal_background_callback(); } - (void)windowDidDeminiaturize:(NSNotification *)notification { - kinc_internal_foreground_callback(); + iron_internal_foreground_callback(); } - (void)windowDidResignMain:(NSNotification *)notification { - kinc_internal_pause_callback(); + iron_internal_pause_callback(); } - (void)windowDidBecomeMain:(NSNotification *)notification { - kinc_internal_resume_callback(); + iron_internal_resume_callback(); } @end -int kinc_window_x() { +int iron_window_x() { return 0; } -int kinc_window_y() { +int iron_window_y() { return 0; } -void kinc_window_resize(int width, int height) {} +void iron_window_resize(int width, int height) {} -void kinc_window_move(int x, int y) {} +void iron_window_move(int x, int y) {} -void kinc_window_change_features(int features) {} +void iron_window_change_features(int features) {} -void kinc_window_change_mode(kinc_window_mode_t mode) {} +void iron_window_change_mode(iron_window_mode_t mode) {} -void kinc_window_destroy() {} +void iron_window_destroy() {} -void kinc_window_show() {} +void iron_window_show() {} -void kinc_window_hide() {} +void iron_window_hide() {} -void kinc_window_set_title(const char *title) {} +void iron_window_set_title(const char *title) {} -void kinc_window_create(kinc_window_options_t *win) { +void iron_window_create(iron_window_options_t *win) { } -void kinc_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) { +void iron_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) { windows[0].resizeCallback = callback; windows[0].resizeCallbackData = data; } -kinc_window_mode_t kinc_window_get_mode() { - return KINC_WINDOW_MODE_WINDOW; +iron_window_mode_t iron_window_get_mode() { + return IRON_WINDOW_MODE_WINDOW; } -int kinc_window_display() { +int iron_window_display() { return 0; } diff --git a/base/sources/backends/metal_gpu.h b/base/sources/backends/metal_gpu.h index 3e4bd828..cff03c51 100644 --- a/base/sources/backends/metal_gpu.h +++ b/base/sources/backends/metal_gpu.h @@ -5,24 +5,24 @@ #pragma once -struct kinc_g5_index_buffer; +struct iron_g5_index_buffer; typedef struct { - struct kinc_g5_index_buffer *current_index_buffer; + struct iron_g5_index_buffer *current_index_buffer; } CommandList5Impl; -typedef struct kinc_g5_compute_shader_impl { +typedef struct iron_g5_compute_shader_impl { char name[1024]; void *_function; void *_pipeline; void *_reflection; -} kinc_g5_compute_shader_impl; +} iron_g5_compute_shader_impl; -struct kinc_g5_shader; +struct iron_g5_shader; typedef struct { - struct kinc_g5_shader *vertex_shader; - struct kinc_g5_shader *fragment_shader; + struct iron_g5_shader *vertex_shader; + struct iron_g5_shader *fragment_shader; void *_pipeline; void *_pipelineDepth; void *_reflection; @@ -40,9 +40,9 @@ typedef struct { int computeOffset; } ConstantLocation5Impl; -typedef struct kinc_g5_sampler_impl { +typedef struct iron_g5_sampler_impl { void *sampler; -} kinc_g5_sampler_impl_t; +} iron_g5_sampler_impl_t; typedef struct { char name[1024]; @@ -51,11 +51,11 @@ typedef struct { typedef struct { void *_raytracingPipeline; -} kinc_g5_raytrace_pipeline_impl_t; +} iron_g5_raytrace_pipeline_impl_t; typedef struct { void *_accelerationStructure; -} kinc_g5_raytrace_acceleration_structure_impl_t; +} iron_g5_raytrace_acceleration_structure_impl_t; typedef struct { int index; diff --git a/base/sources/backends/metal_gpu.m b/base/sources/backends/metal_gpu.m index a7c1c668..c8a5df8a 100644 --- a/base/sources/backends/metal_gpu.m +++ b/base/sources/backends/metal_gpu.m @@ -25,27 +25,27 @@ int newRenderTargetHeight; id drawable; id depthTexture; int depthBits; -bool kinc_internal_metal_has_depth = false; -static kinc_g5_texture_t fallback_render_target; +bool iron_internal_metal_has_depth = false; +static iron_g5_texture_t fallback_render_target; static int framebuffer_count = 0; -void kinc_g5_internal_new_render_pass(kinc_g5_texture_t **renderTargets, int count, bool wait, unsigned clear_flags, unsigned color, float depth); -void kinc_g5_internal_pipeline_set(kinc_g5_pipeline_t *pipeline); -static kinc_g5_texture_t *lastRenderTargets[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; -static kinc_g5_pipeline_t *lastPipeline = NULL; -extern bool kinc_internal_metal_has_depth; +void iron_g5_internal_new_render_pass(iron_g5_texture_t **renderTargets, int count, bool wait, unsigned clear_flags, unsigned color, float depth); +void iron_g5_internal_pipeline_set(iron_g5_pipeline_t *pipeline); +static iron_g5_texture_t *lastRenderTargets[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; +static iron_g5_pipeline_t *lastPipeline = NULL; +extern bool iron_internal_metal_has_depth; id getMetalDevice(void); id getMetalQueue(void); id getMetalEncoder(void); id getMetalLibrary(void); -bool kinc_internal_current_render_target_has_depth(void); -static kinc_g5_raytrace_acceleration_structure_t *accel; -static kinc_g5_raytrace_pipeline_t *pipeline; -static kinc_g5_texture_t *output = NULL; -static kinc_g5_constant_buffer_t *constant_buf; +bool iron_internal_current_render_target_has_depth(void); +static iron_g5_raytrace_acceleration_structure_t *accel; +static iron_g5_raytrace_pipeline_t *pipeline; +static iron_g5_texture_t *output = NULL; +static iron_g5_constant_buffer_t *constant_buf; typedef struct inst { - kinc_matrix4x4_t m; + iron_matrix4x4_t m; int i; } inst_t; @@ -54,54 +54,54 @@ NSMutableArray *_primitive_accels; id _instance_accel; dispatch_semaphore_t _sem; -static kinc_g5_texture_t *_texpaint0; -static kinc_g5_texture_t *_texpaint1; -static kinc_g5_texture_t *_texpaint2; -static kinc_g5_texture_t *_texenv; -static kinc_g5_texture_t *_texsobol; -static kinc_g5_texture_t *_texscramble; -static kinc_g5_texture_t *_texrank; +static iron_g5_texture_t *_texpaint0; +static iron_g5_texture_t *_texpaint1; +static iron_g5_texture_t *_texpaint2; +static iron_g5_texture_t *_texenv; +static iron_g5_texture_t *_texsobol; +static iron_g5_texture_t *_texscramble; +static iron_g5_texture_t *_texrank; -static kinc_g5_vertex_buffer_t *vb[16]; -static kinc_g5_vertex_buffer_t *vb_last[16]; -static kinc_g5_index_buffer_t *ib[16]; +static iron_g5_vertex_buffer_t *vb[16]; +static iron_g5_vertex_buffer_t *vb_last[16]; +static iron_g5_index_buffer_t *ib[16]; static int vb_count = 0; static int vb_count_last = 0; static inst_t instances[1024]; static int instances_count = 0; -kinc_g5_vertex_buffer_t *currentVertexBuffer = NULL; -bool kinc_g5_transpose_mat = true; +iron_g5_vertex_buffer_t *currentVertexBuffer = NULL; +bool iron_g5_transpose_mat = true; id getMetalEncoder(void) { return render_command_encoder; } -void kinc_g5_internal_destroy_window() { +void iron_g5_internal_destroy_window() { } -void kinc_g5_internal_destroy(void) { +void iron_g5_internal_destroy(void) { } -void kinc_g5_internal_resize(int, int); +void iron_g5_internal_resize(int, int); -void kinc_internal_resize(int width, int height) { - kinc_g5_internal_resize(width, height); +void iron_internal_resize(int width, int height) { + iron_g5_internal_resize(width, height); } -void kinc_g5_internal_init(void) { +void iron_g5_internal_init(void) { } -void kinc_g5_internal_init_window(int depthBufferBits, bool vsync) { +void iron_g5_internal_init_window(int depthBufferBits, bool vsync) { depthBits = depthBufferBits; - kinc_g5_render_target_init(&fallback_render_target, 32, 32, KINC_IMAGE_FORMAT_RGBA32, 0); + iron_g5_render_target_init(&fallback_render_target, 32, 32, IRON_IMAGE_FORMAT_RGBA32, 0); } -void kinc_g5_flush(void) { +void iron_g5_flush(void) { } -bool kinc_internal_current_render_target_has_depth(void) { - return kinc_internal_metal_has_depth; +bool iron_internal_current_render_target_has_depth(void) { + return iron_internal_metal_has_depth; } static void start_render_pass(void) { @@ -128,7 +128,7 @@ static void end_render_pass(void) { render_command_encoder = nil; } -void kinc_g5_begin(kinc_g5_texture_t *renderTarget) { +void iron_g5_begin(iron_g5_texture_t *renderTarget) { CAMetalLayer *metalLayer = getMetalLayer(); drawable = [metalLayer nextDrawable]; @@ -145,10 +145,10 @@ void kinc_g5_begin(kinc_g5_texture_t *renderTarget) { descriptor.usage = MTLTextureUsageRenderTarget; id device = getMetalDevice(); depthTexture = [device newTextureWithDescriptor:descriptor]; - kinc_internal_metal_has_depth = true; + iron_internal_metal_has_depth = true; } else { - kinc_internal_metal_has_depth = false; + iron_internal_metal_has_depth = false; } id texture = drawable.texture; @@ -176,10 +176,10 @@ void kinc_g5_begin(kinc_g5_texture_t *renderTarget) { render_command_encoder = [command_buffer renderCommandEncoderWithDescriptor:renderPassDescriptor]; } -void kinc_g5_end() { +void iron_g5_end() { } -bool kinc_g5_swap_buffers(void) { +bool iron_g5_swap_buffers(void) { if (command_buffer != nil && render_command_encoder != nil) { [render_command_encoder endEncoding]; [command_buffer presentDrawable:drawable]; @@ -192,7 +192,7 @@ bool kinc_g5_swap_buffers(void) { return true; } -void kinc_g5_internal_new_render_pass(kinc_g5_texture_t **renderTargets, int count, bool wait, unsigned clear_flags, unsigned color, float depth) { +void iron_g5_internal_new_render_pass(iron_g5_texture_t **renderTargets, int count, bool wait, unsigned clear_flags, unsigned color, float depth) { if (command_buffer != nil && render_command_encoder != nil) { [render_command_encoder endEncoding]; [command_buffer commit]; @@ -208,24 +208,24 @@ void kinc_g5_internal_new_render_pass(kinc_g5_texture_t **renderTargets, int cou renderPassDescriptor.colorAttachments[i].texture = (__bridge id)fallback_render_target.impl._tex; renderPassDescriptor.depthAttachment.texture = nil; renderPassDescriptor.stencilAttachment.texture = nil; - kinc_internal_metal_has_depth = false; + iron_internal_metal_has_depth = false; } else { renderPassDescriptor.colorAttachments[i].texture = drawable.texture; renderPassDescriptor.depthAttachment.texture = depthTexture; renderPassDescriptor.stencilAttachment.texture = depthTexture; - kinc_internal_metal_has_depth = depthTexture != nil; + iron_internal_metal_has_depth = depthTexture != nil; } } else { renderPassDescriptor.colorAttachments[i].texture = (__bridge id)renderTargets[i]->impl._tex; renderPassDescriptor.depthAttachment.texture = (__bridge id)renderTargets[0]->impl._depthTex; renderPassDescriptor.stencilAttachment.texture = (__bridge id)renderTargets[0]->impl._depthTex; - kinc_internal_metal_has_depth = renderTargets[0]->impl._depthTex != nil; + iron_internal_metal_has_depth = renderTargets[0]->impl._depthTex != nil; } - if (clear_flags & KINC_G5_CLEAR_COLOR) { + if (clear_flags & IRON_G5_CLEAR_COLOR) { float red, green, blue, alpha; - kinc_color_components(color, &red, &green, &blue, &alpha); + iron_color_components(color, &red, &green, &blue, &alpha); renderPassDescriptor.colorAttachments[i].loadAction = MTLLoadActionClear; renderPassDescriptor.colorAttachments[i].storeAction = MTLStoreActionStore; renderPassDescriptor.colorAttachments[i].clearColor = MTLClearColorMake(red, green, blue, alpha); @@ -237,7 +237,7 @@ void kinc_g5_internal_new_render_pass(kinc_g5_texture_t **renderTargets, int cou } } - if (clear_flags & KINC_G5_CLEAR_DEPTH) { + if (clear_flags & IRON_G5_CLEAR_DEPTH) { renderPassDescriptor.depthAttachment.clearDepth = depth; renderPassDescriptor.depthAttachment.loadAction = MTLLoadActionClear; renderPassDescriptor.depthAttachment.storeAction = MTLStoreActionStore; @@ -257,15 +257,15 @@ void kinc_g5_internal_new_render_pass(kinc_g5_texture_t **renderTargets, int cou render_command_encoder = [command_buffer renderCommandEncoderWithDescriptor:renderPassDescriptor]; } -int kinc_g5_max_bound_textures(void) { +int iron_g5_max_bound_textures(void) { return 16; } -void kinc_g5_command_list_init(kinc_g5_command_list_t *list) { +void iron_g5_command_list_init(iron_g5_command_list_t *list) { list->impl.current_index_buffer = NULL; } -void kinc_g5_command_list_destroy(kinc_g5_command_list_t *list) {} +void iron_g5_command_list_destroy(iron_g5_command_list_t *list) {} static int formatSize(MTLPixelFormat format) { switch (format) { @@ -282,31 +282,31 @@ static int formatSize(MTLPixelFormat format) { } } -void kinc_g5_command_list_begin(kinc_g5_command_list_t *list) { +void iron_g5_command_list_begin(iron_g5_command_list_t *list) { list->impl.current_index_buffer = NULL; lastRenderTargets[0] = NULL; } -void kinc_g5_command_list_end(kinc_g5_command_list_t *list) {} +void iron_g5_command_list_end(iron_g5_command_list_t *list) {} -void kinc_g5_command_list_clear(kinc_g5_command_list_t *list, struct kinc_g5_texture *renderTarget, unsigned flags, unsigned color, float depth) { +void iron_g5_command_list_clear(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget, unsigned flags, unsigned color, float depth) { if (renderTarget->framebuffer_index >= 0) { - kinc_g5_internal_new_render_pass(NULL, 1, false, flags, color, depth); + iron_g5_internal_new_render_pass(NULL, 1, false, flags, color, depth); } else { - kinc_g5_internal_new_render_pass(&renderTarget, 1, false, flags, color, depth); + iron_g5_internal_new_render_pass(&renderTarget, 1, false, flags, color, depth); } } -void kinc_g5_command_list_render_target_to_framebuffer_barrier(kinc_g5_command_list_t *list, struct kinc_g5_texture *renderTarget) {} +void iron_g5_command_list_render_target_to_framebuffer_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) {} -void kinc_g5_command_list_framebuffer_to_render_target_barrier(kinc_g5_command_list_t *list, struct kinc_g5_texture *renderTarget) {} +void iron_g5_command_list_framebuffer_to_render_target_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) {} -void kinc_g5_command_list_draw_indexed_vertices(kinc_g5_command_list_t *list) { - kinc_g5_command_list_draw_indexed_vertices_from_to(list, 0, kinc_g5_index_buffer_count(list->impl.current_index_buffer)); +void iron_g5_command_list_draw_indexed_vertices(iron_g5_command_list_t *list) { + iron_g5_command_list_draw_indexed_vertices_from_to(list, 0, iron_g5_index_buffer_count(list->impl.current_index_buffer)); } -void kinc_g5_command_list_draw_indexed_vertices_from_to(kinc_g5_command_list_t *list, int start, int count) { +void iron_g5_command_list_draw_indexed_vertices_from_to(iron_g5_command_list_t *list, int start, int count) { id indexBuffer = (__bridge id)list->impl.current_index_buffer->impl.metal_buffer; id encoder = getMetalEncoder(); [encoder drawIndexedPrimitives:MTLPrimitiveTypeTriangle @@ -316,7 +316,7 @@ void kinc_g5_command_list_draw_indexed_vertices_from_to(kinc_g5_command_list_t * indexBufferOffset:start * 4]; } -void kinc_g5_command_list_viewport(kinc_g5_command_list_t *list, int x, int y, int width, int height) { +void iron_g5_command_list_viewport(iron_g5_command_list_t *list, int x, int y, int width, int height) { id encoder = getMetalEncoder(); MTLViewport viewport; viewport.originX = x; @@ -328,7 +328,7 @@ void kinc_g5_command_list_viewport(kinc_g5_command_list_t *list, int x, int y, i [encoder setViewport:viewport]; } -void kinc_g5_command_list_scissor(kinc_g5_command_list_t *list, int x, int y, int width, int height) { +void iron_g5_command_list_scissor(iron_g5_command_list_t *list, int x, int y, int width, int height) { id encoder = getMetalEncoder(); MTLScissorRect scissor; scissor.x = x; @@ -340,15 +340,15 @@ void kinc_g5_command_list_scissor(kinc_g5_command_list_t *list, int x, int y, in target_h = lastRenderTargets[0]->height; } else { - target_w = kinc_window_width(); - target_h = kinc_window_height(); + target_w = iron_window_width(); + target_h = iron_window_height(); } scissor.width = (x + width <= target_w) ? width : target_w - x; scissor.height = (y + height <= target_h) ? height : target_h - y; [encoder setScissorRect:scissor]; } -void kinc_g5_command_list_disable_scissor(kinc_g5_command_list_t *list) { +void iron_g5_command_list_disable_scissor(iron_g5_command_list_t *list) { id encoder = getMetalEncoder(); MTLScissorRect scissor; scissor.x = 0; @@ -358,47 +358,47 @@ void kinc_g5_command_list_disable_scissor(kinc_g5_command_list_t *list) { scissor.height = lastRenderTargets[0]->height; } else { - scissor.width = kinc_window_width(); - scissor.height = kinc_window_height(); + scissor.width = iron_window_width(); + scissor.height = iron_window_height(); } [encoder setScissorRect:scissor]; } -void kinc_g5_command_list_set_pipeline(kinc_g5_command_list_t *list, struct kinc_g5_pipeline *pipeline) { - kinc_g5_internal_pipeline_set(pipeline); +void iron_g5_command_list_set_pipeline(iron_g5_command_list_t *list, struct iron_g5_pipeline *pipeline) { + iron_g5_internal_pipeline_set(pipeline); lastPipeline = pipeline; } -void kinc_g5_command_list_set_vertex_buffer(kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer *buffer) { - kinc_g5_internal_vertex_buffer_set(buffer); +void iron_g5_command_list_set_vertex_buffer(iron_g5_command_list_t *list, struct iron_g5_vertex_buffer *buffer) { + iron_g5_internal_vertex_buffer_set(buffer); } -void kinc_g5_command_list_set_index_buffer(kinc_g5_command_list_t *list, struct kinc_g5_index_buffer *buffer) { +void iron_g5_command_list_set_index_buffer(iron_g5_command_list_t *list, struct iron_g5_index_buffer *buffer) { list->impl.current_index_buffer = buffer; } -void kinc_g5_command_list_set_render_targets(kinc_g5_command_list_t *list, struct kinc_g5_texture **targets, int count) { +void iron_g5_command_list_set_render_targets(iron_g5_command_list_t *list, struct iron_g5_texture **targets, int count) { if (targets[0]->framebuffer_index >= 0) { for (int i = 0; i < 8; ++i) lastRenderTargets[i] = NULL; - kinc_g5_internal_new_render_pass(NULL, 1, false, 0, 0, 0.0f); + iron_g5_internal_new_render_pass(NULL, 1, false, 0, 0, 0.0f); } else { for (int i = 0; i < count; ++i) lastRenderTargets[i] = targets[i]; for (int i = count; i < 8; ++i) lastRenderTargets[i] = NULL; - kinc_g5_internal_new_render_pass(targets, count, false, 0, 0, 0.0f); + iron_g5_internal_new_render_pass(targets, count, false, 0, 0, 0.0f); } } -void kinc_g5_command_list_upload_index_buffer(kinc_g5_command_list_t *list, struct kinc_g5_index_buffer *buffer) {} +void iron_g5_command_list_upload_index_buffer(iron_g5_command_list_t *list, struct iron_g5_index_buffer *buffer) {} -void kinc_g5_command_list_upload_vertex_buffer(kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer *buffer) {} +void iron_g5_command_list_upload_vertex_buffer(iron_g5_command_list_t *list, struct iron_g5_vertex_buffer *buffer) {} -void kinc_g5_command_list_upload_texture(kinc_g5_command_list_t *list, struct kinc_g5_texture *texture) {} +void iron_g5_command_list_upload_texture(iron_g5_command_list_t *list, struct iron_g5_texture *texture) {} -void kinc_g5_command_list_get_render_target_pixels(kinc_g5_command_list_t *list, kinc_g5_texture_t *render_target, uint8_t *data) { +void iron_g5_command_list_get_render_target_pixels(iron_g5_command_list_t *list, iron_g5_texture_t *render_target, uint8_t *data) { // Create readback buffer if (render_target->impl._texReadback == NULL) { id device = getMetalDevice(); @@ -439,89 +439,89 @@ void kinc_g5_command_list_get_render_target_pixels(kinc_g5_command_list_t *list, [tex getBytes:data bytesPerRow:formatByteSize * render_target->width fromRegion:region mipmapLevel:0]; } -void kinc_g5_command_list_execute(kinc_g5_command_list_t *list) { +void iron_g5_command_list_execute(iron_g5_command_list_t *list) { if (lastRenderTargets[0] == NULL) { - kinc_g5_internal_new_render_pass(NULL, 1, false, 0, 0, 0.0f); + iron_g5_internal_new_render_pass(NULL, 1, false, 0, 0, 0.0f); } else { int count = 1; while (lastRenderTargets[count] != NULL) count++; - kinc_g5_internal_new_render_pass(lastRenderTargets, count, false, 0, 0, 0.0f); + iron_g5_internal_new_render_pass(lastRenderTargets, count, false, 0, 0, 0.0f); } if (lastPipeline != NULL) - kinc_g5_internal_pipeline_set(lastPipeline); + iron_g5_internal_pipeline_set(lastPipeline); } -void kinc_g5_command_list_wait_for_execution_to_finish(kinc_g5_command_list_t *list) { +void iron_g5_command_list_wait_for_execution_to_finish(iron_g5_command_list_t *list) { id commandQueue = getMetalQueue(); id commandBuffer = [commandQueue commandBuffer]; [commandBuffer commit]; [commandBuffer waitUntilCompleted]; } -void kinc_g5_command_list_set_vertex_constant_buffer(kinc_g5_command_list_t *list, struct kinc_g5_constant_buffer *buffer, int offset, size_t size) { +void iron_g5_command_list_set_vertex_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size) { id buf = (__bridge id)buffer->impl._buffer; id encoder = getMetalEncoder(); [encoder setVertexBuffer:buf offset:offset atIndex:1]; } -void kinc_g5_command_list_set_fragment_constant_buffer(kinc_g5_command_list_t *list, struct kinc_g5_constant_buffer *buffer, int offset, size_t size) { +void iron_g5_command_list_set_fragment_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size) { id buf = (__bridge id)buffer->impl._buffer; id encoder = getMetalEncoder(); [encoder setFragmentBuffer:buf offset:offset atIndex:0]; } -void kinc_g5_command_list_set_compute_constant_buffer(kinc_g5_command_list_t *list, struct kinc_g5_constant_buffer *buffer, int offset, size_t size) { +void iron_g5_command_list_set_compute_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size) { assert(compute_command_encoder != nil); id buf = (__bridge id)buffer->impl._buffer; [compute_command_encoder setBuffer:buf offset:offset atIndex:1]; } -void kinc_g5_command_list_render_target_to_texture_barrier(kinc_g5_command_list_t *list, struct kinc_g5_texture *renderTarget) { +void iron_g5_command_list_render_target_to_texture_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) { } -void kinc_g5_command_list_texture_to_render_target_barrier(kinc_g5_command_list_t *list, struct kinc_g5_texture *renderTarget) {} +void iron_g5_command_list_texture_to_render_target_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) {} -void kinc_g5_command_list_set_texture(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_texture_t *texture) { +void iron_g5_command_list_set_texture(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *texture) { id tex = (__bridge id)texture->impl._tex; if (compute_command_encoder != nil) { - [compute_command_encoder setTexture:tex atIndex:unit.stages[KINC_G5_SHADER_TYPE_COMPUTE]]; + [compute_command_encoder setTexture:tex atIndex:unit.stages[IRON_G5_SHADER_TYPE_COMPUTE]]; } else { - if (unit.stages[KINC_G5_SHADER_TYPE_VERTEX] >= 0) { - [render_command_encoder setVertexTexture:tex atIndex:unit.stages[KINC_G5_SHADER_TYPE_VERTEX]]; + if (unit.stages[IRON_G5_SHADER_TYPE_VERTEX] >= 0) { + [render_command_encoder setVertexTexture:tex atIndex:unit.stages[IRON_G5_SHADER_TYPE_VERTEX]]; } - if (unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT] >= 0) { - [render_command_encoder setFragmentTexture:tex atIndex:unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT]]; + if (unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] >= 0) { + [render_command_encoder setFragmentTexture:tex atIndex:unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]]; } } } -void kinc_g5_command_list_set_texture_from_render_target_depth(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_texture_t *target) { +void iron_g5_command_list_set_texture_from_render_target_depth(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *target) { id encoder = getMetalEncoder(); id depth_tex = (__bridge id)target->impl._depthTex; - if (unit.stages[KINC_G5_SHADER_TYPE_VERTEX] >= 0) { - [encoder setVertexTexture:depth_tex atIndex:unit.stages[KINC_G5_SHADER_TYPE_VERTEX]]; + if (unit.stages[IRON_G5_SHADER_TYPE_VERTEX] >= 0) { + [encoder setVertexTexture:depth_tex atIndex:unit.stages[IRON_G5_SHADER_TYPE_VERTEX]]; } - if (unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT] >= 0) { - [encoder setFragmentTexture:depth_tex atIndex:unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT]]; + if (unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] >= 0) { + [encoder setFragmentTexture:depth_tex atIndex:unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]]; } } -void kinc_g5_command_list_set_sampler(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_sampler_t *sampler) { +void iron_g5_command_list_set_sampler(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_sampler_t *sampler) { id encoder = getMetalEncoder(); id mtl_sampler = (__bridge id)sampler->impl.sampler; - if (unit.stages[KINC_G5_SHADER_TYPE_VERTEX] >= 0) { - [encoder setVertexSamplerState:mtl_sampler atIndex:unit.stages[KINC_G5_SHADER_TYPE_VERTEX]]; + if (unit.stages[IRON_G5_SHADER_TYPE_VERTEX] >= 0) { + [encoder setVertexSamplerState:mtl_sampler atIndex:unit.stages[IRON_G5_SHADER_TYPE_VERTEX]]; } - if (unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT] >= 0) { - [encoder setFragmentSamplerState:mtl_sampler atIndex:unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT]]; + if (unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] >= 0) { + [encoder setFragmentSamplerState:mtl_sampler atIndex:unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]]; } } -void kinc_g5_command_list_set_compute_shader(kinc_g5_command_list_t *list, kinc_g5_compute_shader *shader) { +void iron_g5_command_list_set_compute_shader(iron_g5_command_list_t *list, iron_g5_compute_shader *shader) { if (compute_command_encoder == nil) { end_render_pass(); compute_command_encoder = [command_buffer computeCommandEncoder]; @@ -531,7 +531,7 @@ void kinc_g5_command_list_set_compute_shader(kinc_g5_command_list_t *list, kinc_ [compute_command_encoder setComputePipelineState:pipeline]; } -void kinc_g5_command_list_compute(kinc_g5_command_list_t *list, int x, int y, int z) { +void iron_g5_command_list_compute(iron_g5_command_list_t *list, int x, int y, int z) { assert(compute_command_encoder != nil); MTLSize perGrid; @@ -551,7 +551,7 @@ void kinc_g5_command_list_compute(kinc_g5_command_list_t *list, int x, int y, in start_render_pass(); } -void kinc_g5_compute_shader_init(kinc_g5_compute_shader *shader, void *_data, int length) { +void iron_g5_compute_shader_init(iron_g5_compute_shader *shader, void *_data, int length) { shader->impl.name[0] = 0; { @@ -599,7 +599,7 @@ void kinc_g5_compute_shader_init(kinc_g5_compute_shader *shader, void *_data, in shader->impl._reflection = (__bridge_retained void *)reflection; } -void kinc_g5_compute_shader_destroy(kinc_g5_compute_shader *shader) { +void iron_g5_compute_shader_destroy(iron_g5_compute_shader *shader) { id function = (__bridge_transfer id)shader->impl._function; function = nil; shader->impl._function = NULL; @@ -613,8 +613,8 @@ void kinc_g5_compute_shader_destroy(kinc_g5_compute_shader *shader) { shader->impl._reflection = NULL; } -kinc_g5_constant_location_t kinc_g5_compute_shader_get_constant_location(kinc_g5_compute_shader *shader, const char *name) { - kinc_g5_constant_location_t location; +iron_g5_constant_location_t iron_g5_compute_shader_get_constant_location(iron_g5_compute_shader *shader, const char *name) { + iron_g5_constant_location_t location; location.impl.vertexOffset = -1; location.impl.fragmentOffset = -1; location.impl.computeOffset = -1; @@ -639,122 +639,122 @@ kinc_g5_constant_location_t kinc_g5_compute_shader_get_constant_location(kinc_g5 return location; } -kinc_g5_texture_unit_t kinc_g5_compute_shader_get_texture_unit(kinc_g5_compute_shader *shader, const char *name) { - kinc_g5_texture_unit_t unit; - for (int i = 0; i < KINC_G5_SHADER_TYPE_COUNT; ++i) { +iron_g5_texture_unit_t iron_g5_compute_shader_get_texture_unit(iron_g5_compute_shader *shader, const char *name) { + iron_g5_texture_unit_t unit; + for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { unit.stages[i] = -1; } MTLComputePipelineReflection *reflection = (__bridge MTLComputePipelineReflection *)shader->impl._reflection; for (MTLArgument *arg in reflection.arguments) { if ([arg type] == MTLArgumentTypeTexture && strcmp([[arg name] UTF8String], name) == 0) { - unit.stages[KINC_G5_SHADER_TYPE_COMPUTE] = (int)[arg index]; + unit.stages[IRON_G5_SHADER_TYPE_COMPUTE] = (int)[arg index]; } } return unit; } -static MTLBlendFactor convert_blending_factor(kinc_g5_blending_factor_t factor) { +static MTLBlendFactor convert_blending_factor(iron_g5_blending_factor_t factor) { switch (factor) { - case KINC_G5_BLEND_ONE: + case IRON_G5_BLEND_ONE: return MTLBlendFactorOne; - case KINC_G5_BLEND_ZERO: + case IRON_G5_BLEND_ZERO: return MTLBlendFactorZero; - case KINC_G5_BLEND_SOURCE_ALPHA: + case IRON_G5_BLEND_SOURCE_ALPHA: return MTLBlendFactorSourceAlpha; - case KINC_G5_BLEND_DEST_ALPHA: + case IRON_G5_BLEND_DEST_ALPHA: return MTLBlendFactorDestinationAlpha; - case KINC_G5_BLEND_INV_SOURCE_ALPHA: + case IRON_G5_BLEND_INV_SOURCE_ALPHA: return MTLBlendFactorOneMinusSourceAlpha; - case KINC_G5_BLEND_INV_DEST_ALPHA: + case IRON_G5_BLEND_INV_DEST_ALPHA: return MTLBlendFactorOneMinusDestinationAlpha; - case KINC_G5_BLEND_SOURCE_COLOR: + case IRON_G5_BLEND_SOURCE_COLOR: return MTLBlendFactorSourceColor; - case KINC_G5_BLEND_DEST_COLOR: + case IRON_G5_BLEND_DEST_COLOR: return MTLBlendFactorDestinationColor; - case KINC_G5_BLEND_INV_SOURCE_COLOR: + case IRON_G5_BLEND_INV_SOURCE_COLOR: return MTLBlendFactorOneMinusSourceColor; - case KINC_G5_BLEND_INV_DEST_COLOR: + case IRON_G5_BLEND_INV_DEST_COLOR: return MTLBlendFactorOneMinusDestinationColor; - case KINC_G5_BLEND_CONSTANT: + case IRON_G5_BLEND_CONSTANT: return MTLBlendFactorBlendColor; - case KINC_G5_BLEND_INV_CONSTANT: + case IRON_G5_BLEND_INV_CONSTANT: return MTLBlendFactorOneMinusBlendColor; } } -static MTLBlendOperation convert_blending_operation(kinc_g5_blending_operation_t op) { +static MTLBlendOperation convert_blending_operation(iron_g5_blending_operation_t op) { switch (op) { - case KINC_G5_BLENDOP_ADD: + case IRON_G5_BLENDOP_ADD: return MTLBlendOperationAdd; - case KINC_G5_BLENDOP_SUBTRACT: + case IRON_G5_BLENDOP_SUBTRACT: return MTLBlendOperationSubtract; - case KINC_G5_BLENDOP_REVERSE_SUBTRACT: + case IRON_G5_BLENDOP_REVERSE_SUBTRACT: return MTLBlendOperationReverseSubtract; - case KINC_G5_BLENDOP_MIN: + case IRON_G5_BLENDOP_MIN: return MTLBlendOperationMin; - case KINC_G5_BLENDOP_MAX: + case IRON_G5_BLENDOP_MAX: return MTLBlendOperationMax; } } -static MTLCompareFunction convert_compare_mode(kinc_g5_compare_mode_t compare) { +static MTLCompareFunction convert_compare_mode(iron_g5_compare_mode_t compare) { switch (compare) { - case KINC_G5_COMPARE_MODE_ALWAYS: + case IRON_G5_COMPARE_MODE_ALWAYS: return MTLCompareFunctionAlways; - case KINC_G5_COMPARE_MODE_NEVER: + case IRON_G5_COMPARE_MODE_NEVER: return MTLCompareFunctionNever; - case KINC_G5_COMPARE_MODE_EQUAL: + case IRON_G5_COMPARE_MODE_EQUAL: return MTLCompareFunctionEqual; - case KINC_G5_COMPARE_MODE_NOT_EQUAL: + case IRON_G5_COMPARE_MODE_NOT_EQUAL: return MTLCompareFunctionNotEqual; - case KINC_G5_COMPARE_MODE_LESS: + case IRON_G5_COMPARE_MODE_LESS: return MTLCompareFunctionLess; - case KINC_G5_COMPARE_MODE_LESS_EQUAL: + case IRON_G5_COMPARE_MODE_LESS_EQUAL: return MTLCompareFunctionLessEqual; - case KINC_G5_COMPARE_MODE_GREATER: + case IRON_G5_COMPARE_MODE_GREATER: return MTLCompareFunctionGreater; - case KINC_G5_COMPARE_MODE_GREATER_EQUAL: + case IRON_G5_COMPARE_MODE_GREATER_EQUAL: return MTLCompareFunctionGreaterEqual; } } -static MTLCullMode convert_cull_mode(kinc_g5_cull_mode_t cull) { +static MTLCullMode convert_cull_mode(iron_g5_cull_mode_t cull) { switch (cull) { - case KINC_G5_CULL_MODE_CLOCKWISE: + case IRON_G5_CULL_MODE_CLOCKWISE: return MTLCullModeFront; - case KINC_G5_CULL_MODE_COUNTERCLOCKWISE: + case IRON_G5_CULL_MODE_COUNTERCLOCKWISE: return MTLCullModeBack; - case KINC_G5_CULL_MODE_NEVER: + case IRON_G5_CULL_MODE_NEVER: return MTLCullModeNone; } } -static MTLPixelFormat convert_render_target_format(kinc_image_format_t format) { +static MTLPixelFormat convert_render_target_format(iron_image_format_t format) { switch (format) { - case KINC_IMAGE_FORMAT_RGBA128: + case IRON_IMAGE_FORMAT_RGBA128: return MTLPixelFormatRGBA32Float; - case KINC_IMAGE_FORMAT_RGBA64: + case IRON_IMAGE_FORMAT_RGBA64: return MTLPixelFormatRGBA16Float; - case KINC_IMAGE_FORMAT_R32: + case IRON_IMAGE_FORMAT_R32: return MTLPixelFormatR32Float; - case KINC_IMAGE_FORMAT_R16: + case IRON_IMAGE_FORMAT_R16: return MTLPixelFormatR16Float; - case KINC_IMAGE_FORMAT_R8: + case IRON_IMAGE_FORMAT_R8: return MTLPixelFormatR8Unorm; - case KINC_IMAGE_FORMAT_RGBA32: + case IRON_IMAGE_FORMAT_RGBA32: default: return MTLPixelFormatBGRA8Unorm; } } -void kinc_g5_pipeline_init(kinc_g5_pipeline_t *pipeline) { +void iron_g5_pipeline_init(iron_g5_pipeline_t *pipeline) { memset(&pipeline->impl, 0, sizeof(pipeline->impl)); - kinc_g5_internal_pipeline_set_defaults(pipeline); + iron_g5_internal_pipeline_set_defaults(pipeline); } -void kinc_g5_pipeline_destroy(kinc_g5_pipeline_t *pipeline) { +void iron_g5_pipeline_destroy(iron_g5_pipeline_t *pipeline) { pipeline->impl._reflection = NULL; pipeline->impl._depthStencil = NULL; @@ -788,15 +788,15 @@ static int findAttributeIndex(NSArray *attributes, const c return -1; } -void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipeline) { +void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipeline) { MTLRenderPipelineDescriptor *renderPipelineDesc = [[MTLRenderPipelineDescriptor alloc] init]; renderPipelineDesc.vertexFunction = (__bridge id)pipeline->vertex_shader->impl.mtlFunction; renderPipelineDesc.fragmentFunction = (__bridge id)pipeline->fragment_shader->impl.mtlFunction; for (int i = 0; i < pipeline->color_attachment_count; ++i) { renderPipelineDesc.colorAttachments[i].pixelFormat = convert_render_target_format(pipeline->color_attachment[i]); renderPipelineDesc.colorAttachments[i].blendingEnabled = - pipeline->blend_source != KINC_G5_BLEND_ONE || pipeline->blend_destination != KINC_G5_BLEND_ZERO || - pipeline->alpha_blend_source != KINC_G5_BLEND_ONE || pipeline->alpha_blend_destination != KINC_G5_BLEND_ZERO; + pipeline->blend_source != IRON_G5_BLEND_ONE || pipeline->blend_destination != IRON_G5_BLEND_ZERO || + pipeline->alpha_blend_source != IRON_G5_BLEND_ONE || pipeline->alpha_blend_destination != IRON_G5_BLEND_ZERO; renderPipelineDesc.colorAttachments[i].sourceRGBBlendFactor = convert_blending_factor(pipeline->blend_source); renderPipelineDesc.colorAttachments[i].destinationRGBBlendFactor = convert_blending_factor(pipeline->blend_destination); renderPipelineDesc.colorAttachments[i].rgbBlendOperation = convert_blending_operation(pipeline->blend_operation); @@ -819,7 +819,7 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipeline) { int index = findAttributeIndex(renderPipelineDesc.vertexFunction.vertexAttributes, pipeline->input_layout->elements[i].name); if (index < 0) { - kinc_log("Could not find vertex attribute %s\n", pipeline->input_layout->elements[i].name); + iron_log("Could not find vertex attribute %s\n", pipeline->input_layout->elements[i].name); } if (index >= 0) { @@ -827,28 +827,28 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipeline) { vertexDescriptor.attributes[index].offset = offset; } - offset += kinc_g5_vertex_data_size(pipeline->input_layout->elements[i].data); + offset += iron_g5_vertex_data_size(pipeline->input_layout->elements[i].data); if (index >= 0) { switch (pipeline->input_layout->elements[i].data) { - case KINC_G5_VERTEX_DATA_F32_1X: + case IRON_G5_VERTEX_DATA_F32_1X: vertexDescriptor.attributes[index].format = MTLVertexFormatFloat; break; - case KINC_G5_VERTEX_DATA_F32_2X: + case IRON_G5_VERTEX_DATA_F32_2X: vertexDescriptor.attributes[index].format = MTLVertexFormatFloat2; break; - case KINC_G5_VERTEX_DATA_F32_3X: + case IRON_G5_VERTEX_DATA_F32_3X: vertexDescriptor.attributes[index].format = MTLVertexFormatFloat3; break; - case KINC_G5_VERTEX_DATA_F32_4X: + case IRON_G5_VERTEX_DATA_F32_4X: vertexDescriptor.attributes[index].format = MTLVertexFormatFloat4; break; - case KINC_G5_VERTEX_DATA_U8_4X_NORM: + case IRON_G5_VERTEX_DATA_U8_4X_NORM: vertexDescriptor.attributes[index].format = MTLVertexFormatUChar4Normalized; break; - case KINC_G5_VERTEX_DATA_I16_2X_NORM: + case IRON_G5_VERTEX_DATA_I16_2X_NORM: vertexDescriptor.attributes[index].format = MTLVertexFormatShort2Normalized; break; - case KINC_G5_VERTEX_DATA_I16_4X_NORM: + case IRON_G5_VERTEX_DATA_I16_4X_NORM: vertexDescriptor.attributes[index].format = MTLVertexFormatShort4Normalized; break; } @@ -894,9 +894,9 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipeline) { pipeline->impl._depthStencilNone = (__bridge_retained void *)[device newDepthStencilStateWithDescriptor:depthStencilDescriptor]; } -void kinc_g5_internal_pipeline_set(kinc_g5_pipeline_t *pipeline) { +void iron_g5_internal_pipeline_set(iron_g5_pipeline_t *pipeline) { id encoder = getMetalEncoder(); - if (kinc_internal_current_render_target_has_depth()) { + if (iron_internal_current_render_target_has_depth()) { id pipe = (__bridge id)pipeline->impl._pipelineDepth; [encoder setRenderPipelineState:pipe]; id depthStencil = (__bridge id)pipeline->impl._depthStencil; @@ -912,12 +912,12 @@ void kinc_g5_internal_pipeline_set(kinc_g5_pipeline_t *pipeline) { [encoder setCullMode:convert_cull_mode(pipeline->cull_mode)]; } -kinc_g5_constant_location_t kinc_g5_pipeline_get_constant_location(kinc_g5_pipeline_t *pipeline, const char *name) { +iron_g5_constant_location_t iron_g5_pipeline_get_constant_location(iron_g5_pipeline_t *pipeline, const char *name) { if (strcmp(name, "bias") == 0) { name = "bias0"; } - kinc_g5_constant_location_t location; + iron_g5_constant_location_t location; location.impl.vertexOffset = -1; location.impl.fragmentOffset = -1; location.impl.computeOffset = -1; @@ -957,23 +957,23 @@ kinc_g5_constant_location_t kinc_g5_pipeline_get_constant_location(kinc_g5_pipel return location; } -kinc_g5_texture_unit_t kinc_g5_pipeline_get_texture_unit(kinc_g5_pipeline_t *pipeline, const char *name) { - kinc_g5_texture_unit_t unit = {0}; - for (int i = 0; i < KINC_G5_SHADER_TYPE_COUNT; ++i) { +iron_g5_texture_unit_t iron_g5_pipeline_get_texture_unit(iron_g5_pipeline_t *pipeline, const char *name) { + iron_g5_texture_unit_t unit = {0}; + for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { unit.stages[i] = -1; } MTLRenderPipelineReflection *reflection = (__bridge MTLRenderPipelineReflection *)pipeline->impl._reflection; for (MTLArgument *arg in reflection.fragmentArguments) { if ([arg type] == MTLArgumentTypeTexture && strcmp([[arg name] UTF8String], name) == 0) { - unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT] = (int)[arg index]; + unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] = (int)[arg index]; break; } } for (MTLArgument *arg in reflection.vertexArguments) { if ([arg type] == MTLArgumentTypeTexture && strcmp([[arg name] UTF8String], name) == 0) { - unit.stages[KINC_G5_SHADER_TYPE_VERTEX] = (int)[arg index]; + unit.stages[IRON_G5_SHADER_TYPE_VERTEX] = (int)[arg index]; break; } } @@ -981,15 +981,15 @@ kinc_g5_texture_unit_t kinc_g5_pipeline_get_texture_unit(kinc_g5_pipeline_t *pip return unit; } -static MTLSamplerAddressMode convert_addressing(kinc_g5_texture_addressing_t mode) { +static MTLSamplerAddressMode convert_addressing(iron_g5_texture_addressing_t mode) { switch (mode) { - case KINC_G5_TEXTURE_ADDRESSING_REPEAT: + case IRON_G5_TEXTURE_ADDRESSING_REPEAT: return MTLSamplerAddressModeRepeat; - case KINC_G5_TEXTURE_ADDRESSING_BORDER: + case IRON_G5_TEXTURE_ADDRESSING_BORDER: return MTLSamplerAddressModeClampToBorderColor; - case KINC_G5_TEXTURE_ADDRESSING_CLAMP: + case IRON_G5_TEXTURE_ADDRESSING_CLAMP: return MTLSamplerAddressModeClampToEdge; - case KINC_G5_TEXTURE_ADDRESSING_MIRROR: + case IRON_G5_TEXTURE_ADDRESSING_MIRROR: return MTLSamplerAddressModeMirrorRepeat; default: assert(false); @@ -997,13 +997,13 @@ static MTLSamplerAddressMode convert_addressing(kinc_g5_texture_addressing_t mod } } -static MTLSamplerMipFilter convert_mipmap_mode(kinc_g5_mipmap_filter_t filter) { +static MTLSamplerMipFilter convert_mipmap_mode(iron_g5_mipmap_filter_t filter) { switch (filter) { - case KINC_G5_MIPMAP_FILTER_NONE: + case IRON_G5_MIPMAP_FILTER_NONE: return MTLSamplerMipFilterNotMipmapped; - case KINC_G5_MIPMAP_FILTER_POINT: + case IRON_G5_MIPMAP_FILTER_POINT: return MTLSamplerMipFilterNearest; - case KINC_G5_MIPMAP_FILTER_LINEAR: + case IRON_G5_MIPMAP_FILTER_LINEAR: return MTLSamplerMipFilterLinear; default: assert(false); @@ -1011,13 +1011,13 @@ static MTLSamplerMipFilter convert_mipmap_mode(kinc_g5_mipmap_filter_t filter) { } } -static MTLSamplerMinMagFilter convert_texture_filter(kinc_g5_texture_filter_t filter) { +static MTLSamplerMinMagFilter convert_texture_filter(iron_g5_texture_filter_t filter) { switch (filter) { - case KINC_G5_TEXTURE_FILTER_POINT: + case IRON_G5_TEXTURE_FILTER_POINT: return MTLSamplerMinMagFilterNearest; - case KINC_G5_TEXTURE_FILTER_LINEAR: + case IRON_G5_TEXTURE_FILTER_LINEAR: return MTLSamplerMinMagFilterLinear; - case KINC_G5_TEXTURE_FILTER_ANISOTROPIC: + case IRON_G5_TEXTURE_FILTER_ANISOTROPIC: return MTLSamplerMinMagFilterLinear; // ? default: assert(false); @@ -1025,7 +1025,7 @@ static MTLSamplerMinMagFilter convert_texture_filter(kinc_g5_texture_filter_t fi } } -void kinc_g5_sampler_init(kinc_g5_sampler_t *sampler, const kinc_g5_sampler_options_t *options) { +void iron_g5_sampler_init(iron_g5_sampler_t *sampler, const iron_g5_sampler_options_t *options) { id device = getMetalDevice(); MTLSamplerDescriptor *desc = (MTLSamplerDescriptor *)[[MTLSamplerDescriptor alloc] init]; @@ -1042,18 +1042,18 @@ void kinc_g5_sampler_init(kinc_g5_sampler_t *sampler, const kinc_g5_sampler_opti sampler->impl.sampler = (__bridge_retained void *)[device newSamplerStateWithDescriptor:desc]; } -void kinc_g5_sampler_destroy(kinc_g5_sampler_t *sampler) { +void iron_g5_sampler_destroy(iron_g5_sampler_t *sampler) { id mtl_sampler = (__bridge_transfer id)sampler->impl.sampler; mtl_sampler = nil; } -void kinc_g5_shader_destroy(kinc_g5_shader_t *shader) { +void iron_g5_shader_destroy(iron_g5_shader_t *shader) { id function = (__bridge_transfer id)shader->impl.mtlFunction; function = nil; shader->impl.mtlFunction = NULL; } -void kinc_g5_shader_init(kinc_g5_shader_t *shader, const void *source, size_t length, kinc_g5_shader_type_t type) { +void iron_g5_shader_init(iron_g5_shader_t *shader, const void *source, size_t length, iron_g5_shader_type_t type) { shader->impl.name[0] = 0; { @@ -1085,7 +1085,7 @@ void kinc_g5_shader_init(kinc_g5_shader_t *shader, const void *source, size_t le NSError *error = nil; library = [device newLibraryWithSource:[[NSString alloc] initWithBytes:data length:length encoding:NSUTF8StringEncoding] options:nil error:&error]; if (library == nil) { - kinc_error("%s", error.localizedDescription.UTF8String); + iron_error("%s", error.localizedDescription.UTF8String); } } shader->impl.mtlFunction = (__bridge_retained void *)[library newFunctionWithName:[NSString stringWithCString:shader->impl.name @@ -1094,13 +1094,13 @@ void kinc_g5_shader_init(kinc_g5_shader_t *shader, const void *source, size_t le assert(shader->impl.mtlFunction); } -bool kinc_g5_raytrace_supported() { +bool iron_g5_raytrace_supported() { id device = getMetalDevice(); return device.supportsRaytracing; } -void kinc_g5_raytrace_pipeline_init(kinc_g5_raytrace_pipeline_t *pipeline, kinc_g5_command_list_t *command_list, void *ray_shader, int ray_shader_size, - kinc_g5_constant_buffer_t *constant_buffer) { +void iron_g5_raytrace_pipeline_init(iron_g5_raytrace_pipeline_t *pipeline, iron_g5_command_list_t *command_list, void *ray_shader, int ray_shader_size, + iron_g5_constant_buffer_t *constant_buffer) { id device = getMetalDevice(); if (!device.supportsRaytracing) return; constant_buf = constant_buffer; @@ -1110,7 +1110,7 @@ void kinc_g5_raytrace_pipeline_init(kinc_g5_raytrace_pipeline_t *pipeline, kinc_ options:nil error:&error]; if (library == nil) { - kinc_error("%s", error.localizedDescription.UTF8String); + iron_error("%s", error.localizedDescription.UTF8String); } MTLComputePipelineDescriptor *descriptor = [[MTLComputePipelineDescriptor alloc] init]; @@ -1120,7 +1120,7 @@ void kinc_g5_raytrace_pipeline_init(kinc_g5_raytrace_pipeline_t *pipeline, kinc_ _sem = dispatch_semaphore_create(2); } -void kinc_g5_raytrace_pipeline_destroy(kinc_g5_raytrace_pipeline_t *pipeline) { +void iron_g5_raytrace_pipeline_destroy(iron_g5_raytrace_pipeline_t *pipeline) { } id create_acceleration_sctructure(MTLAccelerationStructureDescriptor *descriptor) { @@ -1154,13 +1154,13 @@ id create_acceleration_sctructure(MTLAccelerationStruc return compacted_acceleration_structure; } -void kinc_g5_raytrace_acceleration_structure_init(kinc_g5_raytrace_acceleration_structure_t *accel) { +void iron_g5_raytrace_acceleration_structure_init(iron_g5_raytrace_acceleration_structure_t *accel) { vb_count = 0; instances_count = 0; } -void kinc_g5_raytrace_acceleration_structure_add(kinc_g5_raytrace_acceleration_structure_t *accel, kinc_g5_vertex_buffer_t *_vb, kinc_g5_index_buffer_t *_ib, - kinc_matrix4x4_t _transform) { +void iron_g5_raytrace_acceleration_structure_add(iron_g5_raytrace_acceleration_structure_t *accel, iron_g5_vertex_buffer_t *_vb, iron_g5_index_buffer_t *_ib, + iron_matrix4x4_t _transform) { int vb_i = -1; for (int i = 0; i < vb_count; ++i) { @@ -1181,18 +1181,18 @@ void kinc_g5_raytrace_acceleration_structure_add(kinc_g5_raytrace_acceleration_s instances_count++; } -void _kinc_g5_raytrace_acceleration_structure_destroy_bottom(kinc_g5_raytrace_acceleration_structure_t *accel) { +void _iron_g5_raytrace_acceleration_structure_destroy_bottom(iron_g5_raytrace_acceleration_structure_t *accel) { // for (int i = 0; i < vb_count_last; ++i) { // } _primitive_accels = nil; } -void _kinc_g5_raytrace_acceleration_structure_destroy_top(kinc_g5_raytrace_acceleration_structure_t *accel) { +void _iron_g5_raytrace_acceleration_structure_destroy_top(iron_g5_raytrace_acceleration_structure_t *accel) { _instance_accel = nil; } -void kinc_g5_raytrace_acceleration_structure_build(kinc_g5_raytrace_acceleration_structure_t *accel, kinc_g5_command_list_t *command_list, - kinc_g5_vertex_buffer_t *_vb_full, kinc_g5_index_buffer_t *_ib_full) { +void iron_g5_raytrace_acceleration_structure_build(iron_g5_raytrace_acceleration_structure_t *accel, iron_g5_command_list_t *command_list, + iron_g5_vertex_buffer_t *_vb_full, iron_g5_index_buffer_t *_ib_full) { bool build_bottom = false; for (int i = 0; i < 16; ++i) { @@ -1204,9 +1204,9 @@ void kinc_g5_raytrace_acceleration_structure_build(kinc_g5_raytrace_acceleration if (vb_count_last > 0) { if (build_bottom) { - _kinc_g5_raytrace_acceleration_structure_destroy_bottom(accel); + _iron_g5_raytrace_acceleration_structure_destroy_bottom(accel); } - _kinc_g5_raytrace_acceleration_structure_destroy_top(accel); + _iron_g5_raytrace_acceleration_structure_destroy_top(accel); } vb_count_last = vb_count; @@ -1254,9 +1254,9 @@ void kinc_g5_raytrace_acceleration_structure_build(kinc_g5_raytrace_acceleration _instance_accel = create_acceleration_sctructure(inst_accel_descriptor); } -void kinc_g5_raytrace_acceleration_structure_destroy(kinc_g5_raytrace_acceleration_structure_t *accel) {} +void iron_g5_raytrace_acceleration_structure_destroy(iron_g5_raytrace_acceleration_structure_t *accel) {} -void kinc_g5_raytrace_set_textures(kinc_g5_texture_t *texpaint0, kinc_g5_texture_t *texpaint1, kinc_g5_texture_t *texpaint2, kinc_g5_texture_t *texenv, kinc_g5_texture_t *texsobol, kinc_g5_texture_t *texscramble, kinc_g5_texture_t *texrank) { +void iron_g5_raytrace_set_textures(iron_g5_texture_t *texpaint0, iron_g5_texture_t *texpaint1, iron_g5_texture_t *texpaint2, iron_g5_texture_t *texenv, iron_g5_texture_t *texsobol, iron_g5_texture_t *texscramble, iron_g5_texture_t *texrank) { _texpaint0 = texpaint0; _texpaint1 = texpaint1; _texpaint2 = texpaint2; @@ -1266,19 +1266,19 @@ void kinc_g5_raytrace_set_textures(kinc_g5_texture_t *texpaint0, kinc_g5_texture _texrank = texrank; } -void kinc_g5_raytrace_set_acceleration_structure(kinc_g5_raytrace_acceleration_structure_t *_accel) { +void iron_g5_raytrace_set_acceleration_structure(iron_g5_raytrace_acceleration_structure_t *_accel) { accel = _accel; } -void kinc_g5_raytrace_set_pipeline(kinc_g5_raytrace_pipeline_t *_pipeline) { +void iron_g5_raytrace_set_pipeline(iron_g5_raytrace_pipeline_t *_pipeline) { pipeline = _pipeline; } -void kinc_g5_raytrace_set_target(kinc_g5_texture_t *_output) { +void iron_g5_raytrace_set_target(iron_g5_texture_t *_output) { output = _output; } -void kinc_g5_raytrace_dispatch_rays(kinc_g5_command_list_t *command_list) { +void iron_g5_raytrace_dispatch_rays(iron_g5_command_list_t *command_list) { id device = getMetalDevice(); if (!device.supportsRaytracing) return; dispatch_semaphore_wait(_sem, DISPATCH_TIME_FOREVER); @@ -1320,48 +1320,48 @@ void kinc_g5_raytrace_dispatch_rays(kinc_g5_command_list_t *command_list) { [command_buffer commit]; } -static MTLPixelFormat convert_image_format(kinc_image_format_t format) { +static MTLPixelFormat convert_image_format(iron_image_format_t format) { switch (format) { - case KINC_IMAGE_FORMAT_RGBA32: + case IRON_IMAGE_FORMAT_RGBA32: return MTLPixelFormatRGBA8Unorm; - case KINC_IMAGE_FORMAT_R8: + case IRON_IMAGE_FORMAT_R8: return MTLPixelFormatR8Unorm; - case KINC_IMAGE_FORMAT_R16: + case IRON_IMAGE_FORMAT_R16: return MTLPixelFormatR16Float; - case KINC_IMAGE_FORMAT_R32: + case IRON_IMAGE_FORMAT_R32: return MTLPixelFormatR32Float; - case KINC_IMAGE_FORMAT_RGBA128: + case IRON_IMAGE_FORMAT_RGBA128: return MTLPixelFormatRGBA32Float; - case KINC_IMAGE_FORMAT_RGBA64: + case IRON_IMAGE_FORMAT_RGBA64: return MTLPixelFormatRGBA16Float; - case KINC_IMAGE_FORMAT_BGRA32: + case IRON_IMAGE_FORMAT_BGRA32: return MTLPixelFormatBGRA8Unorm; } } -static int formatByteSize(kinc_image_format_t format) { +static int formatByteSize(iron_image_format_t format) { switch (format) { - case KINC_IMAGE_FORMAT_RGBA128: + case IRON_IMAGE_FORMAT_RGBA128: return 16; - case KINC_IMAGE_FORMAT_RGBA64: + case IRON_IMAGE_FORMAT_RGBA64: return 8; - case KINC_IMAGE_FORMAT_R16: + case IRON_IMAGE_FORMAT_R16: return 2; - case KINC_IMAGE_FORMAT_R8: + case IRON_IMAGE_FORMAT_R8: return 1; - case KINC_IMAGE_FORMAT_BGRA32: - case KINC_IMAGE_FORMAT_RGBA32: - case KINC_IMAGE_FORMAT_R32: + case IRON_IMAGE_FORMAT_BGRA32: + case IRON_IMAGE_FORMAT_RGBA32: + case IRON_IMAGE_FORMAT_R32: default: return 4; } } -static void create(kinc_g5_texture_t *texture, int width, int height, int format, bool writable) { +static void create(iron_g5_texture_t *texture, int width, int height, int format, bool writable) { texture->impl.has_mipmaps = false; id device = getMetalDevice(); - MTLTextureDescriptor *descriptor = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:convert_image_format((kinc_image_format_t)format) + MTLTextureDescriptor *descriptor = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:convert_image_format((iron_image_format_t)format) width:width height:height mipmapped:NO]; @@ -1369,7 +1369,7 @@ static void create(kinc_g5_texture_t *texture, int width, int height, int format descriptor.width = width; descriptor.height = height; descriptor.depth = 1; - descriptor.pixelFormat = convert_image_format((kinc_image_format_t)format); + descriptor.pixelFormat = convert_image_format((iron_image_format_t)format); descriptor.arrayLength = 1; descriptor.mipmapLevelCount = 1; // TODO: Make less textures writable @@ -1380,26 +1380,26 @@ static void create(kinc_g5_texture_t *texture, int width, int height, int format texture->impl._tex = (__bridge_retained void *)[device newTextureWithDescriptor:descriptor]; } -void kinc_g5_texture_init(kinc_g5_texture_t *texture, int width, int height, kinc_image_format_t format) { +void iron_g5_texture_init(iron_g5_texture_t *texture, int width, int height, iron_image_format_t format) { texture->width = width; texture->height = height; texture->format = format; - texture->impl.data = malloc(width * height * (format == KINC_IMAGE_FORMAT_R8 ? 1 : 4)); + texture->impl.data = malloc(width * height * (format == IRON_IMAGE_FORMAT_R8 ? 1 : 4)); create(texture, width, height, format, true); texture->_uploaded = true; texture->data = NULL; - texture->state = KINC_INTERNAL_RENDER_TARGET_STATE_TEXTURE; + texture->state = IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE; texture->framebuffer_index = -1; } -void kinc_g5_texture_init_from_bytes(kinc_g5_texture_t *texture, void *data, int width, int height, kinc_image_format_t format) { +void iron_g5_texture_init_from_bytes(iron_g5_texture_t *texture, void *data, int width, int height, iron_image_format_t format) { texture->width = width; texture->height = height; texture->format = format; texture->data = data; texture->_uploaded = false; texture->impl.data = NULL; - texture->state = KINC_INTERNAL_RENDER_TARGET_STATE_TEXTURE; + texture->state = IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE; texture->framebuffer_index = -1; create(texture, width, height, format, true); id tex = (__bridge id)texture->impl._tex; @@ -1407,21 +1407,21 @@ void kinc_g5_texture_init_from_bytes(kinc_g5_texture_t *texture, void *data, int mipmapLevel:0 slice:0 withBytes:data - bytesPerRow:kinc_g5_texture_stride(texture) - bytesPerImage:kinc_g5_texture_stride(texture) * texture->height]; + bytesPerRow:iron_g5_texture_stride(texture) + bytesPerImage:iron_g5_texture_stride(texture) * texture->height]; } -void kinc_g5_texture_init_non_sampled_access(kinc_g5_texture_t *texture, int width, int height, kinc_image_format_t format) { +void iron_g5_texture_init_non_sampled_access(iron_g5_texture_t *texture, int width, int height, iron_image_format_t format) { texture->width = width; texture->height = height; texture->format = format; - texture->impl.data = malloc(width * height * (format == KINC_IMAGE_FORMAT_R8 ? 1 : 4)); - texture->state = KINC_INTERNAL_RENDER_TARGET_STATE_TEXTURE; + texture->impl.data = malloc(width * height * (format == IRON_IMAGE_FORMAT_R8 ? 1 : 4)); + texture->state = IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE; texture->framebuffer_index = -1; create(texture, width, height, format, true); } -void kinc_g5_texture_destroy(kinc_g5_texture_t *target) { +void iron_g5_texture_destroy(iron_g5_texture_t *target) { id tex = (__bridge_transfer id)target->impl._tex; tex = nil; target->impl._tex = NULL; @@ -1444,27 +1444,27 @@ void kinc_g5_texture_destroy(kinc_g5_texture_t *target) { } } -int kinc_g5_texture_stride(kinc_g5_texture_t *texture) { +int iron_g5_texture_stride(iron_g5_texture_t *texture) { switch (texture->format) { - case KINC_IMAGE_FORMAT_R8: + case IRON_IMAGE_FORMAT_R8: return texture->width; - case KINC_IMAGE_FORMAT_RGBA32: - case KINC_IMAGE_FORMAT_BGRA32: + case IRON_IMAGE_FORMAT_RGBA32: + case IRON_IMAGE_FORMAT_BGRA32: default: return texture->width * 4; - case KINC_IMAGE_FORMAT_RGBA64: + case IRON_IMAGE_FORMAT_RGBA64: return texture->width * 8; - case KINC_IMAGE_FORMAT_RGBA128: + case IRON_IMAGE_FORMAT_RGBA128: return texture->width * 16; } } -void kinc_g5_texture_generate_mipmaps(kinc_g5_texture_t *texture, int levels) {} +void iron_g5_texture_generate_mipmaps(iron_g5_texture_t *texture, int levels) {} -void kinc_g5_texture_set_mipmap(kinc_g5_texture_t *texture, kinc_g5_texture_t *mipmap, int level) { +void iron_g5_texture_set_mipmap(iron_g5_texture_t *texture, iron_g5_texture_t *mipmap, int level) { if (!texture->impl.has_mipmaps) { id device = getMetalDevice(); - MTLTextureDescriptor *descriptor = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:convert_image_format((kinc_image_format_t)texture->format) + MTLTextureDescriptor *descriptor = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:convert_image_format((iron_image_format_t)texture->format) width:texture->width height:texture->height mipmapped:YES]; @@ -1472,7 +1472,7 @@ void kinc_g5_texture_set_mipmap(kinc_g5_texture_t *texture, kinc_g5_texture_t *m descriptor.width = texture->width; descriptor.height = texture->height; descriptor.depth = 1; - descriptor.pixelFormat = convert_image_format((kinc_image_format_t)texture->format); + descriptor.pixelFormat = convert_image_format((iron_image_format_t)texture->format); descriptor.arrayLength = 1; bool writable = true; if (writable) { @@ -1511,32 +1511,32 @@ void kinc_g5_texture_set_mipmap(kinc_g5_texture_t *texture, kinc_g5_texture_t *m bytesPerRow:mipmap->width * formatByteSize(mipmap->format)]; } -static MTLPixelFormat convert_format(kinc_image_format_t format) { +static MTLPixelFormat convert_format(iron_image_format_t format) { switch (format) { - case KINC_IMAGE_FORMAT_RGBA128: + case IRON_IMAGE_FORMAT_RGBA128: return MTLPixelFormatRGBA32Float; - case KINC_IMAGE_FORMAT_RGBA64: + case IRON_IMAGE_FORMAT_RGBA64: return MTLPixelFormatRGBA16Float; - case KINC_IMAGE_FORMAT_R32: + case IRON_IMAGE_FORMAT_R32: return MTLPixelFormatR32Float; - case KINC_IMAGE_FORMAT_R16: + case IRON_IMAGE_FORMAT_R16: return MTLPixelFormatR16Float; - case KINC_IMAGE_FORMAT_R8: + case IRON_IMAGE_FORMAT_R8: return MTLPixelFormatR8Unorm; - case KINC_IMAGE_FORMAT_RGBA32: + case IRON_IMAGE_FORMAT_RGBA32: default: return MTLPixelFormatBGRA8Unorm; } } -static void render_target_init(kinc_g5_texture_t *target, int width, int height, kinc_image_format_t format, int depthBufferBits, int framebuffer_index) { - memset(target, 0, sizeof(kinc_g5_texture_t)); +static void render_target_init(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits, int framebuffer_index) { + memset(target, 0, sizeof(iron_g5_texture_t)); target->width = width; target->height = height; target->data = NULL; target->_uploaded = true; - target->state = KINC_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; + target->state = IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; target->framebuffer_index = framebuffer_index; id device = getMetalDevice(); @@ -1572,35 +1572,35 @@ static void render_target_init(kinc_g5_texture_t *target, int width, int height, target->impl._texReadback = NULL; } -void kinc_g5_render_target_init(kinc_g5_texture_t *target, int width, int height, kinc_image_format_t format, int depthBufferBits) { +void iron_g5_render_target_init(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { render_target_init(target, width, height, format, depthBufferBits, -1); target->width = target->width = width; target->height = target->height = height; - target->state = KINC_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; + target->state = IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; target->_uploaded = true; } -void kinc_g5_render_target_init_framebuffer(kinc_g5_texture_t *target, int width, int height, kinc_image_format_t format, int depthBufferBits) { +void iron_g5_render_target_init_framebuffer(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { render_target_init(target, width, height, format, depthBufferBits, framebuffer_count); framebuffer_count += 1; } -void kinc_g5_render_target_set_depth_from(kinc_g5_texture_t *target, kinc_g5_texture_t *source) { +void iron_g5_render_target_set_depth_from(iron_g5_texture_t *target, iron_g5_texture_t *source) { target->impl._depthTex = source->impl._depthTex; } -static void vertex_buffer_unset(kinc_g5_vertex_buffer_t *buffer) { +static void vertex_buffer_unset(iron_g5_vertex_buffer_t *buffer) { if (currentVertexBuffer == buffer) currentVertexBuffer = NULL; } -void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int count, kinc_g5_vertex_structure_t *structure, bool gpuMemory) { +void iron_g5_vertex_buffer_init(iron_g5_vertex_buffer_t *buffer, int count, iron_g5_vertex_structure_t *structure, bool gpuMemory) { memset(&buffer->impl, 0, sizeof(buffer->impl)); buffer->impl.myCount = count; buffer->impl.gpuMemory = gpuMemory; for (int i = 0; i < structure->size; ++i) { - kinc_g5_vertex_element_t element = structure->elements[i]; - buffer->impl.myStride += kinc_g5_vertex_data_size(element.data); + iron_g5_vertex_element_t element = structure->elements[i]; + buffer->impl.myStride += iron_g5_vertex_data_size(element.data); } id device = getMetalDevice(); @@ -1614,22 +1614,22 @@ void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int count, kinc buffer->impl.lastCount = 0; } -void kinc_g5_vertex_buffer_destroy(kinc_g5_vertex_buffer_t *buf) { +void iron_g5_vertex_buffer_destroy(iron_g5_vertex_buffer_t *buf) { id buffer = (__bridge_transfer id)buf->impl.mtlBuffer; buffer = nil; buf->impl.mtlBuffer = NULL; vertex_buffer_unset(buf); } -float *kinc_g5_vertex_buffer_lock_all(kinc_g5_vertex_buffer_t *buf) { +float *iron_g5_vertex_buffer_lock_all(iron_g5_vertex_buffer_t *buf) { buf->impl.lastStart = 0; - buf->impl.lastCount = kinc_g5_vertex_buffer_count(buf); + buf->impl.lastCount = iron_g5_vertex_buffer_count(buf); id buffer = (__bridge id)buf->impl.mtlBuffer; float *floats = (float *)[buffer contents]; return floats; } -float *kinc_g5_vertex_buffer_lock(kinc_g5_vertex_buffer_t *buf, int start, int count) { +float *iron_g5_vertex_buffer_lock(iron_g5_vertex_buffer_t *buf, int start, int count) { buf->impl.lastStart = start; buf->impl.lastCount = count; id buffer = (__bridge id)buf->impl.mtlBuffer; @@ -1637,13 +1637,13 @@ float *kinc_g5_vertex_buffer_lock(kinc_g5_vertex_buffer_t *buf, int start, int c return &floats[start * buf->impl.myStride / sizeof(float)]; } -void kinc_g5_vertex_buffer_unlock_all(kinc_g5_vertex_buffer_t *buf) { +void iron_g5_vertex_buffer_unlock_all(iron_g5_vertex_buffer_t *buf) { } -void kinc_g5_vertex_buffer_unlock(kinc_g5_vertex_buffer_t *buf, int count) { +void iron_g5_vertex_buffer_unlock(iron_g5_vertex_buffer_t *buf, int count) { } -int kinc_g5_internal_vertex_buffer_set(kinc_g5_vertex_buffer_t *buf) { +int iron_g5_internal_vertex_buffer_set(iron_g5_vertex_buffer_t *buf) { currentVertexBuffer = buf; id encoder = getMetalEncoder(); @@ -1653,31 +1653,31 @@ int kinc_g5_internal_vertex_buffer_set(kinc_g5_vertex_buffer_t *buf) { return 0; } -int kinc_g5_vertex_buffer_count(kinc_g5_vertex_buffer_t *buffer) { +int iron_g5_vertex_buffer_count(iron_g5_vertex_buffer_t *buffer) { return buffer->impl.myCount; } -int kinc_g5_vertex_buffer_stride(kinc_g5_vertex_buffer_t *buffer) { +int iron_g5_vertex_buffer_stride(iron_g5_vertex_buffer_t *buffer) { return buffer->impl.myStride; } -void kinc_g5_constant_buffer_init(kinc_g5_constant_buffer_t *buffer, int size) { +void iron_g5_constant_buffer_init(iron_g5_constant_buffer_t *buffer, int size) { buffer->impl.mySize = size; buffer->data = NULL; buffer->impl._buffer = (__bridge_retained void *)[getMetalDevice() newBufferWithLength:size options:MTLResourceOptionCPUCacheModeDefault]; } -void kinc_g5_constant_buffer_destroy(kinc_g5_constant_buffer_t *buffer) { +void iron_g5_constant_buffer_destroy(iron_g5_constant_buffer_t *buffer) { id buf = (__bridge_transfer id)buffer->impl._buffer; buf = nil; buffer->impl._buffer = NULL; } -void kinc_g5_constant_buffer_lock_all(kinc_g5_constant_buffer_t *buffer) { - kinc_g5_constant_buffer_lock(buffer, 0, kinc_g5_constant_buffer_size(buffer)); +void iron_g5_constant_buffer_lock_all(iron_g5_constant_buffer_t *buffer) { + iron_g5_constant_buffer_lock(buffer, 0, iron_g5_constant_buffer_size(buffer)); } -void kinc_g5_constant_buffer_lock(kinc_g5_constant_buffer_t *buffer, int start, int count) { +void iron_g5_constant_buffer_lock(iron_g5_constant_buffer_t *buffer, int start, int count) { buffer->impl.lastStart = start; buffer->impl.lastCount = count; id buf = (__bridge id)buffer->impl._buffer; @@ -1685,15 +1685,15 @@ void kinc_g5_constant_buffer_lock(kinc_g5_constant_buffer_t *buffer, int start, buffer->data = &data[start]; } -void kinc_g5_constant_buffer_unlock(kinc_g5_constant_buffer_t *buffer) { +void iron_g5_constant_buffer_unlock(iron_g5_constant_buffer_t *buffer) { buffer->data = NULL; } -int kinc_g5_constant_buffer_size(kinc_g5_constant_buffer_t *buffer) { +int iron_g5_constant_buffer_size(iron_g5_constant_buffer_t *buffer) { return buffer->impl.mySize; } -void kinc_g5_index_buffer_init(kinc_g5_index_buffer_t *buffer, int indexCount, bool gpuMemory) { +void iron_g5_index_buffer_init(iron_g5_index_buffer_t *buffer, int indexCount, bool gpuMemory) { buffer->impl.count = indexCount; buffer->impl.gpu_memory = gpuMemory; buffer->impl.last_start = 0; @@ -1708,36 +1708,36 @@ void kinc_g5_index_buffer_init(kinc_g5_index_buffer_t *buffer, int indexCount, b options:options]; } -void kinc_g5_index_buffer_destroy(kinc_g5_index_buffer_t *buffer) { +void iron_g5_index_buffer_destroy(iron_g5_index_buffer_t *buffer) { id buf = (__bridge_transfer id)buffer->impl.metal_buffer; buf = nil; buffer->impl.metal_buffer = NULL; } -static int kinc_g5_internal_index_buffer_stride(kinc_g5_index_buffer_t *buffer) { +static int iron_g5_internal_index_buffer_stride(iron_g5_index_buffer_t *buffer) { return 4; } -void *kinc_g5_index_buffer_lock_all(kinc_g5_index_buffer_t *buffer) { - return kinc_g5_index_buffer_lock(buffer, 0, kinc_g5_index_buffer_count(buffer)); +void *iron_g5_index_buffer_lock_all(iron_g5_index_buffer_t *buffer) { + return iron_g5_index_buffer_lock(buffer, 0, iron_g5_index_buffer_count(buffer)); } -void *kinc_g5_index_buffer_lock(kinc_g5_index_buffer_t *buffer, int start, int count) { +void *iron_g5_index_buffer_lock(iron_g5_index_buffer_t *buffer, int start, int count) { buffer->impl.last_start = start; buffer->impl.last_count = count; id metal_buffer = (__bridge id)buffer->impl.metal_buffer; uint8_t *data = (uint8_t *)[metal_buffer contents]; - return &data[start * kinc_g5_internal_index_buffer_stride(buffer)]; + return &data[start * iron_g5_internal_index_buffer_stride(buffer)]; } -void kinc_g5_index_buffer_unlock_all(kinc_g5_index_buffer_t *buffer) { - kinc_g5_index_buffer_unlock(buffer, buffer->impl.last_count); +void iron_g5_index_buffer_unlock_all(iron_g5_index_buffer_t *buffer) { + iron_g5_index_buffer_unlock(buffer, buffer->impl.last_count); } -void kinc_g5_index_buffer_unlock(kinc_g5_index_buffer_t *buffer, int count) { +void iron_g5_index_buffer_unlock(iron_g5_index_buffer_t *buffer, int count) { } -int kinc_g5_index_buffer_count(kinc_g5_index_buffer_t *buffer) { +int iron_g5_index_buffer_count(iron_g5_index_buffer_t *buffer) { return buffer->impl.count; } diff --git a/base/sources/backends/posix_thread.c b/base/sources/backends/posix_thread.c index 775bddcc..ac2baa1d 100644 --- a/base/sources/backends/posix_thread.c +++ b/base/sources/backends/posix_thread.c @@ -5,30 +5,30 @@ #include #include -void kinc_mutex_init(kinc_mutex_t *mutex) { +void iron_mutex_init(iron_mutex_t *mutex) { pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(&mutex->impl.mutex, &attr); } -void kinc_mutex_destroy(kinc_mutex_t *mutex) { +void iron_mutex_destroy(iron_mutex_t *mutex) { pthread_mutex_destroy(&mutex->impl.mutex); } -bool kinc_mutex_try_to_lock(kinc_mutex_t *mutex) { +bool iron_mutex_try_to_lock(iron_mutex_t *mutex) { return pthread_mutex_trylock(&mutex->impl.mutex) == 0; } -void kinc_mutex_lock(kinc_mutex_t *mutex) { +void iron_mutex_lock(iron_mutex_t *mutex) { pthread_mutex_lock(&mutex->impl.mutex); } -void kinc_mutex_unlock(kinc_mutex_t *mutex) { +void iron_mutex_unlock(iron_mutex_t *mutex) { pthread_mutex_unlock(&mutex->impl.mutex); } -#if !defined(KINC_IOS) && !defined(KINC_MACOS) +#if !defined(IRON_IOS) && !defined(IRON_MACOS) struct thread_start { void (*thread)(void *param); @@ -46,7 +46,7 @@ static void *ThreadProc(void *arg) { return NULL; } -void kinc_thread_init(kinc_thread_t *t, void (*thread)(void *param), void *param) { +void iron_thread_init(iron_thread_t *t, void (*thread)(void *param), void *param) { t->impl.param = param; t->impl.thread = thread; pthread_attr_t attr; @@ -67,20 +67,20 @@ void kinc_thread_init(kinc_thread_t *t, void (*thread)(void *param), void *param pthread_attr_destroy(&attr); } -void kinc_thread_wait_and_destroy(kinc_thread_t *thread) { +void iron_thread_wait_and_destroy(iron_thread_t *thread) { int ret; do { ret = pthread_join(thread->impl.pthread, NULL); } while (ret != 0); } -bool kinc_thread_try_to_destroy(kinc_thread_t *thread) { +bool iron_thread_try_to_destroy(iron_thread_t *thread) { return pthread_join(thread->impl.pthread, NULL) == 0; } -void kinc_threads_init() {} +void iron_threads_init() {} -void kinc_threads_quit() {} +void iron_threads_quit() {} // Alternatively _GNU_SOURCE can be defined to make // the headers declare it but let's not make it too @@ -88,14 +88,14 @@ void kinc_threads_quit() {} int pthread_setname_np(pthread_t thread, const char *name); #endif -void kinc_thread_set_name(const char *name) { -#if !defined(KINC_IOS) && !defined(KINC_MACOS) +void iron_thread_set_name(const char *name) { +#if !defined(IRON_IOS) && !defined(IRON_MACOS) pthread_setname_np(pthread_self(), name); #else pthread_setname_np(name); #endif } -void kinc_thread_sleep(int milliseconds) { +void iron_thread_sleep(int milliseconds) { usleep(1000 * (useconds_t)milliseconds); } diff --git a/base/sources/backends/posix_thread.h b/base/sources/backends/posix_thread.h index 41aaae1c..748ceb48 100644 --- a/base/sources/backends/posix_thread.h +++ b/base/sources/backends/posix_thread.h @@ -5,43 +5,43 @@ typedef struct { pthread_mutex_t mutex; -} kinc_mutex_impl_t; +} iron_mutex_impl_t; typedef struct { void *param; void (*thread)(void *param); pthread_t pthread; -} kinc_thread_impl_t; +} iron_thread_impl_t; -#if defined(KINC_MACOS) || defined(KINC_IOS) +#if defined(IRON_MACOS) || defined(IRON_IOS) #include -static inline bool kinc_atomic_compare_exchange(volatile int32_t *pointer, int32_t old_value, int32_t new_value) { +static inline bool iron_atomic_compare_exchange(volatile int32_t *pointer, int32_t old_value, int32_t new_value) { return OSAtomicCompareAndSwap32Barrier(old_value, new_value, pointer); } -static inline bool kinc_atomic_compare_exchange_pointer(void *volatile *pointer, void *old_value, void *new_value) { +static inline bool iron_atomic_compare_exchange_pointer(void *volatile *pointer, void *old_value, void *new_value) { return OSAtomicCompareAndSwapPtrBarrier(old_value, new_value, pointer); } -static inline int32_t kinc_atomic_increment(volatile int32_t *pointer) { +static inline int32_t iron_atomic_increment(volatile int32_t *pointer) { return OSAtomicIncrement32Barrier(pointer) - 1; } -static inline int32_t kinc_atomic_decrement(volatile int32_t *pointer) { +static inline int32_t iron_atomic_decrement(volatile int32_t *pointer) { return OSAtomicDecrement32Barrier(pointer) + 1; } -static inline void kinc_atomic_exchange(volatile int32_t *pointer, int32_t value) { +static inline void iron_atomic_exchange(volatile int32_t *pointer, int32_t value) { __sync_swap(pointer, value); } -static inline void kinc_atomic_exchange_float(volatile float *pointer, float value) { +static inline void iron_atomic_exchange_float(volatile float *pointer, float value) { __sync_swap((volatile int32_t *)pointer, *(int32_t *)&value); } -static inline void kinc_atomic_exchange_double(volatile double *pointer, double value) { +static inline void iron_atomic_exchange_double(volatile double *pointer, double value) { __sync_swap((volatile int64_t *)pointer, *(int64_t *)&value); } @@ -49,33 +49,33 @@ static inline void kinc_atomic_exchange_double(volatile double *pointer, double // clang/gcc intrinsics -static inline bool kinc_atomic_compare_exchange(volatile int32_t *pointer, int32_t old_value, int32_t new_value) { +static inline bool iron_atomic_compare_exchange(volatile int32_t *pointer, int32_t old_value, int32_t new_value) { return __sync_val_compare_and_swap(pointer, old_value, new_value) == old_value; } -static inline bool kinc_atomic_compare_exchange_pointer(void *volatile *pointer, void *old_value, void *new_value) { +static inline bool iron_atomic_compare_exchange_pointer(void *volatile *pointer, void *old_value, void *new_value) { return __sync_val_compare_and_swap(pointer, old_value, new_value) == old_value; } -static inline int32_t kinc_atomic_increment(volatile int32_t *pointer) { +static inline int32_t iron_atomic_increment(volatile int32_t *pointer) { return __sync_fetch_and_add(pointer, 1); } -static inline int32_t kinc_atomic_decrement(volatile int32_t *pointer) { +static inline int32_t iron_atomic_decrement(volatile int32_t *pointer) { return __sync_fetch_and_sub(pointer, 1); } #ifdef __clang__ -static inline void kinc_atomic_exchange(volatile int32_t *pointer, int32_t value) { +static inline void iron_atomic_exchange(volatile int32_t *pointer, int32_t value) { __sync_swap(pointer, value); } -static inline void kinc_atomic_exchange_float(volatile float *pointer, float value) { +static inline void iron_atomic_exchange_float(volatile float *pointer, float value) { __sync_swap((volatile int32_t *)pointer, *(int32_t *)&value); } -static inline void kinc_atomic_exchange_double(volatile double *pointer, double value) { +static inline void iron_atomic_exchange_double(volatile double *pointer, double value) { __sync_swap((volatile int64_t *)pointer, *(int64_t *)&value); } @@ -83,15 +83,15 @@ static inline void kinc_atomic_exchange_double(volatile double *pointer, double // Beware, __sync_lock_test_and_set is not a full barrier and can have platform-specific weirdness -static inline void kinc_atomic_exchange(volatile int32_t *pointer, int32_t value) { +static inline void iron_atomic_exchange(volatile int32_t *pointer, int32_t value) { __sync_lock_test_and_set(pointer, value); } -static inline void kinc_atomic_exchange_float(volatile float *pointer, float value) { +static inline void iron_atomic_exchange_float(volatile float *pointer, float value) { __sync_lock_test_and_set((volatile int32_t *)pointer, *(int32_t *)&value); } -static inline void kinc_atomic_exchange_double(volatile double *pointer, double value) { +static inline void iron_atomic_exchange_double(volatile double *pointer, double value) { __sync_lock_test_and_set((volatile int64_t *)pointer, *(int64_t *)&value); } @@ -99,16 +99,16 @@ static inline void kinc_atomic_exchange_double(volatile double *pointer, double #endif -#define KINC_ATOMIC_COMPARE_EXCHANGE(pointer, oldValue, newValue) (kinc_atomic_compare_exchange(pointer, oldValue, newValue)) +#define IRON_ATOMIC_COMPARE_EXCHANGE(pointer, oldValue, newValue) (iron_atomic_compare_exchange(pointer, oldValue, newValue)) -#define KINC_ATOMIC_COMPARE_EXCHANGE_POINTER(pointer, oldValue, newValue) (kinc_atomic_compare_exchange_pointer(pointer, oldValue, newValue)) +#define IRON_ATOMIC_COMPARE_EXCHANGE_POINTER(pointer, oldValue, newValue) (iron_atomic_compare_exchange_pointer(pointer, oldValue, newValue)) -#define KINC_ATOMIC_INCREMENT(pointer) (kinc_atomic_increment(pointer)) +#define IRON_ATOMIC_INCREMENT(pointer) (iron_atomic_increment(pointer)) -#define KINC_ATOMIC_DECREMENT(pointer) (kinc_atomic_decrement(pointer)) +#define IRON_ATOMIC_DECREMENT(pointer) (iron_atomic_decrement(pointer)) -#define KINC_ATOMIC_EXCHANGE_32(pointer, value) (kinc_atomic_exchange(pointer, value)) +#define IRON_ATOMIC_EXCHANGE_32(pointer, value) (iron_atomic_exchange(pointer, value)) -#define KINC_ATOMIC_EXCHANGE_FLOAT(pointer, value) (kinc_atomic_exchange_float(pointer, value)) +#define IRON_ATOMIC_EXCHANGE_FLOAT(pointer, value) (iron_atomic_exchange_float(pointer, value)) -#define KINC_ATOMIC_EXCHANGE_DOUBLE(pointer, value) (kinc_atomic_exchange_double(pointer, value)) +#define IRON_ATOMIC_EXCHANGE_DOUBLE(pointer, value) (iron_atomic_exchange_double(pointer, value)) diff --git a/base/sources/backends/vulkan_gpu.c b/base/sources/backends/vulkan_gpu.c index 35ca3f31..dc8f887a 100644 --- a/base/sources/backends/vulkan_gpu.c +++ b/base/sources/backends/vulkan_gpu.c @@ -23,21 +23,21 @@ static void command_list_should_wait_for_framebuffer(void); static VkDescriptorSetLayout compute_descriptor_layout; static int framebuffer_count = 0; -extern kinc_g5_texture_t *vulkan_textures[16]; +extern iron_g5_texture_t *vulkan_textures[16]; VkDescriptorSet getDescriptorSet(void); static VkDescriptorSet get_compute_descriptor_set(void); void setImageLayout(VkCommandBuffer _buffer, VkImage image, VkImageAspectFlags aspectMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout); VkRenderPassBeginInfo currentRenderPassBeginInfo; VkPipeline currentVulkanPipeline; -kinc_g5_texture_t *currentRenderTargets[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; +iron_g5_texture_t *currentRenderTargets[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; static bool onBackBuffer = false; static uint32_t lastVertexConstantBufferOffset = 0; static uint32_t lastFragmentConstantBufferOffset = 0; static uint32_t lastComputeConstantBufferOffset = 0; -static kinc_g5_pipeline_t *current_pipeline = NULL; -static kinc_g5_compute_shader *current_compute_shader = NULL; +static iron_g5_pipeline_t *current_pipeline = NULL; +static iron_g5_compute_shader *current_compute_shader = NULL; static int mrtIndex = 0; static VkFramebuffer mrtFramebuffer[16]; static VkRenderPass mrtRenderPass[16]; @@ -45,12 +45,12 @@ static VkRenderPass mrtRenderPass[16]; static bool in_render_pass = false; static bool wait_for_framebuffer = false; -static void parse_shader(uint32_t *shader_source, int shader_length, kinc_internal_named_number *locations, kinc_internal_named_number *textureBindings, kinc_internal_named_number *uniformOffsets); +static void parse_shader(uint32_t *shader_source, int shader_length, iron_internal_named_number *locations, iron_internal_named_number *textureBindings, iron_internal_named_number *uniformOffsets); static VkShaderModule create_shader_module(const void *code, size_t size); static VkDescriptorPool compute_descriptor_pool; VkDescriptorSetLayout desc_layout; -extern kinc_g5_texture_t *vulkan_textures[16]; +extern iron_g5_texture_t *vulkan_textures[16]; extern uint32_t swapchainImageCount; extern uint32_t current_buffer; @@ -99,7 +99,7 @@ void set_image_layout(VkImage image, VkImageAspectFlags aspectMask, VkImageLayou // djb2 -uint32_t kinc_internal_hash_name(unsigned char *str) { +uint32_t iron_internal_hash_name(unsigned char *str) { unsigned long hash = 5381; int c; while ((c = *str++)) { @@ -111,16 +111,16 @@ uint32_t kinc_internal_hash_name(unsigned char *str) { struct vk_funs vk = {0}; struct vk_context vk_ctx = {0}; -void kinc_vulkan_get_instance_extensions(const char **extensions, int *index, int max); -VkBool32 kinc_vulkan_get_physical_device_presentation_support(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex); -VkResult kinc_vulkan_create_surface(VkInstance instance, VkSurfaceKHR *surface); -void kinc_g5_internal_resize(int, int); +void iron_vulkan_get_instance_extensions(const char **extensions, int *index, int max); +VkBool32 iron_vulkan_get_physical_device_presentation_support(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex); +VkResult iron_vulkan_create_surface(VkInstance instance, VkSurfaceKHR *surface); +void iron_g5_internal_resize(int, int); #define GET_INSTANCE_PROC_ADDR(instance, entrypoint) \ { \ vk.fp##entrypoint = (PFN_vk##entrypoint)vkGetInstanceProcAddr(instance, "vk" #entrypoint); \ if (vk.fp##entrypoint == NULL) { \ - kinc_error("vkGetInstanceProcAddr failed to find vk" #entrypoint); \ + iron_error("vkGetInstanceProcAddr failed to find vk" #entrypoint); \ } \ } @@ -130,7 +130,7 @@ void create_descriptor_layout(void); static void create_compute_descriptor_layout(void); void set_image_layout(VkImage image, VkImageAspectFlags aspectMask, VkImageLayout old_image_layout, VkImageLayout new_image_layout); -kinc_g5_texture_t *vulkan_textures[16] = { +iron_g5_texture_t *vulkan_textures[16] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; @@ -159,10 +159,10 @@ static VkBool32 vkDebugUtilsMessengerCallbackEXT( void *puser_data) { if (message_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) { - kinc_error("Vulkan ERROR: Code %d : %s", pcallback_data->messageIdNumber, pcallback_data->pMessage); + iron_error("Vulkan ERROR: Code %d : %s", pcallback_data->messageIdNumber, pcallback_data->pMessage); } else if (message_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) { - kinc_log("Vulkan WARNING: Code %d : %s", pcallback_data->messageIdNumber, pcallback_data->pMessage); + iron_log("Vulkan WARNING: Code %d : %s", pcallback_data->messageIdNumber, pcallback_data->pMessage); } return VK_FALSE; } @@ -180,7 +180,7 @@ bool memory_type_from_properties(uint32_t typeBits, VkFlags requirements_mask, u return false; } -void kinc_internal_resize(int width, int height) { +void iron_internal_resize(int width, int height) { struct vk_window *window = &vk_ctx.windows[0]; if (window->width != width || window->height != height) { window->resized = true; @@ -188,7 +188,7 @@ void kinc_internal_resize(int width, int height) { window->height = height; } - kinc_g5_internal_resize(width, height); + iron_g5_internal_resize(width, height); } VkSwapchainKHR cleanup_swapchain() { @@ -238,10 +238,10 @@ void create_swapchain() { vk.fpDestroySwapchainKHR(vk_ctx.device, oldSwapchain, NULL); oldSwapchain = VK_NULL_HANDLE; vk.fpDestroySurfaceKHR(vk_ctx.instance, window->surface, NULL); - VkResult err = kinc_vulkan_create_surface(vk_ctx.instance, &window->surface); + VkResult err = iron_vulkan_create_surface(vk_ctx.instance, &window->surface); assert(!err); - window->width = kinc_window_width(); - window->height = kinc_window_height(); + window->width = iron_window_width(); + window->height = iron_window_height(); window->surface_destroyed = false; } @@ -316,7 +316,7 @@ void create_swapchain() { swapchain_info.compositeAlpha = VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR; } else { - kinc_error("No supported composite alpha, this should not happen.\nPlease go complain to the writers of your Vulkan driver."); + iron_error("No supported composite alpha, this should not happen.\nPlease go complain to the writers of your Vulkan driver."); exit(1); } @@ -650,7 +650,7 @@ static bool check_extensions(const char **wanted_extensions, int wanted_extensio for (int i = 0; i < wanted_extension_count; i++) { if (!found_extensions[i]) { - kinc_error("Failed to find extension %s", wanted_extensions[i]); + iron_error("Failed to find extension %s", wanted_extensions[i]); missing_extensions = true; } } @@ -670,7 +670,7 @@ static bool find_layer(VkLayerProperties *layers, int layer_count, const char *w return false; } -void kinc_g5_internal_init() { +void iron_g5_internal_init() { VkResult err; uint32_t instance_layer_count = 0; @@ -688,7 +688,7 @@ void kinc_g5_internal_init() { #ifdef VALIDATE vk_ctx.validation_found = find_layer(instance_layers, instance_layer_count, "VK_LAYER_KHRONOS_validation"); if (vk_ctx.validation_found) { - kinc_log("Running with Vulkan validation layers enabled."); + iron_log("Running with Vulkan validation layers enabled."); wanted_instance_layers[wanted_instance_layer_count++] = "VK_LAYER_KHRONOS_validation"; } #endif @@ -703,7 +703,7 @@ void kinc_g5_internal_init() { wanted_instance_extensions[wanted_instance_extension_count++] = VK_KHR_SURFACE_EXTENSION_NAME; wanted_instance_extensions[wanted_instance_extension_count++] = VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME; - kinc_vulkan_get_instance_extensions(wanted_instance_extensions, &wanted_instance_extension_count, ARRAY_SIZE(wanted_instance_extensions)); + iron_vulkan_get_instance_extensions(wanted_instance_extensions, &wanted_instance_extension_count, ARRAY_SIZE(wanted_instance_extensions)); err = vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, NULL); assert(!err); @@ -714,7 +714,7 @@ void kinc_g5_internal_init() { check_extensions(wanted_instance_extensions, wanted_instance_extension_count, instance_extensions, instance_extension_count); if (missing_instance_extensions) { - kinc_error(""); + iron_error(""); } #ifdef VALIDATE @@ -727,12 +727,12 @@ void kinc_g5_internal_init() { VkApplicationInfo app = {0}; app.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; app.pNext = NULL; - app.pApplicationName = kinc_application_name(); + app.pApplicationName = iron_application_name(); app.applicationVersion = 0; - app.pEngineName = "Kore"; + app.pEngineName = "Iron"; app.engineVersion = 0; -#ifdef KINC_ANDROID +#ifdef IRON_ANDROID app.apiVersion = VK_API_VERSION_1_0; // VK_API_VERSION_1_1 #else app.apiVersion = VK_API_VERSION_1_2; // VKRT @@ -760,13 +760,13 @@ void kinc_g5_internal_init() { err = vkCreateInstance(&info, NULL, &vk_ctx.instance); if (err == VK_ERROR_INCOMPATIBLE_DRIVER) { - kinc_error("Vulkan driver is incompatible"); + iron_error("Vulkan driver is incompatible"); } else if (err == VK_ERROR_EXTENSION_NOT_PRESENT) { - kinc_error("Vulkan extension not found"); + iron_error("Vulkan extension not found"); } else if (err) { - kinc_error("Can not create Vulkan instance"); + iron_error("Can not create Vulkan instance"); } uint32_t gpu_count; @@ -790,7 +790,7 @@ void kinc_g5_internal_init() { bool can_present = false; bool can_render = false; for (uint32_t i = 0; i < queue_count; i++) { - VkBool32 queue_supports_present = kinc_vulkan_get_physical_device_presentation_support(gpu, i); + VkBool32 queue_supports_present = iron_vulkan_get_physical_device_presentation_support(gpu, i); if (queue_supports_present) { can_present = true; } @@ -836,16 +836,16 @@ void kinc_g5_internal_init() { } if (vk_ctx.gpu == VK_NULL_HANDLE) { - kinc_error("No Vulkan device that supports presentation found"); + iron_error("No Vulkan device that supports presentation found"); } VkPhysicalDeviceProperties properties; vkGetPhysicalDeviceProperties(vk_ctx.gpu, &properties); - kinc_log("Chosen Vulkan device: %s", properties.deviceName); + iron_log("Chosen Vulkan device: %s", properties.deviceName); free(physical_devices); } else { - kinc_error("No Vulkan device found"); + iron_error("No Vulkan device found"); } static const char *wanted_device_layers[64]; @@ -877,7 +877,7 @@ void kinc_g5_internal_init() { // Allows negative viewport height to flip viewport wanted_device_extensions[wanted_device_extension_count++] = VK_KHR_MAINTENANCE1_EXTENSION_NAME; - if (kinc_g5_raytrace_supported()) { + if (iron_g5_raytrace_supported()) { wanted_device_extensions[wanted_device_extension_count++] = VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME; wanted_device_extensions[wanted_device_extension_count++] = VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME; wanted_device_extensions[wanted_device_extension_count++] = VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME; @@ -945,7 +945,7 @@ void kinc_g5_internal_init() { // Iterate over each queue to learn whether it supports presenting: VkBool32 *supportsPresent = (VkBool32 *)malloc(queue_count * sizeof(VkBool32)); for (uint32_t i = 0; i < queue_count; i++) { - supportsPresent[i] = kinc_vulkan_get_physical_device_presentation_support(vk_ctx.gpu, i); + supportsPresent[i] = iron_vulkan_get_physical_device_presentation_support(vk_ctx.gpu, i); } // Search for a graphics and a present queue in the array of queue @@ -979,11 +979,11 @@ void kinc_g5_internal_init() { // Generate error if could not find both a graphics and a present queue if (graphicsQueueNodeIndex == UINT32_MAX || presentQueueNodeIndex == UINT32_MAX) { - kinc_error("Graphics or present queue not found"); + iron_error("Graphics or present queue not found"); } if (graphicsQueueNodeIndex != presentQueueNodeIndex) { - kinc_error("Graphics and present queue do not match"); + iron_error("Graphics and present queue do not match"); } graphics_queue_node_index = graphicsQueueNodeIndex; @@ -1012,7 +1012,7 @@ void kinc_g5_internal_init() { VkPhysicalDeviceRayTracingPipelineFeaturesKHR rayTracingPipelineExt = {0}; VkPhysicalDeviceAccelerationStructureFeaturesKHR rayTracingAccelerationStructureExt = {0}; VkPhysicalDeviceBufferDeviceAddressFeatures bufferDeviceAddressExt = {0}; - if (kinc_g5_raytrace_supported()) { + if (iron_g5_raytrace_supported()) { rayTracingPipelineExt.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR; rayTracingPipelineExt.pNext = NULL; rayTracingPipelineExt.rayTracingPipeline = VK_TRUE; @@ -1060,25 +1060,25 @@ void kinc_g5_internal_init() { assert(!err); } -void kinc_g5_internal_destroy() {} +void iron_g5_internal_destroy() {} -void kinc_vulkan_init_window() { +void iron_vulkan_init_window() { // this function is used in the android backend struct vk_window *window = &vk_ctx.windows[0]; // delay swapchain/surface recreation - // otherwise trouble ensues due to G4onG5 backend ending the command list in kinc_g4_begin + // otherwise trouble ensues due to G4onG5 backend ending the command list in iron_g4_begin window->resized = true; window->surface_destroyed = true; } -void kinc_g5_internal_init_window(int depthBufferBits, bool vsync) { +void iron_g5_internal_init_window(int depthBufferBits, bool vsync) { struct vk_window *window = &vk_ctx.windows[0]; window->depth_bits = depthBufferBits; window->vsynced = vsync; - VkResult err = kinc_vulkan_create_surface(vk_ctx.instance, &window->surface); + VkResult err = iron_vulkan_create_surface(vk_ctx.instance, &window->surface); assert(!err); VkBool32 surface_supported; @@ -1114,16 +1114,16 @@ void kinc_g5_internal_init_window(int depthBufferBits, bool vsync) { } } free(surfFormats); - window->width = kinc_window_width(); - window->height = kinc_window_height(); + window->width = iron_window_width(); + window->height = iron_window_height(); create_swapchain(); create_render_target_render_pass(window); began = false; - kinc_g5_begin(NULL); + iron_g5_begin(NULL); } -void kinc_g5_internal_destroy_window() { +void iron_g5_internal_destroy_window() { struct vk_window *window = &vk_ctx.windows[0]; VkSwapchainKHR swapchain = cleanup_swapchain(); destroy_render_target_pass(window); @@ -1131,11 +1131,11 @@ void kinc_g5_internal_destroy_window() { vk.fpDestroySurfaceKHR(vk_ctx.instance, window->surface, NULL); } -bool kinc_g5_swap_buffers() { +bool iron_g5_swap_buffers() { return true; } -void kinc_g5_begin(kinc_g5_texture_t *renderTarget) { +void iron_g5_begin(iron_g5_texture_t *renderTarget) { struct vk_window *window = &vk_ctx.windows[0]; if (began) { @@ -1168,7 +1168,7 @@ void kinc_g5_begin(kinc_g5_texture_t *renderTarget) { while (err != VK_SUCCESS && err != VK_SUBOPTIMAL_KHR); } -void kinc_g5_end() { +void iron_g5_end() { VkPresentInfoKHR present = {0}; present.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; present.pNext = NULL; @@ -1198,11 +1198,11 @@ void kinc_g5_end() { began = false; } -void kinc_g5_flush() { +void iron_g5_flush() { vkDeviceWaitIdle(vk_ctx.device); } -bool kinc_vulkan_internal_get_size(int *width, int *height) { +bool iron_vulkan_internal_get_size(int *width, int *height) { // this is exclusively used by the Android backend at the moment if (vk_ctx.windows[0].surface) { VkSurfaceCapabilitiesKHR capabilities; @@ -1217,22 +1217,22 @@ bool kinc_vulkan_internal_get_size(int *width, int *height) { } } -bool kinc_g5_raytrace_supported() { -#ifdef KINC_ANDROID +bool iron_g5_raytrace_supported() { +#ifdef IRON_ANDROID return false; #else return true; #endif } -int kinc_g5_max_bound_textures(void) { +int iron_g5_max_bound_textures(void) { VkPhysicalDeviceProperties props; vkGetPhysicalDeviceProperties(vk_ctx.gpu, &props); return props.limits.maxPerStageDescriptorSamplers; } -static void endPass(kinc_g5_command_list_t *list) { +static void endPass(iron_g5_command_list_t *list) { if (in_render_pass) { vkCmdEndRenderPass(list->impl._buffer); in_render_pass = false; @@ -1389,7 +1389,7 @@ void flush_init_cmd() { vk_ctx.setup_cmd = VK_NULL_HANDLE; } -void set_viewport_and_scissor(kinc_g5_command_list_t *list) { +void set_viewport_and_scissor(iron_g5_command_list_t *list) { VkViewport viewport; memset(&viewport, 0, sizeof(viewport)); VkRect2D scissor; @@ -1397,13 +1397,13 @@ void set_viewport_and_scissor(kinc_g5_command_list_t *list) { if (currentRenderTargets[0] == NULL || currentRenderTargets[0]->framebuffer_index >= 0) { viewport.x = 0; - viewport.y = (float)kinc_window_height(); - viewport.width = (float)kinc_window_width(); - viewport.height = -(float)kinc_window_height(); + viewport.y = (float)iron_window_height(); + viewport.width = (float)iron_window_width(); + viewport.height = -(float)iron_window_height(); viewport.minDepth = (float)0.0f; viewport.maxDepth = (float)1.0f; - scissor.extent.width = kinc_window_width(); - scissor.extent.height = kinc_window_height(); + scissor.extent.width = iron_window_width(); + scissor.extent.height = iron_window_height(); scissor.offset.x = 0; scissor.offset.y = 0; } @@ -1424,7 +1424,7 @@ void set_viewport_and_scissor(kinc_g5_command_list_t *list) { vkCmdSetScissor(list->impl._buffer, 0, 1, &scissor); } -void kinc_g5_command_list_init(kinc_g5_command_list_t *list) { +void iron_g5_command_list_init(iron_g5_command_list_t *list) { VkCommandBufferAllocateInfo cmd = {0}; cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; cmd.pNext = NULL; @@ -1445,12 +1445,12 @@ void kinc_g5_command_list_init(kinc_g5_command_list_t *list) { list->impl._indexCount = 0; } -void kinc_g5_command_list_destroy(kinc_g5_command_list_t *list) { +void iron_g5_command_list_destroy(iron_g5_command_list_t *list) { vkFreeCommandBuffers(vk_ctx.device, vk_ctx.cmd_pool, 1, &list->impl._buffer); vkDestroyFence(vk_ctx.device, list->impl.fence, NULL); } -void kinc_g5_command_list_begin(kinc_g5_command_list_t *list) { +void iron_g5_command_list_begin(iron_g5_command_list_t *list) { VkResult err = vkWaitForFences(vk_ctx.device, 1, &list->impl.fence, VK_TRUE, UINT64_MAX); assert(!err); @@ -1522,7 +1522,7 @@ void kinc_g5_command_list_begin(kinc_g5_command_list_t *list) { mrtIndex = 0; } -void kinc_g5_command_list_end(kinc_g5_command_list_t *list) { +void iron_g5_command_list_end(iron_g5_command_list_t *list) { vkCmdEndRenderPass(list->impl._buffer); VkImageMemoryBarrier prePresentBarrier = {0}; @@ -1548,7 +1548,7 @@ void kinc_g5_command_list_end(kinc_g5_command_list_t *list) { assert(!err); } -void kinc_g5_command_list_clear(kinc_g5_command_list_t *list, struct kinc_g5_texture *renderTarget, unsigned flags, unsigned color, float depth) { +void iron_g5_command_list_clear(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget, unsigned flags, unsigned color, float depth) { VkClearRect clearRect = {0}; clearRect.rect.offset.x = 0; clearRect.rect.offset.y = 0; @@ -1559,7 +1559,7 @@ void kinc_g5_command_list_clear(kinc_g5_command_list_t *list, struct kinc_g5_tex int count = 0; VkClearAttachment attachments[2]; - if (flags & KINC_G5_CLEAR_COLOR) { + if (flags & IRON_G5_CLEAR_COLOR) { VkClearColorValue clearColor = {0}; clearColor.float32[0] = ((color & 0x00ff0000) >> 16) / 255.0f; clearColor.float32[1] = ((color & 0x0000ff00) >> 8) / 255.0f; @@ -1570,7 +1570,7 @@ void kinc_g5_command_list_clear(kinc_g5_command_list_t *list, struct kinc_g5_tex attachments[count].clearValue.color = clearColor; count++; } - if ((flags & KINC_G5_CLEAR_DEPTH) && renderTarget->impl.depthBufferBits > 0) { + if ((flags & IRON_G5_CLEAR_DEPTH) && renderTarget->impl.depthBufferBits > 0) { attachments[count].aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; attachments[count].clearValue.depthStencil.depth = depth; attachments[count].clearValue.depthStencil.stencil = 0; @@ -1579,19 +1579,19 @@ void kinc_g5_command_list_clear(kinc_g5_command_list_t *list, struct kinc_g5_tex vkCmdClearAttachments(list->impl._buffer, count, attachments, 1, &clearRect); } -void kinc_g5_command_list_render_target_to_framebuffer_barrier(kinc_g5_command_list_t *list, struct kinc_g5_texture *renderTarget) {} +void iron_g5_command_list_render_target_to_framebuffer_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) {} -void kinc_g5_command_list_framebuffer_to_render_target_barrier(kinc_g5_command_list_t *list, struct kinc_g5_texture *renderTarget) {} +void iron_g5_command_list_framebuffer_to_render_target_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) {} -void kinc_g5_command_list_draw_indexed_vertices(kinc_g5_command_list_t *list) { - kinc_g5_command_list_draw_indexed_vertices_from_to(list, 0, list->impl._indexCount); +void iron_g5_command_list_draw_indexed_vertices(iron_g5_command_list_t *list) { + iron_g5_command_list_draw_indexed_vertices_from_to(list, 0, list->impl._indexCount); } -void kinc_g5_command_list_draw_indexed_vertices_from_to(kinc_g5_command_list_t *list, int start, int count) { +void iron_g5_command_list_draw_indexed_vertices_from_to(iron_g5_command_list_t *list, int start, int count) { vkCmdDrawIndexed(list->impl._buffer, count, 1, start, 0, 0); } -void kinc_g5_command_list_viewport(kinc_g5_command_list_t *list, int x, int y, int width, int height) { +void iron_g5_command_list_viewport(iron_g5_command_list_t *list, int x, int y, int width, int height) { VkViewport viewport; memset(&viewport, 0, sizeof(viewport)); viewport.x = (float)x; @@ -1603,7 +1603,7 @@ void kinc_g5_command_list_viewport(kinc_g5_command_list_t *list, int x, int y, i vkCmdSetViewport(list->impl._buffer, 0, 1, &viewport); } -void kinc_g5_command_list_scissor(kinc_g5_command_list_t *list, int x, int y, int width, int height) { +void iron_g5_command_list_scissor(iron_g5_command_list_t *list, int x, int y, int width, int height) { VkRect2D scissor; memset(&scissor, 0, sizeof(scissor)); scissor.extent.width = width; @@ -1613,12 +1613,12 @@ void kinc_g5_command_list_scissor(kinc_g5_command_list_t *list, int x, int y, in vkCmdSetScissor(list->impl._buffer, 0, 1, &scissor); } -void kinc_g5_command_list_disable_scissor(kinc_g5_command_list_t *list) { +void iron_g5_command_list_disable_scissor(iron_g5_command_list_t *list) { VkRect2D scissor; memset(&scissor, 0, sizeof(scissor)); if (currentRenderTargets[0] == NULL || currentRenderTargets[0]->framebuffer_index >= 0) { - scissor.extent.width = kinc_window_width(); - scissor.extent.height = kinc_window_height(); + scissor.extent.width = iron_window_width(); + scissor.extent.height = iron_window_height(); } else { scissor.extent.width = currentRenderTargets[0]->width; @@ -1627,7 +1627,7 @@ void kinc_g5_command_list_disable_scissor(kinc_g5_command_list_t *list) { vkCmdSetScissor(list->impl._buffer, 0, 1, &scissor); } -void kinc_g5_command_list_set_pipeline(kinc_g5_command_list_t *list, struct kinc_g5_pipeline *pipeline) { +void iron_g5_command_list_set_pipeline(iron_g5_command_list_t *list, struct iron_g5_pipeline *pipeline) { current_pipeline = pipeline; lastVertexConstantBufferOffset = 0; lastFragmentConstantBufferOffset = 0; @@ -1642,7 +1642,7 @@ void kinc_g5_command_list_set_pipeline(kinc_g5_command_list_t *list, struct kinc } } -void kinc_g5_command_list_set_vertex_buffer(kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer *vertexBuffer) { +void iron_g5_command_list_set_vertex_buffer(iron_g5_command_list_t *list, struct iron_g5_vertex_buffer *vertexBuffer) { VkBuffer buffers[1]; VkDeviceSize offsets[1]; buffers[0] = vertexBuffer->impl.buf; @@ -1650,25 +1650,25 @@ void kinc_g5_command_list_set_vertex_buffer(kinc_g5_command_list_t *list, struct vkCmdBindVertexBuffers(list->impl._buffer, 0, 1, buffers, offsets); } -void kinc_g5_command_list_set_index_buffer(kinc_g5_command_list_t *list, struct kinc_g5_index_buffer *indexBuffer) { - list->impl._indexCount = kinc_g5_index_buffer_count(indexBuffer); +void iron_g5_command_list_set_index_buffer(iron_g5_command_list_t *list, struct iron_g5_index_buffer *indexBuffer) { + list->impl._indexCount = iron_g5_index_buffer_count(indexBuffer); vkCmdBindIndexBuffer(list->impl._buffer, indexBuffer->impl.buf, 0, VK_INDEX_TYPE_UINT32); } -void kinc_internal_restore_render_target(kinc_g5_command_list_t *list, struct kinc_g5_texture *target) { +void iron_internal_restore_render_target(iron_g5_command_list_t *list, struct iron_g5_texture *target) { VkViewport viewport; memset(&viewport, 0, sizeof(viewport)); viewport.x = 0; - viewport.y = (float)kinc_window_height(); - viewport.width = (float)kinc_window_width(); - viewport.height = -(float)kinc_window_height(); + viewport.y = (float)iron_window_height(); + viewport.width = (float)iron_window_width(); + viewport.height = -(float)iron_window_height(); viewport.minDepth = (float)0.0f; viewport.maxDepth = (float)1.0f; vkCmdSetViewport(list->impl._buffer, 0, 1, &viewport); VkRect2D scissor; memset(&scissor, 0, sizeof(scissor)); - scissor.extent.width = kinc_window_width(); - scissor.extent.height = kinc_window_height(); + scissor.extent.width = iron_window_width(); + scissor.extent.height = iron_window_height(); scissor.offset.x = 0; scissor.offset.y = 0; vkCmdSetScissor(list->impl._buffer, 0, 1, &scissor); @@ -1697,8 +1697,8 @@ void kinc_internal_restore_render_target(kinc_g5_command_list_t *list, struct ki rp_begin.framebuffer = vk_ctx.windows[0].framebuffers[vk_ctx.windows[0].current_image]; rp_begin.renderArea.offset.x = 0; rp_begin.renderArea.offset.y = 0; - rp_begin.renderArea.extent.width = kinc_window_width(); - rp_begin.renderArea.extent.height = kinc_window_height(); + rp_begin.renderArea.extent.width = iron_window_width(); + rp_begin.renderArea.extent.height = iron_window_height(); rp_begin.clearValueCount = 2; rp_begin.pClearValues = clear_values; vkCmdBeginRenderPass(list->impl._buffer, &rp_begin, VK_SUBPASS_CONTENTS_INLINE); @@ -1711,7 +1711,7 @@ void kinc_internal_restore_render_target(kinc_g5_command_list_t *list, struct ki } } -void kinc_g5_command_list_set_render_targets(kinc_g5_command_list_t *list, struct kinc_g5_texture **targets, int count) { +void iron_g5_command_list_set_render_targets(iron_g5_command_list_t *list, struct iron_g5_texture **targets, int count) { for (int i = 0; i < count; ++i) { currentRenderTargets[i] = targets[i]; } @@ -1720,7 +1720,7 @@ void kinc_g5_command_list_set_render_targets(kinc_g5_command_list_t *list, struc } if (targets[0]->framebuffer_index >= 0) { - kinc_internal_restore_render_target(list, targets[0]); + iron_internal_restore_render_target(list, targets[0]); return; } @@ -1893,13 +1893,13 @@ void kinc_g5_command_list_set_render_targets(kinc_g5_command_list_t *list, struc } } -void kinc_g5_command_list_upload_index_buffer(kinc_g5_command_list_t *list, struct kinc_g5_index_buffer *buffer) {} +void iron_g5_command_list_upload_index_buffer(iron_g5_command_list_t *list, struct iron_g5_index_buffer *buffer) {} -void kinc_g5_command_list_upload_vertex_buffer(kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer *buffer) {} +void iron_g5_command_list_upload_vertex_buffer(iron_g5_command_list_t *list, struct iron_g5_vertex_buffer *buffer) {} -void kinc_g5_command_list_upload_texture(kinc_g5_command_list_t *list, struct kinc_g5_texture *texture) {} +void iron_g5_command_list_upload_texture(iron_g5_command_list_t *list, struct iron_g5_texture *texture) {} -void kinc_g5_command_list_get_render_target_pixels(kinc_g5_command_list_t *list, kinc_g5_texture_t *render_target, uint8_t *data) { +void iron_g5_command_list_get_render_target_pixels(iron_g5_command_list_t *list, iron_g5_texture_t *render_target, uint8_t *data) { VkFormat format = render_target->impl.format; int format_bytes_size = format_size(format); @@ -1956,10 +1956,10 @@ void kinc_g5_command_list_get_render_target_pixels(kinc_g5_command_list_t *list, vkCmdBeginRenderPass(list->impl._buffer, ¤tRenderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE); in_render_pass = true; - kinc_g5_command_list_end(list); - kinc_g5_command_list_execute(list); - kinc_g5_command_list_wait_for_execution_to_finish(list); - kinc_g5_command_list_begin(list); + iron_g5_command_list_end(list); + iron_g5_command_list_execute(list); + iron_g5_command_list_wait_for_execution_to_finish(list); + iron_g5_command_list_begin(list); // Read buffer void *p; @@ -1968,19 +1968,19 @@ void kinc_g5_command_list_get_render_target_pixels(kinc_g5_command_list_t *list, vkUnmapMemory(vk_ctx.device, render_target->impl.readback_memory); } -void kinc_g5_command_list_texture_to_render_target_barrier(kinc_g5_command_list_t *list, struct kinc_g5_texture *renderTarget) { +void iron_g5_command_list_texture_to_render_target_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) { // render-passes are used to transition render-targets } -void kinc_g5_command_list_render_target_to_texture_barrier(kinc_g5_command_list_t *list, struct kinc_g5_texture *renderTarget) { +void iron_g5_command_list_render_target_to_texture_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) { // render-passes are used to transition render-targets } -void kinc_g5_command_list_set_vertex_constant_buffer(kinc_g5_command_list_t *list, struct kinc_g5_constant_buffer *buffer, int offset, size_t size) { +void iron_g5_command_list_set_vertex_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size) { lastVertexConstantBufferOffset = offset; } -void kinc_g5_command_list_set_fragment_constant_buffer(kinc_g5_command_list_t *list, struct kinc_g5_constant_buffer *buffer, int offset, size_t size) { +void iron_g5_command_list_set_fragment_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size) { lastFragmentConstantBufferOffset = offset; VkDescriptorSet descriptor_set = getDescriptorSet(); @@ -1988,7 +1988,7 @@ void kinc_g5_command_list_set_fragment_constant_buffer(kinc_g5_command_list_t *l vkCmdBindDescriptorSets(list->impl._buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, current_pipeline->impl.pipeline_layout, 0, 1, &descriptor_set, 2, offsets); } -void kinc_g5_command_list_set_compute_constant_buffer(kinc_g5_command_list_t *list, struct kinc_g5_constant_buffer *buffer, int offset, size_t size) { +void iron_g5_command_list_set_compute_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size) { lastComputeConstantBufferOffset = offset; VkDescriptorSet descriptor_set = get_compute_descriptor_set(); @@ -2001,7 +2001,7 @@ static void command_list_should_wait_for_framebuffer(void) { wait_for_framebuffer = true; } -void kinc_g5_command_list_execute(kinc_g5_command_list_t *list) { +void iron_g5_command_list_execute(iron_g5_command_list_t *list) { // Make sure the previous execution is done, so we can reuse the fence // Not optimal of course VkResult err = vkWaitForFences(vk_ctx.device, 1, &list->impl.fence, VK_TRUE, UINT64_MAX); @@ -2037,46 +2037,46 @@ void kinc_g5_command_list_execute(kinc_g5_command_list_t *list) { assert(!err); } -void kinc_g5_command_list_wait_for_execution_to_finish(kinc_g5_command_list_t *list) { +void iron_g5_command_list_wait_for_execution_to_finish(iron_g5_command_list_t *list) { VkResult err = vkWaitForFences(vk_ctx.device, 1, &list->impl.fence, VK_TRUE, UINT64_MAX); assert(!err); } -void kinc_g5_command_list_set_sampler(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_sampler_t *sampler) { - if (unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT] >= 0) { - vulkan_samplers[unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT]] = sampler->impl.sampler; +void iron_g5_command_list_set_sampler(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_sampler_t *sampler) { + if (unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] >= 0) { + vulkan_samplers[unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]] = sampler->impl.sampler; } } -void kinc_g5_command_list_set_texture(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_texture_t *texture) { - if (unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT] >= 0) { - texture->impl.stage = unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT]; - vulkan_textures[unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT]] = texture; +void iron_g5_command_list_set_texture(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *texture) { + if (unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] >= 0) { + texture->impl.stage = unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]; + vulkan_textures[unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]] = texture; } - else if (unit.stages[KINC_G5_SHADER_TYPE_VERTEX] >= 0) { - texture->impl.stage = unit.stages[KINC_G5_SHADER_TYPE_VERTEX]; - vulkan_textures[unit.stages[KINC_G5_SHADER_TYPE_VERTEX]] = texture; + else if (unit.stages[IRON_G5_SHADER_TYPE_VERTEX] >= 0) { + texture->impl.stage = unit.stages[IRON_G5_SHADER_TYPE_VERTEX]; + vulkan_textures[unit.stages[IRON_G5_SHADER_TYPE_VERTEX]] = texture; } } -void kinc_g5_command_list_set_texture_from_render_target_depth(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_texture_t *target) { - if (unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT] >= 0) { - target->impl.stage_depth = unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT]; - vulkan_textures[unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT]] = target; +void iron_g5_command_list_set_texture_from_render_target_depth(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *target) { + if (unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] >= 0) { + target->impl.stage_depth = unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]; + vulkan_textures[unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]] = target; } - else if (unit.stages[KINC_G5_SHADER_TYPE_VERTEX] >= 0) { - target->impl.stage_depth = unit.stages[KINC_G5_SHADER_TYPE_VERTEX]; - vulkan_textures[unit.stages[KINC_G5_SHADER_TYPE_VERTEX]] = target; + else if (unit.stages[IRON_G5_SHADER_TYPE_VERTEX] >= 0) { + target->impl.stage_depth = unit.stages[IRON_G5_SHADER_TYPE_VERTEX]; + vulkan_textures[unit.stages[IRON_G5_SHADER_TYPE_VERTEX]] = target; } } -void kinc_g5_command_list_set_compute_shader(kinc_g5_command_list_t *list, kinc_g5_compute_shader *shader) { +void iron_g5_command_list_set_compute_shader(iron_g5_command_list_t *list, iron_g5_compute_shader *shader) { current_compute_shader = shader; vkCmdBindPipeline(list->impl._buffer, VK_PIPELINE_BIND_POINT_COMPUTE, shader->impl.pipeline); //**vkCmdBindDescriptorSets(list->impl._buffer, VK_PIPELINE_BIND_POINT_COMPUTE, shader->impl.pipeline_layout, 0, 1, &shader->impl.descriptor_set, 0, 0); } -void kinc_g5_command_list_compute(kinc_g5_command_list_t *list, int x, int y, int z) { +void iron_g5_command_list_compute(iron_g5_command_list_t *list, int x, int y, int z) { if (in_render_pass) { vkCmdEndRenderPass(list->impl._buffer); in_render_pass = false; @@ -2092,7 +2092,7 @@ void kinc_g5_command_list_compute(kinc_g5_command_list_t *list, int x, int y, in ++render_target_count; } if (render_target_count > 0) { - kinc_g5_command_list_set_render_targets(list, currentRenderTargets, render_target_count); + iron_g5_command_list_set_render_targets(list, currentRenderTargets, render_target_count); } } @@ -2149,10 +2149,10 @@ static void create_compute_descriptor_layout(void) { assert(!err); } -void kinc_g5_compute_shader_init(kinc_g5_compute_shader *shader, void *_data, int length) { - memset(shader->impl.locations, 0, sizeof(kinc_internal_named_number) * KINC_INTERNAL_NAMED_NUMBER_COUNT); - memset(shader->impl.offsets, 0, sizeof(kinc_internal_named_number) * KINC_INTERNAL_NAMED_NUMBER_COUNT); - memset(shader->impl.texture_bindings, 0, sizeof(kinc_internal_named_number) * KINC_INTERNAL_NAMED_NUMBER_COUNT); +void iron_g5_compute_shader_init(iron_g5_compute_shader *shader, void *_data, int length) { + memset(shader->impl.locations, 0, sizeof(iron_internal_named_number) * IRON_INTERNAL_NAMED_NUMBER_COUNT); + memset(shader->impl.offsets, 0, sizeof(iron_internal_named_number) * IRON_INTERNAL_NAMED_NUMBER_COUNT); + memset(shader->impl.texture_bindings, 0, sizeof(iron_internal_named_number) * IRON_INTERNAL_NAMED_NUMBER_COUNT); parse_shader((uint32_t *)_data, length, shader->impl.locations, shader->impl.texture_bindings, shader->impl.offsets); VkPipelineLayoutCreateInfo pPipelineLayoutCreateInfo = {0}; @@ -2187,17 +2187,17 @@ void kinc_g5_compute_shader_init(kinc_g5_compute_shader *shader, void *_data, in vkDestroyShaderModule(vk_ctx.device, shader->impl.shader_module, NULL); } -void kinc_g5_compute_shader_destroy(kinc_g5_compute_shader *shader) {} +void iron_g5_compute_shader_destroy(iron_g5_compute_shader *shader) {} -kinc_g5_constant_location_t kinc_g5_compute_shader_get_constant_location(kinc_g5_compute_shader *shader, const char *name) { - kinc_g5_constant_location_t location = {0}; +iron_g5_constant_location_t iron_g5_compute_shader_get_constant_location(iron_g5_compute_shader *shader, const char *name) { + iron_g5_constant_location_t location = {0}; - uint32_t hash = kinc_internal_hash_name((unsigned char *)name); + uint32_t hash = iron_internal_hash_name((unsigned char *)name); return location; } -kinc_g5_texture_unit_t kinc_g5_compute_shader_get_texture_unit(kinc_g5_compute_shader *shader, const char *name) { +iron_g5_texture_unit_t iron_g5_compute_shader_get_texture_unit(iron_g5_compute_shader *shader, const char *name) { char unitName[64]; int unitOffset = 0; size_t len = strlen(name); @@ -2209,19 +2209,19 @@ kinc_g5_texture_unit_t kinc_g5_compute_shader_get_texture_unit(kinc_g5_compute_s unitName[len - 3] = 0; // Strip array from name } - uint32_t hash = kinc_internal_hash_name((unsigned char *)unitName); + uint32_t hash = iron_internal_hash_name((unsigned char *)unitName); - kinc_g5_texture_unit_t unit; - for (int i = 0; i < KINC_G5_SHADER_TYPE_COUNT; ++i) { + iron_g5_texture_unit_t unit; + for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { unit.stages[i] = -1; } - unit.stages[KINC_G5_SHADER_TYPE_COMPUTE] = 0; + unit.stages[IRON_G5_SHADER_TYPE_COMPUTE] = 0; return unit; } -static bool has_number(kinc_internal_named_number *named_numbers, const char *name) { - for (int i = 0; i < KINC_INTERNAL_NAMED_NUMBER_COUNT; ++i) { +static bool has_number(iron_internal_named_number *named_numbers, const char *name) { + for (int i = 0; i < IRON_INTERNAL_NAMED_NUMBER_COUNT; ++i) { if (strcmp(named_numbers[i].name, name) == 0) { return true; } @@ -2229,8 +2229,8 @@ static bool has_number(kinc_internal_named_number *named_numbers, const char *na return false; } -static uint32_t find_number(kinc_internal_named_number *named_numbers, const char *name) { - for (int i = 0; i < KINC_INTERNAL_NAMED_NUMBER_COUNT; ++i) { +static uint32_t find_number(iron_internal_named_number *named_numbers, const char *name) { + for (int i = 0; i < IRON_INTERNAL_NAMED_NUMBER_COUNT; ++i) { if (strcmp(named_numbers[i].name, name) == 0) { return named_numbers[i].number; } @@ -2238,15 +2238,15 @@ static uint32_t find_number(kinc_internal_named_number *named_numbers, const cha return -1; } -static void set_number(kinc_internal_named_number *named_numbers, const char *name, uint32_t number) { - for (int i = 0; i < KINC_INTERNAL_NAMED_NUMBER_COUNT; ++i) { +static void set_number(iron_internal_named_number *named_numbers, const char *name, uint32_t number) { + for (int i = 0; i < IRON_INTERNAL_NAMED_NUMBER_COUNT; ++i) { if (strcmp(named_numbers[i].name, name) == 0) { named_numbers[i].number = number; return; } } - for (int i = 0; i < KINC_INTERNAL_NAMED_NUMBER_COUNT; ++i) { + for (int i = 0; i < IRON_INTERNAL_NAMED_NUMBER_COUNT; ++i) { if (named_numbers[i].name[0] == 0) { strcpy(named_numbers[i].name, name); named_numbers[i].number = number; @@ -2305,8 +2305,8 @@ static void add_offset(uint32_t id, uint32_t offset) { ++offsets_size; } -static void parse_shader(uint32_t *shader_source, int shader_length, kinc_internal_named_number *locations, kinc_internal_named_number *textureBindings, - kinc_internal_named_number *uniformOffsets) { +static void parse_shader(uint32_t *shader_source, int shader_length, iron_internal_named_number *locations, iron_internal_named_number *textureBindings, + iron_internal_named_number *uniformOffsets) { names_size = 0; memberNames_size = 0; locs_size = 0; @@ -2415,47 +2415,47 @@ static VkShaderModule create_shader_module(const void *code, size_t size) { return module; } -static VkShaderModule prepare_vs(VkShaderModule *vert_shader_module, kinc_g5_shader_t *vertex_shader) { +static VkShaderModule prepare_vs(VkShaderModule *vert_shader_module, iron_g5_shader_t *vertex_shader) { *vert_shader_module = create_shader_module(vertex_shader->impl.source, vertex_shader->impl.length); return *vert_shader_module; } -static VkShaderModule prepare_fs(VkShaderModule *frag_shader_module, kinc_g5_shader_t *fragment_shader) { +static VkShaderModule prepare_fs(VkShaderModule *frag_shader_module, iron_g5_shader_t *fragment_shader) { *frag_shader_module = create_shader_module(fragment_shader->impl.source, fragment_shader->impl.length); return *frag_shader_module; } -static VkFormat convert_format(kinc_image_format_t format) { +static VkFormat convert_format(iron_image_format_t format) { switch (format) { - case KINC_IMAGE_FORMAT_RGBA128: + case IRON_IMAGE_FORMAT_RGBA128: return VK_FORMAT_R32G32B32A32_SFLOAT; - case KINC_IMAGE_FORMAT_RGBA64: + case IRON_IMAGE_FORMAT_RGBA64: return VK_FORMAT_R16G16B16A16_SFLOAT; - case KINC_IMAGE_FORMAT_R32: + case IRON_IMAGE_FORMAT_R32: return VK_FORMAT_R32_SFLOAT; - case KINC_IMAGE_FORMAT_R16: + case IRON_IMAGE_FORMAT_R16: return VK_FORMAT_R16_SFLOAT; - case KINC_IMAGE_FORMAT_R8: + case IRON_IMAGE_FORMAT_R8: return VK_FORMAT_R8_UNORM; - case KINC_IMAGE_FORMAT_RGBA32: + case IRON_IMAGE_FORMAT_RGBA32: default: return VK_FORMAT_B8G8R8A8_UNORM; } } -void kinc_g5_pipeline_init(kinc_g5_pipeline_t *pipeline) { - kinc_g5_internal_pipeline_init(pipeline); - kinc_g5_internal_pipeline_set_defaults(pipeline); +void iron_g5_pipeline_init(iron_g5_pipeline_t *pipeline) { + iron_g5_internal_pipeline_init(pipeline); + iron_g5_internal_pipeline_set_defaults(pipeline); } -void kinc_g5_pipeline_destroy(kinc_g5_pipeline_t *pipeline) { +void iron_g5_pipeline_destroy(iron_g5_pipeline_t *pipeline) { vkDestroyPipeline(vk_ctx.device, pipeline->impl.framebuffer_pipeline, NULL); vkDestroyPipeline(vk_ctx.device, pipeline->impl.rendertarget_pipeline, NULL); vkDestroyPipelineLayout(vk_ctx.device, pipeline->impl.pipeline_layout, NULL); } -kinc_g5_constant_location_t kinc_g5_pipeline_get_constant_location(kinc_g5_pipeline_t *pipeline, const char *name) { - kinc_g5_constant_location_t location; +iron_g5_constant_location_t iron_g5_pipeline_get_constant_location(iron_g5_pipeline_t *pipeline, const char *name) { + iron_g5_constant_location_t location; location.impl.vertexOffset = -1; location.impl.fragmentOffset = -1; location.impl.computeOffset = -1; @@ -2468,9 +2468,9 @@ kinc_g5_constant_location_t kinc_g5_pipeline_get_constant_location(kinc_g5_pipel return location; } -kinc_g5_texture_unit_t kinc_g5_pipeline_get_texture_unit(kinc_g5_pipeline_t *pipeline, const char *name) { - kinc_g5_texture_unit_t unit; - for (int i = 0; i < KINC_G5_SHADER_TYPE_COUNT; ++i) { +iron_g5_texture_unit_t iron_g5_pipeline_get_texture_unit(iron_g5_pipeline_t *pipeline, const char *name) { + iron_g5_texture_unit_t unit; + for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { unit.stages[i] = -1; } @@ -2478,77 +2478,77 @@ kinc_g5_texture_unit_t kinc_g5_pipeline_get_texture_unit(kinc_g5_pipeline_t *pip assert(number == -1 || number >= 2); // something wrong with the SPIR-V when this triggers if (number >= 0) { - unit.stages[KINC_G5_SHADER_TYPE_VERTEX] = number - 2; + unit.stages[IRON_G5_SHADER_TYPE_VERTEX] = number - 2; } else { number = find_number(pipeline->impl.fragmentTextureBindings, name); if (number >= 0) { - unit.stages[KINC_G5_SHADER_TYPE_FRAGMENT] = number - 2; + unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] = number - 2; } } return unit; } -static VkCullModeFlagBits convert_cull_mode(kinc_g5_cull_mode_t cull_mode) { +static VkCullModeFlagBits convert_cull_mode(iron_g5_cull_mode_t cull_mode) { switch (cull_mode) { - case KINC_G5_CULL_MODE_CLOCKWISE: + case IRON_G5_CULL_MODE_CLOCKWISE: return VK_CULL_MODE_BACK_BIT; - case KINC_G5_CULL_MODE_COUNTERCLOCKWISE: + case IRON_G5_CULL_MODE_COUNTERCLOCKWISE: return VK_CULL_MODE_FRONT_BIT; - case KINC_G5_CULL_MODE_NEVER: + case IRON_G5_CULL_MODE_NEVER: default: return VK_CULL_MODE_NONE; } } -static VkCompareOp convert_compare_mode(kinc_g5_compare_mode_t compare) { +static VkCompareOp convert_compare_mode(iron_g5_compare_mode_t compare) { switch (compare) { default: - case KINC_G5_COMPARE_MODE_ALWAYS: + case IRON_G5_COMPARE_MODE_ALWAYS: return VK_COMPARE_OP_ALWAYS; - case KINC_G5_COMPARE_MODE_NEVER: + case IRON_G5_COMPARE_MODE_NEVER: return VK_COMPARE_OP_NEVER; - case KINC_G5_COMPARE_MODE_EQUAL: + case IRON_G5_COMPARE_MODE_EQUAL: return VK_COMPARE_OP_EQUAL; - case KINC_G5_COMPARE_MODE_NOT_EQUAL: + case IRON_G5_COMPARE_MODE_NOT_EQUAL: return VK_COMPARE_OP_NOT_EQUAL; - case KINC_G5_COMPARE_MODE_LESS: + case IRON_G5_COMPARE_MODE_LESS: return VK_COMPARE_OP_LESS; - case KINC_G5_COMPARE_MODE_LESS_EQUAL: + case IRON_G5_COMPARE_MODE_LESS_EQUAL: return VK_COMPARE_OP_LESS_OR_EQUAL; - case KINC_G5_COMPARE_MODE_GREATER: + case IRON_G5_COMPARE_MODE_GREATER: return VK_COMPARE_OP_GREATER; - case KINC_G5_COMPARE_MODE_GREATER_EQUAL: + case IRON_G5_COMPARE_MODE_GREATER_EQUAL: return VK_COMPARE_OP_GREATER_OR_EQUAL; } } -static VkBlendFactor convert_blend_factor(kinc_g5_blending_factor_t factor) { +static VkBlendFactor convert_blend_factor(iron_g5_blending_factor_t factor) { switch (factor) { - case KINC_G5_BLEND_ONE: + case IRON_G5_BLEND_ONE: return VK_BLEND_FACTOR_ONE; - case KINC_G5_BLEND_ZERO: + case IRON_G5_BLEND_ZERO: return VK_BLEND_FACTOR_ZERO; - case KINC_G5_BLEND_SOURCE_ALPHA: + case IRON_G5_BLEND_SOURCE_ALPHA: return VK_BLEND_FACTOR_SRC_ALPHA; - case KINC_G5_BLEND_DEST_ALPHA: + case IRON_G5_BLEND_DEST_ALPHA: return VK_BLEND_FACTOR_DST_ALPHA; - case KINC_G5_BLEND_INV_SOURCE_ALPHA: + case IRON_G5_BLEND_INV_SOURCE_ALPHA: return VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; - case KINC_G5_BLEND_INV_DEST_ALPHA: + case IRON_G5_BLEND_INV_DEST_ALPHA: return VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA; - case KINC_G5_BLEND_SOURCE_COLOR: + case IRON_G5_BLEND_SOURCE_COLOR: return VK_BLEND_FACTOR_SRC_COLOR; - case KINC_G5_BLEND_DEST_COLOR: + case IRON_G5_BLEND_DEST_COLOR: return VK_BLEND_FACTOR_DST_COLOR; - case KINC_G5_BLEND_INV_SOURCE_COLOR: + case IRON_G5_BLEND_INV_SOURCE_COLOR: return VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR; - case KINC_G5_BLEND_INV_DEST_COLOR: + case IRON_G5_BLEND_INV_DEST_COLOR: return VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR; - case KINC_G5_BLEND_CONSTANT: + case IRON_G5_BLEND_CONSTANT: return VK_BLEND_FACTOR_CONSTANT_COLOR; - case KINC_G5_BLEND_INV_CONSTANT: + case IRON_G5_BLEND_INV_CONSTANT: return VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR; default: assert(false); @@ -2556,17 +2556,17 @@ static VkBlendFactor convert_blend_factor(kinc_g5_blending_factor_t factor) { } } -static VkBlendOp convert_blend_operation(kinc_g5_blending_operation_t op) { +static VkBlendOp convert_blend_operation(iron_g5_blending_operation_t op) { switch (op) { - case KINC_G5_BLENDOP_ADD: + case IRON_G5_BLENDOP_ADD: return VK_BLEND_OP_ADD; - case KINC_G5_BLENDOP_SUBTRACT: + case IRON_G5_BLENDOP_SUBTRACT: return VK_BLEND_OP_SUBTRACT; - case KINC_G5_BLENDOP_REVERSE_SUBTRACT: + case IRON_G5_BLENDOP_REVERSE_SUBTRACT: return VK_BLEND_OP_REVERSE_SUBTRACT; - case KINC_G5_BLENDOP_MIN: + case IRON_G5_BLENDOP_MIN: return VK_BLEND_OP_MIN; - case KINC_G5_BLENDOP_MAX: + case IRON_G5_BLENDOP_MAX: return VK_BLEND_OP_MAX; default: assert(false); @@ -2574,13 +2574,13 @@ static VkBlendOp convert_blend_operation(kinc_g5_blending_operation_t op) { } } -void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipeline) { - memset(pipeline->impl.vertexLocations, 0, sizeof(kinc_internal_named_number) * KINC_INTERNAL_NAMED_NUMBER_COUNT); - memset(pipeline->impl.vertexOffsets, 0, sizeof(kinc_internal_named_number) * KINC_INTERNAL_NAMED_NUMBER_COUNT); - memset(pipeline->impl.fragmentLocations, 0, sizeof(kinc_internal_named_number) * KINC_INTERNAL_NAMED_NUMBER_COUNT); - memset(pipeline->impl.fragmentOffsets, 0, sizeof(kinc_internal_named_number) * KINC_INTERNAL_NAMED_NUMBER_COUNT); - memset(pipeline->impl.vertexTextureBindings, 0, sizeof(kinc_internal_named_number) * KINC_INTERNAL_NAMED_NUMBER_COUNT); - memset(pipeline->impl.fragmentTextureBindings, 0, sizeof(kinc_internal_named_number) * KINC_INTERNAL_NAMED_NUMBER_COUNT); +void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipeline) { + memset(pipeline->impl.vertexLocations, 0, sizeof(iron_internal_named_number) * IRON_INTERNAL_NAMED_NUMBER_COUNT); + memset(pipeline->impl.vertexOffsets, 0, sizeof(iron_internal_named_number) * IRON_INTERNAL_NAMED_NUMBER_COUNT); + memset(pipeline->impl.fragmentLocations, 0, sizeof(iron_internal_named_number) * IRON_INTERNAL_NAMED_NUMBER_COUNT); + memset(pipeline->impl.fragmentOffsets, 0, sizeof(iron_internal_named_number) * IRON_INTERNAL_NAMED_NUMBER_COUNT); + memset(pipeline->impl.vertexTextureBindings, 0, sizeof(iron_internal_named_number) * IRON_INTERNAL_NAMED_NUMBER_COUNT); + memset(pipeline->impl.fragmentTextureBindings, 0, sizeof(iron_internal_named_number) * IRON_INTERNAL_NAMED_NUMBER_COUNT); parse_shader((uint32_t *)pipeline->vertex_shader->impl.source, pipeline->vertex_shader->impl.length, pipeline->impl.vertexLocations, pipeline->impl.vertexTextureBindings, pipeline->impl.vertexOffsets); parse_shader((uint32_t *)pipeline->fragment_shader->impl.source, pipeline->fragment_shader->impl.length, pipeline->impl.fragmentLocations, @@ -2631,33 +2631,33 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipeline) { uint32_t attr = 0; uint32_t offset = 0; for (int i = 0; i < pipeline->input_layout->size; ++i) { - kinc_g5_vertex_element_t element = pipeline->input_layout->elements[i]; + iron_g5_vertex_element_t element = pipeline->input_layout->elements[i]; vi_attrs[attr].binding = 0; vi_attrs[attr].location = find_number(pipeline->impl.vertexLocations, element.name); vi_attrs[attr].offset = offset; - offset += kinc_g5_vertex_data_size(element.data); + offset += iron_g5_vertex_data_size(element.data); switch (element.data) { - case KINC_G5_VERTEX_DATA_F32_1X: + case IRON_G5_VERTEX_DATA_F32_1X: vi_attrs[attr].format = VK_FORMAT_R32_SFLOAT; break; - case KINC_G5_VERTEX_DATA_F32_2X: + case IRON_G5_VERTEX_DATA_F32_2X: vi_attrs[attr].format = VK_FORMAT_R32G32_SFLOAT; break; - case KINC_G5_VERTEX_DATA_F32_3X: + case IRON_G5_VERTEX_DATA_F32_3X: vi_attrs[attr].format = VK_FORMAT_R32G32B32_SFLOAT; break; - case KINC_G5_VERTEX_DATA_F32_4X: + case IRON_G5_VERTEX_DATA_F32_4X: vi_attrs[attr].format = VK_FORMAT_R32G32B32A32_SFLOAT; break; - case KINC_G5_VERTEX_DATA_U8_4X_NORM: + case IRON_G5_VERTEX_DATA_U8_4X_NORM: vi_attrs[attr].format = VK_FORMAT_R8G8B8A8_UNORM; break; - case KINC_G5_VERTEX_DATA_I16_2X_NORM: + case IRON_G5_VERTEX_DATA_I16_2X_NORM: vi_attrs[attr].format = VK_FORMAT_R16G16_SNORM; break; - case KINC_G5_VERTEX_DATA_I16_4X_NORM: + case IRON_G5_VERTEX_DATA_I16_4X_NORM: vi_attrs[attr].format = VK_FORMAT_R16G16B16A16_SNORM; break; } @@ -2691,10 +2691,10 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipeline) { (pipeline->color_write_mask_green[i] ? VK_COLOR_COMPONENT_G_BIT : 0) | (pipeline->color_write_mask_blue[i] ? VK_COLOR_COMPONENT_B_BIT : 0) | (pipeline->color_write_mask_alpha[i] ? VK_COLOR_COMPONENT_A_BIT : 0); - att_state[i].blendEnable = pipeline->blend_source != KINC_G5_BLEND_ONE || - pipeline->blend_destination != KINC_G5_BLEND_ZERO || - pipeline->alpha_blend_source != KINC_G5_BLEND_ONE || - pipeline->alpha_blend_destination != KINC_G5_BLEND_ZERO; + att_state[i].blendEnable = pipeline->blend_source != IRON_G5_BLEND_ONE || + pipeline->blend_destination != IRON_G5_BLEND_ZERO || + pipeline->alpha_blend_source != IRON_G5_BLEND_ONE || + pipeline->alpha_blend_destination != IRON_G5_BLEND_ZERO; att_state[i].srcColorBlendFactor = convert_blend_factor(pipeline->blend_source); att_state[i].dstColorBlendFactor = convert_blend_factor(pipeline->blend_destination); att_state[i].colorBlendOp = convert_blend_operation(pipeline->blend_operation); @@ -2714,7 +2714,7 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipeline) { memset(&ds, 0, sizeof(ds)); ds.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; - ds.depthTestEnable = pipeline->depth_mode != KINC_G5_COMPARE_MODE_ALWAYS; + ds.depthTestEnable = pipeline->depth_mode != IRON_G5_COMPARE_MODE_ALWAYS; ds.depthWriteEnable = pipeline->depth_write; ds.depthCompareOp = convert_compare_mode(pipeline->depth_mode); ds.depthBoundsTestEnable = VK_FALSE; @@ -3264,7 +3264,7 @@ static VkDescriptorSet get_compute_descriptor_set() { return descriptor_set; } -void kinc_g5_shader_init(kinc_g5_shader_t *shader, const void *source, size_t length, kinc_g5_shader_type_t type) { +void iron_g5_shader_init(iron_g5_shader_t *shader, const void *source, size_t length, iron_g5_shader_type_t type) { shader->impl.length = (int)length; shader->impl.id = 0; shader->impl.source = (char *)malloc(length + 1); @@ -3274,22 +3274,22 @@ void kinc_g5_shader_init(kinc_g5_shader_t *shader, const void *source, size_t le shader->impl.source[length] = 0; } -void kinc_g5_shader_destroy(kinc_g5_shader_t *shader) { +void iron_g5_shader_destroy(iron_g5_shader_t *shader) { free(shader->impl.source); shader->impl.source = NULL; } -static VkCompareOp convert_compare_mode(kinc_g5_compare_mode_t compare); +static VkCompareOp convert_compare_mode(iron_g5_compare_mode_t compare); -static VkSamplerAddressMode convert_addressing(kinc_g5_texture_addressing_t mode) { +static VkSamplerAddressMode convert_addressing(iron_g5_texture_addressing_t mode) { switch (mode) { - case KINC_G5_TEXTURE_ADDRESSING_REPEAT: + case IRON_G5_TEXTURE_ADDRESSING_REPEAT: return VK_SAMPLER_ADDRESS_MODE_REPEAT; - case KINC_G5_TEXTURE_ADDRESSING_BORDER: + case IRON_G5_TEXTURE_ADDRESSING_BORDER: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER; - case KINC_G5_TEXTURE_ADDRESSING_CLAMP: + case IRON_G5_TEXTURE_ADDRESSING_CLAMP: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; - case KINC_G5_TEXTURE_ADDRESSING_MIRROR: + case IRON_G5_TEXTURE_ADDRESSING_MIRROR: return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT; default: assert(false); @@ -3297,12 +3297,12 @@ static VkSamplerAddressMode convert_addressing(kinc_g5_texture_addressing_t mode } } -static VkSamplerMipmapMode convert_mipmap_mode(kinc_g5_mipmap_filter_t filter) { +static VkSamplerMipmapMode convert_mipmap_mode(iron_g5_mipmap_filter_t filter) { switch (filter) { - case KINC_G5_MIPMAP_FILTER_NONE: - case KINC_G5_MIPMAP_FILTER_POINT: + case IRON_G5_MIPMAP_FILTER_NONE: + case IRON_G5_MIPMAP_FILTER_POINT: return VK_SAMPLER_MIPMAP_MODE_NEAREST; - case KINC_G5_MIPMAP_FILTER_LINEAR: + case IRON_G5_MIPMAP_FILTER_LINEAR: return VK_SAMPLER_MIPMAP_MODE_LINEAR; default: assert(false); @@ -3310,13 +3310,13 @@ static VkSamplerMipmapMode convert_mipmap_mode(kinc_g5_mipmap_filter_t filter) { } } -static VkFilter convert_texture_filter(kinc_g5_texture_filter_t filter) { +static VkFilter convert_texture_filter(iron_g5_texture_filter_t filter) { switch (filter) { - case KINC_G5_TEXTURE_FILTER_POINT: + case IRON_G5_TEXTURE_FILTER_POINT: return VK_FILTER_NEAREST; - case KINC_G5_TEXTURE_FILTER_LINEAR: + case IRON_G5_TEXTURE_FILTER_LINEAR: return VK_FILTER_LINEAR; - case KINC_G5_TEXTURE_FILTER_ANISOTROPIC: + case IRON_G5_TEXTURE_FILTER_ANISOTROPIC: return VK_FILTER_LINEAR; // ? default: assert(false); @@ -3324,7 +3324,7 @@ static VkFilter convert_texture_filter(kinc_g5_texture_filter_t filter) { } } -void kinc_g5_sampler_init(kinc_g5_sampler_t *sampler, const kinc_g5_sampler_options_t *options) { +void iron_g5_sampler_init(iron_g5_sampler_t *sampler, const iron_g5_sampler_options_t *options) { VkSamplerCreateInfo info = {0}; info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; info.pNext = NULL; @@ -3340,7 +3340,7 @@ void kinc_g5_sampler_init(kinc_g5_sampler_t *sampler, const kinc_g5_sampler_opti info.minFilter = convert_texture_filter(options->minification_filter); info.anisotropyEnable = - (options->magnification_filter == KINC_G5_TEXTURE_FILTER_ANISOTROPIC || options->minification_filter == KINC_G5_TEXTURE_FILTER_ANISOTROPIC); + (options->magnification_filter == IRON_G5_TEXTURE_FILTER_ANISOTROPIC || options->minification_filter == IRON_G5_TEXTURE_FILTER_ANISOTROPIC); info.maxAnisotropy = 1; info.maxLod = 32; @@ -3349,7 +3349,7 @@ void kinc_g5_sampler_init(kinc_g5_sampler_t *sampler, const kinc_g5_sampler_opti vkCreateSampler(vk_ctx.device, &info, NULL, &sampler->impl.sampler); } -void kinc_g5_sampler_destroy(kinc_g5_sampler_t *sampler) { +void iron_g5_sampler_destroy(iron_g5_sampler_t *sampler) { vkDestroySampler(vk_ctx.device, sampler->impl.sampler, NULL); } @@ -3499,46 +3499,46 @@ static void prepare_texture_image(uint8_t *tex_colors, uint32_t width, uint32_t set_image_layout(tex_obj->image, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_UNDEFINED, tex_obj->imageLayout); } -static VkFormat convert_image_format(kinc_image_format_t format) { +static VkFormat convert_image_format(iron_image_format_t format) { switch (format) { - case KINC_IMAGE_FORMAT_RGBA128: + case IRON_IMAGE_FORMAT_RGBA128: return VK_FORMAT_R32G32B32A32_SFLOAT; - case KINC_IMAGE_FORMAT_RGBA64: + case IRON_IMAGE_FORMAT_RGBA64: return VK_FORMAT_R16G16B16A16_SFLOAT; - case KINC_IMAGE_FORMAT_R8: + case IRON_IMAGE_FORMAT_R8: return VK_FORMAT_R8_UNORM; - case KINC_IMAGE_FORMAT_R16: + case IRON_IMAGE_FORMAT_R16: return VK_FORMAT_R16_SFLOAT; - case KINC_IMAGE_FORMAT_R32: + case IRON_IMAGE_FORMAT_R32: return VK_FORMAT_R32_SFLOAT; - case KINC_IMAGE_FORMAT_BGRA32: + case IRON_IMAGE_FORMAT_BGRA32: return VK_FORMAT_B8G8R8A8_UNORM; - case KINC_IMAGE_FORMAT_RGBA32: + case IRON_IMAGE_FORMAT_RGBA32: return VK_FORMAT_R8G8B8A8_UNORM; default: return VK_FORMAT_B8G8R8A8_UNORM; } } -static int format_byte_size(kinc_image_format_t format) { +static int format_byte_size(iron_image_format_t format) { switch (format) { - case KINC_IMAGE_FORMAT_RGBA128: + case IRON_IMAGE_FORMAT_RGBA128: return 16; - case KINC_IMAGE_FORMAT_RGBA64: + case IRON_IMAGE_FORMAT_RGBA64: return 8; - case KINC_IMAGE_FORMAT_R16: + case IRON_IMAGE_FORMAT_R16: return 2; - case KINC_IMAGE_FORMAT_R8: + case IRON_IMAGE_FORMAT_R8: return 1; - case KINC_IMAGE_FORMAT_BGRA32: - case KINC_IMAGE_FORMAT_RGBA32: - case KINC_IMAGE_FORMAT_R32: + case IRON_IMAGE_FORMAT_BGRA32: + case IRON_IMAGE_FORMAT_RGBA32: + case IRON_IMAGE_FORMAT_R32: default: return 4; } } -static void update_stride(kinc_g5_texture_t *texture) { +static void update_stride(iron_g5_texture_t *texture) { VkImageSubresource subres = {0}; subres.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; subres.mipLevel = 0; @@ -3550,7 +3550,7 @@ static void update_stride(kinc_g5_texture_t *texture) { texture->impl.stride = (int)layout.rowPitch; } -void kinc_g5_texture_init_from_bytes(kinc_g5_texture_t *texture, void *data, int width, int height, kinc_image_format_t format) { +void iron_g5_texture_init_from_bytes(iron_g5_texture_t *texture, void *data, int width, int height, iron_image_format_t format) { texture->width = width; texture->height = height; texture->_uploaded = false; @@ -3558,7 +3558,7 @@ void kinc_g5_texture_init_from_bytes(kinc_g5_texture_t *texture, void *data, int texture->data = data; texture->impl.stage = 0; texture->impl.stage_depth = -1; - texture->state = KINC_INTERNAL_RENDER_TARGET_STATE_TEXTURE; + texture->state = IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE; texture->framebuffer_index = -1; const VkFormat tex_format = convert_image_format(format); @@ -3642,7 +3642,7 @@ void kinc_g5_texture_init_from_bytes(kinc_g5_texture_t *texture, void *data, int assert(!err); } -void kinc_g5_texture_init(kinc_g5_texture_t *texture, int width, int height, kinc_image_format_t format) { +void iron_g5_texture_init(iron_g5_texture_t *texture, int width, int height, iron_image_format_t format) { texture->width = width; texture->height = height; texture->_uploaded = true; @@ -3650,7 +3650,7 @@ void kinc_g5_texture_init(kinc_g5_texture_t *texture, int width, int height, kin texture->data = NULL; texture->impl.stage = 0; texture->impl.stage_depth = -1; - texture->state = KINC_INTERNAL_RENDER_TARGET_STATE_TEXTURE; + texture->state = IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE; texture->framebuffer_index = -1; const VkFormat tex_format = convert_image_format(format); @@ -3690,7 +3690,7 @@ void kinc_g5_texture_init(kinc_g5_texture_t *texture, int width, int height, kin assert(!err); } -void kinc_g5_texture_init_non_sampled_access(kinc_g5_texture_t *texture, int width, int height, kinc_image_format_t format) { +void iron_g5_texture_init_non_sampled_access(iron_g5_texture_t *texture, int width, int height, iron_image_format_t format) { texture->width = width; texture->height = height; @@ -3731,7 +3731,7 @@ void kinc_g5_texture_init_non_sampled_access(kinc_g5_texture_t *texture, int wid assert(!err); } -void kinc_g5_texture_destroy(kinc_g5_texture_t *target) { +void iron_g5_texture_destroy(iron_g5_texture_t *target) { if (target->framebuffer_index >= 0) { framebuffer_count -= 1; } @@ -3751,15 +3751,15 @@ void kinc_g5_texture_destroy(kinc_g5_texture_t *target) { } } -void kinc_g5_internal_texture_set(kinc_g5_texture_t *texture, int unit) {} +void iron_g5_internal_texture_set(iron_g5_texture_t *texture, int unit) {} -int kinc_g5_texture_stride(kinc_g5_texture_t *texture) { +int iron_g5_texture_stride(iron_g5_texture_t *texture) { return texture->impl.stride; } -void kinc_g5_texture_generate_mipmaps(kinc_g5_texture_t *texture, int levels) {} +void iron_g5_texture_generate_mipmaps(iron_g5_texture_t *texture, int levels) {} -void kinc_g5_texture_set_mipmap(kinc_g5_texture_t *texture, kinc_g5_texture_t *mipmap, int level) { +void iron_g5_texture_set_mipmap(iron_g5_texture_t *texture, iron_g5_texture_t *mipmap, int level) { // VkBuffer staging_buffer; // VkDeviceMemory staging_buffer_mem; @@ -3887,7 +3887,7 @@ void setImageLayout(VkCommandBuffer _buffer, VkImage image, VkImageAspectFlags a vkCmdPipelineBarrier(_buffer, srcStageFlags, dstStageFlags, 0, 0, NULL, 0, NULL, 1, &imageMemoryBarrier); } -static void render_target_init(kinc_g5_texture_t *target, int width, int height, kinc_image_format_t format, int depthBufferBits, int framebuffer_index) { +static void render_target_init(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits, int framebuffer_index) { target->framebuffer_index = framebuffer_index; target->width = width; target->height = height; @@ -4062,20 +4062,20 @@ static void render_target_init(kinc_g5_texture_t *target, int width, int height, } } -void kinc_g5_render_target_init(kinc_g5_texture_t *target, int width, int height, kinc_image_format_t format, int depthBufferBits) { +void iron_g5_render_target_init(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { render_target_init(target, width, height, format, depthBufferBits, -1); target->width = width; target->height = height; - target->state = KINC_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; + target->state = IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; target->_uploaded = true; } -void kinc_g5_render_target_init_framebuffer(kinc_g5_texture_t *target, int width, int height, kinc_image_format_t format, int depthBufferBits) { +void iron_g5_render_target_init_framebuffer(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { render_target_init(target, width, height, format, depthBufferBits, framebuffer_count); framebuffer_count += 1; } -void kinc_g5_render_target_set_depth_from(kinc_g5_texture_t *target, kinc_g5_texture_t *source) { +void iron_g5_render_target_set_depth_from(iron_g5_texture_t *target, iron_g5_texture_t *source) { target->impl.depthImage = source->impl.depthImage; target->impl.depthMemory = source->impl.depthMemory; target->impl.depthView = source->impl.depthView; @@ -4111,12 +4111,12 @@ void kinc_g5_render_target_set_depth_from(kinc_g5_texture_t *target, kinc_g5_tex } } -void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int vertexCount, kinc_g5_vertex_structure_t *structure, bool gpuMemory) { +void iron_g5_vertex_buffer_init(iron_g5_vertex_buffer_t *buffer, int vertexCount, iron_g5_vertex_structure_t *structure, bool gpuMemory) { buffer->impl.myCount = vertexCount; buffer->impl.myStride = 0; for (int i = 0; i < structure->size; ++i) { - kinc_g5_vertex_element_t element = structure->elements[i]; - buffer->impl.myStride += kinc_g5_vertex_data_size(element.data); + iron_g5_vertex_element_t element = structure->elements[i]; + buffer->impl.myStride += iron_g5_vertex_data_size(element.data); } VkBufferCreateInfo buf_info = {0}; @@ -4125,7 +4125,7 @@ void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int vertexCount buf_info.size = vertexCount * buffer->impl.myStride; buf_info.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT; - if (kinc_g5_raytrace_supported()) { + if (iron_g5_raytrace_supported()) { buf_info.usage |= VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT; buf_info.usage |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; buf_info.usage |= VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR; @@ -4157,7 +4157,7 @@ void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int vertexCount assert(pass); VkMemoryAllocateFlagsInfo memory_allocate_flags_info = {0}; - if (kinc_g5_raytrace_supported()) { + if (iron_g5_raytrace_supported()) { memory_allocate_flags_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO; memory_allocate_flags_info.flags = VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR; buffer->impl.mem_alloc.pNext = &memory_allocate_flags_info; @@ -4170,48 +4170,48 @@ void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int vertexCount assert(!err); } -static void unset_vertex_buffer(kinc_g5_vertex_buffer_t *buffer) { +static void unset_vertex_buffer(iron_g5_vertex_buffer_t *buffer) { } -void kinc_g5_vertex_buffer_destroy(kinc_g5_vertex_buffer_t *buffer) { +void iron_g5_vertex_buffer_destroy(iron_g5_vertex_buffer_t *buffer) { unset_vertex_buffer(buffer); vkFreeMemory(vk_ctx.device, buffer->impl.mem, NULL); vkDestroyBuffer(vk_ctx.device, buffer->impl.buf, NULL); } -float *kinc_g5_vertex_buffer_lock_all(kinc_g5_vertex_buffer_t *buffer) { - return kinc_g5_vertex_buffer_lock(buffer, 0, buffer->impl.myCount); +float *iron_g5_vertex_buffer_lock_all(iron_g5_vertex_buffer_t *buffer) { + return iron_g5_vertex_buffer_lock(buffer, 0, buffer->impl.myCount); } -float *kinc_g5_vertex_buffer_lock(kinc_g5_vertex_buffer_t *buffer, int start, int count) { +float *iron_g5_vertex_buffer_lock(iron_g5_vertex_buffer_t *buffer, int start, int count) { VkResult err = vkMapMemory(vk_ctx.device, buffer->impl.mem, start * buffer->impl.myStride, count * buffer->impl.myStride, 0, (void **)&buffer->impl.data); assert(!err); return buffer->impl.data; } -void kinc_g5_vertex_buffer_unlock_all(kinc_g5_vertex_buffer_t *buffer) { +void iron_g5_vertex_buffer_unlock_all(iron_g5_vertex_buffer_t *buffer) { vkUnmapMemory(vk_ctx.device, buffer->impl.mem); } -void kinc_g5_vertex_buffer_unlock(kinc_g5_vertex_buffer_t *buffer, int count) { +void iron_g5_vertex_buffer_unlock(iron_g5_vertex_buffer_t *buffer, int count) { vkUnmapMemory(vk_ctx.device, buffer->impl.mem); } -int kinc_g5_internal_vertex_buffer_set(kinc_g5_vertex_buffer_t *buffer) { +int iron_g5_internal_vertex_buffer_set(iron_g5_vertex_buffer_t *buffer) { return 0; } -int kinc_g5_vertex_buffer_count(kinc_g5_vertex_buffer_t *buffer) { +int iron_g5_vertex_buffer_count(iron_g5_vertex_buffer_t *buffer) { return buffer->impl.myCount; } -int kinc_g5_vertex_buffer_stride(kinc_g5_vertex_buffer_t *buffer) { +int iron_g5_vertex_buffer_stride(iron_g5_vertex_buffer_t *buffer) { return buffer->impl.myStride; } -bool kinc_g5_transpose_mat = true; +bool iron_g5_transpose_mat = true; static void createUniformBuffer(VkBuffer *buf, VkMemoryAllocateInfo *mem_alloc, VkDeviceMemory *mem, VkDescriptorBufferInfo *buffer_info, int size) { VkBufferCreateInfo buf_info; @@ -4219,7 +4219,7 @@ static void createUniformBuffer(VkBuffer *buf, VkMemoryAllocateInfo *mem_alloc, buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; buf_info.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; - if (kinc_g5_raytrace_supported()) { + if (iron_g5_raytrace_supported()) { buf_info.usage |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; } @@ -4249,7 +4249,7 @@ static void createUniformBuffer(VkBuffer *buf, VkMemoryAllocateInfo *mem_alloc, buffer_info->range = size; } -void kinc_g5_constant_buffer_init(kinc_g5_constant_buffer_t *buffer, int size) { +void iron_g5_constant_buffer_init(iron_g5_constant_buffer_t *buffer, int size) { buffer->impl.mySize = size; buffer->data = NULL; @@ -4273,33 +4273,33 @@ void kinc_g5_constant_buffer_init(kinc_g5_constant_buffer_t *buffer, int size) { vkUnmapMemory(vk_ctx.device, buffer->impl.mem); } -void kinc_g5_constant_buffer_destroy(kinc_g5_constant_buffer_t *buffer) { +void iron_g5_constant_buffer_destroy(iron_g5_constant_buffer_t *buffer) { vkFreeMemory(vk_ctx.device, buffer->impl.mem, NULL); vkDestroyBuffer(vk_ctx.device, buffer->impl.buf, NULL); } -void kinc_g5_constant_buffer_lock_all(kinc_g5_constant_buffer_t *buffer) { - kinc_g5_constant_buffer_lock(buffer, 0, kinc_g5_constant_buffer_size(buffer)); +void iron_g5_constant_buffer_lock_all(iron_g5_constant_buffer_t *buffer) { + iron_g5_constant_buffer_lock(buffer, 0, iron_g5_constant_buffer_size(buffer)); } -void kinc_g5_constant_buffer_lock(kinc_g5_constant_buffer_t *buffer, int start, int count) { +void iron_g5_constant_buffer_lock(iron_g5_constant_buffer_t *buffer, int start, int count) { VkResult err = vkMapMemory(vk_ctx.device, buffer->impl.mem, start, count, 0, (void **)&buffer->data); assert(!err); } -void kinc_g5_constant_buffer_unlock(kinc_g5_constant_buffer_t *buffer) { +void iron_g5_constant_buffer_unlock(iron_g5_constant_buffer_t *buffer) { vkUnmapMemory(vk_ctx.device, buffer->impl.mem); buffer->data = NULL; } -int kinc_g5_constant_buffer_size(kinc_g5_constant_buffer_t *buffer) { +int iron_g5_constant_buffer_size(iron_g5_constant_buffer_t *buffer) { return buffer->impl.mySize; } -static void unset(kinc_g5_index_buffer_t *buffer) { +static void unset(iron_g5_index_buffer_t *buffer) { } -void kinc_g5_index_buffer_init(kinc_g5_index_buffer_t *buffer, int indexCount, bool gpuMemory) { +void iron_g5_index_buffer_init(iron_g5_index_buffer_t *buffer, int indexCount, bool gpuMemory) { buffer->impl.count = indexCount; VkBufferCreateInfo buf_info = {0}; @@ -4308,7 +4308,7 @@ void kinc_g5_index_buffer_init(kinc_g5_index_buffer_t *buffer, int indexCount, b buf_info.size = indexCount * sizeof(uint32_t); buf_info.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; - if (kinc_g5_raytrace_supported()) { + if (iron_g5_raytrace_supported()) { buf_info.usage |= VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT; buf_info.usage |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; buf_info.usage |= VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR; @@ -4336,7 +4336,7 @@ void kinc_g5_index_buffer_init(kinc_g5_index_buffer_t *buffer, int indexCount, b assert(pass); VkMemoryAllocateFlagsInfo memory_allocate_flags_info = {0}; - if (kinc_g5_raytrace_supported()) { + if (iron_g5_raytrace_supported()) { memory_allocate_flags_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO; memory_allocate_flags_info.flags = VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR; buffer->impl.mem_alloc.pNext = &memory_allocate_flags_info; @@ -4349,41 +4349,41 @@ void kinc_g5_index_buffer_init(kinc_g5_index_buffer_t *buffer, int indexCount, b assert(!err); } -void kinc_g5_index_buffer_destroy(kinc_g5_index_buffer_t *buffer) { +void iron_g5_index_buffer_destroy(iron_g5_index_buffer_t *buffer) { unset(buffer); vkFreeMemory(vk_ctx.device, buffer->impl.mem, NULL); vkDestroyBuffer(vk_ctx.device, buffer->impl.buf, NULL); } -static int kinc_g5_internal_index_buffer_stride(kinc_g5_index_buffer_t *buffer) { +static int iron_g5_internal_index_buffer_stride(iron_g5_index_buffer_t *buffer) { return 4; } -void *kinc_g5_index_buffer_lock_all(kinc_g5_index_buffer_t *buffer) { - return kinc_g5_index_buffer_lock(buffer, 0, kinc_g5_index_buffer_count(buffer)); +void *iron_g5_index_buffer_lock_all(iron_g5_index_buffer_t *buffer) { + return iron_g5_index_buffer_lock(buffer, 0, iron_g5_index_buffer_count(buffer)); } -void *kinc_g5_index_buffer_lock(kinc_g5_index_buffer_t *buffer, int start, int count) { +void *iron_g5_index_buffer_lock(iron_g5_index_buffer_t *buffer, int start, int count) { uint8_t *data; VkResult err = vkMapMemory(vk_ctx.device, buffer->impl.mem, 0, buffer->impl.mem_alloc.allocationSize, 0, (void **)&data); assert(!err); - return &data[start * kinc_g5_internal_index_buffer_stride(buffer)]; + return &data[start * iron_g5_internal_index_buffer_stride(buffer)]; } -void kinc_g5_index_buffer_unlock_all(kinc_g5_index_buffer_t *buffer) { +void iron_g5_index_buffer_unlock_all(iron_g5_index_buffer_t *buffer) { vkUnmapMemory(vk_ctx.device, buffer->impl.mem); } -void kinc_g5_index_buffer_unlock(kinc_g5_index_buffer_t *buffer, int count) { - kinc_g5_index_buffer_unlock_all(buffer); +void iron_g5_index_buffer_unlock(iron_g5_index_buffer_t *buffer, int count) { + iron_g5_index_buffer_unlock_all(buffer); } -int kinc_g5_index_buffer_count(kinc_g5_index_buffer_t *buffer) { +int iron_g5_index_buffer_count(iron_g5_index_buffer_t *buffer) { return buffer->impl.count; } -#ifndef KINC_ANDROID +#ifndef IRON_ANDROID extern VkRenderPassBeginInfo currentRenderPassBeginInfo; extern VkFramebuffer *framebuffers; @@ -4397,24 +4397,24 @@ static const char *closesthit_shader_name = "closesthit"; static const char *miss_shader_name = "miss"; typedef struct inst { - kinc_matrix4x4_t m; + iron_matrix4x4_t m; int i; } inst_t; static VkDescriptorPool raytrace_descriptor_pool; -static kinc_g5_raytrace_acceleration_structure_t *accel; -static kinc_g5_raytrace_pipeline_t *pipeline; -static kinc_g5_texture_t *output = NULL; -static kinc_g5_texture_t *texpaint0; -static kinc_g5_texture_t *texpaint1; -static kinc_g5_texture_t *texpaint2; -static kinc_g5_texture_t *texenv; -static kinc_g5_texture_t *texsobol; -static kinc_g5_texture_t *texscramble; -static kinc_g5_texture_t *texrank; -static kinc_g5_vertex_buffer_t *vb[16]; -static kinc_g5_vertex_buffer_t *vb_last[16]; -static kinc_g5_index_buffer_t *ib[16]; +static iron_g5_raytrace_acceleration_structure_t *accel; +static iron_g5_raytrace_pipeline_t *pipeline; +static iron_g5_texture_t *output = NULL; +static iron_g5_texture_t *texpaint0; +static iron_g5_texture_t *texpaint1; +static iron_g5_texture_t *texpaint2; +static iron_g5_texture_t *texenv; +static iron_g5_texture_t *texsobol; +static iron_g5_texture_t *texscramble; +static iron_g5_texture_t *texrank; +static iron_g5_vertex_buffer_t *vb[16]; +static iron_g5_vertex_buffer_t *vb_last[16]; +static iron_g5_index_buffer_t *ib[16]; static int vb_count = 0; static int vb_count_last = 0; static inst_t instances[1024]; @@ -4434,8 +4434,8 @@ static PFN_vkCmdBuildAccelerationStructuresKHR _vkCmdBuildAccelerationStructures static PFN_vkDestroyAccelerationStructureKHR _vkDestroyAccelerationStructureKHR = NULL; static PFN_vkCmdTraceRaysKHR _vkCmdTraceRaysKHR = NULL; -void kinc_g5_raytrace_pipeline_init(kinc_g5_raytrace_pipeline_t *pipeline, kinc_g5_command_list_t *command_list, void *ray_shader, int ray_shader_size, - kinc_g5_constant_buffer_t *constant_buffer) { +void iron_g5_raytrace_pipeline_init(iron_g5_raytrace_pipeline_t *pipeline, iron_g5_command_list_t *command_list, void *ray_shader, int ray_shader_size, + iron_g5_constant_buffer_t *constant_buffer) { output = NULL; pipeline->_constant_buffer = constant_buffer; @@ -4750,7 +4750,7 @@ void kinc_g5_raytrace_pipeline_init(kinc_g5_raytrace_pipeline_t *pipeline, kinc_ } } -void kinc_g5_raytrace_pipeline_destroy(kinc_g5_raytrace_pipeline_t *pipeline) { +void iron_g5_raytrace_pipeline_destroy(iron_g5_raytrace_pipeline_t *pipeline) { vkDestroyPipeline(vk_ctx.device, pipeline->impl.pipeline, NULL); vkDestroyPipelineLayout(vk_ctx.device, pipeline->impl.pipeline_layout, NULL); vkDestroyDescriptorSetLayout(vk_ctx.device, pipeline->impl.descriptor_set_layout, NULL); @@ -4764,7 +4764,7 @@ uint64_t get_buffer_device_address(VkBuffer buffer) { return _vkGetBufferDeviceAddressKHR(vk_ctx.device, &buffer_device_address_info); } -void kinc_g5_raytrace_acceleration_structure_init(kinc_g5_raytrace_acceleration_structure_t *accel) { +void iron_g5_raytrace_acceleration_structure_init(iron_g5_raytrace_acceleration_structure_t *accel) { _vkGetBufferDeviceAddressKHR = (void *)vkGetDeviceProcAddr(vk_ctx.device, "vkGetBufferDeviceAddressKHR"); _vkCreateAccelerationStructureKHR = (void *)vkGetDeviceProcAddr(vk_ctx.device, "vkCreateAccelerationStructureKHR"); _vkGetAccelerationStructureDeviceAddressKHR = (void *)vkGetDeviceProcAddr(vk_ctx.device, "vkGetAccelerationStructureDeviceAddressKHR"); @@ -4774,8 +4774,8 @@ void kinc_g5_raytrace_acceleration_structure_init(kinc_g5_raytrace_acceleration_ instances_count = 0; } -void kinc_g5_raytrace_acceleration_structure_add(kinc_g5_raytrace_acceleration_structure_t *accel, kinc_g5_vertex_buffer_t *_vb, kinc_g5_index_buffer_t *_ib, - kinc_matrix4x4_t _transform) { +void iron_g5_raytrace_acceleration_structure_add(iron_g5_raytrace_acceleration_structure_t *accel, iron_g5_vertex_buffer_t *_vb, iron_g5_index_buffer_t *_ib, + iron_matrix4x4_t _transform) { int vb_i = -1; for (int i = 0; i < vb_count; ++i) { @@ -4796,7 +4796,7 @@ void kinc_g5_raytrace_acceleration_structure_add(kinc_g5_raytrace_acceleration_s instances_count++; } -void _kinc_g5_raytrace_acceleration_structure_destroy_bottom(kinc_g5_raytrace_acceleration_structure_t *accel) { +void _iron_g5_raytrace_acceleration_structure_destroy_bottom(iron_g5_raytrace_acceleration_structure_t *accel) { _vkDestroyAccelerationStructureKHR = (void *)vkGetDeviceProcAddr(vk_ctx.device, "vkDestroyAccelerationStructureKHR"); for (int i = 0; i < vb_count_last; ++i) { _vkDestroyAccelerationStructureKHR(vk_ctx.device, accel->impl.bottom_level_acceleration_structure[i], NULL); @@ -4805,7 +4805,7 @@ void _kinc_g5_raytrace_acceleration_structure_destroy_bottom(kinc_g5_raytrace_ac } } -void _kinc_g5_raytrace_acceleration_structure_destroy_top(kinc_g5_raytrace_acceleration_structure_t *accel) { +void _iron_g5_raytrace_acceleration_structure_destroy_top(iron_g5_raytrace_acceleration_structure_t *accel) { _vkDestroyAccelerationStructureKHR = (void *)vkGetDeviceProcAddr(vk_ctx.device, "vkDestroyAccelerationStructureKHR"); _vkDestroyAccelerationStructureKHR(vk_ctx.device, accel->impl.top_level_acceleration_structure, NULL); vkFreeMemory(vk_ctx.device, accel->impl.top_level_mem, NULL); @@ -4814,8 +4814,8 @@ void _kinc_g5_raytrace_acceleration_structure_destroy_top(kinc_g5_raytrace_accel vkDestroyBuffer(vk_ctx.device, accel->impl.instances_buffer, NULL); } -void kinc_g5_raytrace_acceleration_structure_build(kinc_g5_raytrace_acceleration_structure_t *accel, kinc_g5_command_list_t *command_list, - kinc_g5_vertex_buffer_t *_vb_full, kinc_g5_index_buffer_t *_ib_full) { +void iron_g5_raytrace_acceleration_structure_build(iron_g5_raytrace_acceleration_structure_t *accel, iron_g5_command_list_t *command_list, + iron_g5_vertex_buffer_t *_vb_full, iron_g5_index_buffer_t *_ib_full) { bool build_bottom = false; for (int i = 0; i < 16; ++i) { @@ -4827,9 +4827,9 @@ void kinc_g5_raytrace_acceleration_structure_build(kinc_g5_raytrace_acceleration if (vb_count_last > 0) { if (build_bottom) { - _kinc_g5_raytrace_acceleration_structure_destroy_bottom(accel); + _iron_g5_raytrace_acceleration_structure_destroy_bottom(accel); } - _kinc_g5_raytrace_acceleration_structure_destroy_top(accel); + _iron_g5_raytrace_acceleration_structure_destroy_top(accel); } vb_count_last = vb_count; @@ -5349,7 +5349,7 @@ void kinc_g5_raytrace_acceleration_structure_build(kinc_g5_raytrace_acceleration } } -void kinc_g5_raytrace_acceleration_structure_destroy(kinc_g5_raytrace_acceleration_structure_t *accel) { +void iron_g5_raytrace_acceleration_structure_destroy(iron_g5_raytrace_acceleration_structure_t *accel) { // _vkDestroyAccelerationStructureKHR = (void *)vkGetDeviceProcAddr(vk_ctx.device, "vkDestroyAccelerationStructureKHR"); // for (int i = 0; i < vb_count; ++i) { // _vkDestroyAccelerationStructureKHR(vk_ctx.device, accel->impl.bottom_level_acceleration_structure[i], NULL); @@ -5363,7 +5363,7 @@ void kinc_g5_raytrace_acceleration_structure_destroy(kinc_g5_raytrace_accelerati // vkDestroyBuffer(vk_ctx.device, accel->impl.instances_buffer, NULL); } -void kinc_g5_raytrace_set_textures(kinc_g5_texture_t *_texpaint0, kinc_g5_texture_t *_texpaint1, kinc_g5_texture_t *_texpaint2, kinc_g5_texture_t *_texenv, kinc_g5_texture_t *_texsobol, kinc_g5_texture_t *_texscramble, kinc_g5_texture_t *_texrank) { +void iron_g5_raytrace_set_textures(iron_g5_texture_t *_texpaint0, iron_g5_texture_t *_texpaint1, iron_g5_texture_t *_texpaint2, iron_g5_texture_t *_texenv, iron_g5_texture_t *_texsobol, iron_g5_texture_t *_texscramble, iron_g5_texture_t *_texrank) { texpaint0 = _texpaint0; texpaint1 = _texpaint1; texpaint2 = _texpaint2; @@ -5373,15 +5373,15 @@ void kinc_g5_raytrace_set_textures(kinc_g5_texture_t *_texpaint0, kinc_g5_textur texrank = _texrank; } -void kinc_g5_raytrace_set_acceleration_structure(kinc_g5_raytrace_acceleration_structure_t *_accel) { +void iron_g5_raytrace_set_acceleration_structure(iron_g5_raytrace_acceleration_structure_t *_accel) { accel = _accel; } -void kinc_g5_raytrace_set_pipeline(kinc_g5_raytrace_pipeline_t *_pipeline) { +void iron_g5_raytrace_set_pipeline(iron_g5_raytrace_pipeline_t *_pipeline) { pipeline = _pipeline; } -void kinc_g5_raytrace_set_target(kinc_g5_texture_t *_output) { +void iron_g5_raytrace_set_target(iron_g5_texture_t *_output) { if (_output != output) { vkDestroyImage(vk_ctx.device, _output->impl.image, NULL); @@ -5435,7 +5435,7 @@ void kinc_g5_raytrace_set_target(kinc_g5_texture_t *_output) { output = _output; } -void kinc_g5_raytrace_dispatch_rays(kinc_g5_command_list_t *command_list) { +void iron_g5_raytrace_dispatch_rays(iron_g5_command_list_t *command_list) { VkWriteDescriptorSetAccelerationStructureKHR descriptor_acceleration_structure_info = {0}; descriptor_acceleration_structure_info.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR; descriptor_acceleration_structure_info.accelerationStructureCount = 1; diff --git a/base/sources/backends/vulkan_gpu.h b/base/sources/backends/vulkan_gpu.h index 1a6c7dfb..051ad96e 100644 --- a/base/sources/backends/vulkan_gpu.h +++ b/base/sources/backends/vulkan_gpu.h @@ -6,19 +6,19 @@ #include #include -#define KINC_INTERNAL_NAMED_NUMBER_COUNT 32 +#define IRON_INTERNAL_NAMED_NUMBER_COUNT 32 typedef struct { char name[256]; uint32_t number; -} kinc_internal_named_number; +} iron_internal_named_number; typedef struct { uint32_t hash; uint32_t index; -} kinc_internal_hash_index_t; +} iron_internal_hash_index_t; -uint32_t kinc_internal_hash_name(unsigned char *str); +uint32_t iron_internal_hash_name(unsigned char *str); struct vk_funs { PFN_vkGetPhysicalDeviceSurfaceSupportKHR fpGetPhysicalDeviceSurfaceSupportKHR; @@ -110,15 +110,15 @@ typedef struct { VkFence fence; } CommandList5Impl; -typedef struct kinc_g5_compute_shader_impl { - kinc_internal_named_number locations[KINC_INTERNAL_NAMED_NUMBER_COUNT]; - kinc_internal_named_number texture_bindings[KINC_INTERNAL_NAMED_NUMBER_COUNT]; - kinc_internal_named_number offsets[KINC_INTERNAL_NAMED_NUMBER_COUNT]; +typedef struct iron_g5_compute_shader_impl { + iron_internal_named_number locations[IRON_INTERNAL_NAMED_NUMBER_COUNT]; + iron_internal_named_number texture_bindings[IRON_INTERNAL_NAMED_NUMBER_COUNT]; + iron_internal_named_number offsets[IRON_INTERNAL_NAMED_NUMBER_COUNT]; VkPipelineLayout pipeline_layout; VkPipeline pipeline; VkShaderModule shader_module; -} kinc_g5_compute_shader_impl; +} iron_g5_compute_shader_impl; typedef struct PipelineState5Impl_s { const char **textures; @@ -130,12 +130,12 @@ typedef struct PipelineState5Impl_s { VkShaderModule vert_shader_module; VkShaderModule frag_shader_module; - kinc_internal_named_number vertexLocations[KINC_INTERNAL_NAMED_NUMBER_COUNT]; - kinc_internal_named_number fragmentLocations[KINC_INTERNAL_NAMED_NUMBER_COUNT]; - kinc_internal_named_number vertexTextureBindings[KINC_INTERNAL_NAMED_NUMBER_COUNT]; - kinc_internal_named_number fragmentTextureBindings[KINC_INTERNAL_NAMED_NUMBER_COUNT]; - kinc_internal_named_number vertexOffsets[KINC_INTERNAL_NAMED_NUMBER_COUNT]; - kinc_internal_named_number fragmentOffsets[KINC_INTERNAL_NAMED_NUMBER_COUNT]; + iron_internal_named_number vertexLocations[IRON_INTERNAL_NAMED_NUMBER_COUNT]; + iron_internal_named_number fragmentLocations[IRON_INTERNAL_NAMED_NUMBER_COUNT]; + iron_internal_named_number vertexTextureBindings[IRON_INTERNAL_NAMED_NUMBER_COUNT]; + iron_internal_named_number fragmentTextureBindings[IRON_INTERNAL_NAMED_NUMBER_COUNT]; + iron_internal_named_number vertexOffsets[IRON_INTERNAL_NAMED_NUMBER_COUNT]; + iron_internal_named_number fragmentOffsets[IRON_INTERNAL_NAMED_NUMBER_COUNT]; VkPipelineLayout pipeline_layout; } PipelineState5Impl; @@ -160,9 +160,9 @@ typedef struct { int length; } Shader5Impl; -typedef struct kinc_g5_sampler_impl { +typedef struct iron_g5_sampler_impl { VkSampler sampler; -} kinc_g5_sampler_impl_t; +} iron_g5_sampler_impl_t; typedef struct { VkImageLayout imageLayout; @@ -218,7 +218,7 @@ typedef struct { VkMemoryAllocateInfo mem_alloc; } IndexBuffer5Impl; -#ifndef KINC_ANDROID +#ifndef IRON_ANDROID typedef struct { VkPipeline pipeline; @@ -228,7 +228,7 @@ typedef struct { VkBuffer raygen_shader_binding_table; VkBuffer miss_shader_binding_table; VkBuffer hit_shader_binding_table; -} kinc_g5_raytrace_pipeline_impl_t; +} iron_g5_raytrace_pipeline_impl_t; typedef struct { VkAccelerationStructureKHR top_level_acceleration_structure; @@ -242,6 +242,6 @@ typedef struct { VkDeviceMemory top_level_mem; VkBuffer instances_buffer; VkDeviceMemory instances_mem; -} kinc_g5_raytrace_acceleration_structure_impl_t; +} iron_g5_raytrace_acceleration_structure_impl_t; #endif diff --git a/base/sources/backends/wasm_audio.c b/base/sources/backends/wasm_audio.c index 6d800508..b5c38714 100644 --- a/base/sources/backends/wasm_audio.c +++ b/base/sources/backends/wasm_audio.c @@ -1,22 +1,22 @@ -#ifdef KINC_A2 +#ifdef IRON_A2 #include #include -static kinc_a2_buffer_t a2_buffer; +static iron_a2_buffer_t a2_buffer; -void kinc_a2_init() { - kinc_a2_internal_init(); +void iron_a2_init() { + iron_a2_internal_init(); } -void kinc_a2_update() {} +void iron_a2_update() {} -void kinc_a2_shutdown() {} +void iron_a2_shutdown() {} static uint32_t samples_per_second = 44100; -uint32_t kinc_a2_samples_per_second(void) { +uint32_t iron_a2_samples_per_second(void) { return samples_per_second; } diff --git a/base/sources/backends/wasm_system.c b/base/sources/backends/wasm_system.c index e4b71de0..fc57b695 100644 --- a/base/sources/backends/wasm_system.c +++ b/base/sources/backends/wasm_system.c @@ -6,26 +6,26 @@ #include #include -void kinc_display_init(void) {} +void iron_display_init(void) {} -int kinc_primary_display(void) { +int iron_primary_display(void) { return 0; } -int kinc_count_displays(void) { +int iron_count_displays(void) { return 1; } -bool kinc_display_available(int display_index) { +bool iron_display_available(int display_index) { return false; } -const char *kinc_display_name(int display_index) { +const char *iron_display_name(int display_index) { return "Browser"; } -kinc_display_mode_t kinc_display_current_mode(int display_index) { - kinc_display_mode_t mode; +iron_display_mode_t iron_display_current_mode(int display_index) { + iron_display_mode_t mode; mode.x = 0; mode.y = 0; mode.width = 800; @@ -36,12 +36,12 @@ kinc_display_mode_t kinc_display_current_mode(int display_index) { return mode; } -int kinc_display_count_available_modes(int display_index) { +int iron_display_count_available_modes(int display_index) { return 1; } -kinc_display_mode_t kinc_display_available_mode(int display_index, int mode_index) { - kinc_display_mode_t mode; +iron_display_mode_t iron_display_available_mode(int display_index, int mode_index) { + iron_display_mode_t mode; mode.x = 0; mode.y = 0; mode.width = 800; @@ -52,70 +52,70 @@ kinc_display_mode_t kinc_display_available_mode(int display_index, int mode_inde return mode; } -void kinc_internal_mouse_lock() {} +void iron_internal_mouse_lock() {} -void kinc_internal_mouse_unlock(void) {} +void iron_internal_mouse_unlock(void) {} -bool kinc_mouse_can_lock(void) { +bool iron_mouse_can_lock(void) { return false; } -void kinc_mouse_show() {} +void iron_mouse_show() {} -void kinc_mouse_hide() {} +void iron_mouse_hide() {} -void kinc_mouse_set_position(int x, int y) {} +void iron_mouse_set_position(int x, int y) {} -void kinc_mouse_get_position(int *x, int *y) {} +void iron_mouse_get_position(int *x, int *y) {} __attribute__((import_module("imports"), import_name("js_time"))) int js_time(); -extern int kinc_internal_window_width; -extern int kinc_internal_window_height; +extern int iron_internal_window_width; +extern int iron_internal_window_height; -void kinc_init(const char *name, int width, int height, kinc_window_options_t *win) { - kinc_window_options_t defaultWin; +void iron_init(const char *name, int width, int height, iron_window_options_t *win) { + iron_window_options_t defaultWin; if (win == NULL) { - kinc_window_options_set_defaults(&defaultWin); + iron_window_options_set_defaults(&defaultWin); win = &defaultWin; } win->width = width; win->height = height; - kinc_internal_window_width = width; - kinc_internal_window_height = height; + iron_internal_window_width = width; + iron_internal_window_height = height; - kinc_g5_internal_init(); - kinc_g4_internal_init_window(win->depth_bits, true); + iron_g5_internal_init(); + iron_g4_internal_init_window(win->depth_bits, true); } -bool kinc_internal_handle_messages() { +bool iron_internal_handle_messages() { return true; } -void kinc_set_keep_screen_on(bool on) {} +void iron_set_keep_screen_on(bool on) {} -double kinc_frequency(void) { +double iron_frequency(void) { return 1000.0; } -kinc_ticks_t kinc_timestamp(void) { - return (kinc_ticks_t)(js_time()); +iron_ticks_t iron_timestamp(void) { + return (iron_ticks_t)(js_time()); } -double kinc_time(void) { +double iron_time(void) { return js_time() / 1000.0; } -int kinc_cpu_cores(void) { +int iron_cpu_cores(void) { return 4; } -int kinc_hardware_threads(void) { +int iron_hardware_threads(void) { return 4; } -void kinc_internal_shutdown(void) {} +void iron_internal_shutdown(void) {} extern int kickstart(int argc, char **argv); @@ -124,95 +124,95 @@ __attribute__((export_name("_start"))) void _start(void) { } __attribute__((export_name("_update"))) void _update(void) { - kinc_internal_update_callback(); - kinc_a2_update(); + iron_internal_update_callback(); + iron_a2_update(); } __attribute__((export_name("_mousedown"))) void _mousedown(int button, int x, int y) { - kinc_internal_mouse_trigger_press(0, button, x, y); + iron_internal_mouse_trigger_press(0, button, x, y); } __attribute__((export_name("_mouseup"))) void _mouseup(int button, int x, int y) { - kinc_internal_mouse_trigger_release(0, button, x, y); + iron_internal_mouse_trigger_release(0, button, x, y); } __attribute__((export_name("_mousemove"))) void _mousemove(int x, int y) { - kinc_internal_mouse_trigger_move(0, x, y); + iron_internal_mouse_trigger_move(0, x, y); } __attribute__((export_name("_wheel"))) void _wheel(int delta) { - kinc_internal_mouse_trigger_scroll(0, delta); + iron_internal_mouse_trigger_scroll(0, delta); } __attribute__((export_name("_keydown"))) void _keydown(int key) { - kinc_internal_keyboard_trigger_key_down(key); + iron_internal_keyboard_trigger_key_down(key); } __attribute__((export_name("_keyup"))) void _keyup(int key) { - kinc_internal_keyboard_trigger_key_up(key); + iron_internal_keyboard_trigger_key_up(key); } -int kinc_internal_window_width = 0; -int kinc_internal_window_height = 0; -kinc_window_mode_t kinc_internal_window_mode = KINC_WINDOW_MODE_WINDOW; +int iron_internal_window_width = 0; +int iron_internal_window_height = 0; +iron_window_mode_t iron_internal_window_mode = IRON_WINDOW_MODE_WINDOW; -int kinc_window_x() { +int iron_window_x() { return 0; } -int kinc_window_y() { +int iron_window_y() { return 0; } -int kinc_window_width() { - return kinc_internal_window_width; +int iron_window_width() { + return iron_internal_window_width; } -int kinc_window_height() { - return kinc_internal_window_height; +int iron_window_height() { + return iron_internal_window_height; } -void kinc_window_resize(int width, int height) {} +void iron_window_resize(int width, int height) {} -void kinc_window_move(int x, int y) {} +void iron_window_move(int x, int y) {} -void kinc_window_change_features(int features) {} +void iron_window_change_features(int features) {} // In HTML5 fullscreen is activable only from user input. -void kinc_window_change_mode(kinc_window_mode_t mode) { - if (mode == KINC_WINDOW_MODE_FULLSCREEN) { - if (kinc_internal_window_mode == KINC_WINDOW_MODE_FULLSCREEN) { - kinc_internal_window_mode = mode; +void iron_window_change_mode(iron_window_mode_t mode) { + if (mode == IRON_WINDOW_MODE_FULLSCREEN) { + if (iron_internal_window_mode == IRON_WINDOW_MODE_FULLSCREEN) { + iron_internal_window_mode = mode; return; } // TODO: call js Fullscreen API - kinc_internal_window_mode = mode; + iron_internal_window_mode = mode; } else { - if (mode == kinc_internal_window_mode) { + if (mode == iron_internal_window_mode) { return; } // TODO: call js Fullscreen API - kinc_internal_window_mode = mode; + iron_internal_window_mode = mode; } } -void kinc_window_destroy() {} +void iron_window_destroy() {} -void kinc_window_show() {} +void iron_window_show() {} -void kinc_window_hide() {} +void iron_window_hide() {} // TODO: change browser title. -void kinc_window_set_title(const char *title) {} +void iron_window_set_title(const char *title) {} -void kinc_window_create(kinc_window_options_t *win) {} +void iron_window_create(iron_window_options_t *win) {} -void kinc_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) {} +void iron_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) {} -void kinc_window_set_close_callback(bool (*callback)(void *), void *data) {} +void iron_window_set_close_callback(bool (*callback)(void *), void *data) {} -kinc_window_mode_t kinc_window_get_mode() { - return kinc_internal_window_mode; +iron_window_mode_t iron_window_get_mode() { + return iron_internal_window_mode; } diff --git a/base/sources/backends/wasm_thread.c b/base/sources/backends/wasm_thread.c index 93243c5d..5fcbb4fd 100644 --- a/base/sources/backends/wasm_thread.c +++ b/base/sources/backends/wasm_thread.c @@ -1,27 +1,27 @@ #include -void kinc_thread_init(kinc_thread_t *t, void (*thread)(void *param), void *param) {} +void iron_thread_init(iron_thread_t *t, void (*thread)(void *param), void *param) {} -void kinc_thread_wait_and_destroy(kinc_thread_t *thread) {} +void iron_thread_wait_and_destroy(iron_thread_t *thread) {} -bool kinc_thread_try_to_destroy(kinc_thread_t *thread) { +bool iron_thread_try_to_destroy(iron_thread_t *thread) { return false; } -void kinc_threads_init() {} +void iron_threads_init() {} -void kinc_threads_quit() {} +void iron_threads_quit() {} -void kinc_thread_sleep(int milliseconds) {} +void iron_thread_sleep(int milliseconds) {} -void kinc_mutex_init(kinc_mutex_t *mutex) {} +void iron_mutex_init(iron_mutex_t *mutex) {} -void kinc_mutex_destroy(kinc_mutex_t *mutex) {} +void iron_mutex_destroy(iron_mutex_t *mutex) {} -bool kinc_mutex_try_to_lock(kinc_mutex_t *mutex) { +bool iron_mutex_try_to_lock(iron_mutex_t *mutex) { return false; } -void kinc_mutex_lock(kinc_mutex_t *mutex) {} +void iron_mutex_lock(iron_mutex_t *mutex) {} -void kinc_mutex_unlock(kinc_mutex_t *mutex) {} +void iron_mutex_unlock(iron_mutex_t *mutex) {} diff --git a/base/sources/backends/wasm_thread.h b/base/sources/backends/wasm_thread.h index 774a9ded..2dd7565e 100644 --- a/base/sources/backends/wasm_thread.h +++ b/base/sources/backends/wasm_thread.h @@ -2,22 +2,22 @@ typedef struct { int nothing; -} kinc_thread_impl_t; +} iron_thread_impl_t; typedef struct { int nothing; -} kinc_mutex_impl_t; +} iron_mutex_impl_t; #pragma once -#define KINC_ATOMIC_COMPARE_EXCHANGE(pointer, oldValue, newValue) +#define IRON_ATOMIC_COMPARE_EXCHANGE(pointer, oldValue, newValue) -#define KINC_ATOMIC_COMPARE_EXCHANGE_POINTER(pointer, oldValue, newValue) +#define IRON_ATOMIC_COMPARE_EXCHANGE_POINTER(pointer, oldValue, newValue) -#define KINC_ATOMIC_INCREMENT(pointer) +#define IRON_ATOMIC_INCREMENT(pointer) -#define KINC_ATOMIC_DECREMENT(pointer) +#define IRON_ATOMIC_DECREMENT(pointer) -#define KINC_ATOMIC_EXCHANGE_32(pointer, value) +#define IRON_ATOMIC_EXCHANGE_32(pointer, value) -#define KINC_ATOMIC_EXCHANGE_FLOAT(pointer, value) +#define IRON_ATOMIC_EXCHANGE_FLOAT(pointer, value) diff --git a/base/sources/backends/wasm_video.c b/base/sources/backends/wasm_video.c index cd1d4aed..72e35026 100644 --- a/base/sources/backends/wasm_video.c +++ b/base/sources/backends/wasm_video.c @@ -1,57 +1,57 @@ #include -void kinc_video_init(kinc_video_t *video, const char *filename) {} +void iron_video_init(iron_video_t *video, const char *filename) {} -void kinc_video_destroy(kinc_video_t *video) {} +void iron_video_destroy(iron_video_t *video) {} -void kinc_video_play(kinc_video_t *video, bool loop) {} +void iron_video_play(iron_video_t *video, bool loop) {} -void kinc_video_pause(kinc_video_t *video) {} +void iron_video_pause(iron_video_t *video) {} -void kinc_video_stop(kinc_video_t *video) {} +void iron_video_stop(iron_video_t *video) {} -int kinc_video_width(kinc_video_t *video) { +int iron_video_width(iron_video_t *video) { return 256; } -int kinc_video_height(kinc_video_t *video) { +int iron_video_height(iron_video_t *video) { return 256; } -kinc_g5_texture_t *kinc_video_current_image(kinc_video_t *video) { +iron_g5_texture_t *iron_video_current_image(iron_video_t *video) { return NULL; } -double kinc_video_duration(kinc_video_t *video) { +double iron_video_duration(iron_video_t *video) { return 0.0; } -double kinc_video_position(kinc_video_t *video) { +double iron_video_position(iron_video_t *video) { return 0.0; } -bool kinc_video_finished(kinc_video_t *video) { +bool iron_video_finished(iron_video_t *video) { return false; } -bool kinc_video_paused(kinc_video_t *video) { +bool iron_video_paused(iron_video_t *video) { return false; } -void kinc_video_update(kinc_video_t *video, double time) {} +void iron_video_update(iron_video_t *video, double time) {} -void kinc_internal_video_sound_stream_init(kinc_internal_video_sound_stream_t *stream, int channel_count, int frequency) {} +void iron_internal_video_sound_stream_init(iron_internal_video_sound_stream_t *stream, int channel_count, int frequency) {} -void kinc_internal_video_sound_stream_destroy(kinc_internal_video_sound_stream_t *stream) {} +void iron_internal_video_sound_stream_destroy(iron_internal_video_sound_stream_t *stream) {} -void kinc_internal_video_sound_stream_insert_data(kinc_internal_video_sound_stream_t *stream, float *data, int sample_count) {} +void iron_internal_video_sound_stream_insert_data(iron_internal_video_sound_stream_t *stream, float *data, int sample_count) {} static float samples[2] = {0}; -float *kinc_internal_video_sound_stream_next_frame(kinc_internal_video_sound_stream_t *stream) { +float *iron_internal_video_sound_stream_next_frame(iron_internal_video_sound_stream_t *stream) { return samples; } -bool kinc_internal_video_sound_stream_ended(kinc_internal_video_sound_stream_t *stream) { +bool iron_internal_video_sound_stream_ended(iron_internal_video_sound_stream_t *stream) { return true; } diff --git a/base/sources/backends/wasm_video.h b/base/sources/backends/wasm_video.h index 425f2d02..59852a70 100644 --- a/base/sources/backends/wasm_video.h +++ b/base/sources/backends/wasm_video.h @@ -2,18 +2,18 @@ typedef struct { int nothing; -} kinc_video_impl_t; +} iron_video_impl_t; -typedef struct kinc_internal_video_sound_stream { +typedef struct iron_internal_video_sound_stream { int nothing; -} kinc_internal_video_sound_stream_t; +} iron_internal_video_sound_stream_t; -void kinc_internal_video_sound_stream_init(kinc_internal_video_sound_stream_t *stream, int channel_count, int frequency); +void iron_internal_video_sound_stream_init(iron_internal_video_sound_stream_t *stream, int channel_count, int frequency); -void kinc_internal_video_sound_stream_destroy(kinc_internal_video_sound_stream_t *stream); +void iron_internal_video_sound_stream_destroy(iron_internal_video_sound_stream_t *stream); -void kinc_internal_video_sound_stream_insert_data(kinc_internal_video_sound_stream_t *stream, float *data, int sample_count); +void iron_internal_video_sound_stream_insert_data(iron_internal_video_sound_stream_t *stream, float *data, int sample_count); -float *kinc_internal_video_sound_stream_next_frame(kinc_internal_video_sound_stream_t *stream); +float *iron_internal_video_sound_stream_next_frame(iron_internal_video_sound_stream_t *stream); -bool kinc_internal_video_sound_stream_ended(kinc_internal_video_sound_stream_t *stream); +bool iron_internal_video_sound_stream_ended(iron_internal_video_sound_stream_t *stream); diff --git a/base/sources/backends/webgpu_gpu.c b/base/sources/backends/webgpu_gpu.c index 016d0c52..7ebadebe 100644 --- a/base/sources/backends/webgpu_gpu.c +++ b/base/sources/backends/webgpu_gpu.c @@ -18,15 +18,15 @@ WGPUDevice device; WGPUQueue queue; WGPUSwapChain swapChain; -void kinc_g5_internal_destroy_window() {} +void iron_g5_internal_destroy_window() {} -void kinc_g5_internal_destroy() {} +void iron_g5_internal_destroy() {} -void kinc_g5_internal_init() {} +void iron_g5_internal_init() {} -void kinc_g5_internal_init_window(int depthBufferBits, bool vsync) { - newRenderTargetWidth = renderTargetWidth = kinc_width(); - newRenderTargetHeight = renderTargetHeight = kinc_height(); +void iron_g5_internal_init_window(int depthBufferBits, bool vsync) { + newRenderTargetWidth = renderTargetWidth = iron_width(); + newRenderTargetHeight = renderTargetHeight = iron_height(); device = emscripten_webgpu_get_device(); queue = wgpuDeviceGetQueue(device); @@ -45,43 +45,43 @@ void kinc_g5_internal_init_window(int depthBufferBits, bool vsync) { memset(&scDesc, 0, sizeof(scDesc)); scDesc.usage = WGPUTextureUsage_RenderAttachment; scDesc.format = WGPUTextureFormat_BGRA8Unorm; - scDesc.width = kinc_width(); - scDesc.height = kinc_height(); + scDesc.width = iron_width(); + scDesc.height = iron_height(); scDesc.presentMode = WGPUPresentMode_Fifo; swapChain = wgpuDeviceCreateSwapChain(device, surface, &scDesc); } -void kinc_g5_begin(kinc_g5_texture_t *renderTarget) {} +void iron_g5_begin(iron_g5_texture_t *renderTarget) {} -void kinc_g5_end() {} +void iron_g5_end() {} -bool kinc_g5_swap_buffers() { +bool iron_g5_swap_buffers() { return true; } -void kinc_g5_flush() {} +void iron_g5_flush() {} -bool kinc_g5_raytrace_supported() { +bool iron_g5_raytrace_supported() { return false; } extern WGPUDevice device; -kinc_g5_vertex_buffer_t *kinc_g5_internal_current_vertex_buffer = NULL; +iron_g5_vertex_buffer_t *iron_g5_internal_current_vertex_buffer = NULL; -void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int count, kinc_g5_vertex_structure_t *structure, bool gpuMemory) { +void iron_g5_vertex_buffer_init(iron_g5_vertex_buffer_t *buffer, int count, iron_g5_vertex_structure_t *structure, bool gpuMemory) { buffer->impl.count = count; buffer->impl.stride = 0; for (int i = 0; i < structure->size; ++i) { - buffer->impl.stride += kinc_g5_vertex_data_size(structure->elements[i].data); + buffer->impl.stride += iron_g5_vertex_data_size(structure->elements[i].data); } } -void kinc_g5_vertex_buffer_destroy(kinc_g5_vertex_buffer_t *buffer) { +void iron_g5_vertex_buffer_destroy(iron_g5_vertex_buffer_t *buffer) { } -float *kinc_g5_vertex_buffer_lock_all(kinc_g5_vertex_buffer_t *buffer) { +float *iron_g5_vertex_buffer_lock_all(iron_g5_vertex_buffer_t *buffer) { WGPUBufferDescriptor bDesc; memset(&bDesc, 0, sizeof(bDesc)); bDesc.size = buffer->impl.count * buffer->impl.stride * sizeof(float); @@ -91,96 +91,96 @@ float *kinc_g5_vertex_buffer_lock_all(kinc_g5_vertex_buffer_t *buffer) { return wgpuBufferGetMappedRange(buffer->impl.buffer, 0, bDesc.size); } -float *kinc_g5_vertex_buffer_lock(kinc_g5_vertex_buffer_t *buffer, int start, int count) { +float *iron_g5_vertex_buffer_lock(iron_g5_vertex_buffer_t *buffer, int start, int count) { return NULL; } -void kinc_g5_vertex_buffer_unlock_all(kinc_g5_vertex_buffer_t *buffer) { +void iron_g5_vertex_buffer_unlock_all(iron_g5_vertex_buffer_t *buffer) { wgpuBufferUnmap(buffer->impl.buffer); } -void kinc_g5_vertex_buffer_unlock(kinc_g5_vertex_buffer_t* buffer, int count) { +void iron_g5_vertex_buffer_unlock(iron_g5_vertex_buffer_t* buffer, int count) { } -int kinc_g5_vertex_buffer_count(kinc_g5_vertex_buffer_t *buffer) { +int iron_g5_vertex_buffer_count(iron_g5_vertex_buffer_t *buffer) { return buffer->impl.count; } -int kinc_g5_vertex_buffer_stride(kinc_g5_vertex_buffer_t *buffer) { +int iron_g5_vertex_buffer_stride(iron_g5_vertex_buffer_t *buffer) { return buffer->impl.stride; } -bool kinc_g5_transpose_mat = false; +bool iron_g5_transpose_mat = false; -void kinc_g5_constant_buffer_init(kinc_g5_constant_buffer_t *buffer, int size) { +void iron_g5_constant_buffer_init(iron_g5_constant_buffer_t *buffer, int size) { } -void kinc_g5_constant_buffer_destroy(kinc_g5_constant_buffer_t *buffer) {} +void iron_g5_constant_buffer_destroy(iron_g5_constant_buffer_t *buffer) {} -void kinc_g5_constant_buffer_lock_all(kinc_g5_constant_buffer_t *buffer) { - kinc_g5_constant_buffer_lock(buffer, 0, kinc_g5_constant_buffer_size(buffer)); +void iron_g5_constant_buffer_lock_all(iron_g5_constant_buffer_t *buffer) { + iron_g5_constant_buffer_lock(buffer, 0, iron_g5_constant_buffer_size(buffer)); } -void kinc_g5_constant_buffer_lock(kinc_g5_constant_buffer_t *buffer, int start, int count) {} +void iron_g5_constant_buffer_lock(iron_g5_constant_buffer_t *buffer, int start, int count) {} -void kinc_g5_constant_buffer_unlock(kinc_g5_constant_buffer_t *buffer) { +void iron_g5_constant_buffer_unlock(iron_g5_constant_buffer_t *buffer) { } -int kinc_g5_constant_buffer_size(kinc_g5_constant_buffer_t *buffer) { +int iron_g5_constant_buffer_size(iron_g5_constant_buffer_t *buffer) { return 0; } -kinc_g5_index_buffer_t *kinc_g5_internal_current_index_buffer = NULL; +iron_g5_index_buffer_t *iron_g5_internal_current_index_buffer = NULL; -void kinc_g5_index_buffer_init(kinc_g5_index_buffer_t *buffer, int count, bool gpuMemory) { +void iron_g5_index_buffer_init(iron_g5_index_buffer_t *buffer, int count, bool gpuMemory) { buffer->impl.count = count; } -void kinc_g5_index_buffer_destroy(kinc_g5_index_buffer_t *buffer) { +void iron_g5_index_buffer_destroy(iron_g5_index_buffer_t *buffer) { } -static int kinc_g5_internal_index_buffer_stride(kinc_g5_index_buffer_t *buffer) { +static int iron_g5_internal_index_buffer_stride(iron_g5_index_buffer_t *buffer) { return 4; } -void *kinc_g5_index_buffer_lock_all(kinc_g5_index_buffer_t *buffer) { - kinc_g5_index_buffer_lock(buffer, 0, kinc_g5_index_buffer_count(buffer)); +void *iron_g5_index_buffer_lock_all(iron_g5_index_buffer_t *buffer) { + iron_g5_index_buffer_lock(buffer, 0, iron_g5_index_buffer_count(buffer)); } -void *kinc_g5_index_buffer_lock(kinc_g5_index_buffer_t *buffer, int start, int count) { +void *iron_g5_index_buffer_lock(iron_g5_index_buffer_t *buffer, int start, int count) { WGPUBufferDescriptor bDesc; memset(&bDesc, 0, sizeof(bDesc)); - bDesc.size = count * kinc_g5_internal_index_buffer_stride(buffer); + bDesc.size = count * iron_g5_internal_index_buffer_stride(buffer); bDesc.usage = WGPUBufferUsage_Index | WGPUBufferUsage_CopyDst; bDesc.mappedAtCreation = true; buffer->impl.buffer = wgpuDeviceCreateBuffer(device, &bDesc); - return wgpuBufferGetMappedRange(buffer->impl.buffer, start * kinc_g5_internal_index_buffer_stride(buffer), bDesc.size); + return wgpuBufferGetMappedRange(buffer->impl.buffer, start * iron_g5_internal_index_buffer_stride(buffer), bDesc.size); } -void kinc_g5_index_buffer_unlock_all(kinc_g5_index_buffer_t *buffer) { +void iron_g5_index_buffer_unlock_all(iron_g5_index_buffer_t *buffer) { wgpuBufferUnmap(buffer->impl.buffer); } -void kinc_g5_index_buffer_unlock(kinc_g5_index_buffer_t *buffer, int count) { - kinc_g5_index_buffer_unlock_all(buffer); +void iron_g5_index_buffer_unlock(iron_g5_index_buffer_t *buffer, int count) { + iron_g5_index_buffer_unlock_all(buffer); } -void kinc_g5_internal_index_buffer_set(kinc_g5_index_buffer_t *buffer) { +void iron_g5_internal_index_buffer_set(iron_g5_index_buffer_t *buffer) { } -int kinc_g5_index_buffer_count(kinc_g5_index_buffer_t *buffer) { +int iron_g5_index_buffer_count(iron_g5_index_buffer_t *buffer) { return buffer->impl.count; } -void kinc_g5_texture_init(kinc_g5_texture_t *texture, int width, int height, kinc_image_format_t format) { +void iron_g5_texture_init(iron_g5_texture_t *texture, int width, int height, iron_image_format_t format) { // WGPUExtent3D size = {}; - // size.width = kinc_width(); - // size.height = kinc_height(); + // size.width = iron_width(); + // size.height = iron_height(); // size.depth = 1; // WGPUTextureDescriptor tDesc = {}; @@ -203,52 +203,52 @@ void kinc_g5_texture_init(kinc_g5_texture_t *texture, int width, int height, kin texture->data = NULL; } -void kinc_g5_texture_init_from_bytes(kinc_g5_texture_t *texture, void *data, int width, int height, kinc_image_format_t format) {} -void kinc_g5_texture_init_from_encoded_data(kinc_g5_texture_t *texture, void *data, int size, const char *format, bool readable) {} -void kinc_g5_texture_init_from_data(kinc_g5_texture_t *texture, void *data, int width, int height, int format, bool readable) {} -void kinc_g5_texture_init_non_sampled_access(kinc_g5_texture_t *texture, int width, int height, kinc_image_format_t format) {} -void kinc_g5_texture_destroy(kinc_g5_texture_t *texture) {} +void iron_g5_texture_init_from_bytes(iron_g5_texture_t *texture, void *data, int width, int height, iron_image_format_t format) {} +void iron_g5_texture_init_from_encoded_data(iron_g5_texture_t *texture, void *data, int size, const char *format, bool readable) {} +void iron_g5_texture_init_from_data(iron_g5_texture_t *texture, void *data, int width, int height, int format, bool readable) {} +void iron_g5_texture_init_non_sampled_access(iron_g5_texture_t *texture, int width, int height, iron_image_format_t format) {} +void iron_g5_texture_destroy(iron_g5_texture_t *texture) {} -int kinc_g5_texture_stride(kinc_g5_texture_t *texture) { +int iron_g5_texture_stride(iron_g5_texture_t *texture) { return 32; } -void kinc_g5_texture_generate_mipmaps(kinc_g5_texture_t *texture, int levels) {} +void iron_g5_texture_generate_mipmaps(iron_g5_texture_t *texture, int levels) {} -void kinc_g5_texture_set_mipmap(kinc_g5_texture_t *texture, kinc_g5_texture_t *mipmap, int level) {} +void iron_g5_texture_set_mipmap(iron_g5_texture_t *texture, iron_g5_texture_t *mipmap, int level) {} -void kinc_g5_render_target_init(kinc_g5_texture_t *target, int width, int height, kinc_image_format_t format, int depthBufferBits) { +void iron_g5_render_target_init(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { target->width = target->width = width; target->height = target->height = height; - target->state = KINC_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; + target->state = IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; target->data = NULL; target->_uploaded = true; } -void kinc_g5_render_target_init_framebuffer(kinc_g5_texture_t *target, int width, int height, kinc_image_format_t format, int depthBufferBits) {} +void iron_g5_render_target_init_framebuffer(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) {} -void kinc_g5_render_target_set_depth_from(kinc_g5_texture_t *renderTarget, kinc_g5_texture_t *source) {} +void iron_g5_render_target_set_depth_from(iron_g5_texture_t *renderTarget, iron_g5_texture_t *source) {} -void kinc_g5_render_target_get_pixels(kinc_g5_texture_t *renderTarget, uint8_t *data) {} +void iron_g5_render_target_get_pixels(iron_g5_texture_t *renderTarget, uint8_t *data) {} extern WGPUDevice device; -void kinc_g5_pipeline_init(kinc_g5_pipeline_t *pipe) { - kinc_g5_internal_pipeline_init(pipe); - kinc_g5_internal_pipeline_set_defaults(pipe); +void iron_g5_pipeline_init(iron_g5_pipeline_t *pipe) { + iron_g5_internal_pipeline_init(pipe); + iron_g5_internal_pipeline_set_defaults(pipe); } -kinc_g5_constant_location_t kinc_g5_pipeline_get_constant_location(kinc_g5_pipeline_t *pipe, const char* name) { - kinc_g5_constant_location_t location; +iron_g5_constant_location_t iron_g5_pipeline_get_constant_location(iron_g5_pipeline_t *pipe, const char* name) { + iron_g5_constant_location_t location; return location; } -kinc_g5_texture_unit_t kinc_g5_pipeline_get_texture_unit(kinc_g5_pipeline_t *pipe, const char *name) { - kinc_g5_texture_unit_t unit; +iron_g5_texture_unit_t iron_g5_pipeline_get_texture_unit(iron_g5_pipeline_t *pipe, const char *name) { + iron_g5_texture_unit_t unit; return unit; } -void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipe) { +void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipe) { WGPUColorTargetState csDesc; memset(&csDesc, 0, sizeof(csDesc)); csDesc.format = WGPUTextureFormat_BGRA8Unorm; @@ -274,27 +274,27 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipe) { for (int i = 0; i < pipe->input_layout->size; ++i) { vaDesc[i].shaderLocation = i; vaDesc[i].offset = offset; - offset += kinc_g5_vertex_data_size(pipe->input_layout->elements[i].data); + offset += iron_g5_vertex_data_size(pipe->input_layout->elements[i].data); switch (pipe->input_layout->elements[i].data) { - case KINC_G5_VERTEX_DATA_F32_1X: + case IRON_G5_VERTEX_DATA_F32_1X: vaDesc[i].format = WGPUVertexFormat_Float32; break; - case KINC_G5_VERTEX_DATA_F32_2X: + case IRON_G5_VERTEX_DATA_F32_2X: vaDesc[i].format = WGPUVertexFormat_Float32x2; break; - case KINC_G5_VERTEX_DATA_F32_3X: + case IRON_G5_VERTEX_DATA_F32_3X: vaDesc[i].format = WGPUVertexFormat_Float32x3; break; - case KINC_G5_VERTEX_DATA_F32_4X: + case IRON_G5_VERTEX_DATA_F32_4X: vaDesc[i].format = WGPUVertexFormat_Float32x4; break; - case KINC_G5_VERTEX_DATA_U8_4X_NORM: + case IRON_G5_VERTEX_DATA_U8_4X_NORM: vaDesc[i].format = WGPUVertexFormat_Unorm8x4; break; - case KINC_G5_VERTEX_DATA_I16_2X_NORM: + case IRON_G5_VERTEX_DATA_I16_2X_NORM: vaDesc[i].format = WGPUVertexFormat_Snorm16x2; break; - case KINC_G5_VERTEX_DATA_I16_4X_NORM: + case IRON_G5_VERTEX_DATA_I16_4X_NORM: vaDesc[i].format = WGPUVertexFormat_Snorm16x4; break; } @@ -347,11 +347,11 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipe) { pipe->impl.pipeline = wgpuDeviceCreateRenderPipeline(device, &rpDesc); } -void kinc_g5_sampler_init(kinc_g5_sampler_t *sampler, const kinc_g5_sampler_options_t *options) {} +void iron_g5_sampler_init(iron_g5_sampler_t *sampler, const iron_g5_sampler_options_t *options) {} -void kinc_g5_sampler_destroy(kinc_g5_sampler_t *sampler) {} +void iron_g5_sampler_destroy(iron_g5_sampler_t *sampler) {} -void kinc_g5_shader_init(kinc_g5_shader_t *shader, const void *source, size_t length, kinc_g5_shader_type_t type) { +void iron_g5_shader_init(iron_g5_shader_t *shader, const void *source, size_t length, iron_g5_shader_type_t type) { WGPUShaderModuleSPIRVDescriptor smSpirvDesc; memset(&smSpirvDesc, 0, sizeof(smSpirvDesc)); smSpirvDesc.chain.sType = WGPUSType_ShaderModuleSPIRVDescriptor; @@ -363,7 +363,7 @@ void kinc_g5_shader_init(kinc_g5_shader_t *shader, const void *source, size_t le shader->impl.module = wgpuDeviceCreateShaderModule(device, &smDesc); } -void kinc_g5_shader_destroy(kinc_g5_shader_t *shader) {} +void iron_g5_shader_destroy(iron_g5_shader_t *shader) {} @@ -377,11 +377,11 @@ extern WGPUDevice device; extern WGPUQueue queue; extern WGPUSwapChain swapChain; -void kinc_g5_command_list_init(kinc_g5_command_list_t *list) {} +void iron_g5_command_list_init(iron_g5_command_list_t *list) {} -void kinc_g5_command_list_destroy(kinc_g5_command_list_t *list) {} +void iron_g5_command_list_destroy(iron_g5_command_list_t *list) {} -void kinc_g5_command_list_begin(kinc_g5_command_list_t *list) { +void iron_g5_command_list_begin(iron_g5_command_list_t *list) { WGPUCommandEncoderDescriptor ceDesc; memset(&ceDesc, 0, sizeof(ceDesc)); list->impl.encoder = wgpuDeviceCreateCommandEncoder(device, &ceDesc); @@ -402,7 +402,7 @@ void kinc_g5_command_list_begin(kinc_g5_command_list_t *list) { list->impl.pass = wgpuCommandEncoderBeginRenderPass(list->impl.encoder, &passDesc); } -void kinc_g5_command_list_end(kinc_g5_command_list_t *list) { +void iron_g5_command_list_end(iron_g5_command_list_t *list) { wgpuRenderPassEncoderEnd(list->impl.pass); WGPUCommandBufferDescriptor cbDesc; @@ -411,101 +411,101 @@ void kinc_g5_command_list_end(kinc_g5_command_list_t *list) { wgpuQueueSubmit(queue, 1, &commands); } -void kinc_g5_command_list_clear(kinc_g5_command_list_t *list, struct kinc_g5_texture *renderTarget, unsigned flags, unsigned color, float depth) { +void iron_g5_command_list_clear(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget, unsigned flags, unsigned color, float depth) { } -void kinc_g5_command_list_render_target_to_framebuffer_barrier(kinc_g5_command_list_t *list, struct kinc_g5_texture *renderTarget) {} -void kinc_g5_command_list_framebuffer_to_render_target_barrier(kinc_g5_command_list_t *list, struct kinc_g5_texture *renderTarget) {} -void kinc_g5_command_list_texture_to_render_target_barrier(kinc_g5_command_list_t *list, struct kinc_g5_texture *renderTarget) {} -void kinc_g5_command_list_render_target_to_texture_barrier(kinc_g5_command_list_t *list, struct kinc_g5_texture *renderTarget) {} +void iron_g5_command_list_render_target_to_framebuffer_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) {} +void iron_g5_command_list_framebuffer_to_render_target_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) {} +void iron_g5_command_list_texture_to_render_target_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) {} +void iron_g5_command_list_render_target_to_texture_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) {} -void kinc_g5_command_list_draw_indexed_vertices(kinc_g5_command_list_t *list) { +void iron_g5_command_list_draw_indexed_vertices(iron_g5_command_list_t *list) { wgpuRenderPassEncoderDrawIndexed(list->impl.pass, list->impl.indexCount, 1, 0, 0, 0); } -void kinc_g5_command_list_draw_indexed_vertices_from_to(kinc_g5_command_list_t *list, int start, int count) { +void iron_g5_command_list_draw_indexed_vertices_from_to(iron_g5_command_list_t *list, int start, int count) { } -void kinc_g5_command_list_viewport(kinc_g5_command_list_t *list, int x, int y, int width, int height) { +void iron_g5_command_list_viewport(iron_g5_command_list_t *list, int x, int y, int width, int height) { } -void kinc_g5_command_list_scissor(kinc_g5_command_list_t *list, int x, int y, int width, int height) { +void iron_g5_command_list_scissor(iron_g5_command_list_t *list, int x, int y, int width, int height) { } -void kinc_g5_command_list_disable_scissor(kinc_g5_command_list_t *list) {} +void iron_g5_command_list_disable_scissor(iron_g5_command_list_t *list) {} -void kinc_g5_command_list_set_pipeline(kinc_g5_command_list_t *list, struct kinc_g5_pipeline *pipeline) { +void iron_g5_command_list_set_pipeline(iron_g5_command_list_t *list, struct iron_g5_pipeline *pipeline) { wgpuRenderPassEncoderSetPipeline(list->impl.pass, pipeline->impl.pipeline); } -void kinc_g5_command_list_set_pipeline_layout(kinc_g5_command_list_t *list) {} +void iron_g5_command_list_set_pipeline_layout(iron_g5_command_list_t *list) {} -void kinc_g5_command_list_set_vertex_buffer(kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer *buffer) { - uint64_t size = (kinc_g5_vertex_buffer_count(buffer)) * kinc_g5_vertex_buffer_stride(buffer); +void iron_g5_command_list_set_vertex_buffer(iron_g5_command_list_t *list, struct iron_g5_vertex_buffer *buffer) { + uint64_t size = (iron_g5_vertex_buffer_count(buffer)) * iron_g5_vertex_buffer_stride(buffer); wgpuRenderPassEncoderSetVertexBuffer(list->impl.pass, 0, buffer->impl.buffer, 0, size); } -void kinc_g5_command_list_set_index_buffer(kinc_g5_command_list_t *list, struct kinc_g5_index_buffer *buffer) { - list->impl.indexCount = kinc_g5_index_buffer_count(buffer); - uint64_t size = kinc_g5_index_buffer_count(buffer) * sizeof(int); +void iron_g5_command_list_set_index_buffer(iron_g5_command_list_t *list, struct iron_g5_index_buffer *buffer) { + list->impl.indexCount = iron_g5_index_buffer_count(buffer); + uint64_t size = iron_g5_index_buffer_count(buffer) * sizeof(int); wgpuRenderPassEncoderSetIndexBuffer(list->impl.pass, buffer->impl.buffer, WGPUIndexFormat_Uint32, 0, size); } -void kinc_g5_command_list_set_render_targets(kinc_g5_command_list_t *list, struct kinc_g5_texture **targets, int count) { +void iron_g5_command_list_set_render_targets(iron_g5_command_list_t *list, struct iron_g5_texture **targets, int count) { } -void kinc_g5_command_list_upload_index_buffer(kinc_g5_command_list_t *list, struct kinc_g5_index_buffer *buffer) {} -void kinc_g5_command_list_upload_vertex_buffer(kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer *buffer) {} -void kinc_g5_command_list_upload_texture(kinc_g5_command_list_t *list, struct kinc_g5_texture *texture) {} -void kinc_g5_command_list_get_render_target_pixels(kinc_g5_command_list_t *list, kinc_g5_texture_t *render_target, uint8_t *data) {} +void iron_g5_command_list_upload_index_buffer(iron_g5_command_list_t *list, struct iron_g5_index_buffer *buffer) {} +void iron_g5_command_list_upload_vertex_buffer(iron_g5_command_list_t *list, struct iron_g5_vertex_buffer *buffer) {} +void iron_g5_command_list_upload_texture(iron_g5_command_list_t *list, struct iron_g5_texture *texture) {} +void iron_g5_command_list_get_render_target_pixels(iron_g5_command_list_t *list, iron_g5_texture_t *render_target, uint8_t *data) {} -void kinc_g5_command_list_execute(kinc_g5_command_list_t *list) { +void iron_g5_command_list_execute(iron_g5_command_list_t *list) { } -void kinc_g5_command_list_wait_for_execution_to_finish(kinc_g5_command_list_t *list) { +void iron_g5_command_list_wait_for_execution_to_finish(iron_g5_command_list_t *list) { } -void kinc_g5_command_list_set_vertex_constant_buffer(kinc_g5_command_list_t *list, struct kinc_g5_constant_buffer *buffer, int offset, size_t size) { +void iron_g5_command_list_set_vertex_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size) { } -void kinc_g5_command_list_set_fragment_constant_buffer(kinc_g5_command_list_t *list, struct kinc_g5_constant_buffer *buffer, int offset, size_t size) { +void iron_g5_command_list_set_fragment_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size) { } -void kinc_g5_command_list_set_compute_constant_buffer(kinc_g5_command_list_t *list, struct kinc_g5_constant_buffer *buffer, int offset, size_t size) { +void iron_g5_command_list_set_compute_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size) { } -void kinc_g5_command_list_set_texture(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_texture_t *texture) { +void iron_g5_command_list_set_texture(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *texture) { } -void kinc_g5_command_list_set_sampler(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_sampler_t *sampler) {} +void iron_g5_command_list_set_sampler(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_sampler_t *sampler) {} -void kinc_g5_command_list_set_texture_from_render_target_depth(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_texture_t *renderTarget) {} +void iron_g5_command_list_set_texture_from_render_target_depth(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *renderTarget) {} -void kinc_g5_command_list_set_compute_shader(kinc_g5_command_list_t *list, kinc_g5_compute_shader *shader) {} +void iron_g5_command_list_set_compute_shader(iron_g5_command_list_t *list, iron_g5_compute_shader *shader) {} -void kinc_g5_command_list_compute(kinc_g5_command_list_t *list, int x, int y, int z) {} +void iron_g5_command_list_compute(iron_g5_command_list_t *list, int x, int y, int z) {} -void kinc_g5_compute_shader_init(kinc_g5_compute_shader *shader, void *source, int length) {} +void iron_g5_compute_shader_init(iron_g5_compute_shader *shader, void *source, int length) {} -void kinc_g5_compute_shader_destroy(kinc_g5_compute_shader *shader) {} +void iron_g5_compute_shader_destroy(iron_g5_compute_shader *shader) {} -kinc_g5_constant_location_t kinc_g5_compute_shader_get_constant_location(kinc_g5_compute_shader *shader, const char *name) { - kinc_g5_constant_location_t location = {0}; +iron_g5_constant_location_t iron_g5_compute_shader_get_constant_location(iron_g5_compute_shader *shader, const char *name) { + iron_g5_constant_location_t location = {0}; return location; } -kinc_g5_texture_unit_t kinc_g5_compute_shader_get_texture_unit(kinc_g5_compute_shader *shader, const char *name) { - kinc_g5_texture_unit_t unit = {0}; +iron_g5_texture_unit_t iron_g5_compute_shader_get_texture_unit(iron_g5_compute_shader *shader, const char *name) { + iron_g5_texture_unit_t unit = {0}; return unit; } diff --git a/base/sources/backends/webgpu_gpu.h b/base/sources/backends/webgpu_gpu.h index 0e34e24d..f2c202cc 100644 --- a/base/sources/backends/webgpu_gpu.h +++ b/base/sources/backends/webgpu_gpu.h @@ -37,9 +37,9 @@ typedef struct { int computeOffset; } ConstantLocation5Impl; -typedef struct kinc_g5_sampler_impl { +typedef struct iron_g5_sampler_impl { int a; -} kinc_g5_sampler_impl_t; +} iron_g5_sampler_impl_t; struct WGPUShaderModuleImpl; @@ -53,6 +53,6 @@ typedef struct { int indexCount; } CommandList5Impl; -typedef struct kinc_g5_compute_shader_impl { +typedef struct iron_g5_compute_shader_impl { int nothing; -} kinc_g5_compute_shader_impl; +} iron_g5_compute_shader_impl; diff --git a/base/sources/backends/windows_audio.c b/base/sources/backends/windows_audio.c index 25d968bc..c1773240 100644 --- a/base/sources/backends/windows_audio.c +++ b/base/sources/backends/windows_audio.c @@ -1,5 +1,5 @@ -#ifdef KINC_A2 +#ifdef IRON_A2 #include #include @@ -68,7 +68,7 @@ DEFINE_GUID(CLSID_MMDeviceEnumerator, 0xBCDE0395, 0xE52F, 0x467C, 0x8E, 0x3D, 0x #endif // based on the implementation in soloud and Microsoft sample code -static kinc_a2_buffer_t a2_buffer; +static iron_a2_buffer_t a2_buffer; static IMMDeviceEnumerator *deviceEnumerator; static IMMDevice *device; @@ -82,7 +82,7 @@ static WAVEFORMATEX *closestFormat; static WAVEFORMATEX *format; static uint32_t samples_per_second = 44100; -uint32_t kinc_a2_samples_per_second(void) { +uint32_t iron_a2_samples_per_second(void) { return samples_per_second; } @@ -102,7 +102,7 @@ static bool initDefaultDevice() { bufferEndEvent = 0; } - kinc_log("Initializing a new default audio device."); + iron_log("Initializing a new default audio device."); HRESULT hr = deviceEnumerator->lpVtbl->GetDefaultAudioEndpoint(deviceEnumerator, eRender, eConsole, &device); if (hr == S_OK) { @@ -124,7 +124,7 @@ static bool initDefaultDevice() { HRESULT supported = audioClient->lpVtbl->IsFormatSupported(audioClient, AUDCLNT_SHAREMODE_SHARED, format, &closestFormat); if (supported == S_FALSE) { - kinc_log("Falling back to the system's preferred WASAPI mix format.", supported); + iron_log("Falling back to the system's preferred WASAPI mix format.", supported); if (closestFormat != NULL) { format = closestFormat; } @@ -135,29 +135,29 @@ static bool initDefaultDevice() { HRESULT result = audioClient->lpVtbl->Initialize(audioClient, AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_EVENTCALLBACK, 40 * 1000 * 10, 0, format, 0); if (result != S_OK) { - kinc_log("Could not initialize WASAPI audio, going silent (error code 0x%x).", result); + iron_log("Could not initialize WASAPI audio, going silent (error code 0x%x).", result); return false; } uint32_t old_samples_per_second = samples_per_second; samples_per_second = format->nSamplesPerSec; if (samples_per_second != old_samples_per_second) { - kinc_a2_internal_sample_rate_callback(); + iron_a2_internal_sample_rate_callback(); } a2_buffer.channel_count = 2; bufferFrames = 0; - kinc_microsoft_affirm(audioClient->lpVtbl->GetBufferSize(audioClient, &bufferFrames)); - kinc_microsoft_affirm(audioClient->lpVtbl->GetService(audioClient, &IID_IAudioRenderClient, (void **)&renderClient)); + iron_microsoft_affirm(audioClient->lpVtbl->GetBufferSize(audioClient, &bufferFrames)); + iron_microsoft_affirm(audioClient->lpVtbl->GetService(audioClient, &IID_IAudioRenderClient, (void **)&renderClient)); bufferEndEvent = CreateEvent(0, FALSE, FALSE, 0); - kinc_microsoft_affirm(audioClient->lpVtbl->SetEventHandle(audioClient, bufferEndEvent)); + iron_microsoft_affirm(audioClient->lpVtbl->SetEventHandle(audioClient, bufferEndEvent)); return true; } else { - kinc_log("Could not initialize WASAPI audio."); + iron_log("Could not initialize WASAPI audio."); return false; } } @@ -208,7 +208,7 @@ static void submitBuffer(unsigned frames) { return; } - if (kinc_a2_internal_callback(&a2_buffer, frames)) { + if (iron_a2_internal_callback(&a2_buffer, frames)) { if (format->wFormatTag == WAVE_FORMAT_PCM) { for (UINT32 i = 0; i < frames; ++i) { copyS16Sample((int16_t *)&buffer[i * format->nBlockAlign], (int16_t *)&buffer[i * format->nBlockAlign + 2]); @@ -255,16 +255,16 @@ static DWORD WINAPI audioThread(LPVOID ignored) { return 0; } -void kinc_windows_co_initialize(void); +void iron_windows_co_initialize(void); static bool initialized = false; -void kinc_a2_init() { +void iron_a2_init() { if (initialized) { return; } - kinc_a2_internal_init(); + iron_a2_internal_init(); initialized = true; a2_buffer.read_location = 0; @@ -276,15 +276,15 @@ void kinc_a2_init() { audioProcessingDoneEvent = CreateEvent(0, FALSE, FALSE, 0); - kinc_windows_co_initialize(); - kinc_microsoft_affirm(CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &IID_IMMDeviceEnumerator, (void **)&deviceEnumerator)); + iron_windows_co_initialize(); + iron_microsoft_affirm(CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &IID_IMMDeviceEnumerator, (void **)&deviceEnumerator)); if (initDefaultDevice()) { CreateThread(0, 65536, audioThread, NULL, 0, 0); } } -void kinc_a2_update() {} +void iron_a2_update() {} #define SAFE_RELEASE(punk) \ if ((punk) != NULL) { \ @@ -292,7 +292,7 @@ void kinc_a2_update() {} (punk) = NULL; \ } -void kinc_a2_shutdown() { +void iron_a2_shutdown() { // Wait for last data in buffer to play before stopping. // Sleep((DWORD)(hnsActualDuration/REFTIMES_PER_MILLISEC/2)); diff --git a/base/sources/backends/windows_net.c b/base/sources/backends/windows_net.c index a07ff202..0fedb129 100644 --- a/base/sources/backends/windows_net.c +++ b/base/sources/backends/windows_net.c @@ -7,14 +7,14 @@ static const wchar_t *convert(int method) { switch (method) { - case KINC_HTTP_GET: + case IRON_HTTP_GET: default: return L"GET"; - case KINC_HTTP_POST: + case IRON_HTTP_POST: return L"POST"; - case KINC_HTTP_PUT: + case IRON_HTTP_PUT: return L"PUT"; - case KINC_HTTP_DELETE: + case IRON_HTTP_DELETE: return L"DELETE"; } } @@ -22,11 +22,11 @@ static const wchar_t *convert(int method) { static char *returnData = NULL; static int returnDataSize = 0; -void kinc_http_request(const char *url, const char *path, const char *data, int port, bool secure, int method, const char *header, - kinc_http_callback_t callback, void *callbackdata) { +void iron_http_request(const char *url, const char *path, const char *data, int port, bool secure, int method, const char *header, + iron_http_callback_t callback, void *callbackdata) { // based on https://docs.microsoft.com/en-us/windows/desktop/winhttp/winhttp-sessions-overview - HINTERNET hSession = WinHttpOpen(L"WinHTTP via Kore/1.0", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0); + HINTERNET hSession = WinHttpOpen(L"WinHTTP via Iron/1.0", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0); HINTERNET hConnect = NULL; if (hSession) { @@ -64,14 +64,14 @@ void kinc_http_request(const char *url, const char *path, const char *data, int do { dwSize = 0; if (!WinHttpQueryDataAvailable(hRequest, &dwSize)) { - kinc_error("Error %d in WinHttpQueryDataAvailable.\n", GetLastError()); + iron_error("Error %d in WinHttpQueryDataAvailable.\n", GetLastError()); } if ((int)dwSize + 1 > returnDataSize - returnDataIndex) { int newReturnDataSize = (returnDataIndex + dwSize + 1) * 2; char *newReturnData = (char *)malloc(newReturnDataSize); if (newReturnData == 0) { - kinc_error("Out of memory\n"); + iron_error("Out of memory\n"); } memcpy(newReturnData, returnData, returnDataSize); returnDataSize = newReturnDataSize; @@ -80,7 +80,7 @@ void kinc_http_request(const char *url, const char *path, const char *data, int DWORD dwDownloaded = 0; if (!WinHttpReadData(hRequest, (LPVOID)(&returnData[returnDataIndex]), dwSize, &dwDownloaded)) { - kinc_error("Error %d in WinHttpReadData.\n", GetLastError()); + iron_error("Error %d in WinHttpReadData.\n", GetLastError()); } returnDataIndex += dwSize; } while (dwSize > 0); @@ -93,7 +93,7 @@ void kinc_http_request(const char *url, const char *path, const char *data, int returnData[returnDataIndex] = 0; if (!bResults) { - kinc_error("Error %d has occurred.\n", GetLastError()); + iron_error("Error %d has occurred.\n", GetLastError()); } if (hRequest) { diff --git a/base/sources/backends/windows_system.c b/base/sources/backends/windows_system.c index 28046b5c..9754f672 100644 --- a/base/sources/backends/windows_system.c +++ b/base/sources/backends/windows_system.c @@ -146,32 +146,32 @@ static void winerror(HRESULT result) { FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buffer, 0, NULL); - kinc_error("Error: %s", buffer); + iron_error("Error: %s", buffer); } else { - kinc_error("Unknown Windows error, return value was 0x%x.", result); + iron_error("Unknown Windows error, return value was 0x%x.", result); } } -void kinc_microsoft_affirm(HRESULT result) { +void iron_microsoft_affirm(HRESULT result) { if (result != S_OK) { winerror(result); } } -void kinc_microsoft_affirm_message(HRESULT result, const char *format, ...) { +void iron_microsoft_affirm_message(HRESULT result, const char *format, ...) { } -void kinc_microsoft_format(const char *format, va_list args, wchar_t *buffer) { +void iron_microsoft_format(const char *format, va_list args, wchar_t *buffer) { char cbuffer[4096]; vsprintf(cbuffer, format, args); MultiByteToWideChar(CP_UTF8, 0, cbuffer, -1, buffer, 4096); } -#ifdef KINC_NO_CLIB +#ifdef IRON_NO_CLIB #ifndef NDEBUG void _wassert(wchar_t const *message, wchar_t const *filename, unsigned line) { __debugbreak(); @@ -263,7 +263,7 @@ static BOOL CALLBACK EnumerationCallback(HMONITOR monitor, HDC hdc_unused, LPREC return TRUE; } -void kinc_display_init() { +void iron_display_init() { if (display_initialized) { return; } @@ -276,22 +276,22 @@ void kinc_display_init() { display_initialized = true; } -int kinc_windows_get_display_for_monitor(struct HMONITOR__ *monitor) { +int iron_windows_get_display_for_monitor(struct HMONITOR__ *monitor) { for (int i = 0; i < MAXIMUM_DISPLAYS; ++i) { if (displays[i].monitor == monitor) { return i; } } - kinc_error("Display for monitor not found"); + iron_error("Display for monitor not found"); return -1; } -int kinc_count_displays() { +int iron_count_displays() { return screen_counter; } -int kinc_primary_display() { +int iron_primary_display() { for (int i = 0; i < MAXIMUM_DISPLAYS; ++i) { DisplayData *display = &displays[i]; @@ -300,15 +300,15 @@ int kinc_primary_display() { } } - kinc_error("No primary display defined"); + iron_error("No primary display defined"); return -1; } -kinc_display_mode_t kinc_display_available_mode(int display_index, int mode_index) { +iron_display_mode_t iron_display_available_mode(int display_index, int mode_index) { DEVMODEA dev_mode = {0}; dev_mode.dmSize = sizeof(DEVMODEA); EnumDisplaySettingsA(displays[display_index].name, mode_index, &dev_mode); - kinc_display_mode_t mode; + iron_display_mode_t mode; mode.x = displays[display_index].x; mode.y = displays[display_index].y; mode.width = dev_mode.dmPelsWidth; @@ -319,7 +319,7 @@ kinc_display_mode_t kinc_display_available_mode(int display_index, int mode_inde return mode; } -int kinc_display_count_available_modes(int display_index) { +int iron_display_count_available_modes(int display_index) { DEVMODEA dev_mode = {0}; dev_mode.dmSize = sizeof(DEVMODEA); int i = 0; @@ -328,7 +328,7 @@ int kinc_display_count_available_modes(int display_index) { return i; } -bool kinc_windows_set_display_mode(int display_index, int width, int height, int bpp, int frequency) { +bool iron_windows_set_display_mode(int display_index, int width, int height, int bpp, int frequency) { DisplayData *display = &displays[display_index]; display->mode_changed = true; DEVMODEA mode = {0}; @@ -350,32 +350,32 @@ bool kinc_windows_set_display_mode(int display_index, int width, int height, int return success; } -void kinc_windows_restore_display(int display) { +void iron_windows_restore_display(int display) { if (displays[display].mode_changed) { ChangeDisplaySettingsA(&original_modes[display], 0); } } -void kinc_windows_restore_displays() { +void iron_windows_restore_displays() { for (int i = 0; i < MAXIMUM_DISPLAYS; ++i) { - kinc_windows_restore_display(i); + iron_windows_restore_display(i); } } -bool kinc_display_available(int display_index) { +bool iron_display_available(int display_index) { if (display_index < 0 || display_index >= MAXIMUM_DISPLAYS) { return false; } return displays[display_index].available; } -const char *kinc_display_name(int display_index) { +const char *iron_display_name(int display_index) { return displays[display_index].name; } -kinc_display_mode_t kinc_display_current_mode(int display_index) { +iron_display_mode_t iron_display_current_mode(int display_index) { DisplayData *display = &displays[display_index]; - kinc_display_mode_t mode; + iron_display_mode_t mode; mode.x = display->x; mode.y = display->y; mode.width = display->width; @@ -386,49 +386,49 @@ kinc_display_mode_t kinc_display_current_mode(int display_index) { return mode; } -void kinc_internal_mouse_lock() { - kinc_mouse_hide(); - HWND handle = kinc_windows_window_handle(); +void iron_internal_mouse_lock() { + iron_mouse_hide(); + HWND handle = iron_windows_window_handle(); SetCapture(handle); RECT rect; GetWindowRect(handle, &rect); ClipCursor(&rect); } -void kinc_internal_mouse_unlock(void) { - kinc_mouse_show(); +void iron_internal_mouse_unlock(void) { + iron_mouse_show(); ReleaseCapture(); ClipCursor(NULL); } -bool kinc_mouse_can_lock(void) { +bool iron_mouse_can_lock(void) { return true; } -void kinc_mouse_show() { +void iron_mouse_show() { // Work around the internal counter of ShowCursor while (ShowCursor(true) < 0) { } } -void kinc_mouse_hide() { +void iron_mouse_hide() { // Work around the internal counter of ShowCursor while (ShowCursor(false) >= 0) { } } -void kinc_mouse_set_position(int x, int y) { +void iron_mouse_set_position(int x, int y) { POINT point; point.x = x; point.y = y; - ClientToScreen(kinc_windows_window_handle(), &point); + ClientToScreen(iron_windows_window_handle(), &point); SetCursorPos(point.x, point.y); } -void kinc_mouse_get_position(int *x, int *y) { +void iron_mouse_get_position(int *x, int *y) { POINT point; GetCursorPos(&point); - ScreenToClient(kinc_windows_window_handle(), &point); + ScreenToClient(iron_windows_window_handle(), &point); *x = point.x; *y = point.y; } @@ -437,7 +437,7 @@ void kinc_mouse_get_position(int *x, int *y) { __declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001; __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; -void kinc_internal_resize(int width, int height); +void iron_internal_resize(int width, int height); typedef BOOL(WINAPI *GetPointerInfoType)(UINT32 pointerId, POINTER_INFO *pointerInfo); static GetPointerInfoType MyGetPointerInfo = NULL; @@ -448,7 +448,7 @@ static EnableNonClientDpiScalingType MyEnableNonClientDpiScaling = NULL; #define MAX_TOUCH_POINTS 10 -#define KINC_DINPUT_MAX_COUNT 8 +#define IRON_DINPUT_MAX_COUNT 8 struct touchpoint { int sysID; @@ -497,132 +497,132 @@ static void ReleaseTouchIndex(int dwID) { static void initKeyTranslation() { for (int i = 0; i < 256; ++i) - keyTranslated[i] = KINC_KEY_UNKNOWN; + keyTranslated[i] = IRON_KEY_UNKNOWN; - keyTranslated[VK_BACK] = KINC_KEY_BACKSPACE; - keyTranslated[VK_TAB] = KINC_KEY_TAB; - keyTranslated[VK_CLEAR] = KINC_KEY_CLEAR; - keyTranslated[VK_RETURN] = KINC_KEY_RETURN; - keyTranslated[VK_SHIFT] = KINC_KEY_SHIFT; - keyTranslated[VK_CONTROL] = KINC_KEY_CONTROL; - keyTranslated[VK_MENU] = KINC_KEY_ALT; - keyTranslated[VK_PAUSE] = KINC_KEY_PAUSE; - keyTranslated[VK_CAPITAL] = KINC_KEY_CAPS_LOCK; - keyTranslated[VK_KANA] = KINC_KEY_KANA; - keyTranslated[VK_HANGUL] = KINC_KEY_HANGUL; - keyTranslated[VK_JUNJA] = KINC_KEY_JUNJA; - keyTranslated[VK_FINAL] = KINC_KEY_FINAL; - keyTranslated[VK_HANJA] = KINC_KEY_HANJA; - keyTranslated[VK_KANJI] = KINC_KEY_KANJI; - keyTranslated[VK_ESCAPE] = KINC_KEY_ESCAPE; - keyTranslated[VK_SPACE] = KINC_KEY_SPACE; - keyTranslated[VK_PRIOR] = KINC_KEY_PAGE_UP; - keyTranslated[VK_NEXT] = KINC_KEY_PAGE_DOWN; - keyTranslated[VK_END] = KINC_KEY_END; - keyTranslated[VK_HOME] = KINC_KEY_HOME; - keyTranslated[VK_LEFT] = KINC_KEY_LEFT; - keyTranslated[VK_UP] = KINC_KEY_UP; - keyTranslated[VK_RIGHT] = KINC_KEY_RIGHT; - keyTranslated[VK_DOWN] = KINC_KEY_DOWN; - keyTranslated[VK_PRINT] = KINC_KEY_PRINT; - keyTranslated[VK_INSERT] = KINC_KEY_INSERT; - keyTranslated[VK_DELETE] = KINC_KEY_DELETE; - keyTranslated[VK_HELP] = KINC_KEY_HELP; - keyTranslated[0x30] = KINC_KEY_0; - keyTranslated[0x31] = KINC_KEY_1; - keyTranslated[0x32] = KINC_KEY_2; - keyTranslated[0x33] = KINC_KEY_3; - keyTranslated[0x34] = KINC_KEY_4; - keyTranslated[0x35] = KINC_KEY_5; - keyTranslated[0x36] = KINC_KEY_6; - keyTranslated[0x37] = KINC_KEY_7; - keyTranslated[0x38] = KINC_KEY_8; - keyTranslated[0x39] = KINC_KEY_9; - keyTranslated[0x41] = KINC_KEY_A; - keyTranslated[0x42] = KINC_KEY_B; - keyTranslated[0x43] = KINC_KEY_C; - keyTranslated[0x44] = KINC_KEY_D; - keyTranslated[0x45] = KINC_KEY_E; - keyTranslated[0x46] = KINC_KEY_F; - keyTranslated[0x47] = KINC_KEY_G; - keyTranslated[0x48] = KINC_KEY_H; - keyTranslated[0x49] = KINC_KEY_I; - keyTranslated[0x4A] = KINC_KEY_J; - keyTranslated[0x4B] = KINC_KEY_K; - keyTranslated[0x4C] = KINC_KEY_L; - keyTranslated[0x4D] = KINC_KEY_M; - keyTranslated[0x4E] = KINC_KEY_N; - keyTranslated[0x4F] = KINC_KEY_O; - keyTranslated[0x50] = KINC_KEY_P; - keyTranslated[0x51] = KINC_KEY_Q; - keyTranslated[0x52] = KINC_KEY_R; - keyTranslated[0x53] = KINC_KEY_S; - keyTranslated[0x54] = KINC_KEY_T; - keyTranslated[0x55] = KINC_KEY_U; - keyTranslated[0x56] = KINC_KEY_V; - keyTranslated[0x57] = KINC_KEY_W; - keyTranslated[0x58] = KINC_KEY_X; - keyTranslated[0x59] = KINC_KEY_Y; - keyTranslated[0x5A] = KINC_KEY_Z; - keyTranslated[VK_LWIN] = KINC_KEY_WIN; - keyTranslated[VK_RWIN] = KINC_KEY_WIN; - keyTranslated[VK_APPS] = KINC_KEY_CONTEXT_MENU; - keyTranslated[VK_NUMPAD0] = KINC_KEY_NUMPAD_0; - keyTranslated[VK_NUMPAD1] = KINC_KEY_NUMPAD_1; - keyTranslated[VK_NUMPAD2] = KINC_KEY_NUMPAD_2; - keyTranslated[VK_NUMPAD3] = KINC_KEY_NUMPAD_3; - keyTranslated[VK_NUMPAD4] = KINC_KEY_NUMPAD_4; - keyTranslated[VK_NUMPAD5] = KINC_KEY_NUMPAD_5; - keyTranslated[VK_NUMPAD6] = KINC_KEY_NUMPAD_6; - keyTranslated[VK_NUMPAD7] = KINC_KEY_NUMPAD_7; - keyTranslated[VK_NUMPAD8] = KINC_KEY_NUMPAD_8; - keyTranslated[VK_NUMPAD9] = KINC_KEY_NUMPAD_9; - keyTranslated[VK_MULTIPLY] = KINC_KEY_MULTIPLY; - keyTranslated[VK_ADD] = KINC_KEY_ADD; - keyTranslated[VK_SUBTRACT] = KINC_KEY_SUBTRACT; - keyTranslated[VK_DECIMAL] = KINC_KEY_DECIMAL; - keyTranslated[VK_DIVIDE] = KINC_KEY_DIVIDE; - keyTranslated[VK_F1] = KINC_KEY_F1; - keyTranslated[VK_F2] = KINC_KEY_F2; - keyTranslated[VK_F3] = KINC_KEY_F3; - keyTranslated[VK_F4] = KINC_KEY_F4; - keyTranslated[VK_F5] = KINC_KEY_F5; - keyTranslated[VK_F6] = KINC_KEY_F6; - keyTranslated[VK_F7] = KINC_KEY_F7; - keyTranslated[VK_F8] = KINC_KEY_F8; - keyTranslated[VK_F9] = KINC_KEY_F9; - keyTranslated[VK_F10] = KINC_KEY_F10; - keyTranslated[VK_F11] = KINC_KEY_F11; - keyTranslated[VK_F12] = KINC_KEY_F12; - keyTranslated[VK_F13] = KINC_KEY_F13; - keyTranslated[VK_F14] = KINC_KEY_F14; - keyTranslated[VK_F15] = KINC_KEY_F15; - keyTranslated[VK_F16] = KINC_KEY_F16; - keyTranslated[VK_F17] = KINC_KEY_F17; - keyTranslated[VK_F18] = KINC_KEY_F18; - keyTranslated[VK_F19] = KINC_KEY_F19; - keyTranslated[VK_F20] = KINC_KEY_F20; - keyTranslated[VK_F21] = KINC_KEY_F21; - keyTranslated[VK_F22] = KINC_KEY_F22; - keyTranslated[VK_F23] = KINC_KEY_F23; - keyTranslated[VK_F24] = KINC_KEY_F24; - keyTranslated[VK_NUMLOCK] = KINC_KEY_NUM_LOCK; - keyTranslated[VK_SCROLL] = KINC_KEY_SCROLL_LOCK; - keyTranslated[VK_LSHIFT] = KINC_KEY_SHIFT; - keyTranslated[VK_RSHIFT] = KINC_KEY_SHIFT; - keyTranslated[VK_LCONTROL] = KINC_KEY_CONTROL; - keyTranslated[VK_RCONTROL] = KINC_KEY_CONTROL; - keyTranslated[VK_OEM_1] = KINC_KEY_SEMICOLON; - keyTranslated[VK_OEM_PLUS] = KINC_KEY_PLUS; - keyTranslated[VK_OEM_COMMA] = KINC_KEY_COMMA; - keyTranslated[VK_OEM_MINUS] = KINC_KEY_HYPHEN_MINUS; - keyTranslated[VK_OEM_PERIOD] = KINC_KEY_PERIOD; - keyTranslated[VK_OEM_2] = KINC_KEY_SLASH; - keyTranslated[VK_OEM_3] = KINC_KEY_BACK_QUOTE; - keyTranslated[VK_OEM_4] = KINC_KEY_OPEN_BRACKET; - keyTranslated[VK_OEM_5] = KINC_KEY_BACK_SLASH; - keyTranslated[VK_OEM_6] = KINC_KEY_CLOSE_BRACKET; - keyTranslated[VK_OEM_7] = KINC_KEY_QUOTE; + keyTranslated[VK_BACK] = IRON_KEY_BACKSPACE; + keyTranslated[VK_TAB] = IRON_KEY_TAB; + keyTranslated[VK_CLEAR] = IRON_KEY_CLEAR; + keyTranslated[VK_RETURN] = IRON_KEY_RETURN; + keyTranslated[VK_SHIFT] = IRON_KEY_SHIFT; + keyTranslated[VK_CONTROL] = IRON_KEY_CONTROL; + keyTranslated[VK_MENU] = IRON_KEY_ALT; + keyTranslated[VK_PAUSE] = IRON_KEY_PAUSE; + keyTranslated[VK_CAPITAL] = IRON_KEY_CAPS_LOCK; + keyTranslated[VK_KANA] = IRON_KEY_KANA; + keyTranslated[VK_HANGUL] = IRON_KEY_HANGUL; + keyTranslated[VK_JUNJA] = IRON_KEY_JUNJA; + keyTranslated[VK_FINAL] = IRON_KEY_FINAL; + keyTranslated[VK_HANJA] = IRON_KEY_HANJA; + keyTranslated[VK_KANJI] = IRON_KEY_KANJI; + keyTranslated[VK_ESCAPE] = IRON_KEY_ESCAPE; + keyTranslated[VK_SPACE] = IRON_KEY_SPACE; + keyTranslated[VK_PRIOR] = IRON_KEY_PAGE_UP; + keyTranslated[VK_NEXT] = IRON_KEY_PAGE_DOWN; + keyTranslated[VK_END] = IRON_KEY_END; + keyTranslated[VK_HOME] = IRON_KEY_HOME; + keyTranslated[VK_LEFT] = IRON_KEY_LEFT; + keyTranslated[VK_UP] = IRON_KEY_UP; + keyTranslated[VK_RIGHT] = IRON_KEY_RIGHT; + keyTranslated[VK_DOWN] = IRON_KEY_DOWN; + keyTranslated[VK_PRINT] = IRON_KEY_PRINT; + keyTranslated[VK_INSERT] = IRON_KEY_INSERT; + keyTranslated[VK_DELETE] = IRON_KEY_DELETE; + keyTranslated[VK_HELP] = IRON_KEY_HELP; + keyTranslated[0x30] = IRON_KEY_0; + keyTranslated[0x31] = IRON_KEY_1; + keyTranslated[0x32] = IRON_KEY_2; + keyTranslated[0x33] = IRON_KEY_3; + keyTranslated[0x34] = IRON_KEY_4; + keyTranslated[0x35] = IRON_KEY_5; + keyTranslated[0x36] = IRON_KEY_6; + keyTranslated[0x37] = IRON_KEY_7; + keyTranslated[0x38] = IRON_KEY_8; + keyTranslated[0x39] = IRON_KEY_9; + keyTranslated[0x41] = IRON_KEY_A; + keyTranslated[0x42] = IRON_KEY_B; + keyTranslated[0x43] = IRON_KEY_C; + keyTranslated[0x44] = IRON_KEY_D; + keyTranslated[0x45] = IRON_KEY_E; + keyTranslated[0x46] = IRON_KEY_F; + keyTranslated[0x47] = IRON_KEY_G; + keyTranslated[0x48] = IRON_KEY_H; + keyTranslated[0x49] = IRON_KEY_I; + keyTranslated[0x4A] = IRON_KEY_J; + keyTranslated[0x4B] = IRON_KEY_K; + keyTranslated[0x4C] = IRON_KEY_L; + keyTranslated[0x4D] = IRON_KEY_M; + keyTranslated[0x4E] = IRON_KEY_N; + keyTranslated[0x4F] = IRON_KEY_O; + keyTranslated[0x50] = IRON_KEY_P; + keyTranslated[0x51] = IRON_KEY_Q; + keyTranslated[0x52] = IRON_KEY_R; + keyTranslated[0x53] = IRON_KEY_S; + keyTranslated[0x54] = IRON_KEY_T; + keyTranslated[0x55] = IRON_KEY_U; + keyTranslated[0x56] = IRON_KEY_V; + keyTranslated[0x57] = IRON_KEY_W; + keyTranslated[0x58] = IRON_KEY_X; + keyTranslated[0x59] = IRON_KEY_Y; + keyTranslated[0x5A] = IRON_KEY_Z; + keyTranslated[VK_LWIN] = IRON_KEY_WIN; + keyTranslated[VK_RWIN] = IRON_KEY_WIN; + keyTranslated[VK_APPS] = IRON_KEY_CONTEXT_MENU; + keyTranslated[VK_NUMPAD0] = IRON_KEY_NUMPAD_0; + keyTranslated[VK_NUMPAD1] = IRON_KEY_NUMPAD_1; + keyTranslated[VK_NUMPAD2] = IRON_KEY_NUMPAD_2; + keyTranslated[VK_NUMPAD3] = IRON_KEY_NUMPAD_3; + keyTranslated[VK_NUMPAD4] = IRON_KEY_NUMPAD_4; + keyTranslated[VK_NUMPAD5] = IRON_KEY_NUMPAD_5; + keyTranslated[VK_NUMPAD6] = IRON_KEY_NUMPAD_6; + keyTranslated[VK_NUMPAD7] = IRON_KEY_NUMPAD_7; + keyTranslated[VK_NUMPAD8] = IRON_KEY_NUMPAD_8; + keyTranslated[VK_NUMPAD9] = IRON_KEY_NUMPAD_9; + keyTranslated[VK_MULTIPLY] = IRON_KEY_MULTIPLY; + keyTranslated[VK_ADD] = IRON_KEY_ADD; + keyTranslated[VK_SUBTRACT] = IRON_KEY_SUBTRACT; + keyTranslated[VK_DECIMAL] = IRON_KEY_DECIMAL; + keyTranslated[VK_DIVIDE] = IRON_KEY_DIVIDE; + keyTranslated[VK_F1] = IRON_KEY_F1; + keyTranslated[VK_F2] = IRON_KEY_F2; + keyTranslated[VK_F3] = IRON_KEY_F3; + keyTranslated[VK_F4] = IRON_KEY_F4; + keyTranslated[VK_F5] = IRON_KEY_F5; + keyTranslated[VK_F6] = IRON_KEY_F6; + keyTranslated[VK_F7] = IRON_KEY_F7; + keyTranslated[VK_F8] = IRON_KEY_F8; + keyTranslated[VK_F9] = IRON_KEY_F9; + keyTranslated[VK_F10] = IRON_KEY_F10; + keyTranslated[VK_F11] = IRON_KEY_F11; + keyTranslated[VK_F12] = IRON_KEY_F12; + keyTranslated[VK_F13] = IRON_KEY_F13; + keyTranslated[VK_F14] = IRON_KEY_F14; + keyTranslated[VK_F15] = IRON_KEY_F15; + keyTranslated[VK_F16] = IRON_KEY_F16; + keyTranslated[VK_F17] = IRON_KEY_F17; + keyTranslated[VK_F18] = IRON_KEY_F18; + keyTranslated[VK_F19] = IRON_KEY_F19; + keyTranslated[VK_F20] = IRON_KEY_F20; + keyTranslated[VK_F21] = IRON_KEY_F21; + keyTranslated[VK_F22] = IRON_KEY_F22; + keyTranslated[VK_F23] = IRON_KEY_F23; + keyTranslated[VK_F24] = IRON_KEY_F24; + keyTranslated[VK_NUMLOCK] = IRON_KEY_NUM_LOCK; + keyTranslated[VK_SCROLL] = IRON_KEY_SCROLL_LOCK; + keyTranslated[VK_LSHIFT] = IRON_KEY_SHIFT; + keyTranslated[VK_RSHIFT] = IRON_KEY_SHIFT; + keyTranslated[VK_LCONTROL] = IRON_KEY_CONTROL; + keyTranslated[VK_RCONTROL] = IRON_KEY_CONTROL; + keyTranslated[VK_OEM_1] = IRON_KEY_SEMICOLON; + keyTranslated[VK_OEM_PLUS] = IRON_KEY_PLUS; + keyTranslated[VK_OEM_COMMA] = IRON_KEY_COMMA; + keyTranslated[VK_OEM_MINUS] = IRON_KEY_HYPHEN_MINUS; + keyTranslated[VK_OEM_PERIOD] = IRON_KEY_PERIOD; + keyTranslated[VK_OEM_2] = IRON_KEY_SLASH; + keyTranslated[VK_OEM_3] = IRON_KEY_BACK_QUOTE; + keyTranslated[VK_OEM_4] = IRON_KEY_OPEN_BRACKET; + keyTranslated[VK_OEM_5] = IRON_KEY_BACK_SLASH; + keyTranslated[VK_OEM_6] = IRON_KEY_CLOSE_BRACKET; + keyTranslated[VK_OEM_7] = IRON_KEY_QUOTE; } static bool detectGamepad = true; @@ -645,14 +645,14 @@ static int cursor = 0; static HCURSOR cursors[NUM_CURSORS]; static bool bg_erased = false; -void kinc_mouse_set_cursor(int set_cursor) { +void iron_mouse_set_cursor(int set_cursor) { cursor = set_cursor >= NUM_CURSORS ? 0 : set_cursor; if (cursors_initialized) { SetCursor(cursors[cursor]); } } -LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { +LRESULT WINAPI IronWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { DWORD pointerId; POINTER_INFO pointerInfo = {0}; POINTER_PEN_INFO penInfo = {0}; @@ -682,14 +682,14 @@ LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L case WM_SIZE: { int width = LOWORD(lParam); int height = HIWORD(lParam); - kinc_internal_resize(width, height); - kinc_internal_call_resize_callback(width, height); + iron_internal_resize(width, height); + iron_internal_call_resize_callback(width, height); break; } case WM_CLOSE: { - if (kinc_internal_call_close_callback()) { - kinc_window_destroy(); - kinc_stop(); + if (iron_internal_call_close_callback()) { + iron_window_destroy(); + iron_stop(); return 0; } return 0; @@ -702,12 +702,12 @@ LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L } case WM_ACTIVATE: if (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE) { - kinc_internal_mouse_window_activated(); - kinc_internal_foreground_callback(); + iron_internal_mouse_window_activated(); + iron_internal_foreground_callback(); } else { - kinc_internal_mouse_window_deactivated(); - kinc_internal_background_callback(); + iron_internal_mouse_window_deactivated(); + iron_internal_background_callback(); #ifdef HANDLE_ALT_ENTER altDown = false; #endif @@ -719,7 +719,7 @@ LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L case WM_MOUSEMOVE: mouseX = GET_X_LPARAM(lParam); mouseY = GET_Y_LPARAM(lParam); - kinc_internal_mouse_trigger_move(mouseX, mouseY); + iron_internal_mouse_trigger_move(mouseX, mouseY); break; case WM_CREATE: cursors[0] = LoadCursor(0, IDC_ARROW); @@ -748,51 +748,51 @@ LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L } break; case WM_LBUTTONDOWN: - if (!kinc_mouse_is_locked()) + if (!iron_mouse_is_locked()) SetCapture(hWnd); mouseX = GET_X_LPARAM(lParam); mouseY = GET_Y_LPARAM(lParam); - kinc_internal_mouse_trigger_press(0, mouseX, mouseY); + iron_internal_mouse_trigger_press(0, mouseX, mouseY); break; case WM_LBUTTONUP: - if (!kinc_mouse_is_locked()) + if (!iron_mouse_is_locked()) ReleaseCapture(); mouseX = GET_X_LPARAM(lParam); mouseY = GET_Y_LPARAM(lParam); - kinc_internal_mouse_trigger_release(0, mouseX, mouseY); + iron_internal_mouse_trigger_release(0, mouseX, mouseY); break; case WM_RBUTTONDOWN: mouseX = GET_X_LPARAM(lParam); mouseY = GET_Y_LPARAM(lParam); - kinc_internal_mouse_trigger_press(1, mouseX, mouseY); + iron_internal_mouse_trigger_press(1, mouseX, mouseY); break; case WM_RBUTTONUP: mouseX = GET_X_LPARAM(lParam); mouseY = GET_Y_LPARAM(lParam); - kinc_internal_mouse_trigger_release(1, mouseX, mouseY); + iron_internal_mouse_trigger_release(1, mouseX, mouseY); break; case WM_MBUTTONDOWN: mouseX = GET_X_LPARAM(lParam); mouseY = GET_Y_LPARAM(lParam); - kinc_internal_mouse_trigger_press(2, mouseX, mouseY); + iron_internal_mouse_trigger_press(2, mouseX, mouseY); break; case WM_MBUTTONUP: mouseX = GET_X_LPARAM(lParam); mouseY = GET_Y_LPARAM(lParam); - kinc_internal_mouse_trigger_release(2, mouseX, mouseY); + iron_internal_mouse_trigger_release(2, mouseX, mouseY); break; case WM_XBUTTONDOWN: mouseX = GET_X_LPARAM(lParam); mouseY = GET_Y_LPARAM(lParam); - kinc_internal_mouse_trigger_press(HIWORD(wParam) + 2, mouseX, mouseY); + iron_internal_mouse_trigger_press(HIWORD(wParam) + 2, mouseX, mouseY); break; case WM_XBUTTONUP: mouseX = GET_X_LPARAM(lParam); mouseY = GET_Y_LPARAM(lParam); - kinc_internal_mouse_trigger_release(HIWORD(wParam) + 2, mouseX, mouseY); + iron_internal_mouse_trigger_release(HIWORD(wParam) + 2, mouseX, mouseY); break; case WM_MOUSEWHEEL: - kinc_internal_mouse_trigger_scroll(GET_WHEEL_DELTA_WPARAM(wParam) / -120); + iron_internal_mouse_trigger_scroll(GET_WHEEL_DELTA_WPARAM(wParam) / -120); break; case WM_POINTERDOWN: pointerId = GET_POINTERID_WPARAM(wParam); @@ -800,7 +800,7 @@ LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L if (pointerInfo.pointerType == PT_PEN) { MyGetPointerPenInfo(pointerId, &penInfo); ScreenToClient(hWnd, &pointerInfo.ptPixelLocation); - kinc_internal_pen_trigger_press(pointerInfo.ptPixelLocation.x, pointerInfo.ptPixelLocation.y, + iron_internal_pen_trigger_press(pointerInfo.ptPixelLocation.x, pointerInfo.ptPixelLocation.y, penInfo.pressure / 1024.0f); } break; @@ -810,7 +810,7 @@ LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L if (pointerInfo.pointerType == PT_PEN) { MyGetPointerPenInfo(pointerId, &penInfo); ScreenToClient(hWnd, &pointerInfo.ptPixelLocation); - kinc_internal_pen_trigger_release(pointerInfo.ptPixelLocation.x, pointerInfo.ptPixelLocation.y, + iron_internal_pen_trigger_release(pointerInfo.ptPixelLocation.x, pointerInfo.ptPixelLocation.y, penInfo.pressure / 1024.0f); } break; @@ -820,7 +820,7 @@ LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L if (pointerInfo.pointerType == PT_PEN) { MyGetPointerPenInfo(pointerId, &penInfo); ScreenToClient(hWnd, &pointerInfo.ptPixelLocation); - kinc_internal_pen_trigger_move(pointerInfo.ptPixelLocation.x, pointerInfo.ptPixelLocation.y, + iron_internal_pen_trigger_move(pointerInfo.ptPixelLocation.x, pointerInfo.ptPixelLocation.y, penInfo.pressure / 1024.0f); } break; @@ -842,7 +842,7 @@ LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L if (ti.dwFlags & TOUCHEVENTF_UP) { tindex = GetTouchIndex(ti.dwID); ReleaseTouchIndex(ti.dwID); - kinc_internal_surface_trigger_touch_end(tindex, ptInput.x, ptInput.y); + iron_internal_surface_trigger_touch_end(tindex, ptInput.x, ptInput.y); } else { bool touchExisits = GetTouchIndex(ti.dwID) != -1; @@ -852,13 +852,13 @@ LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L if (touchPoints[tindex].x != ptInput.x || touchPoints[tindex].y != ptInput.y) { touchPoints[tindex].x = ptInput.x; touchPoints[tindex].y = ptInput.y; - kinc_internal_surface_trigger_move(tindex, ptInput.x, ptInput.y); + iron_internal_surface_trigger_move(tindex, ptInput.x, ptInput.y); } } else { touchPoints[tindex].x = ptInput.x; touchPoints[tindex].y = ptInput.y; - kinc_internal_surface_trigger_touch_start(tindex, ptInput.x, ptInput.y); + iron_internal_surface_trigger_touch_start(tindex, ptInput.x, ptInput.y); } } } @@ -882,17 +882,17 @@ LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L if (!keyPressed[wParam]) { keyPressed[wParam] = true; - if (keyTranslated[wParam] == KINC_KEY_CONTROL) { + if (keyTranslated[wParam] == IRON_KEY_CONTROL) { controlDown = true; } #ifdef HANDLE_ALT_ENTER - else if (keyTranslated[wParam] == KINC_KEY_ALT) { + else if (keyTranslated[wParam] == IRON_KEY_ALT) { altDown = true; } #endif else { - if (controlDown && keyTranslated[wParam] == KINC_KEY_X) { - char *text = kinc_internal_cut_callback(); + if (controlDown && keyTranslated[wParam] == IRON_KEY_X) { + char *text = iron_internal_cut_callback(); if (text != NULL) { wchar_t wtext[4096]; MultiByteToWideChar(CP_UTF8, 0, text, -1, wtext, 4096); @@ -908,8 +908,8 @@ LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L } } - if (controlDown && keyTranslated[wParam] == KINC_KEY_C) { - char *text = kinc_internal_copy_callback(); + if (controlDown && keyTranslated[wParam] == IRON_KEY_C) { + char *text = iron_internal_copy_callback(); if (text != NULL) { wchar_t wtext[4096]; MultiByteToWideChar(CP_UTF8, 0, text, -1, wtext, 4096); @@ -925,7 +925,7 @@ LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L } } - if (controlDown && keyTranslated[wParam] == KINC_KEY_V) { + if (controlDown && keyTranslated[wParam] == IRON_KEY_V) { if (IsClipboardFormatAvailable(CF_UNICODETEXT)) { OpenClipboard(hWnd); HANDLE handle = GetClipboardData(CF_UNICODETEXT); @@ -934,7 +934,7 @@ LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L if (wtext != NULL) { char text[4096]; WideCharToMultiByte(CP_UTF8, 0, wtext, -1, text, 4096, NULL, NULL); - kinc_internal_paste_callback(text); + iron_internal_paste_callback(text); GlobalUnlock(handle); } } @@ -943,53 +943,53 @@ LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L } #ifdef HANDLE_ALT_ENTER - if (altDown && keyTranslated[wParam] == KINC_KEY_RETURN) { - if (kinc_window_get_mode() == KINC_WINDOW_MODE_WINDOW) { - last_window_width = kinc_window_width(); - last_window_height = kinc_window_height(); - last_window_x = kinc_window_x(); - last_window_y = kinc_window_y(); - kinc_window_change_mode(KINC_WINDOW_MODE_FULLSCREEN); + if (altDown && keyTranslated[wParam] == IRON_KEY_RETURN) { + if (iron_window_get_mode() == IRON_WINDOW_MODE_WINDOW) { + last_window_width = iron_window_width(); + last_window_height = iron_window_height(); + last_window_x = iron_window_x(); + last_window_y = iron_window_y(); + iron_window_change_mode(IRON_WINDOW_MODE_FULLSCREEN); } else { - kinc_window_change_mode(KINC_WINDOW_MODE_WINDOW); + iron_window_change_mode(IRON_WINDOW_MODE_WINDOW); if (last_window_width > 0 && last_window_height > 0) { - kinc_window_resize(last_window_width, last_window_height); + iron_window_resize(last_window_width, last_window_height); } if (last_window_x > INT_MIN && last_window_y > INT_MIN) { - kinc_window_move(last_window_x, last_window_y); + iron_window_move(last_window_x, last_window_y); } } } #endif } // No auto-repeat - kinc_internal_keyboard_trigger_key_down(keyTranslated[wParam]); + iron_internal_keyboard_trigger_key_down(keyTranslated[wParam]); } // Auto-repeat - // kinc_internal_keyboard_trigger_key_down(keyTranslated[wParam]); + // iron_internal_keyboard_trigger_key_down(keyTranslated[wParam]); break; case WM_KEYUP: case WM_SYSKEYUP: keyPressed[wParam] = false; - if (keyTranslated[wParam] == KINC_KEY_CONTROL) { + if (keyTranslated[wParam] == IRON_KEY_CONTROL) { controlDown = false; } #ifdef HANDLE_ALT_ENTER - if (keyTranslated[wParam] == KINC_KEY_ALT) { + if (keyTranslated[wParam] == IRON_KEY_ALT) { altDown = false; } #endif - kinc_internal_keyboard_trigger_key_up(keyTranslated[wParam]); + iron_internal_keyboard_trigger_key_up(keyTranslated[wParam]); break; case WM_CHAR: switch (wParam) { case 0x1B: // escape break; default: - kinc_internal_keyboard_trigger_key_press((unsigned)wParam); + iron_internal_keyboard_trigger_key_press((unsigned)wParam); break; } break; @@ -1025,7 +1025,7 @@ LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L for (unsigned i = 0; i < count; ++i) { wchar_t filePath[260]; if (DragQueryFileW(hDrop, i, filePath, 260)) { - kinc_internal_drop_files_callback(filePath); + iron_internal_drop_files_callback(filePath); } } DragFinish(hDrop); @@ -1059,10 +1059,10 @@ void loadXInput() { } static IDirectInput8W *di_instance = NULL; -static IDirectInputDevice8W *di_pads[KINC_DINPUT_MAX_COUNT]; -static DIJOYSTATE2 di_padState[KINC_DINPUT_MAX_COUNT]; -static DIJOYSTATE2 di_lastPadState[KINC_DINPUT_MAX_COUNT]; -static DIDEVCAPS di_deviceCaps[KINC_DINPUT_MAX_COUNT]; +static IDirectInputDevice8W *di_pads[IRON_DINPUT_MAX_COUNT]; +static DIJOYSTATE2 di_padState[IRON_DINPUT_MAX_COUNT]; +static DIJOYSTATE2 di_lastPadState[IRON_DINPUT_MAX_COUNT]; +static DIDEVCAPS di_deviceCaps[IRON_DINPUT_MAX_COUNT]; static int padCount = 0; static void cleanupPad(int padIndex) { @@ -1153,7 +1153,7 @@ static BOOL IsXInputDevice(const GUID *pGuidProductFromDirectInput) { // If it does, then get the VID/PID from var.bstrVal DWORD dwPid = 0, dwVid = 0; WCHAR *strVid = wcsstr(var.bstrVal, L"VID_"); -#ifndef KINC_NO_CLIB +#ifndef IRON_NO_CLIB if (strVid && swscanf(strVid, L"VID_%4X", &dwVid) != 1) { dwVid = 0; } @@ -1195,7 +1195,7 @@ LCleanup: } static void cleanupDirectInput() { - for (int padIndex = 0; padIndex < KINC_DINPUT_MAX_COUNT; ++padIndex) { + for (int padIndex = 0; padIndex < IRON_DINPUT_MAX_COUNT; ++padIndex) { cleanupPad(padIndex); } @@ -1219,7 +1219,7 @@ static BOOL CALLBACK enumerateJoystickAxesCallback(LPCDIDEVICEOBJECTINSTANCEW dd HRESULT hr = di_pads[padCount]->lpVtbl->SetProperty(di_pads[padCount], DIPROP_RANGE, &propertyRange.diph); if (FAILED(hr)) { - kinc_log("DirectInput8 / Pad%i / SetProperty() failed (HRESULT=0x%x)", padCount, hr); + iron_log("DirectInput8 / Pad%i / SetProperty() failed (HRESULT=0x%x)", padCount, hr); return DIENUM_STOP; } @@ -1252,35 +1252,35 @@ static BOOL CALLBACK enumerateJoysticksCallback(LPCDIDEVICEINSTANCEW ddi, LPVOID hr = di_pads[padCount]->lpVtbl->GetDeviceState(di_pads[padCount], sizeof(DIJOYSTATE2), &di_padState[padCount]); if (SUCCEEDED(hr)) { - kinc_log("DirectInput8 / Pad%i / initialized", padCount); + iron_log("DirectInput8 / Pad%i / initialized", padCount); } else { - kinc_log("DirectInput8 / Pad%i / GetDeviceState() failed (HRESULT=0x%x)", padCount, hr); + iron_log("DirectInput8 / Pad%i / GetDeviceState() failed (HRESULT=0x%x)", padCount, hr); } } else { - kinc_log("DirectInput8 / Pad%i / Acquire() failed (HRESULT=0x%x)", padCount, hr); + iron_log("DirectInput8 / Pad%i / Acquire() failed (HRESULT=0x%x)", padCount, hr); cleanupPad(padCount); } } else { - kinc_log("DirectInput8 / Pad%i / EnumObjects(DIDFT_AXIS) failed (HRESULT=0x%x)", padCount, hr); + iron_log("DirectInput8 / Pad%i / EnumObjects(DIDFT_AXIS) failed (HRESULT=0x%x)", padCount, hr); cleanupPad(padCount); } } else { - kinc_log("DirectInput8 / Pad%i / GetCapabilities() failed (HRESULT=0x%x)", padCount, hr); + iron_log("DirectInput8 / Pad%i / GetCapabilities() failed (HRESULT=0x%x)", padCount, hr); cleanupPad(padCount); } } else { - kinc_log("DirectInput8 / Pad%i / SetDataFormat() failed (HRESULT=0x%x)", padCount, hr); + iron_log("DirectInput8 / Pad%i / SetDataFormat() failed (HRESULT=0x%x)", padCount, hr); cleanupPad(padCount); } ++padCount; - if (padCount >= KINC_DINPUT_MAX_COUNT) { + if (padCount >= IRON_DINPUT_MAX_COUNT) { return DIENUM_STOP; } } @@ -1291,10 +1291,10 @@ static BOOL CALLBACK enumerateJoysticksCallback(LPCDIDEVICEINSTANCEW ddi, LPVOID static void initializeDirectInput() { HINSTANCE hinstance = GetModuleHandleW(NULL); - memset(&di_pads, 0, sizeof(IDirectInputDevice8) * KINC_DINPUT_MAX_COUNT); - memset(&di_padState, 0, sizeof(DIJOYSTATE2) * KINC_DINPUT_MAX_COUNT); - memset(&di_lastPadState, 0, sizeof(DIJOYSTATE2) * KINC_DINPUT_MAX_COUNT); - memset(&di_deviceCaps, 0, sizeof(DIDEVCAPS) * KINC_DINPUT_MAX_COUNT); + memset(&di_pads, 0, sizeof(IDirectInputDevice8) * IRON_DINPUT_MAX_COUNT); + memset(&di_padState, 0, sizeof(DIJOYSTATE2) * IRON_DINPUT_MAX_COUNT); + memset(&di_lastPadState, 0, sizeof(DIJOYSTATE2) * IRON_DINPUT_MAX_COUNT); + memset(&di_deviceCaps, 0, sizeof(DIDEVCAPS) * IRON_DINPUT_MAX_COUNT); HRESULT hr = DirectInput8Create(hinstance, DIRECTINPUT_VERSION, &IID_IDirectInput8W, (void **)&di_instance, NULL); @@ -1308,7 +1308,7 @@ static void initializeDirectInput() { } } else { - kinc_log("DirectInput8Create failed (HRESULT=0x%x)", hr); + iron_log("DirectInput8Create failed (HRESULT=0x%x)", hr); } } @@ -1341,7 +1341,7 @@ bool handleDirectInputPad(int padIndex) { } if (*now != *last) { - kinc_internal_gamepad_trigger_axis(padIndex, axisIndex, *now / 32768.0f); + iron_internal_gamepad_trigger_axis(padIndex, axisIndex, *now / 32768.0f); } } @@ -1350,7 +1350,7 @@ bool handleDirectInputPad(int padIndex) { BYTE *last = &di_lastPadState[padIndex].rgbButtons[buttonIndex]; if (*now != *last) { - kinc_internal_gamepad_trigger_button(padIndex, buttonIndex, *now / 255.0f); + iron_internal_gamepad_trigger_button(padIndex, buttonIndex, *now / 255.0f); } } @@ -1369,16 +1369,16 @@ bool handleDirectInputPad(int padIndex) { bool lastRight = (*last == 9000 || *last == 4500 || *last == 13500); if (up != lastUp) { - kinc_internal_gamepad_trigger_button(padIndex, 12, up ? 1.0f : 0.0f); + iron_internal_gamepad_trigger_button(padIndex, 12, up ? 1.0f : 0.0f); } if (down != lastDown) { - kinc_internal_gamepad_trigger_button(padIndex, 13, down ? 1.0f : 0.0f); + iron_internal_gamepad_trigger_button(padIndex, 13, down ? 1.0f : 0.0f); } if (left != lastLeft) { - kinc_internal_gamepad_trigger_button(padIndex, 14, left ? 1.0f : 0.0f); + iron_internal_gamepad_trigger_button(padIndex, 14, left ? 1.0f : 0.0f); } if (right != lastRight) { - kinc_internal_gamepad_trigger_button(padIndex, 15, right ? 1.0f : 0.0f); + iron_internal_gamepad_trigger_button(padIndex, 15, right ? 1.0f : 0.0f); } } @@ -1415,7 +1415,7 @@ static bool isDirectInputGamepad(int gamepad) { return hr == S_OK; } -const char *kinc_gamepad_vendor(int gamepad) { +const char *iron_gamepad_vendor(int gamepad) { if (isXInputGamepad(gamepad)) { return "Microsoft"; } @@ -1424,7 +1424,7 @@ const char *kinc_gamepad_vendor(int gamepad) { } } -const char *kinc_gamepad_product_name(int gamepad) { +const char *iron_gamepad_product_name(int gamepad) { if (isXInputGamepad(gamepad)) { return "Xbox 360 Controller"; } @@ -1433,7 +1433,7 @@ const char *kinc_gamepad_product_name(int gamepad) { } } -bool kinc_internal_handle_messages() { +bool iron_internal_handle_messages() { MSG message; while (PeekMessageW(&message, 0, 0, 0, PM_REMOVE)) { @@ -1443,7 +1443,7 @@ bool kinc_internal_handle_messages() { if (InputGetState != NULL && (detectGamepad || gamepadFound)) { detectGamepad = false; - for (DWORD i = 0; i < KINC_DINPUT_MAX_COUNT; ++i) { + for (DWORD i = 0; i < IRON_DINPUT_MAX_COUNT; ++i) { XINPUT_STATE state; memset(&state, 0, sizeof(XINPUT_STATE)); DWORD dwResult = InputGetState(i, &state); @@ -1460,7 +1460,7 @@ bool kinc_internal_handle_messages() { newaxes[5] = state.Gamepad.bRightTrigger / 255.0f; for (int i2 = 0; i2 < 6; ++i2) { if (axes[i * 6 + i2] != newaxes[i2]) { - kinc_internal_gamepad_trigger_axis(i, i2, newaxes[i2]); + iron_internal_gamepad_trigger_axis(i, i2, newaxes[i2]); axes[i * 6 + i2] = newaxes[i2]; } } @@ -1483,7 +1483,7 @@ bool kinc_internal_handle_messages() { newbuttons[15] = (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) ? 1.0f : 0.0f; for (int i2 = 0; i2 < 16; ++i2) { if (buttons[i * 16 + i2] != newbuttons[i2]) { - kinc_internal_gamepad_trigger_button(i, i2, newbuttons[i2]); + iron_internal_gamepad_trigger_button(i, i2, newbuttons[i2]); buttons[i * 16 + i2] = newbuttons[i2]; } } @@ -1502,19 +1502,19 @@ bool kinc_internal_handle_messages() { static bool keyboardshown = false; static char language[3] = {0}; -void kinc_keyboard_show() { +void iron_keyboard_show() { keyboardshown = true; } -void kinc_keyboard_hide() { +void iron_keyboard_hide() { keyboardshown = false; } -bool kinc_keyboard_active() { +bool iron_keyboard_active() { return keyboardshown; } -void kinc_load_url(const char *url) { +void iron_load_url(const char *url) { #define WURL_SIZE 1024 #define HTTP "http://" #define HTTPS "https://" @@ -1524,7 +1524,7 @@ void kinc_load_url(const char *url) { INT_PTR ret = (INT_PTR)ShellExecuteW(NULL, L"open", wurl, NULL, NULL, SW_SHOWNORMAL); // According to ShellExecuteW's documentation return values > 32 indicate a success. if (ret <= 32) { - kinc_log("Error opening url %s", url); + iron_log("Error opening url %s", url); } } #undef HTTPS @@ -1532,9 +1532,9 @@ void kinc_load_url(const char *url) { #undef WURL_SIZE } -void kinc_set_keep_screen_on(bool on) {} +void iron_set_keep_screen_on(bool on) {} -const char *kinc_language() { +const char *iron_language() { wchar_t wlanguage[3] = {0}; if (GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SISO639LANGNAME, wlanguage, 3)) { @@ -1544,15 +1544,15 @@ const char *kinc_language() { return "en"; } -const char *kinc_system_id() { +const char *iron_system_id() { return "Windows"; } static bool co_initialized = false; -void kinc_windows_co_initialize(void) { +void iron_windows_co_initialize(void) { if (!co_initialized) { - kinc_microsoft_affirm(CoInitializeEx(0, COINIT_MULTITHREADED)); + iron_microsoft_affirm(CoInitializeEx(0, COINIT_MULTITHREADED)); co_initialized = true; } } @@ -1561,7 +1561,7 @@ static wchar_t savePathw[2048] = {0}; static char savePath[2048] = {0}; static void findSavePath() { - kinc_windows_co_initialize(); + iron_windows_co_initialize(); IKnownFolderManager *folders = NULL; CoCreateInstance(&CLSID_KnownFolderManager, NULL, CLSCTX_INPROC_SERVER, &IID_IKnownFolderManager, (LPVOID *)&folders); IKnownFolder *folder = NULL; @@ -1573,7 +1573,7 @@ static void findSavePath() { wcscpy(savePathw, path); wcscat(savePathw, L"\\"); wchar_t name[1024]; - MultiByteToWideChar(CP_UTF8, 0, kinc_application_name(), -1, name, 1024); + MultiByteToWideChar(CP_UTF8, 0, iron_application_name(), -1, name, 1024); wcscat(savePathw, name); wcscat(savePathw, L"\\"); @@ -1585,7 +1585,7 @@ static void findSavePath() { folders->lpVtbl->Release(folders); } -const char *kinc_internal_save_path() { +const char *iron_internal_save_path() { if (savePath[0] == 0) findSavePath(); return savePath; @@ -1595,15 +1595,15 @@ static const char *videoFormats[] = {"ogv", NULL}; static LARGE_INTEGER frequency; static LARGE_INTEGER startCount; -const char **kinc_video_formats() { +const char **iron_video_formats() { return videoFormats; } -bool kinc_gamepad_connected(int num) { +bool iron_gamepad_connected(int num) { return isXInputGamepad(num) || isDirectInputGamepad(num); } -void kinc_gamepad_rumble(int gamepad, float left, float right) { +void iron_gamepad_rumble(int gamepad, float left, float right) { if (isXInputGamepad(gamepad)) { XINPUT_VIBRATION vibration; memset(&vibration, 0, sizeof(XINPUT_VIBRATION)); @@ -1613,23 +1613,23 @@ void kinc_gamepad_rumble(int gamepad, float left, float right) { } } -double kinc_frequency() { +double iron_frequency() { return (double)frequency.QuadPart; } -kinc_ticks_t kinc_timestamp(void) { +iron_ticks_t iron_timestamp(void) { LARGE_INTEGER stamp; QueryPerformanceCounter(&stamp); return stamp.QuadPart - startCount.QuadPart; } -double kinc_time(void) { +double iron_time(void) { LARGE_INTEGER stamp; QueryPerformanceCounter(&stamp); return (double)(stamp.QuadPart - startCount.QuadPart) / (double)frequency.QuadPart; } -#if !defined(KINC_NO_MAIN) && !defined(KINC_NO_CLIB) +#if !defined(IRON_NO_MAIN) && !defined(IRON_NO_CLIB) int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { int ret = kickstart(__argc, __argv); if (ret != 0) { @@ -1651,7 +1651,7 @@ typedef BOOL(__stdcall *MiniDumpWriteDumpType)(IN HANDLE hProcess, IN DWORD Proc static MiniDumpWriteDumpType MyMiniDumpWriteDump; static LONG __stdcall MyCrashHandlerExceptionFilter(EXCEPTION_POINTERS *pEx) { - HANDLE file = CreateFileA("kinc.dmp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFileA("iron.dmp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (file != INVALID_HANDLE_VALUE) { MINIDUMP_EXCEPTION_INFORMATION stMDEI; stMDEI.ThreadId = GetCurrentThreadId(); @@ -1671,7 +1671,7 @@ static void init_crash_handler() { } } -void kinc_init(const char *name, int width, int height, kinc_window_options_t *win) { +void iron_init(const char *name, int width, int height, iron_window_options_t *win) { init_crash_handler(); // Pen functions are only in Windows 8 and later, so load them dynamically @@ -1690,7 +1690,7 @@ void kinc_init(const char *name, int width, int height, kinc_window_options_t *w touchPoints[i].y = -1; } - kinc_display_init(); + iron_display_init(); QueryPerformanceCounter(&startCount); QueryPerformanceFrequency(&frequency); @@ -1699,10 +1699,10 @@ void kinc_init(const char *name, int width, int height, kinc_window_options_t *w keyPressed[i] = false; } - kinc_set_app_name(name); - kinc_window_options_t defaultWin; + iron_set_app_name(name); + iron_window_options_t defaultWin; if (win == NULL) { - kinc_window_options_set_defaults(&defaultWin); + iron_window_options_set_defaults(&defaultWin); win = &defaultWin; } win->width = width; @@ -1711,25 +1711,25 @@ void kinc_init(const char *name, int width, int height, kinc_window_options_t *w win->title = name; } - kinc_g5_internal_init(); + iron_g5_internal_init(); - kinc_window_create(win); + iron_window_create(win); loadXInput(); initializeDirectInput(); } -void kinc_internal_shutdown() { - kinc_windows_hide_windows(); - kinc_internal_shutdown_callback(); - kinc_windows_destroy_windows(); - kinc_g5_internal_destroy(); - kinc_windows_restore_displays(); +void iron_internal_shutdown() { + iron_windows_hide_windows(); + iron_internal_shutdown_callback(); + iron_windows_destroy_windows(); + iron_g5_internal_destroy(); + iron_windows_restore_displays(); } -void kinc_copy_to_clipboard(const char *text) { +void iron_copy_to_clipboard(const char *text) { wchar_t wtext[4096]; MultiByteToWideChar(CP_UTF8, 0, text, -1, wtext, 4096); - OpenClipboard(kinc_windows_window_handle(0)); + OpenClipboard(iron_windows_window_handle(0)); EmptyClipboard(); size_t size = (wcslen(wtext) + 1) * sizeof(wchar_t); HANDLE handle = GlobalAlloc(GMEM_MOVEABLE, size); @@ -1740,7 +1740,7 @@ void kinc_copy_to_clipboard(const char *text) { CloseClipboard(); } -int kinc_cpu_cores(void) { +int iron_cpu_cores(void) { SYSTEM_LOGICAL_PROCESSOR_INFORMATION info[1024]; DWORD returnLength = sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION) * 1024; BOOL success = GetLogicalProcessorInformation(&info[0], &returnLength); @@ -1766,7 +1766,7 @@ int kinc_cpu_cores(void) { return proper_cpu_count; } -int kinc_hardware_threads(void) { +int iron_hardware_threads(void) { SYSTEM_INFO sysinfo; GetSystemInfo(&sysinfo); return sysinfo.dwNumberOfProcessors; @@ -1781,7 +1781,7 @@ typedef unsigned long DWORD; #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE #define DWMWA_USE_IMMERSIVE_DARK_MODE 20 #endif -struct HWND__ *kinc_windows_window_handle(); +struct HWND__ *iron_windows_window_handle(); // Enable visual styles for ui controls #pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") @@ -1798,17 +1798,17 @@ typedef struct { void *closeCallbackData; } WindowData; -LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); +LRESULT WINAPI IronWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); #define MAXIMUM_WINDOWS 1 static WindowData windows[MAXIMUM_WINDOWS] = {0}; -const wchar_t *windowClassName = L"KoreWindow"; +const wchar_t *windowClassName = L"IronWindow"; static void RegisterWindowClass(HINSTANCE hInstance, const wchar_t *className) { WNDCLASSEXW wc = {sizeof(WNDCLASSEXA), CS_OWNDC /*CS_CLASSDC*/, - KoreWindowsMessageProcedure, + IronWindowsMessageProcedure, 0L, 0L, hInstance, @@ -1824,19 +1824,19 @@ static void RegisterWindowClass(HINSTANCE hInstance, const wchar_t *className) { static DWORD getStyle(int features) { DWORD style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP; - if ((features & KINC_WINDOW_FEATURE_RESIZEABLE) && ((features & KINC_WINDOW_FEATURE_BORDERLESS) == 0)) { + if ((features & IRON_WINDOW_FEATURE_RESIZEABLE) && ((features & IRON_WINDOW_FEATURE_BORDERLESS) == 0)) { style |= WS_SIZEBOX; } - if (features & KINC_WINDOW_FEATURE_MAXIMIZABLE) { + if (features & IRON_WINDOW_FEATURE_MAXIMIZABLE) { style |= WS_MAXIMIZEBOX; } - if (features & KINC_WINDOW_FEATURE_MINIMIZABLE) { + if (features & IRON_WINDOW_FEATURE_MINIMIZABLE) { style |= WS_MINIMIZEBOX; } - if ((features & KINC_WINDOW_FEATURE_BORDERLESS) == 0) { + if ((features & IRON_WINDOW_FEATURE_BORDERLESS) == 0) { style |= WS_CAPTION | WS_SYSMENU; } @@ -1846,69 +1846,69 @@ static DWORD getStyle(int features) { static DWORD getExStyle(int features) { DWORD exStyle = WS_EX_APPWINDOW; - if ((features & KINC_WINDOW_FEATURE_BORDERLESS) == 0) { + if ((features & IRON_WINDOW_FEATURE_BORDERLESS) == 0) { exStyle |= WS_EX_WINDOWEDGE; } - if (features & KINC_WINDOW_FEATURE_ON_TOP) { + if (features & IRON_WINDOW_FEATURE_ON_TOP) { exStyle |= WS_EX_TOPMOST; } return exStyle; } -int kinc_window_x() { +int iron_window_x() { RECT rect; GetWindowRect(windows[0].handle, &rect); windows[0].x = rect.left; return windows[0].x; } -int kinc_window_y() { +int iron_window_y() { RECT rect; GetWindowRect(windows[0].handle, &rect); windows[0].y = rect.top; return windows[0].y; } -int kinc_window_width() { +int iron_window_width() { RECT rect; GetClientRect(windows[0].handle, &rect); return rect.right; } -int kinc_window_height() { +int iron_window_height() { RECT rect; GetClientRect(windows[0].handle, &rect); return rect.bottom; } -static DWORD getDwStyle(kinc_window_mode_t mode, int features) { +static DWORD getDwStyle(iron_window_mode_t mode, int features) { switch (mode) { - case KINC_WINDOW_MODE_FULLSCREEN: + case IRON_WINDOW_MODE_FULLSCREEN: return WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP; - case KINC_WINDOW_MODE_WINDOW: + case IRON_WINDOW_MODE_WINDOW: default: return getStyle(features); } } -static DWORD getDwExStyle(kinc_window_mode_t mode, int features) { +static DWORD getDwExStyle(iron_window_mode_t mode, int features) { switch (mode) { - case KINC_WINDOW_MODE_FULLSCREEN: + case IRON_WINDOW_MODE_FULLSCREEN: return WS_EX_APPWINDOW; - case KINC_WINDOW_MODE_WINDOW: + case IRON_WINDOW_MODE_WINDOW: default: return getExStyle(features); } } -static void createWindow(const wchar_t *title, int x, int y, int width, int height, int bpp, int frequency, int features, kinc_window_mode_t windowMode, +static void createWindow(const wchar_t *title, int x, int y, int width, int height, int bpp, int frequency, int features, iron_window_mode_t windowMode, int target_display_index) { HINSTANCE inst = GetModuleHandleW(NULL); RegisterWindowClass(inst, windowClassName); - int display_index = target_display_index == -1 ? kinc_primary_display() : target_display_index; + int display_index = target_display_index == -1 ? iron_primary_display() : target_display_index; RECT WindowRect; WindowRect.left = 0; @@ -1918,7 +1918,7 @@ static void createWindow(const wchar_t *title, int x, int y, int width, int heig AdjustWindowRectEx(&WindowRect, getDwStyle(windowMode, features), FALSE, getDwExStyle(windowMode, features)); - kinc_display_mode_t display_mode = kinc_display_current_mode(display_index); + iron_display_mode_t display_mode = iron_display_current_mode(display_index); int dstx = display_mode.x; int dsty = display_mode.y; @@ -1926,13 +1926,13 @@ static void createWindow(const wchar_t *title, int x, int y, int width, int heig int dsth = height; switch (windowMode) { - case KINC_WINDOW_MODE_WINDOW: + case IRON_WINDOW_MODE_WINDOW: dstx += x < 0 ? (display_mode.width - width) / 2 : x; dsty += y < 0 ? (display_mode.height - height) / 2 : y; dstw = WindowRect.right - WindowRect.left; dsth = WindowRect.bottom - WindowRect.top; break; - case KINC_WINDOW_MODE_FULLSCREEN: + case IRON_WINDOW_MODE_FULLSCREEN: dstw = display_mode.width; dsth = display_mode.height; break; @@ -1960,28 +1960,28 @@ static void createWindow(const wchar_t *title, int x, int y, int width, int heig DWORD cbdata = 4 * sizeof(char); RegGetValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", L"AppsUseLightTheme", RRF_RT_REG_DWORD, NULL, vdata, &cbdata); BOOL use_dark_mode = (int)(vdata[3] << 24 | vdata[2] << 16 | vdata[1] << 8 | vdata[0]) != 1; - DwmSetWindowAttribute(kinc_windows_window_handle(0), DWMWA_USE_IMMERSIVE_DARK_MODE, &use_dark_mode, sizeof(use_dark_mode)); + DwmSetWindowAttribute(iron_windows_window_handle(0), DWMWA_USE_IMMERSIVE_DARK_MODE, &use_dark_mode, sizeof(use_dark_mode)); } -void kinc_window_resize(int width, int height) { +void iron_window_resize(int width, int height) { WindowData *win = &windows[0]; win->manualWidth = width; win->manualHeight = height; switch (win->mode) { - case KINC_WINDOW_MODE_WINDOW: { + case IRON_WINDOW_MODE_WINDOW: { RECT rect; rect.left = 0; rect.top = 0; rect.right = width; rect.bottom = height; - AdjustWindowRectEx(&rect, getDwStyle((kinc_window_mode_t)win->mode, win->features), FALSE, getDwExStyle((kinc_window_mode_t)win->mode, win->features)); - SetWindowPos(win->handle, NULL, kinc_window_x(), kinc_window_y(), rect.right - rect.left, rect.bottom - rect.top, 0); + AdjustWindowRectEx(&rect, getDwStyle((iron_window_mode_t)win->mode, win->features), FALSE, getDwExStyle((iron_window_mode_t)win->mode, win->features)); + SetWindowPos(win->handle, NULL, iron_window_x(), iron_window_y(), rect.right - rect.left, rect.bottom - rect.top, 0); break; } } } -void kinc_window_move(int x, int y) { +void iron_window_move(int x, int y) { WindowData *win = &windows[0]; if (win->mode != 0) { @@ -1994,42 +1994,42 @@ void kinc_window_move(int x, int y) { RECT rect; rect.left = 0; rect.top = 0; - rect.right = kinc_window_width(); - rect.bottom = kinc_window_height(); - AdjustWindowRectEx(&rect, getDwStyle((kinc_window_mode_t)win->mode, win->features), FALSE, getDwExStyle((kinc_window_mode_t)win->mode, win->features)); + rect.right = iron_window_width(); + rect.bottom = iron_window_height(); + AdjustWindowRectEx(&rect, getDwStyle((iron_window_mode_t)win->mode, win->features), FALSE, getDwExStyle((iron_window_mode_t)win->mode, win->features)); SetWindowPos(win->handle, NULL, x, y, rect.right - rect.left, rect.bottom - rect.top, 0); } -void kinc_window_change_features(int features) { +void iron_window_change_features(int features) { WindowData *win = &windows[0]; win->features = features; SetWindowLongW(win->handle, GWL_STYLE, getStyle(features)); SetWindowLongW(win->handle, GWL_EXSTYLE, getExStyle(features)); - HWND on_top = (features & KINC_WINDOW_FEATURE_ON_TOP) ? HWND_TOPMOST : HWND_NOTOPMOST; + HWND on_top = (features & IRON_WINDOW_FEATURE_ON_TOP) ? HWND_TOPMOST : HWND_NOTOPMOST; SetWindowPos(win->handle, on_top, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); - kinc_window_show(); + iron_window_show(); } -void kinc_window_change_mode(kinc_window_mode_t mode) { +void iron_window_change_mode(iron_window_mode_t mode) { WindowData *win = &windows[0]; - int display_index = kinc_window_display(); - kinc_display_mode_t display_mode = kinc_display_current_mode(display_index); + int display_index = iron_window_display(); + iron_display_mode_t display_mode = iron_display_current_mode(display_index); switch (mode) { - case KINC_WINDOW_MODE_WINDOW: { - kinc_windows_restore_display(display_index); - kinc_window_change_features(win->features); - kinc_window_show(); + case IRON_WINDOW_MODE_WINDOW: { + iron_windows_restore_display(display_index); + iron_window_change_features(win->features); + iron_window_show(); break; } - case KINC_WINDOW_MODE_FULLSCREEN: { - kinc_windows_restore_display(display_index); + case IRON_WINDOW_MODE_FULLSCREEN: { + iron_windows_restore_display(display_index); SetWindowLongW(win->handle, GWL_STYLE, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP); SetWindowLongW(win->handle, GWL_EXSTYLE, WS_EX_APPWINDOW); SetWindowPos(win->handle, NULL, display_mode.x, display_mode.y, display_mode.width, display_mode.height, 0); - kinc_window_show(); + iron_window_show(); break; } } @@ -2037,20 +2037,20 @@ void kinc_window_change_mode(kinc_window_mode_t mode) { DragAcceptFiles(win->handle, true); } -kinc_window_mode_t kinc_window_get_mode() { - return (kinc_window_mode_t)windows[0].mode; +iron_window_mode_t iron_window_get_mode() { + return (iron_window_mode_t)windows[0].mode; } -void kinc_window_destroy() { +void iron_window_destroy() { WindowData *win = &windows[0]; if (win->handle != NULL) { - kinc_g5_internal_destroy_window(); + iron_g5_internal_destroy_window(); DestroyWindow(win->handle); win->handle = NULL; } } -void kinc_windows_hide_windows(void) { +void iron_windows_hide_windows(void) { for (int i = 0; i < MAXIMUM_WINDOWS; ++i) { if (windows[i].handle != NULL) { ShowWindow(windows[i].handle, SW_HIDE); @@ -2059,34 +2059,34 @@ void kinc_windows_hide_windows(void) { } } -void kinc_windows_destroy_windows(void) { +void iron_windows_destroy_windows(void) { for (int i = 0; i < MAXIMUM_WINDOWS; ++i) { - kinc_window_destroy(i); + iron_window_destroy(i); } UnregisterClassW(windowClassName, GetModuleHandleW(NULL)); } -void kinc_window_show() { +void iron_window_show() { ShowWindow(windows[0].handle, SW_SHOWDEFAULT); UpdateWindow(windows[0].handle); } -void kinc_window_hide() { +void iron_window_hide() { ShowWindow(windows[0].handle, SW_HIDE); UpdateWindow(windows[0].handle); } -void kinc_window_set_title(const char *title) { +void iron_window_set_title(const char *title) { wchar_t buffer[1024]; MultiByteToWideChar(CP_UTF8, 0, title, -1, buffer, 1024); SetWindowTextW(windows[0].handle, buffer); } -void kinc_window_create(kinc_window_options_t *win) { - kinc_window_options_t defaultWin; +void iron_window_create(iron_window_options_t *win) { + iron_window_options_t defaultWin; if (win == NULL) { - kinc_window_options_set_defaults(&defaultWin); + iron_window_options_set_defaults(&defaultWin); win = &defaultWin; } @@ -2102,38 +2102,38 @@ void kinc_window_create(kinc_window_options_t *win) { bool vsync = win->vsync; - kinc_g4_internal_init_window(win->depth_bits, vsync); + iron_g4_internal_init_window(win->depth_bits, vsync); if (win->visible) { - kinc_window_show(); + iron_window_show(); } } -void kinc_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) { +void iron_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) { windows[0].resizeCallback = callback; windows[0].resizeCallbackData = data; } -void kinc_window_set_close_callback(bool (*callback)(void *data), void *data) { +void iron_window_set_close_callback(bool (*callback)(void *data), void *data) { windows[0].closeCallback = callback; windows[0].closeCallbackData = data; } -int kinc_window_display() { - return kinc_windows_get_display_for_monitor(MonitorFromWindow(windows[0].handle, MONITOR_DEFAULTTOPRIMARY)); +int iron_window_display() { + return iron_windows_get_display_for_monitor(MonitorFromWindow(windows[0].handle, MONITOR_DEFAULTTOPRIMARY)); } -struct HWND__ *kinc_windows_window_handle() { +struct HWND__ *iron_windows_window_handle() { return windows[0].handle; } -void kinc_internal_call_resize_callback(int width, int height) { +void iron_internal_call_resize_callback(int width, int height) { if (windows[0].resizeCallback != NULL) { windows[0].resizeCallback(width, height, windows[0].resizeCallbackData); } } -bool kinc_internal_call_close_callback() { +bool iron_internal_call_close_callback() { if (windows[0].closeCallback != NULL) { return windows[0].closeCallback(windows[0].closeCallbackData); } diff --git a/base/sources/backends/windows_system.h b/base/sources/backends/windows_system.h index d6af44a7..7c1ab131 100644 --- a/base/sources/backends/windows_system.h +++ b/base/sources/backends/windows_system.h @@ -7,14 +7,14 @@ typedef long HRESULT; struct HMONITOR__; struct HWND__; -void kinc_microsoft_affirm(HRESULT result); -void kinc_microsoft_affirm_message(HRESULT result, const char *format, ...); -void kinc_microsoft_format(const char *format, va_list args, wchar_t *buffer); +void iron_microsoft_affirm(HRESULT result); +void iron_microsoft_affirm_message(HRESULT result, const char *format, ...); +void iron_microsoft_format(const char *format, va_list args, wchar_t *buffer); -int kinc_windows_get_display_for_monitor(struct HMONITOR__ *monitor); -bool kinc_windows_set_display_mode(int display_index, int width, int height, int bpp, int frequency); -void kinc_windows_restore_display(int display_index); -void kinc_windows_restore_displays(); -void kinc_windows_hide_windows(); -void kinc_windows_destroy_windows(); -struct HWND__ *kinc_windows_window_handle(); +int iron_windows_get_display_for_monitor(struct HMONITOR__ *monitor); +bool iron_windows_set_display_mode(int display_index, int width, int height, int bpp, int frequency); +void iron_windows_restore_display(int display_index); +void iron_windows_restore_displays(); +void iron_windows_hide_windows(); +void iron_windows_destroy_windows(); +struct HWND__ *iron_windows_window_handle(); diff --git a/base/sources/backends/windows_thread.c b/base/sources/backends/windows_thread.c index f3d14450..b187bf9e 100644 --- a/base/sources/backends/windows_thread.c +++ b/base/sources/backends/windows_thread.c @@ -1,9 +1,9 @@ #include #include -void kinc_threads_init() {} +void iron_threads_init() {} -void kinc_threads_quit() {} +void iron_threads_quit() {} struct thread_start { void (*thread)(void *param); @@ -20,7 +20,7 @@ static DWORD WINAPI ThreadProc(LPVOID arg) { return 0; } -void kinc_thread_init(kinc_thread_t *thread, void (*func)(void *param), void *param) { +void iron_thread_init(iron_thread_t *thread, void (*func)(void *param), void *param) { thread->impl.func = func; thread->impl.param = param; @@ -33,12 +33,12 @@ void kinc_thread_init(kinc_thread_t *thread, void (*func)(void *param), void *pa thread->impl.handle = CreateThread(0, 65536, ThreadProc, (LPVOID)start_index, 0, 0); } -void kinc_thread_wait_and_destroy(kinc_thread_t *thread) { +void iron_thread_wait_and_destroy(iron_thread_t *thread) { WaitForSingleObject(thread->impl.handle, INFINITE); CloseHandle(thread->impl.handle); } -bool kinc_thread_try_to_destroy(kinc_thread_t *thread) { +bool iron_thread_try_to_destroy(iron_thread_t *thread) { DWORD code; GetExitCodeThread(thread->impl.handle, &code); if (code != STILL_ACTIVE) { @@ -52,7 +52,7 @@ typedef HRESULT(WINAPI *SetThreadDescriptionType)(HANDLE hThread, PCWSTR lpThrea static SetThreadDescriptionType MySetThreadDescription = NULL; static bool set_thread_description_loaded = false; -void kinc_thread_set_name(const char *name) { +void iron_thread_set_name(const char *name) { if (!set_thread_description_loaded) { HMODULE kernel32 = LoadLibraryA("kernel32.dll"); MySetThreadDescription = (SetThreadDescriptionType)GetProcAddress(kernel32, "SetThreadDescription"); @@ -66,26 +66,26 @@ void kinc_thread_set_name(const char *name) { } } -void kinc_thread_sleep(int milliseconds) { +void iron_thread_sleep(int milliseconds) { Sleep(milliseconds); } -void kinc_mutex_init(kinc_mutex_t *mutex) { +void iron_mutex_init(iron_mutex_t *mutex) { InitializeCriticalSection((LPCRITICAL_SECTION)&mutex->impl.criticalSection); } -void kinc_mutex_destroy(kinc_mutex_t *mutex) { +void iron_mutex_destroy(iron_mutex_t *mutex) { DeleteCriticalSection((LPCRITICAL_SECTION)&mutex->impl.criticalSection); } -void kinc_mutex_lock(kinc_mutex_t *mutex) { +void iron_mutex_lock(iron_mutex_t *mutex) { EnterCriticalSection((LPCRITICAL_SECTION)&mutex->impl.criticalSection); } -bool kinc_mutex_try_to_lock(kinc_mutex_t *mutex) { +bool iron_mutex_try_to_lock(iron_mutex_t *mutex) { return TryEnterCriticalSection((LPCRITICAL_SECTION)&mutex->impl.criticalSection); } -void kinc_mutex_unlock(kinc_mutex_t *mutex) { +void iron_mutex_unlock(iron_mutex_t *mutex) { LeaveCriticalSection((LPCRITICAL_SECTION)&mutex->impl.criticalSection); } diff --git a/base/sources/backends/windows_thread.h b/base/sources/backends/windows_thread.h index 3b7b5129..beed6460 100644 --- a/base/sources/backends/windows_thread.h +++ b/base/sources/backends/windows_thread.h @@ -6,7 +6,7 @@ typedef struct { void *handle; void *param; void (*func)(void *param); -} kinc_thread_impl_t; +} iron_thread_impl_t; typedef struct { void *DebugInfo; @@ -15,50 +15,50 @@ typedef struct { void *OwningThread; void *LockSemaphore; unsigned long __w64 SpinCount; -} kinc_microsoft_critical_section_t; +} iron_microsoft_critical_section_t; typedef struct { - kinc_microsoft_critical_section_t criticalSection; -} kinc_mutex_impl_t; + iron_microsoft_critical_section_t criticalSection; +} iron_mutex_impl_t; -static inline bool kinc_atomic_compare_exchange(volatile int32_t *pointer, int32_t old_value, int32_t new_value) { +static inline bool iron_atomic_compare_exchange(volatile int32_t *pointer, int32_t old_value, int32_t new_value) { return _InterlockedCompareExchange((volatile long *)pointer, new_value, old_value) == old_value; } -#define KINC_ATOMIC_COMPARE_EXCHANGE(pointer, oldValue, newValue) (kinc_atomic_compare_exchange(pointer, oldValue, newValue)) +#define IRON_ATOMIC_COMPARE_EXCHANGE(pointer, oldValue, newValue) (iron_atomic_compare_exchange(pointer, oldValue, newValue)) -static inline bool kinc_atomic_compare_exchange_pointer(void *volatile *pointer, void *old_value, void *new_value) { +static inline bool iron_atomic_compare_exchange_pointer(void *volatile *pointer, void *old_value, void *new_value) { return _InterlockedCompareExchangePointer(pointer, new_value, old_value) == old_value; } -#define KINC_ATOMIC_COMPARE_EXCHANGE_POINTER(pointer, oldValue, newValue) (kinc_atomic_compare_exchange_pointer(pointer, oldValue, newValue)) +#define IRON_ATOMIC_COMPARE_EXCHANGE_POINTER(pointer, oldValue, newValue) (iron_atomic_compare_exchange_pointer(pointer, oldValue, newValue)) -static inline int32_t kinc_atomic_increment(volatile int32_t *pointer) { +static inline int32_t iron_atomic_increment(volatile int32_t *pointer) { return _InterlockedIncrement((volatile long *)pointer) - 1; } -#define KINC_ATOMIC_INCREMENT(pointer) (kinc_atomic_increment(pointer)) +#define IRON_ATOMIC_INCREMENT(pointer) (iron_atomic_increment(pointer)) -static inline int32_t kinc_atomic_decrement(volatile int32_t *pointer) { +static inline int32_t iron_atomic_decrement(volatile int32_t *pointer) { return _InterlockedDecrement((volatile long *)pointer) + 1; } -#define KINC_ATOMIC_DECREMENT(pointer) (kinc_atomic_decrement(pointer)) +#define IRON_ATOMIC_DECREMENT(pointer) (iron_atomic_decrement(pointer)) -static inline void kinc_atomic_exchange(volatile int32_t *pointer, int32_t value) { +static inline void iron_atomic_exchange(volatile int32_t *pointer, int32_t value) { _InterlockedExchange((volatile long *)pointer, value); } -#define KINC_ATOMIC_EXCHANGE_32(pointer, value) (kinc_atomic_exchange(pointer, value)) +#define IRON_ATOMIC_EXCHANGE_32(pointer, value) (iron_atomic_exchange(pointer, value)) -static inline void kinc_atomic_exchange_float(volatile float *pointer, float value) { +static inline void iron_atomic_exchange_float(volatile float *pointer, float value) { _InterlockedExchange((volatile long *)pointer, *(long *)&value); } -#define KINC_ATOMIC_EXCHANGE_FLOAT(pointer, value) (kinc_atomic_exchange_float(pointer, value)) +#define IRON_ATOMIC_EXCHANGE_FLOAT(pointer, value) (iron_atomic_exchange_float(pointer, value)) -static inline void kinc_atomic_exchange_double(volatile double *pointer, double value) { +static inline void iron_atomic_exchange_double(volatile double *pointer, double value) { _InterlockedExchange64((volatile __int64 *)pointer, *(__int64 *)&value); } -#define KINC_ATOMIC_EXCHANGE_DOUBLE(pointer, value) (kinc_atomic_exchange_double(pointer, value)) +#define IRON_ATOMIC_EXCHANGE_DOUBLE(pointer, value) (iron_atomic_exchange_double(pointer, value)) diff --git a/base/sources/backends/windows_video.c b/base/sources/backends/windows_video.c index 5bf822ff..eb2f2e40 100644 --- a/base/sources/backends/windows_video.c +++ b/base/sources/backends/windows_video.c @@ -1,59 +1,59 @@ // #include -// void kinc_video_init(kinc_video_t *video, const char *filename) {} +// void iron_video_init(iron_video_t *video, const char *filename) {} -// void kinc_video_destroy(kinc_video_t *video) {} +// void iron_video_destroy(iron_video_t *video) {} -// kinc_g5_texture_t *kinc_video_current_image(kinc_video_t *video) { +// iron_g5_texture_t *iron_video_current_image(iron_video_t *video) { // return NULL; // } -// int kinc_video_width(kinc_video_t *video) { +// int iron_video_width(iron_video_t *video) { // return 64; // } -// int kinc_video_height(kinc_video_t *video) { +// int iron_video_height(iron_video_t *video) { // return 64; // } -// void kinc_video_play(kinc_video_t *video, bool loop) {} +// void iron_video_play(iron_video_t *video, bool loop) {} -// void kinc_video_pause(kinc_video_t *video) {} +// void iron_video_pause(iron_video_t *video) {} -// void kinc_video_stop(kinc_video_t *video) {} +// void iron_video_stop(iron_video_t *video) {} -// void kinc_video_update(kinc_video_t *video, double time) {} +// void iron_video_update(iron_video_t *video, double time) {} -// double kinc_video_duration(kinc_video_t *video) { +// double iron_video_duration(iron_video_t *video) { // return 0.0; // } -// double kinc_video_position(kinc_video_t *video) { +// double iron_video_position(iron_video_t *video) { // return 0.0; // } -// bool kinc_video_finished(kinc_video_t *video) { +// bool iron_video_finished(iron_video_t *video) { // return true; // } -// bool kinc_video_paused(kinc_video_t *video) { +// bool iron_video_paused(iron_video_t *video) { // return true; // } -// void kinc_internal_video_sound_stream_init(kinc_internal_video_sound_stream_t *stream, int channel_count, int frequency) {} +// void iron_internal_video_sound_stream_init(iron_internal_video_sound_stream_t *stream, int channel_count, int frequency) {} -// void kinc_internal_video_sound_stream_destroy(kinc_internal_video_sound_stream_t *stream) {} +// void iron_internal_video_sound_stream_destroy(iron_internal_video_sound_stream_t *stream) {} -// void kinc_internal_video_sound_stream_insert_data(kinc_internal_video_sound_stream_t *stream, float *data, int sample_count) {} +// void iron_internal_video_sound_stream_insert_data(iron_internal_video_sound_stream_t *stream, float *data, int sample_count) {} // static float samples[2]; -// float *kinc_internal_video_sound_stream_next_frame(kinc_internal_video_sound_stream_t *stream) { +// float *iron_internal_video_sound_stream_next_frame(iron_internal_video_sound_stream_t *stream) { // samples[0] = 0.0f; // samples[1] = 0.0f; // return samples; // } -// bool kinc_internal_video_sound_stream_ended(kinc_internal_video_sound_stream_t *stream) { +// bool iron_internal_video_sound_stream_ended(iron_internal_video_sound_stream_t *stream) { // return true; // } diff --git a/base/sources/backends/windows_video.h b/base/sources/backends/windows_video.h index 123c062a..4dc57bbd 100644 --- a/base/sources/backends/windows_video.h +++ b/base/sources/backends/windows_video.h @@ -6,18 +6,18 @@ // double position; // bool finished; // bool paused; -// } kinc_video_impl_t; +// } iron_video_impl_t; -// typedef struct kinc_internal_video_sound_stream { +// typedef struct iron_internal_video_sound_stream { // int nothing; -// } kinc_internal_video_sound_stream_t; +// } iron_internal_video_sound_stream_t; -// void kinc_internal_video_sound_stream_init(kinc_internal_video_sound_stream_t *stream, int channel_count, int frequency); +// void iron_internal_video_sound_stream_init(iron_internal_video_sound_stream_t *stream, int channel_count, int frequency); -// void kinc_internal_video_sound_stream_destroy(kinc_internal_video_sound_stream_t *stream); +// void iron_internal_video_sound_stream_destroy(iron_internal_video_sound_stream_t *stream); -// void kinc_internal_video_sound_stream_insert_data(kinc_internal_video_sound_stream_t *stream, float *data, int sample_count); +// void iron_internal_video_sound_stream_insert_data(iron_internal_video_sound_stream_t *stream, float *data, int sample_count); -// float *kinc_internal_video_sound_stream_next_frame(kinc_internal_video_sound_stream_t *stream); +// float *iron_internal_video_sound_stream_next_frame(iron_internal_video_sound_stream_t *stream); -// bool kinc_internal_video_sound_stream_ended(kinc_internal_video_sound_stream_t *stream); +// bool iron_internal_video_sound_stream_ended(iron_internal_video_sound_stream_t *stream); diff --git a/base/sources/iron.h b/base/sources/iron.h index 70ffb93b..49237250 100644 --- a/base/sources/iron.h +++ b/base/sources/iron.h @@ -26,7 +26,7 @@ #include "iron_ui.h" #include "iron_ui_nodes.h" #include "iron_draw.h" -#ifdef KINC_WINDOWS +#ifdef IRON_WINDOWS #include #endif #ifdef WITH_AUDIO @@ -37,9 +37,9 @@ #endif #ifdef WITH_ONNX #include -#ifdef KINC_WINDOWS +#ifdef IRON_WINDOWS #include -#elif defined(KINC_MACOS) +#elif defined(IRON_MACOS) #include #endif const OrtApi *ort = NULL; @@ -130,7 +130,7 @@ char *js_call(void *p) { #ifdef WITH_EMBED buffer_t *embed_get(char *key) { - #ifdef KINC_WINDOWS + #ifdef IRON_WINDOWS key = string_replace_all(key, "\\", "/"); #endif for (int i = 0; i < embed_count; ++i) { @@ -196,9 +196,9 @@ int last_window_height = 0; char temp_string[1024 * 32]; char temp_string_vs[1024 * 128]; char temp_string_fs[1024 * 128]; -#ifdef KINC_WINDOWS +#ifdef IRON_WINDOWS wchar_t temp_wstring[1024 * 32]; -struct HWND__ *kinc_windows_window_handle(); +struct HWND__ *iron_windows_window_handle(); #endif void (*iron_update)(void); @@ -240,15 +240,15 @@ char *_substring(char *s, int32_t start, int32_t end) { int kickstart(int argc, char **argv) { _argc = argc; _argv = argv; -#ifdef KINC_ANDROID +#ifdef IRON_ANDROID char *bindir = "/"; -#elif defined(KINC_IOS) +#elif defined(IRON_IOS) char *bindir = ""; #else char *bindir = argv[0]; #endif -#ifdef KINC_WINDOWS // Handle non-ascii path +#ifdef IRON_WINDOWS // Handle non-ascii path HMODULE hmodule = GetModuleHandleW(NULL); GetModuleFileNameW(hmodule, temp_wstring, 1024); WideCharToMultiByte(CP_UTF8, 0, temp_wstring, -1, temp_string, 4096, NULL, NULL); @@ -273,18 +273,18 @@ int kickstart(int argc, char **argv) { } } -#if !defined(KINC_MACOS) && !defined(KINC_IOS) - kinc_internal_set_files_location(assetsdir); +#if !defined(IRON_MACOS) && !defined(IRON_IOS) + iron_internal_set_files_location(assetsdir); #endif - kinc_threads_init(); - kinc_display_init(); + iron_threads_init(); + iron_display_init(); gc_start(&argc); _kickstart(); #ifdef WITH_AUDIO - kinc_a2_shutdown(); + iron_a2_shutdown(); #endif #ifdef WITH_ONNX if (ort != NULL) { @@ -323,7 +323,7 @@ string_t *iron_get_arg(i32 index) { #endif #define STB_IMAGE_IMPLEMENTATION #include -#ifdef KINC_DIRECT3D12 +#ifdef IRON_DIRECT3D12 #include extern bool waitAfterNextDraw; #endif @@ -333,10 +333,10 @@ extern bool waitAfterNextDraw; #endif #ifdef WITH_NFD #include -#elif defined(KINC_ANDROID) +#elif defined(IRON_ANDROID) #include "android_file_dialog.h" #include "android_http_request.h" -#elif defined(KINC_IOS) +#elif defined(IRON_IOS) #include #include #endif @@ -359,36 +359,36 @@ unsigned char *iron_deflate_raw(unsigned char *data, int data_len, int *out_len, #define SINFL_IMPLEMENTATION #include "sinfl.h" #endif -#if defined(IDLE_SLEEP) && !defined(KINC_WINDOWS) +#if defined(IDLE_SLEEP) && !defined(IRON_WINDOWS) #include #endif -#ifdef KINC_MACOS +#ifdef IRON_MACOS const char *macgetresourcepath(); #endif -#ifdef KINC_IOS +#ifdef IRON_IOS const char *iphonegetresourcepath(); #endif -#if defined(KINC_IOS) || defined(KINC_ANDROID) +#if defined(IRON_IOS) || defined(IRON_ANDROID) char mobile_title[1024]; #endif -#if defined(KINC_VULKAN) && defined(KRAFIX_LIBRARY) +#if defined(IRON_VULKAN) && defined(KRAFIX_LIBRARY) int krafix_compile(const char *source, char *output, int *length, const char *targetlang, const char *system, const char *shadertype, int version); #endif -extern kinc_g5_command_list_t commandList; -static kinc_g5_constant_buffer_t constant_buffer; -static kinc_g5_texture_t *render_target; -static kinc_g5_raytrace_pipeline_t rt_pipeline; -static kinc_g5_raytrace_acceleration_structure_t accel; +extern iron_g5_command_list_t commandList; +static iron_g5_constant_buffer_t constant_buffer; +static iron_g5_texture_t *render_target; +static iron_g5_raytrace_pipeline_t rt_pipeline; +static iron_g5_raytrace_acceleration_structure_t accel; static bool raytrace_created = false; static bool raytrace_accel_created = false; const int constant_buffer_size = 24; void _update(void *data) { - #ifdef KINC_WINDOWS + #ifdef IRON_WINDOWS if (in_background && ++paused_frames > 3) { Sleep(1); return; @@ -396,18 +396,18 @@ void _update(void *data) { #endif #ifdef IDLE_SLEEP - if (last_window_width != kinc_window_width() || last_window_height != kinc_window_height()) { - last_window_width = kinc_window_width(); - last_window_height = kinc_window_height(); + if (last_window_width != iron_window_width() || last_window_height != iron_window_height()) { + last_window_width = iron_window_width(); + last_window_height = iron_window_height(); paused_frames = 0; } - #if defined(KINC_IOS) || defined(KINC_ANDROID) + #if defined(IRON_IOS) || defined(IRON_ANDROID) const int start_sleep = 1200; #else const int start_sleep = 120; #endif if (++paused_frames > start_sleep && !input_down) { - #ifdef KINC_WINDOWS + #ifdef IRON_WINDOWS Sleep(1); #else usleep(1000); @@ -420,13 +420,13 @@ void _update(void *data) { #endif #ifdef WITH_AUDIO - kinc_a2_update(); + iron_a2_update(); #endif - kinc_g4_begin(); + iron_g4_begin(); iron_update(); - kinc_g4_end(); - kinc_g5_swap_buffers(); + iron_g4_end(); + iron_g5_swap_buffers(); } char *_copy(void *data) { @@ -557,7 +557,7 @@ void _mouse_wheel(int delta, void *data) { void _touch_move(int index, int x, int y) { iron_touch_move(index, x, y); - #if defined(KINC_ANDROID) || defined(KINC_IOS) + #if defined(IRON_ANDROID) || defined(IRON_IOS) for (int i = 0; i < ui_instances_count; ++i) { ui_touch_move(ui_instances[i], index, x, y); } @@ -571,7 +571,7 @@ void _touch_move(int index, int x, int y) { void _touch_down(int index, int x, int y) { iron_touch_down(index, x, y); - #if defined(KINC_ANDROID) || defined(KINC_IOS) + #if defined(IRON_ANDROID) || defined(IRON_IOS) for (int i = 0; i < ui_instances_count; ++i) { ui_touch_down(ui_instances[i], index, x, y); } @@ -586,7 +586,7 @@ void _touch_down(int index, int x, int y) { void _touch_up(int index, int x, int y) { iron_touch_up(index, x, y); - #if defined(KINC_ANDROID) || defined(KINC_IOS) + #if defined(IRON_ANDROID) || defined(IRON_IOS) for (int i = 0; i < ui_instances_count; ++i) { ui_touch_up(ui_instances[i], index, x, y); } @@ -654,16 +654,16 @@ void _gamepad_button(int gamepad, int button, float value, void *data) { void _drop_files(wchar_t *file_path, void *data) { // Update mouse position -#ifdef KINC_WINDOWS +#ifdef IRON_WINDOWS POINT p; GetCursorPos(&p); - ScreenToClient(kinc_windows_window_handle(), &p); + ScreenToClient(iron_windows_window_handle(), &p); _mouse_move(p.x, p.y, 0, 0, NULL); #endif char buffer[1024]; -#ifdef KINC_WINDOWS +#ifdef IRON_WINDOWS WideCharToMultiByte(CP_UTF8, 0, file_path, wcslen(file_path), buffer, sizeof(buffer), NULL, NULL); #else wcstombs(buffer, file_path, sizeof(buffer)); @@ -783,56 +783,56 @@ i32 color_set_ab(i32 c, u8 i) { return (i << 24) | (color_get_rb(c) << 16) | (color_get_gb(c) << 8) | color_get_bb(c); } -void iron_init(kinc_window_options_t *ops) { +void _iron_init(iron_window_options_t *ops) { ops->display_index = -1; ops->visible = enable_window; ops->color_bits = 32; ops->depth_bits = ops->use_depth ? 24 : 0; - kinc_init(ops->title, ops->width, ops->height, ops); - kinc_random_init((int)(kinc_time() * 1000)); + iron_init(ops->title, ops->width, ops->height, ops); + iron_random_init((int)(iron_time() * 1000)); - #ifdef KINC_WINDOWS - // Maximized window has x < -1, prevent window centering done by kinc + #ifdef IRON_WINDOWS + // Maximized window has x < -1, prevent window centering if (ops->x < -1 && ops->y < -1) { - kinc_window_move(ops->x, ops->y); + iron_window_move(ops->x, ops->y); } #endif #ifdef WITH_AUDIO - kinc_a1_init(); - kinc_a2_init(); + iron_a1_init(); + iron_a2_init(); #endif - #ifdef KINC_ANDROID + #ifdef IRON_ANDROID android_check_permissions(); #endif } -void iron_set_update_callback(void (*callback)(void)) { +void _iron_set_update_callback(void (*callback)(void)) { iron_update = callback; - kinc_set_update_callback(_update, NULL); + iron_set_update_callback(_update, NULL); } -void iron_set_drop_files_callback(void (*callback)(char *)) { +void _iron_set_drop_files_callback(void (*callback)(char *)) { iron_drop_files = callback; - kinc_set_drop_files_callback(_drop_files, NULL); + iron_set_drop_files_callback(_drop_files, NULL); } void iron_set_cut_copy_paste_callback(char *(*on_cut)(void *), char *(*on_copy)(void *), void (*on_paste)(char *, void *)) { - kinc_set_cut_callback(_cut, NULL); - kinc_set_copy_callback(_copy, NULL); - kinc_set_paste_callback(_paste, NULL); + iron_set_cut_callback(_cut, NULL); + iron_set_copy_callback(_copy, NULL); + iron_set_paste_callback(_paste, NULL); iron_cut = on_cut; iron_copy = on_copy; iron_paste = on_paste; } void iron_set_application_state_callback(void (*on_foreground)(void), void (*on_resume)(void), void (*on_pause)(void), void (*on_background)(void), void (*on_shutdown)(void)) { - kinc_set_foreground_callback(on_foreground != NULL ? _foreground : NULL, NULL); - kinc_set_resume_callback(on_resume != NULL ? _resume : NULL, NULL); - kinc_set_pause_callback(on_pause != NULL ? _pause : NULL, NULL); - kinc_set_background_callback(on_background != NULL ? _background : NULL, NULL); - kinc_set_shutdown_callback(on_shutdown != NULL ? _shutdown : NULL, NULL); + iron_set_foreground_callback(on_foreground != NULL ? _foreground : NULL, NULL); + iron_set_resume_callback(on_resume != NULL ? _resume : NULL, NULL); + iron_set_pause_callback(on_pause != NULL ? _pause : NULL, NULL); + iron_set_background_callback(on_background != NULL ? _background : NULL, NULL); + iron_set_shutdown_callback(on_shutdown != NULL ? _shutdown : NULL, NULL); iron_foreground = on_foreground; iron_resume = on_resume; iron_pause = on_pause; @@ -842,147 +842,147 @@ void iron_set_application_state_callback(void (*on_foreground)(void), void (*on_ void iron_set_keyboard_down_callback(void (*callback)(int)) { iron_key_down = callback; - kinc_keyboard_set_key_down_callback(_key_down, NULL); + iron_keyboard_set_key_down_callback(_key_down, NULL); } void iron_set_keyboard_up_callback(void (*callback)(int)) { iron_key_up = callback; - kinc_keyboard_set_key_up_callback(_key_up, NULL); + iron_keyboard_set_key_up_callback(_key_up, NULL); } void iron_set_keyboard_press_callback(void (*callback)(int)) { iron_key_press = callback; - kinc_keyboard_set_key_press_callback(_key_press, NULL); + iron_keyboard_set_key_press_callback(_key_press, NULL); } void iron_set_mouse_down_callback(void (*callback)(int, int, int)) { iron_mouse_down = callback; - kinc_mouse_set_press_callback(_mouse_down, NULL); + iron_mouse_set_press_callback(_mouse_down, NULL); } void iron_set_mouse_up_callback(void (*callback)(int, int, int)) { iron_mouse_up = callback; - kinc_mouse_set_release_callback(_mouse_up, NULL); + iron_mouse_set_release_callback(_mouse_up, NULL); } void iron_set_mouse_move_callback(void (*callback)(int, int, int, int)) { iron_mouse_move = callback; - kinc_mouse_set_move_callback(_mouse_move, NULL); + iron_mouse_set_move_callback(_mouse_move, NULL); } void iron_set_mouse_wheel_callback(void (*callback)(int)) { iron_mouse_wheel = callback; - kinc_mouse_set_scroll_callback(_mouse_wheel, NULL); + iron_mouse_set_scroll_callback(_mouse_wheel, NULL); } void iron_set_touch_down_callback(void (*callback)(int, int, int)) { iron_touch_down = callback; - kinc_surface_set_touch_start_callback(_touch_down); + iron_surface_set_touch_start_callback(_touch_down); } void iron_set_touch_up_callback(void (*callback)(int, int, int)) { iron_touch_up = callback; - kinc_surface_set_touch_end_callback(_touch_up); + iron_surface_set_touch_end_callback(_touch_up); } void iron_set_touch_move_callback(void (*callback)(int, int, int)) { iron_touch_move = callback; - kinc_surface_set_move_callback(_touch_move); + iron_surface_set_move_callback(_touch_move); } void iron_set_pen_down_callback(void (*callback)(int, int, float)) { iron_pen_down = callback; - kinc_pen_set_press_callback(_pen_down); + iron_pen_set_press_callback(_pen_down); } void iron_set_pen_up_callback(void (*callback)(int, int, float)) { iron_pen_up = callback; - kinc_pen_set_release_callback(_pen_up); + iron_pen_set_release_callback(_pen_up); } void iron_set_pen_move_callback(void (*callback)(int, int, float)) { iron_pen_move = callback; - kinc_pen_set_move_callback(_pen_move); + iron_pen_set_move_callback(_pen_move); } void iron_set_gamepad_axis_callback(void (*callback)(int, int, float)) { iron_gamepad_axis = callback; - kinc_gamepad_set_axis_callback(_gamepad_axis, NULL); + iron_gamepad_set_axis_callback(_gamepad_axis, NULL); } void iron_set_gamepad_button_callback(void (*callback)(int, int, float)) { iron_gamepad_button = callback; - kinc_gamepad_set_button_callback(_gamepad_button, NULL); + iron_gamepad_set_button_callback(_gamepad_button, NULL); } void iron_show_mouse(bool show) { - show ? kinc_mouse_show() : kinc_mouse_hide(); + show ? iron_mouse_show() : iron_mouse_hide(); } void iron_show_keyboard(bool show) { - show ? kinc_keyboard_show() : kinc_keyboard_hide(); + show ? iron_keyboard_show() : iron_keyboard_hide(); } any iron_g4_create_index_buffer(i32 count) { - kinc_g5_index_buffer_t *buffer = (kinc_g5_index_buffer_t *)malloc(sizeof(kinc_g5_index_buffer_t)); - kinc_g5_index_buffer_init(buffer, count, KINC_G4_USAGE_STATIC); + iron_g5_index_buffer_t *buffer = (iron_g5_index_buffer_t *)malloc(sizeof(iron_g5_index_buffer_t)); + iron_g5_index_buffer_init(buffer, count, IRON_G4_USAGE_STATIC); return buffer; } -void iron_g4_delete_index_buffer(kinc_g5_index_buffer_t *buffer) { - kinc_g5_index_buffer_destroy(buffer); +void iron_g4_delete_index_buffer(iron_g5_index_buffer_t *buffer) { + iron_g5_index_buffer_destroy(buffer); free(buffer); } -u32_array_t *iron_g4_lock_index_buffer(kinc_g5_index_buffer_t *buffer) { - void *vertices = kinc_g5_index_buffer_lock_all(buffer); +u32_array_t *iron_g4_lock_index_buffer(iron_g5_index_buffer_t *buffer) { + void *vertices = iron_g5_index_buffer_lock_all(buffer); u32_array_t *ar = (u32_array_t *)malloc(sizeof(u32_array_t)); ar->buffer = vertices; - ar->length = kinc_g5_index_buffer_count(buffer); + ar->length = iron_g5_index_buffer_count(buffer); return ar; } -any iron_g4_create_vertex_buffer(i32 count, kinc_g5_vertex_structure_t *structure, i32 usage) { - kinc_g4_vertex_buffer_t *buffer = (kinc_g4_vertex_buffer_t *)malloc(sizeof(kinc_g4_vertex_buffer_t)); - kinc_g4_vertex_buffer_init(buffer, count, structure, (kinc_g4_usage_t)usage); +any iron_g4_create_vertex_buffer(i32 count, iron_g5_vertex_structure_t *structure, i32 usage) { + iron_g4_vertex_buffer_t *buffer = (iron_g4_vertex_buffer_t *)malloc(sizeof(iron_g4_vertex_buffer_t)); + iron_g4_vertex_buffer_init(buffer, count, structure, (iron_g4_usage_t)usage); return buffer; } -void iron_g4_delete_vertex_buffer(kinc_g4_vertex_buffer_t *buffer) { - kinc_g4_vertex_buffer_destroy(buffer); +void iron_g4_delete_vertex_buffer(iron_g4_vertex_buffer_t *buffer) { + iron_g4_vertex_buffer_destroy(buffer); free(buffer); } -buffer_t *iron_g4_lock_vertex_buffer(kinc_g4_vertex_buffer_t *buffer) { - float *vertices = kinc_g4_vertex_buffer_lock_all(buffer); +buffer_t *iron_g4_lock_vertex_buffer(iron_g4_vertex_buffer_t *buffer) { + float *vertices = iron_g4_vertex_buffer_lock_all(buffer); buffer_t *b = (buffer_t *)malloc(sizeof(buffer_t)); b->buffer = vertices; - b->length = kinc_g4_vertex_buffer_count(buffer) * kinc_g4_vertex_buffer_stride(buffer); + b->length = iron_g4_vertex_buffer_count(buffer) * iron_g4_vertex_buffer_stride(buffer); return b; } void iron_g4_draw_indexed_vertices(i32 start, i32 count) { - #ifdef KINC_DIRECT3D12 - // TODO: Prevent heapIndex overflow in g5_texture.c.h/kinc_g5_internal_set_textures + #ifdef IRON_DIRECT3D12 + // TODO: Prevent heapIndex overflow in g5_texture.c.h/iron_g5_internal_set_textures waitAfterNextDraw = true; #endif if (count < 0) { - kinc_g5_draw_indexed_vertices(); + iron_g5_draw_indexed_vertices(); } else { - kinc_g5_draw_indexed_vertices_from_to(start, count); + iron_g5_draw_indexed_vertices_from_to(start, count); } } -kinc_g5_shader_t *iron_g4_create_shader(buffer_t *data, i32 shader_type) { - kinc_g5_shader_t *shader = (kinc_g5_shader_t *)malloc(sizeof(kinc_g5_shader_t)); - kinc_g5_shader_init(shader, data->buffer, data->length, (kinc_g5_shader_type_t)shader_type); +iron_g5_shader_t *iron_g4_create_shader(buffer_t *data, i32 shader_type) { + iron_g5_shader_t *shader = (iron_g5_shader_t *)malloc(sizeof(iron_g5_shader_t)); + iron_g5_shader_init(shader, data->buffer, data->length, (iron_g5_shader_type_t)shader_type); return shader; } -kinc_g5_shader_t *iron_g4_create_shader_from_source(string_t *source, kinc_g5_shader_type_t shader_type) { - kinc_g5_shader_t *shader = NULL; - char *temp_string_s = shader_type == KINC_G5_SHADER_TYPE_VERTEX ? temp_string_vs : temp_string_fs; +iron_g5_shader_t *iron_g4_create_shader_from_source(string_t *source, iron_g5_shader_type_t shader_type) { + iron_g5_shader_t *shader = NULL; + char *temp_string_s = shader_type == IRON_G5_SHADER_TYPE_VERTEX ? temp_string_vs : temp_string_fs; #ifdef WITH_D3DCOMPILER @@ -992,9 +992,9 @@ kinc_g5_shader_t *iron_g4_create_shader_from_source(string_t *source, kinc_g5_sh ID3DBlob *shader_buffer; UINT flags = D3DCOMPILE_SKIP_OPTIMIZATION | D3DCOMPILE_SKIP_VALIDATION; HRESULT hr = D3DCompile(temp_string_s, strlen(source) + 1, NULL, NULL, NULL, "main", - shader_type == KINC_G5_SHADER_TYPE_VERTEX ? "vs_5_0" : "ps_5_0", flags, 0, &shader_buffer, &error_message); + shader_type == IRON_G5_SHADER_TYPE_VERTEX ? "vs_5_0" : "ps_5_0", flags, 0, &shader_buffer, &error_message); if (hr != S_OK) { - kinc_log("%s", (char *)error_message->lpVtbl->GetBufferPointer(error_message)); + iron_log("%s", (char *)error_message->lpVtbl->GetBufferPointer(error_message)); return NULL; } @@ -1005,7 +1005,7 @@ kinc_g5_shader_t *iron_g4_create_shader_from_source(string_t *source, kinc_g5_sh char *file = malloc(size * 2); int output_len = 0; - if (shader_type == KINC_G5_SHADER_TYPE_VERTEX) { + if (shader_type == IRON_G5_SHADER_TYPE_VERTEX) { bool has_bone = strstr(temp_string_s, " bone :") != NULL; bool has_col = strstr(temp_string_s, " col :") != NULL; bool has_nor = strstr(temp_string_s, " nor :") != NULL; @@ -1106,56 +1106,56 @@ kinc_g5_shader_t *iron_g4_create_shader_from_source(string_t *source, kinc_g5_sh shader_buffer->lpVtbl->Release(shader_buffer); reflector->lpVtbl->Release(reflector); - shader = (kinc_g5_shader_t *)malloc(sizeof(kinc_g5_shader_t)); - kinc_g5_shader_init(shader, file, (int)output_len, shader_type); + shader = (iron_g5_shader_t *)malloc(sizeof(iron_g5_shader_t)); + iron_g5_shader_init(shader, file, (int)output_len, shader_type); free(file); - #elif defined(KINC_METAL) + #elif defined(IRON_METAL) strcpy(temp_string_s, "// my_main\n"); strcat(temp_string_s, source); - shader = (kinc_g5_shader_t *)malloc(sizeof(kinc_g5_shader_t)); - kinc_g5_shader_init(shader, temp_string_s, strlen(temp_string_s), shader_type); + shader = (iron_g5_shader_t *)malloc(sizeof(iron_g5_shader_t)); + iron_g5_shader_init(shader, temp_string_s, strlen(temp_string_s), shader_type); - #elif defined(KINC_VULKAN) && defined(KRAFIX_LIBRARY) + #elif defined(IRON_VULKAN) && defined(KRAFIX_LIBRARY) char *output = malloc(1024 * 1024); int length; - krafix_compile(source, output, &length, "spirv", "windows", shader_type == KINC_G5_SHADER_TYPE_VERTEX ? "vert" : "frag", -1); - shader = (kinc_g5_shader_t *)malloc(sizeof(kinc_g5_shader_t)); - kinc_g5_shader_init(shader, output, length, shader_type); + krafix_compile(source, output, &length, "spirv", "windows", shader_type == IRON_G5_SHADER_TYPE_VERTEX ? "vert" : "frag", -1); + shader = (iron_g5_shader_t *)malloc(sizeof(iron_g5_shader_t)); + iron_g5_shader_init(shader, output, length, shader_type); #endif return shader; } -kinc_g5_pipeline_t *iron_g4_create_pipeline() { - kinc_g5_pipeline_t *pipeline = (kinc_g5_pipeline_t *)malloc(sizeof(kinc_g5_pipeline_t)); - kinc_g5_pipeline_init(pipeline); +iron_g5_pipeline_t *iron_g4_create_pipeline() { + iron_g5_pipeline_t *pipeline = (iron_g5_pipeline_t *)malloc(sizeof(iron_g5_pipeline_t)); + iron_g5_pipeline_init(pipeline); return pipeline; } -void iron_g4_delete_pipeline(kinc_g5_pipeline_t *pipeline) { - kinc_g5_pipeline_destroy(pipeline); +void iron_g4_delete_pipeline(iron_g5_pipeline_t *pipeline) { + iron_g5_pipeline_destroy(pipeline); free(pipeline); } -void iron_g4_compile_pipeline(kinc_g5_pipeline_t *pipeline) { - kinc_g5_pipeline_compile(pipeline); +void iron_g4_compile_pipeline(iron_g5_pipeline_t *pipeline) { + iron_g5_pipeline_compile(pipeline); } -bool _load_image(kinc_file_reader_t *reader, const char *filename, unsigned char **output, int *width, int *height, kinc_image_format_t *format) { - *format = KINC_IMAGE_FORMAT_RGBA32; - int size = (int)kinc_file_reader_size(reader); +bool _load_image(iron_file_reader_t *reader, const char *filename, unsigned char **output, int *width, int *height, iron_image_format_t *format) { + *format = IRON_IMAGE_FORMAT_RGBA32; + int size = (int)iron_file_reader_size(reader); bool success = true; unsigned char *data = (unsigned char *)malloc(size); - kinc_file_reader_read(reader, data, size); - kinc_file_reader_close(reader); + iron_file_reader_read(reader, data, size); + iron_file_reader_close(reader); if (ends_with(filename, "k")) { - *width = kinc_read_s32le(data); - *height = kinc_read_s32le(data + 4); + *width = iron_read_s32le(data); + *height = iron_read_s32le(data + 4); char fourcc[5]; fourcc[0] = data[8]; fourcc[1] = data[9]; @@ -1172,9 +1172,9 @@ bool _load_image(kinc_file_reader_t *reader, const char *filename, unsigned char int output_size = *width * *height * 16; *output = (unsigned char *)malloc(output_size); LZ4_decompress_safe((char *)(data + 12), (char *)*output, compressed_size, output_size); - *format = KINC_IMAGE_FORMAT_RGBA128; + *format = IRON_IMAGE_FORMAT_RGBA128; - #ifdef KINC_IOS // No RGBA128 filtering, convert to RGBA64 + #ifdef IRON_IOS // No RGBA128 filtering, convert to RGBA64 uint32_t *_output32 = (uint32_t *)*output; unsigned char *_output = (unsigned char *)malloc(output_size / 2); uint16_t *_output16 = (uint16_t *)_output; @@ -1182,7 +1182,7 @@ bool _load_image(kinc_file_reader_t *reader, const char *filename, unsigned char uint32_t x = *((uint32_t *)&_output32[i]); _output16[i] = ((x >> 16) & 0x8000) | ((((x & 0x7f800000) - 0x38000000) >> 13) & 0x7c00) | ((x >> 13) & 0x03ff); } - *format = KINC_IMAGE_FORMAT_RGBA64; + *format = IRON_IMAGE_FORMAT_RGBA64; free(*output); *output = _output; #endif @@ -1195,16 +1195,16 @@ bool _load_image(kinc_file_reader_t *reader, const char *filename, unsigned char int comp; *output = (unsigned char *)stbi_loadf_from_memory(data, size, width, height, &comp, 4); if (*output == NULL) { - kinc_error(stbi_failure_reason()); + iron_error(stbi_failure_reason()); success = false; } - *format = KINC_IMAGE_FORMAT_RGBA128; + *format = IRON_IMAGE_FORMAT_RGBA128; } else { // jpg, png, .. int comp; *output = stbi_load_from_memory(data, size, width, height, &comp, 4); if (*output == NULL) { - kinc_error(stbi_failure_reason()); + iron_error(stbi_failure_reason()); success = false; } } @@ -1212,32 +1212,32 @@ bool _load_image(kinc_file_reader_t *reader, const char *filename, unsigned char return success; } -kinc_g5_texture_t *iron_g4_create_texture_from_encoded_bytes(buffer_t *data, string_t *format, bool readable); +iron_g5_texture_t *iron_g4_create_texture_from_encoded_bytes(buffer_t *data, string_t *format, bool readable); -kinc_g5_texture_t *iron_load_image(string_t *file, bool readable) { +iron_g5_texture_t *iron_load_image(string_t *file, bool readable) { #ifdef WITH_EMBED buffer_t *b = embed_get(file); if (b != NULL) { - kinc_g5_texture_t *texture = iron_g4_create_texture_from_encoded_bytes(b, ".k", readable); + iron_g5_texture_t *texture = iron_g4_create_texture_from_encoded_bytes(b, ".k", readable); return texture; } #endif - kinc_file_reader_t reader; - if (!kinc_file_reader_open(&reader, file, KINC_FILE_TYPE_ASSET)) { + iron_file_reader_t reader; + if (!iron_file_reader_open(&reader, file, IRON_FILE_TYPE_ASSET)) { return NULL; } unsigned char *image_data; int image_width; int image_height; - kinc_image_format_t image_format; + iron_image_format_t image_format; if (!_load_image(&reader, file, &image_data, &image_width, &image_height, &image_format)) { return NULL; } - kinc_g5_texture_t *texture = (kinc_g5_texture_t *)malloc(sizeof(kinc_g5_texture_t)); - kinc_g5_texture_init_from_bytes(texture, image_data, image_width, image_height, image_format); + iron_g5_texture_t *texture = (iron_g5_texture_t *)malloc(sizeof(iron_g5_texture_t)); + iron_g5_texture_init_from_bytes(texture, image_data, image_width, image_height, image_format); if (!readable) { free(image_data); } @@ -1245,9 +1245,9 @@ kinc_g5_texture_t *iron_load_image(string_t *file, bool readable) { return texture; } -void iron_unload_image(kinc_g5_texture_t *image) { +void iron_unload_image(iron_g5_texture_t *image) { if (image != NULL) { - kinc_g5_texture_destroy(image); + iron_g5_texture_destroy(image); // free(image); } } @@ -1255,7 +1255,7 @@ void iron_unload_image(kinc_g5_texture_t *image) { #ifdef WITH_AUDIO any iron_load_sound(string_t *file) { - kinc_a1_sound_t *sound = kinc_a1_sound_create(file); + iron_a1_sound_t *sound = iron_a1_sound_create(file); return sound; } @@ -1269,131 +1269,131 @@ buffer_t *iron_load_blob(string_t *file) { } #endif - kinc_file_reader_t reader; - if (!kinc_file_reader_open(&reader, file, KINC_FILE_TYPE_ASSET)) { + iron_file_reader_t reader; + if (!iron_file_reader_open(&reader, file, IRON_FILE_TYPE_ASSET)) { return NULL; } - uint32_t reader_size = (uint32_t)kinc_file_reader_size(&reader); + uint32_t reader_size = (uint32_t)iron_file_reader_size(&reader); buffer_t *buffer = buffer_create(reader_size); - kinc_file_reader_read(&reader, buffer->buffer, reader_size); - kinc_file_reader_close(&reader); + iron_file_reader_read(&reader, buffer->buffer, reader_size); + iron_file_reader_close(&reader); return buffer; } -kinc_g5_constant_location_t *iron_g4_get_constant_location(kinc_g5_pipeline_t *pipeline, string_t *name) { - kinc_g5_constant_location_t location = kinc_g5_pipeline_get_constant_location(pipeline, name); - kinc_g5_constant_location_t *location_copy = (kinc_g5_constant_location_t *)malloc(sizeof(kinc_g5_constant_location_t)); - memcpy(location_copy, &location, sizeof(kinc_g5_constant_location_t)); // TODO +iron_g5_constant_location_t *iron_g4_get_constant_location(iron_g5_pipeline_t *pipeline, string_t *name) { + iron_g5_constant_location_t location = iron_g5_pipeline_get_constant_location(pipeline, name); + iron_g5_constant_location_t *location_copy = (iron_g5_constant_location_t *)malloc(sizeof(iron_g5_constant_location_t)); + memcpy(location_copy, &location, sizeof(iron_g5_constant_location_t)); // TODO return location_copy; } -kinc_g5_texture_unit_t *iron_g4_get_texture_unit(kinc_g5_pipeline_t *pipeline, string_t *name) { - kinc_g5_texture_unit_t unit = kinc_g5_pipeline_get_texture_unit(pipeline, name); - kinc_g5_texture_unit_t *unit_copy = (kinc_g5_texture_unit_t *)malloc(sizeof(kinc_g5_texture_unit_t)); - memcpy(unit_copy, &unit, sizeof(kinc_g5_texture_unit_t)); // TODO +iron_g5_texture_unit_t *iron_g4_get_texture_unit(iron_g5_pipeline_t *pipeline, string_t *name) { + iron_g5_texture_unit_t unit = iron_g5_pipeline_get_texture_unit(pipeline, name); + iron_g5_texture_unit_t *unit_copy = (iron_g5_texture_unit_t *)malloc(sizeof(iron_g5_texture_unit_t)); + memcpy(unit_copy, &unit, sizeof(iron_g5_texture_unit_t)); // TODO return unit_copy; } -void iron_g4_set_texture(kinc_g5_texture_unit_t *unit, kinc_g5_texture_t *texture) { - kinc_g4_set_texture(*unit, texture); +void _iron_g4_set_texture(iron_g5_texture_unit_t *unit, iron_g5_texture_t *texture) { + iron_g4_set_texture(*unit, texture); } -void iron_g4_set_texture_depth(kinc_g5_texture_unit_t *unit, kinc_g5_texture_t *render_target) { - kinc_g4_render_target_use_depth_as_texture(render_target, *unit); +void iron_g4_set_texture_depth(iron_g5_texture_unit_t *unit, iron_g5_texture_t *render_target) { + iron_g4_render_target_use_depth_as_texture(render_target, *unit); } -void iron_g4_set_texture_parameters(kinc_g5_texture_unit_t *unit, i32 u_addr, i32 v_addr, i32 min_filter, i32 mag_filter, i32 mip_filter) { - kinc_g4_set_texture_addressing(*unit, KINC_G4_TEXTURE_DIRECTION_U, (kinc_g4_texture_addressing_t)u_addr); - kinc_g4_set_texture_addressing(*unit, KINC_G4_TEXTURE_DIRECTION_V, (kinc_g4_texture_addressing_t)v_addr); - kinc_g4_set_texture_minification_filter(*unit, (kinc_g4_texture_filter_t)min_filter); - kinc_g4_set_texture_magnification_filter(*unit, (kinc_g4_texture_filter_t)mag_filter); - kinc_g4_set_texture_mipmap_filter(*unit, (kinc_g4_mipmap_filter_t)mip_filter); +void iron_g4_set_texture_parameters(iron_g5_texture_unit_t *unit, i32 u_addr, i32 v_addr, i32 min_filter, i32 mag_filter, i32 mip_filter) { + iron_g4_set_texture_addressing(*unit, IRON_G4_TEXTURE_DIRECTION_U, (iron_g4_texture_addressing_t)u_addr); + iron_g4_set_texture_addressing(*unit, IRON_G4_TEXTURE_DIRECTION_V, (iron_g4_texture_addressing_t)v_addr); + iron_g4_set_texture_minification_filter(*unit, (iron_g4_texture_filter_t)min_filter); + iron_g4_set_texture_magnification_filter(*unit, (iron_g4_texture_filter_t)mag_filter); + iron_g4_set_texture_mipmap_filter(*unit, (iron_g4_mipmap_filter_t)mip_filter); } -void iron_g4_set_bool(kinc_g5_constant_location_t *location, bool value) { - kinc_g4_set_bool(*location, value != 0); +void _iron_g4_set_bool(iron_g5_constant_location_t *location, bool value) { + iron_g4_set_bool(*location, value != 0); } -void iron_g4_set_int(kinc_g5_constant_location_t *location, i32 value) { - kinc_g4_set_int(*location, value); +void _iron_g4_set_int(iron_g5_constant_location_t *location, i32 value) { + iron_g4_set_int(*location, value); } -void iron_g4_set_float(kinc_g5_constant_location_t *location, f32 value) { - kinc_g4_set_float(*location, value); +void _iron_g4_set_float(iron_g5_constant_location_t *location, f32 value) { + iron_g4_set_float(*location, value); } -void iron_g4_set_float2(kinc_g5_constant_location_t *location, f32 value1, f32 value2) { - kinc_g4_set_float2(*location, value1, value2); +void _iron_g4_set_float2(iron_g5_constant_location_t *location, f32 value1, f32 value2) { + iron_g4_set_float2(*location, value1, value2); } -void iron_g4_set_float3(kinc_g5_constant_location_t *location, f32 value1, f32 value2, f32 value3) { - kinc_g4_set_float3(*location, value1, value2, value3); +void _iron_g4_set_float3(iron_g5_constant_location_t *location, f32 value1, f32 value2, f32 value3) { + iron_g4_set_float3(*location, value1, value2, value3); } -void iron_g4_set_float4(kinc_g5_constant_location_t *location, f32 value1, f32 value2, f32 value3, f32 value4) { - kinc_g4_set_float4(*location, value1, value2, value3, value4); +void _iron_g4_set_float4(iron_g5_constant_location_t *location, f32 value1, f32 value2, f32 value3, f32 value4) { + iron_g4_set_float4(*location, value1, value2, value3, value4); } -void iron_g4_set_floats(kinc_g5_constant_location_t *location, f32_array_t *values) { - kinc_g4_set_floats(*location, (float *)values->buffer, values->length); +void _iron_g4_set_floats(iron_g5_constant_location_t *location, f32_array_t *values) { + iron_g4_set_floats(*location, (float *)values->buffer, values->length); } -void iron_g4_set_matrix4(kinc_g5_constant_location_t *location, mat4_t m) { - kinc_g4_set_matrix4(*location, &m); +void _iron_g4_set_matrix4(iron_g5_constant_location_t *location, mat4_t m) { + iron_g4_set_matrix4(*location, &m); } -void iron_g4_set_matrix3(kinc_g5_constant_location_t *location, mat3_t m) { - kinc_g4_set_matrix3(*location, &m); +void _iron_g4_set_matrix3(iron_g5_constant_location_t *location, mat3_t m) { + iron_g4_set_matrix3(*location, &m); } void iron_set_window_title(string_t *title) { - kinc_window_set_title(title); - #if defined(KINC_IOS) || defined(KINC_ANDROID) + iron_window_set_title(title); + #if defined(IRON_IOS) || defined(IRON_ANDROID) strcpy(mobile_title, title); #endif } void iron_set_window_mode(i32 mode) { - kinc_window_change_mode((kinc_window_mode_t)mode); + iron_window_change_mode((iron_window_mode_t)mode); } i32 iron_screen_dpi() { - return kinc_display_current_mode(kinc_primary_display()).pixels_per_inch; + return iron_display_current_mode(iron_primary_display()).pixels_per_inch; } i32 iron_display_width(i32 index) { - return kinc_display_current_mode(index).width; + return iron_display_current_mode(index).width; } i32 iron_display_height(i32 index) { - return kinc_display_current_mode(index).height; + return iron_display_current_mode(index).height; } i32 iron_display_x(i32 index) { - return kinc_display_current_mode(index).x; + return iron_display_current_mode(index).x; } i32 iron_display_y(i32 index) { - return kinc_display_current_mode(index).y; + return iron_display_current_mode(index).y; } i32 iron_display_frequency(i32 index) { - return kinc_display_current_mode(index).frequency; + return iron_display_current_mode(index).frequency; } bool iron_display_is_primary(i32 index) { - return index == kinc_primary_display(); + return index == iron_primary_display(); } -kinc_g5_texture_t *iron_g4_create_render_target(i32 width, i32 height, i32 format, i32 depth_buffer_bits) { - kinc_g5_texture_t *render_target = (kinc_g5_texture_t *)malloc(sizeof(kinc_g5_texture_t)); - kinc_g5_render_target_init(render_target, width, height, (kinc_image_format_t)format, depth_buffer_bits); +iron_g5_texture_t *iron_g4_create_render_target(i32 width, i32 height, i32 format, i32 depth_buffer_bits) { + iron_g5_texture_t *render_target = (iron_g5_texture_t *)malloc(sizeof(iron_g5_texture_t)); + iron_g5_render_target_init(render_target, width, height, (iron_image_format_t)format, depth_buffer_bits); render_target->buffer = NULL; return render_target; } -kinc_g5_texture_t *iron_g4_create_texture_from_bytes(buffer_t *data, i32 width, i32 height, i32 format, bool readable) { - kinc_g5_texture_t *texture = (kinc_g5_texture_t *)malloc(sizeof(kinc_g5_texture_t)); +iron_g5_texture_t *iron_g4_create_texture_from_bytes(buffer_t *data, i32 width, i32 height, i32 format, bool readable) { + iron_g5_texture_t *texture = (iron_g5_texture_t *)malloc(sizeof(iron_g5_texture_t)); texture->buffer = NULL; void *image_data; if (readable) { @@ -1403,24 +1403,24 @@ kinc_g5_texture_t *iron_g4_create_texture_from_bytes(buffer_t *data, i32 width, else { image_data = data->buffer; } - kinc_g5_texture_init_from_bytes(texture, image_data, width, height, (kinc_image_format_t)format); + iron_g5_texture_init_from_bytes(texture, image_data, width, height, (iron_image_format_t)format); return texture; } -kinc_g5_texture_t *iron_g4_create_texture_from_encoded_bytes(buffer_t *data, string_t *format, bool readable) { - kinc_g5_texture_t *texture = (kinc_g5_texture_t *)malloc(sizeof(kinc_g5_texture_t)); +iron_g5_texture_t *iron_g4_create_texture_from_encoded_bytes(buffer_t *data, string_t *format, bool readable) { + iron_g5_texture_t *texture = (iron_g5_texture_t *)malloc(sizeof(iron_g5_texture_t)); texture->buffer = NULL; unsigned char *content_data = (unsigned char *)data->buffer; int content_length = (int)data->length; unsigned char *image_data; - kinc_image_format_t image_format; + iron_image_format_t image_format; int image_width; int image_height; if (ends_with(format, "k")) { - image_width = kinc_read_s32le(content_data); - image_height = kinc_read_s32le(content_data + 4); + image_width = iron_read_s32le(content_data); + image_height = iron_read_s32le(content_data + 4); char fourcc[5]; fourcc[0] = content_data[8]; fourcc[1] = content_data[9]; @@ -1432,27 +1432,27 @@ kinc_g5_texture_t *iron_g4_create_texture_from_encoded_bytes(buffer_t *data, str int output_size = image_width * image_height * 4; image_data = (unsigned char *)malloc(output_size); LZ4_decompress_safe((char *)content_data + 12, (char *)image_data, compressed_size, output_size); - image_format = KINC_IMAGE_FORMAT_RGBA32; + image_format = IRON_IMAGE_FORMAT_RGBA32; } else if (strcmp(fourcc, "LZ4F") == 0) { int output_size = image_width * image_height * 16; image_data = (unsigned char *)malloc(output_size); LZ4_decompress_safe((char *)content_data + 12, (char *)image_data, compressed_size, output_size); - image_format = KINC_IMAGE_FORMAT_RGBA128; + image_format = IRON_IMAGE_FORMAT_RGBA128; } } else if (ends_with(format, "hdr")) { int comp; image_data = (unsigned char *)stbi_loadf_from_memory(content_data, content_length, &image_width, &image_height, &comp, 4); - image_format = KINC_IMAGE_FORMAT_RGBA128; + image_format = IRON_IMAGE_FORMAT_RGBA128; } else { // jpg, png, .. int comp; image_data = stbi_load_from_memory(content_data, content_length, &image_width, &image_height, &comp, 4); - image_format = KINC_IMAGE_FORMAT_RGBA32; + image_format = IRON_IMAGE_FORMAT_RGBA32; } - kinc_g5_texture_init_from_bytes(texture, image_data, image_width, image_height, image_format); + iron_g5_texture_init_from_bytes(texture, image_data, image_width, image_height, image_format); if (!readable) { free(image_data);; } @@ -1460,25 +1460,25 @@ kinc_g5_texture_t *iron_g4_create_texture_from_encoded_bytes(buffer_t *data, str return texture; } -int _format_byte_size(kinc_image_format_t format) { +int _format_byte_size(iron_image_format_t format) { switch (format) { - case KINC_IMAGE_FORMAT_RGBA128: + case IRON_IMAGE_FORMAT_RGBA128: return 16; - case KINC_IMAGE_FORMAT_RGBA64: + case IRON_IMAGE_FORMAT_RGBA64: return 8; - case KINC_IMAGE_FORMAT_R8: + case IRON_IMAGE_FORMAT_R8: return 1; - case KINC_IMAGE_FORMAT_R16: + case IRON_IMAGE_FORMAT_R16: return 2; - case KINC_IMAGE_FORMAT_BGRA32: - case KINC_IMAGE_FORMAT_RGBA32: - case KINC_IMAGE_FORMAT_R32: + case IRON_IMAGE_FORMAT_BGRA32: + case IRON_IMAGE_FORMAT_RGBA32: + case IRON_IMAGE_FORMAT_R32: default: return 4; } } -buffer_t *iron_g4_get_texture_pixels(kinc_g5_texture_t *image) { +buffer_t *iron_g4_get_texture_pixels(iron_g5_texture_t *image) { if (image->buffer == NULL) { image->buffer = malloc(sizeof(buffer_t)); image->buffer->buffer = NULL; @@ -1491,13 +1491,13 @@ buffer_t *iron_g4_get_texture_pixels(kinc_g5_texture_t *image) { } uint8_t *b = (uint8_t *)image->buffer->buffer; - kinc_g5_render_target_get_pixels(image, b); + iron_g5_render_target_get_pixels(image, b); // Release staging texture immediately to save memory - #ifdef KINC_DIRECT3D12 + #ifdef IRON_DIRECT3D12 image->impl.renderTargetReadback->lpVtbl->Release(image->impl.renderTargetReadback); image->impl.renderTargetReadback = NULL; - #elif defined(KINC_METAL) + #elif defined(IRON_METAL) // id texReadback = (__bridge_transfer id)image->impl._texReadback; // texReadback = nil; // image->impl._texReadback = NULL; @@ -1509,44 +1509,44 @@ buffer_t *iron_g4_get_texture_pixels(kinc_g5_texture_t *image) { return image->buffer; } -void iron_g4_set_mipmaps(kinc_g5_texture_t *texture, any_array_t *mipmaps) { +void iron_g4_set_mipmaps(iron_g5_texture_t *texture, any_array_t *mipmaps) { for (int32_t i = 0; i < mipmaps->length; ++i) { - kinc_g5_texture_t *img = mipmaps->buffer[i]; - kinc_g5_texture_t *img_tex = img; - kinc_g5_texture_set_mipmap(texture, img_tex, i + 1); + iron_g5_texture_t *img = mipmaps->buffer[i]; + iron_g5_texture_t *img_tex = img; + iron_g5_texture_set_mipmap(texture, img_tex, i + 1); } } -void iron_g4_begin(kinc_g5_texture_t *render_target, any_array_t *additional) { +void _iron_g4_begin(iron_g5_texture_t *render_target, any_array_t *additional) { if (render_target == NULL) { - kinc_g4_restore_render_target(); + iron_g4_restore_render_target(); } else { - kinc_g5_texture_t *rt = (kinc_g5_texture_t *)render_target; + iron_g5_texture_t *rt = (iron_g5_texture_t *)render_target; int32_t length = 1; - kinc_g5_texture_t *render_targets[8] = { rt, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; + iron_g5_texture_t *render_targets[8] = { rt, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; if (additional != NULL) { length = additional->length + 1; if (length > 8) { length = 8; } for (int32_t i = 1; i < length; ++i) { - kinc_g5_texture_t *img = additional->buffer[i - 1]; - kinc_g5_texture_t *art = (kinc_g5_texture_t *)img; + iron_g5_texture_t *img = additional->buffer[i - 1]; + iron_g5_texture_t *art = (iron_g5_texture_t *)img; render_targets[i] = art; } } - kinc_g4_set_render_targets(render_targets, length); + iron_g4_set_render_targets(render_targets, length); } } -void iron_g4_end() { +void _iron_g4_end() { } void iron_g4_swap_buffers() { - kinc_g4_end(); - kinc_g5_swap_buffers(); - kinc_g4_begin(); + iron_g4_end(); + iron_g5_swap_buffers(); + iron_g4_begin(); } void iron_file_save_bytes(string_t *path, buffer_t *bytes, u64 length) { @@ -1555,7 +1555,7 @@ void iron_file_save_bytes(string_t *path, buffer_t *bytes, u64 length) { byte_length = (u64)bytes->length; } - #ifdef KINC_WINDOWS + #ifdef IRON_WINDOWS MultiByteToWideChar(CP_UTF8, 0, path, -1, temp_wstring, 1024); FILE *file = _wfopen(temp_wstring, L"wb"); #else @@ -1569,13 +1569,13 @@ void iron_file_save_bytes(string_t *path, buffer_t *bytes, u64 length) { } i32 iron_sys_command(string_t *cmd) { - #ifdef KINC_WINDOWS + #ifdef IRON_WINDOWS int wlen = MultiByteToWideChar(CP_UTF8, 0, cmd, -1, NULL, 0); wchar_t *wstr = malloc(sizeof(wchar_t) * wlen); MultiByteToWideChar(CP_UTF8, 0, cmd, -1, wstr, wlen); int result = _wsystem(wstr); free(wstr); - #elif defined(KINC_IOS) + #elif defined(IRON_IOS) int result = 0; #else int result = system(cmd); @@ -1584,22 +1584,22 @@ i32 iron_sys_command(string_t *cmd) { } string_t *iron_get_files_location() { - #ifdef KINC_MACOS + #ifdef IRON_MACOS char path[1024]; strcpy(path, macgetresourcepath()); strcat(path, "/"); - strcat(path, KINC_OUTDIR); + strcat(path, IRON_OUTDIR); strcat(path, "/"); return path; - #elif defined(KINC_IOS) + #elif defined(IRON_IOS) char path[1024]; strcpy(path, iphonegetresourcepath()); strcat(path, "/"); - strcat(path, KINC_OUTDIR); + strcat(path, IRON_OUTDIR); strcat(path, "/"); return path; #else - return kinc_internal_get_files_location(); + return iron_internal_get_files_location(); #endif } @@ -1621,7 +1621,7 @@ void _http_callback(int error, int response, const char *body, void *callback_da free(cbd); } -void iron_http_request(string_t *url, i32 size, void (*callback)(char *, buffer_t *)) { +void _iron_http_request(string_t *url, i32 size, void (*callback)(char *, buffer_t *)) { _callback_data_t *cbd = malloc(sizeof(_callback_data_t)); cbd->size = size; strcpy(cbd->url, url); @@ -1649,23 +1649,23 @@ void iron_http_request(string_t *url, i32 size, void (*callback)(char *, buffer_ url_path[j] = curl[i + 8 + j]; } url_path[j] = 0; - #ifdef KINC_ANDROID // TODO: move to Kinc + #ifdef IRON_ANDROID // TODO: move to iron android_http_request(curl, url_path, NULL, 443, true, 0, NULL, &_http_callback, cbd); - #elif defined(KINC_LINUX) + #elif defined(IRON_LINUX) // TODO #else - kinc_http_request(url_base, url_path, NULL, 443, true, 0, NULL, &_http_callback, cbd); + iron_http_request(url_base, url_path, NULL, 443, true, 0, NULL, &_http_callback, cbd); #endif } bool _window_close_callback(void *data) { - #ifdef KINC_WINDOWS + #ifdef IRON_WINDOWS bool save = false; wchar_t title[1024]; - GetWindowTextW(kinc_windows_window_handle(), title, sizeof(title)); + GetWindowTextW(iron_windows_window_handle(), title, sizeof(title)); bool dirty = wcsstr(title, L"* - ArmorPaint") != NULL; if (dirty) { - int res = MessageBox(kinc_windows_window_handle(), L"Project has been modified, save changes?", L"Save Changes?", MB_YESNOCANCEL | MB_ICONEXCLAMATION); + int res = MessageBox(iron_windows_window_handle(), L"Project has been modified, save changes?", L"Save Changes?", MB_YESNOCANCEL | MB_ICONEXCLAMATION); if (res == IDYES) { save = true; } @@ -1687,12 +1687,12 @@ bool _window_close_callback(void *data) { void iron_set_save_and_quit_callback(void (*callback)(bool)) { iron_save_and_quit = callback; save_and_quit_callback_set = true; - kinc_window_set_close_callback(_window_close_callback, NULL); + iron_window_set_close_callback(_window_close_callback, NULL); } void iron_set_mouse_cursor(i32 id) { - kinc_mouse_set_cursor(id); - #ifdef KINC_WINDOWS + iron_mouse_set_cursor(id); + #ifdef IRON_WINDOWS // Set hand icon for drag even when mouse button is pressed if (id == 1) { SetCursor(LoadCursor(NULL, IDC_HAND)); @@ -1743,7 +1743,7 @@ char *iron_save_dialog(char *filter_list, char *default_path) { return NULL; } -#elif defined(KINC_ANDROID) +#elif defined(IRON_ANDROID) char_ptr_array_t *iron_open_dialog(char *filter_list, char *default_path, bool open_multiple) { AndroidFileDialogOpen(); @@ -1756,7 +1756,7 @@ char *iron_save_dialog(char *filter_list, char *default_path) { return temp_string; } -#elif defined(KINC_IOS) +#elif defined(IRON_IOS) char_ptr_array_t *iron_open_dialog(char *filter_list, char *default_path, bool open_multiple) { // Once finished drop_files callback is called @@ -1787,7 +1787,7 @@ char *iron_read_directory(char *path) { break; } - #ifdef KINC_WINDOWS + #ifdef IRON_WINDOWS char file_path[512]; strcpy(file_path, path); strcat(file_path, "\\"); @@ -1807,18 +1807,18 @@ char *iron_read_directory(char *path) { } bool iron_file_exists(char *path) { - kinc_file_reader_t reader; - if (kinc_file_reader_open(&reader, path, KINC_FILE_TYPE_ASSET)) { - kinc_file_reader_close(&reader); + iron_file_reader_t reader; + if (iron_file_reader_open(&reader, path, IRON_FILE_TYPE_ASSET)) { + iron_file_reader_close(&reader); return true; } return false; } void iron_delete_file(char *path) { - #ifdef KINC_IOS + #ifdef IRON_IOS IOSDeleteFile(path); - #elif defined(KINC_WINDOWS) + #elif defined(IRON_WINDOWS) char cmd[1024]; strcpy(cmd, "del /f \""); strcat(cmd, path); @@ -1887,7 +1887,7 @@ void _write_image(char *path, buffer_t *bytes, i32 w, i32 h, i32 format, int ima comp = 3; pixels = (unsigned char *)malloc(w * h * comp); for (int i = 0; i < w * h; ++i) { - #if defined(KINC_METAL) || defined(KINC_VULKAN) + #if defined(IRON_METAL) || defined(IRON_VULKAN) pixels[i * 3 ] = rgba[i * 4 + 2]; pixels[i * 3 + 1] = rgba[i * 4 + 1]; pixels[i * 3 + 2] = rgba[i * 4 ]; @@ -1902,7 +1902,7 @@ void _write_image(char *path, buffer_t *bytes, i32 w, i32 h, i32 format, int ima comp = 1; pixels = (unsigned char *)malloc(w * h * comp); int off = format - 3; - #if defined(KINC_METAL) || defined(KINC_VULKAN) + #if defined(IRON_METAL) || defined(IRON_VULKAN) off = 2 - off; #endif for (int i = 0; i < w * h; ++i) { @@ -2108,18 +2108,18 @@ buffer_t *iron_ml_inference(buffer_t *model, any_array_t *tensors, any_array_t * ort->SetInterOpNumThreads(ort_session_options, 8); if (use_gpu) { - #ifdef KINC_WINDOWS + #ifdef IRON_WINDOWS ort->SetSessionExecutionMode(ort_session_options, ORT_SEQUENTIAL); ort->DisableMemPattern(ort_session_options); onnx_status = OrtSessionOptionsAppendExecutionProvider_DML(ort_session_options, 0); - #elif defined(KINC_LINUX) + #elif defined(IRON_LINUX) // onnx_status = OrtSessionOptionsAppendExecutionProvider_CUDA(ort_session_options, 0); - #elif defined(KINC_MACOS) + #elif defined(IRON_MACOS) onnx_status = OrtSessionOptionsAppendExecutionProvider_CoreML(ort_session_options, 0); #endif if (onnx_status != NULL) { const char *msg = ort->GetErrorMessage(onnx_status); - kinc_error("%s", msg); + iron_error("%s", msg); ort->ReleaseStatus(onnx_status); } } @@ -2134,7 +2134,7 @@ buffer_t *iron_ml_inference(buffer_t *model, any_array_t *tensors, any_array_t * onnx_status = ort->CreateSessionFromArray(ort_env, model->buffer, (int)model->length, ort_session_options, &session); if (onnx_status != NULL) { const char* msg = ort->GetErrorMessage(onnx_status); - kinc_error("%s", msg); + iron_error("%s", msg); ort->ReleaseStatus(onnx_status); } } @@ -2185,7 +2185,7 @@ buffer_t *iron_ml_inference(buffer_t *model, any_array_t *tensors, any_array_t * onnx_status = ort->Run(session, NULL, input_node_names, input_tensors, length, &output_node_name, 1, &output_tensor); if (onnx_status != NULL) { const char* msg = ort->GetErrorMessage(onnx_status); - kinc_error("%s", msg); + iron_error("%s", msg); ort->ReleaseStatus(onnx_status); } float *float_array; @@ -2236,51 +2236,51 @@ void iron_ml_unload() { void iron_raytrace_init(buffer_t *shader) { if (raytrace_created) { - kinc_g5_constant_buffer_destroy(&constant_buffer); - kinc_g5_raytrace_pipeline_destroy(&rt_pipeline); + iron_g5_constant_buffer_destroy(&constant_buffer); + iron_g5_raytrace_pipeline_destroy(&rt_pipeline); } raytrace_created = true; - kinc_g5_constant_buffer_init(&constant_buffer, constant_buffer_size * 4); - kinc_g5_raytrace_pipeline_init(&rt_pipeline, &commandList, shader->buffer, (int)shader->length, &constant_buffer); + iron_g5_constant_buffer_init(&constant_buffer, constant_buffer_size * 4); + iron_g5_raytrace_pipeline_init(&rt_pipeline, &commandList, shader->buffer, (int)shader->length, &constant_buffer); } void iron_raytrace_as_init() { if (raytrace_accel_created) { - kinc_g5_raytrace_acceleration_structure_destroy(&accel); + iron_g5_raytrace_acceleration_structure_destroy(&accel); } raytrace_accel_created = true; - kinc_g5_raytrace_acceleration_structure_init(&accel); + iron_g5_raytrace_acceleration_structure_init(&accel); } -void iron_raytrace_as_add(kinc_g4_vertex_buffer_t *vb, kinc_g5_index_buffer_t *ib, kinc_matrix4x4_t transform) { - kinc_g5_vertex_buffer_t *vertex_buffer = &vb->impl._buffer; - kinc_g5_raytrace_acceleration_structure_add(&accel, vertex_buffer, ib, transform); +void iron_raytrace_as_add(iron_g4_vertex_buffer_t *vb, iron_g5_index_buffer_t *ib, iron_matrix4x4_t transform) { + iron_g5_vertex_buffer_t *vertex_buffer = &vb->impl._buffer; + iron_g5_raytrace_acceleration_structure_add(&accel, vertex_buffer, ib, transform); } -void iron_raytrace_as_build(kinc_g4_vertex_buffer_t *vb_full, kinc_g5_index_buffer_t *ib_full) { - kinc_g5_raytrace_acceleration_structure_build(&accel, &commandList, &vb_full->impl._buffer, ib_full); +void iron_raytrace_as_build(iron_g4_vertex_buffer_t *vb_full, iron_g5_index_buffer_t *ib_full) { + iron_g5_raytrace_acceleration_structure_build(&accel, &commandList, &vb_full->impl._buffer, ib_full); } -void iron_raytrace_set_textures(kinc_g5_texture_t *tex0, kinc_g5_texture_t *tex1, kinc_g5_texture_t *tex2, kinc_g5_texture_t *texenv, kinc_g5_texture_t *texsobol, kinc_g5_texture_t *texscramble, kinc_g5_texture_t *texrank) { - kinc_g5_texture_t *texpaint0; - kinc_g5_texture_t *texpaint1; - kinc_g5_texture_t *texpaint2; +void iron_raytrace_set_textures(iron_g5_texture_t *tex0, iron_g5_texture_t *tex1, iron_g5_texture_t *tex2, iron_g5_texture_t *texenv, iron_g5_texture_t *texsobol, iron_g5_texture_t *texscramble, iron_g5_texture_t *texrank) { + iron_g5_texture_t *texpaint0; + iron_g5_texture_t *texpaint1; + iron_g5_texture_t *texpaint2; - // kinc_g5_texture_t *texpaint0_image = tex0; - // kinc_g5_texture_t *texpaint0_tex = texpaint0_image; - // kinc_g5_texture_t *texpaint0_rt = texpaint0_image->render_target_; + // iron_g5_texture_t *texpaint0_image = tex0; + // iron_g5_texture_t *texpaint0_tex = texpaint0_image; + // iron_g5_texture_t *texpaint0_rt = texpaint0_image->render_target_; // if (texpaint0_tex != NULL) { - // kinc_g5_texture_t *texture = texpaint0_tex; + // iron_g5_texture_t *texture = texpaint0_tex; // if (!texture->_uploaded) { - // kinc_g5_command_list_upload_texture(&commandList, texture); + // iron_g5_command_list_upload_texture(&commandList, texture); // texture->_uploaded = true; // } - // texpaint0 = (kinc_g5_texture_t *)malloc(sizeof(kinc_g5_texture_t)); - // #ifdef KINC_DIRECT3D12 + // texpaint0 = (iron_g5_texture_t *)malloc(sizeof(iron_g5_texture_t)); + // #ifdef IRON_DIRECT3D12 // texpaint0->impl.srvDescriptorHeap = texture->impl.srvDescriptorHeap; // #endif - // #ifdef KINC_VULKAN + // #ifdef IRON_VULKAN // texpaint0->impl.view = texture->impl.view; // #endif // } @@ -2288,21 +2288,21 @@ void iron_raytrace_set_textures(kinc_g5_texture_t *tex0, kinc_g5_texture_t *tex1 // texpaint0 = texpaint0_rt; // } - // kinc_g5_texture_t *texpaint1_image = tex1; - // kinc_g5_texture_t *texpaint1_tex = texpaint1_image; - // kinc_g5_texture_t *texpaint1_rt = texpaint1_image->render_target_; + // iron_g5_texture_t *texpaint1_image = tex1; + // iron_g5_texture_t *texpaint1_tex = texpaint1_image; + // iron_g5_texture_t *texpaint1_rt = texpaint1_image->render_target_; // if (texpaint1_tex != NULL) { - // kinc_g5_texture_t *texture = texpaint1_tex; + // iron_g5_texture_t *texture = texpaint1_tex; // if (!texture->_uploaded) { - // kinc_g5_command_list_upload_texture(&commandList, texture); + // iron_g5_command_list_upload_texture(&commandList, texture); // texture->_uploaded = true; // } - // texpaint1 = (kinc_g5_texture_t *)malloc(sizeof(kinc_g5_texture_t)); - // #ifdef KINC_DIRECT3D12 + // texpaint1 = (iron_g5_texture_t *)malloc(sizeof(iron_g5_texture_t)); + // #ifdef IRON_DIRECT3D12 // texpaint1->impl.srvDescriptorHeap = texture->impl.srvDescriptorHeap; // #endif - // #ifdef KINC_VULKAN + // #ifdef IRON_VULKAN // texpaint1->impl.view = texture->impl.view; // #endif // } @@ -2310,21 +2310,21 @@ void iron_raytrace_set_textures(kinc_g5_texture_t *tex0, kinc_g5_texture_t *tex1 // texpaint1 = texpaint1_rt; // } - // kinc_g5_texture_t *texpaint2_image = tex2; - // kinc_g5_texture_t *texpaint2_tex = texpaint2_image; - // kinc_g5_texture_t *texpaint2_rt = texpaint2_image->render_target_; + // iron_g5_texture_t *texpaint2_image = tex2; + // iron_g5_texture_t *texpaint2_tex = texpaint2_image; + // iron_g5_texture_t *texpaint2_rt = texpaint2_image->render_target_; // if (texpaint2_tex != NULL) { - // kinc_g5_texture_t *texture = (kinc_g5_texture_t *)texpaint2_tex; + // iron_g5_texture_t *texture = (iron_g5_texture_t *)texpaint2_tex; // if (!texture->_uploaded) { - // kinc_g5_command_list_upload_texture(&commandList, texture); + // iron_g5_command_list_upload_texture(&commandList, texture); // texture->_uploaded = true; // } - // texpaint2 = (kinc_g5_texture_t *)malloc(sizeof(kinc_g5_texture_t)); - // #ifdef KINC_DIRECT3D12 + // texpaint2 = (iron_g5_texture_t *)malloc(sizeof(iron_g5_texture_t)); + // #ifdef IRON_DIRECT3D12 // texpaint2->impl.srvDescriptorHeap = texture->impl.srvDescriptorHeap; // #endif - // #ifdef KINC_VULKAN + // #ifdef IRON_VULKAN // texpaint2->impl.view = texture->impl.view; // #endif // } @@ -2337,23 +2337,23 @@ void iron_raytrace_set_textures(kinc_g5_texture_t *tex0, kinc_g5_texture_t *tex1 texpaint2 = tex2; if (!texenv->_uploaded) { - kinc_g5_command_list_upload_texture(&commandList, texenv); + iron_g5_command_list_upload_texture(&commandList, texenv); texenv->_uploaded = true; } if (!texsobol->_uploaded) { - kinc_g5_command_list_upload_texture(&commandList, texsobol); + iron_g5_command_list_upload_texture(&commandList, texsobol); texsobol->_uploaded = true; } if (!texscramble->_uploaded) { - kinc_g5_command_list_upload_texture(&commandList, texscramble); + iron_g5_command_list_upload_texture(&commandList, texscramble); texscramble->_uploaded = true; } if (!texrank->_uploaded) { - kinc_g5_command_list_upload_texture(&commandList, texrank); + iron_g5_command_list_upload_texture(&commandList, texrank); texrank->_uploaded = true; } - kinc_g5_raytrace_set_textures(texpaint0, texpaint1, texpaint2, texenv, texsobol, texscramble, texrank); + iron_g5_raytrace_set_textures(texpaint0, texpaint1, texpaint2, texenv, texsobol, texscramble, texrank); // if (texpaint0_tex != NULL) { // free(texpaint0); @@ -2366,18 +2366,18 @@ void iron_raytrace_set_textures(kinc_g5_texture_t *tex0, kinc_g5_texture_t *tex1 // } } -void iron_raytrace_dispatch_rays(kinc_g5_texture_t *render_target, buffer_t *buffer) { +void iron_raytrace_dispatch_rays(iron_g5_texture_t *render_target, buffer_t *buffer) { float *cb = (float *)buffer->buffer; - kinc_g5_constant_buffer_lock_all(&constant_buffer); + iron_g5_constant_buffer_lock_all(&constant_buffer); for (int i = 0; i < constant_buffer_size; ++i) { - kinc_g5_constant_buffer_set_float(&constant_buffer, i * 4, cb[i]); + iron_g5_constant_buffer_set_float(&constant_buffer, i * 4, cb[i]); } - kinc_g5_constant_buffer_unlock(&constant_buffer); + iron_g5_constant_buffer_unlock(&constant_buffer); - kinc_g5_raytrace_set_acceleration_structure(&accel); - kinc_g5_raytrace_set_pipeline(&rt_pipeline); - kinc_g5_raytrace_set_target(render_target); - kinc_g5_raytrace_dispatch_rays(&commandList); + iron_g5_raytrace_set_acceleration_structure(&accel); + iron_g5_raytrace_set_pipeline(&rt_pipeline); + iron_g5_raytrace_set_target(render_target); + iron_g5_raytrace_dispatch_rays(&commandList); } #endif diff --git a/base/sources/iron_audio.c b/base/sources/iron_audio.c index 8596315b..af7f7213 100644 --- a/base/sources/iron_audio.c +++ b/base/sources/iron_audio.c @@ -1,6 +1,6 @@ #include "iron_audio.h" -#ifdef KINC_A1 +#ifdef IRON_A1 #include #include @@ -12,30 +12,30 @@ #include #include -struct kinc_a1_channel { - kinc_a1_sound_t *sound; +struct iron_a1_channel { + iron_a1_sound_t *sound; float position; bool loop; volatile float volume; volatile float pitch; }; -struct kinc_a1_stream_channel { - kinc_a1_sound_stream_t *stream; +struct iron_a1_stream_channel { + iron_a1_sound_stream_t *stream; int position; }; -struct kinc_internal_video_channel { - struct kinc_internal_video_sound_stream *stream; +struct iron_internal_video_channel { + struct iron_internal_video_sound_stream *stream; int position; }; -static kinc_mutex_t mutex; +static iron_mutex_t mutex; #define CHANNEL_COUNT 16 -static kinc_a1_channel_t channels[CHANNEL_COUNT]; -static kinc_a1_stream_channel_t streamchannels[CHANNEL_COUNT]; -static kinc_internal_video_channel_t videos[CHANNEL_COUNT]; +static iron_a1_channel_t channels[CHANNEL_COUNT]; +static iron_a1_stream_channel_t streamchannels[CHANNEL_COUNT]; +static iron_internal_video_channel_t videos[CHANNEL_COUNT]; static float sampleLinear(int16_t *data, float position) { int pos1 = (int)position; @@ -46,22 +46,22 @@ static float sampleLinear(int16_t *data, float position) { return sample1 * (1 - a) + sample2 * a; } -static void kinc_a2_on_a1_mix(kinc_a2_buffer_t *buffer, uint32_t samples, void *userdata) { - kinc_a1_mix(buffer, samples); +static void iron_a2_on_a1_mix(iron_a2_buffer_t *buffer, uint32_t samples, void *userdata) { + iron_a1_mix(buffer, samples); } -void kinc_a1_mix(kinc_a2_buffer_t *buffer, uint32_t samples) { +void iron_a1_mix(iron_a2_buffer_t *buffer, uint32_t samples) { for (uint32_t i = 0; i < samples; ++i) { float left_value = 0.0f; float right_value = 0.0f; - kinc_mutex_lock(&mutex); + iron_mutex_lock(&mutex); for (int i = 0; i < CHANNEL_COUNT; ++i) { if (channels[i].sound != NULL) { left_value += sampleLinear(channels[i].sound->left, channels[i].position) * channels[i].volume * channels[i].sound->volume; - right_value = kinc_max(kinc_min(right_value, 1.0f), -1.0f); + right_value = iron_max(iron_min(right_value, 1.0f), -1.0f); right_value += sampleLinear(channels[i].sound->right, channels[i].position) * channels[i].volume * channels[i].sound->volume; - left_value = kinc_max(kinc_min(left_value, 1.0f), -1.0f); + left_value = iron_max(iron_min(left_value, 1.0f), -1.0f); channels[i].position += channels[i].pitch / channels[i].sound->sample_rate_pos; // channels[i].position += 2; @@ -77,12 +77,12 @@ void kinc_a1_mix(kinc_a2_buffer_t *buffer, uint32_t samples) { } for (int i = 0; i < CHANNEL_COUNT; ++i) { if (streamchannels[i].stream != NULL) { - float *samples = kinc_a1_sound_stream_next_frame(streamchannels[i].stream); - left_value += samples[0] * kinc_a1_sound_stream_volume(streamchannels[i].stream); - left_value = kinc_max(kinc_min(left_value, 1.0f), -1.0f); - right_value += samples[1] * kinc_a1_sound_stream_volume(streamchannels[i].stream); - right_value = kinc_max(kinc_min(right_value, 1.0f), -1.0f); - if (kinc_a1_sound_stream_ended(streamchannels[i].stream)) { + float *samples = iron_a1_sound_stream_next_frame(streamchannels[i].stream); + left_value += samples[0] * iron_a1_sound_stream_volume(streamchannels[i].stream); + left_value = iron_max(iron_min(left_value, 1.0f), -1.0f); + right_value += samples[1] * iron_a1_sound_stream_volume(streamchannels[i].stream); + right_value = iron_max(iron_min(right_value, 1.0f), -1.0f); + if (iron_a1_sound_stream_ended(streamchannels[i].stream)) { streamchannels[i].stream = NULL; } } @@ -90,18 +90,18 @@ void kinc_a1_mix(kinc_a2_buffer_t *buffer, uint32_t samples) { for (int i = 0; i < CHANNEL_COUNT; ++i) { if (videos[i].stream != NULL) { - float *samples = kinc_internal_video_sound_stream_next_frame(videos[i].stream); + float *samples = iron_internal_video_sound_stream_next_frame(videos[i].stream); left_value += samples[0]; - left_value = kinc_max(kinc_min(left_value, 1.0f), -1.0f); + left_value = iron_max(iron_min(left_value, 1.0f), -1.0f); right_value += samples[1]; - right_value = kinc_max(kinc_min(right_value, 1.0f), -1.0f); - if (kinc_internal_video_sound_stream_ended(videos[i].stream)) { + right_value = iron_max(iron_min(right_value, 1.0f), -1.0f); + if (iron_internal_video_sound_stream_ended(videos[i].stream)) { videos[i].stream = NULL; } } } - kinc_mutex_unlock(&mutex); + iron_mutex_unlock(&mutex); assert(buffer->channel_count >= 2); buffer->channels[0][buffer->write_location] = left_value; @@ -114,7 +114,7 @@ void kinc_a1_mix(kinc_a2_buffer_t *buffer, uint32_t samples) { } } -void kinc_a1_init(void) { +void iron_a1_init(void) { for (int i = 0; i < CHANNEL_COUNT; ++i) { channels[i].sound = NULL; channels[i].position = 0; @@ -123,15 +123,15 @@ void kinc_a1_init(void) { streamchannels[i].stream = NULL; streamchannels[i].position = 0; } - kinc_mutex_init(&mutex); + iron_mutex_init(&mutex); - kinc_a2_init(); - kinc_a2_set_callback(kinc_a2_on_a1_mix, NULL); + iron_a2_init(); + iron_a2_set_callback(iron_a2_on_a1_mix, NULL); } -kinc_a1_channel_t *kinc_a1_play_sound(kinc_a1_sound_t *sound, bool loop, float pitch, bool unique) { - kinc_a1_channel_t *channel = NULL; - kinc_mutex_lock(&mutex); +iron_a1_channel_t *iron_a1_play_sound(iron_a1_sound_t *sound, bool loop, float pitch, bool unique) { + iron_a1_channel_t *channel = NULL; + iron_mutex_lock(&mutex); bool found = false; for (int i = 0; i < CHANNEL_COUNT; ++i) { if (channels[i].sound == sound) { @@ -152,12 +152,12 @@ kinc_a1_channel_t *kinc_a1_play_sound(kinc_a1_sound_t *sound, bool loop, float p } } } - kinc_mutex_unlock(&mutex); + iron_mutex_unlock(&mutex); return channel; } -void kinc_a1_stop_sound(kinc_a1_sound_t *sound) { - kinc_mutex_lock(&mutex); +void iron_a1_stop_sound(iron_a1_sound_t *sound) { + iron_mutex_lock(&mutex); for (int i = 0; i < CHANNEL_COUNT; ++i) { if (channels[i].sound == sound) { channels[i].sound = NULL; @@ -165,11 +165,11 @@ void kinc_a1_stop_sound(kinc_a1_sound_t *sound) { break; } } - kinc_mutex_unlock(&mutex); + iron_mutex_unlock(&mutex); } -void kinc_a1_play_sound_stream(kinc_a1_sound_stream_t *stream) { - kinc_mutex_lock(&mutex); +void iron_a1_play_sound_stream(iron_a1_sound_stream_t *stream) { + iron_mutex_lock(&mutex); for (int i = 0; i < CHANNEL_COUNT; ++i) { if (streamchannels[i].stream == stream) { @@ -187,11 +187,11 @@ void kinc_a1_play_sound_stream(kinc_a1_sound_stream_t *stream) { } } - kinc_mutex_unlock(&mutex); + iron_mutex_unlock(&mutex); } -void kinc_a1_stop_sound_stream(kinc_a1_sound_stream_t *stream) { - kinc_mutex_lock(&mutex); +void iron_a1_stop_sound_stream(iron_a1_sound_stream_t *stream) { + iron_mutex_lock(&mutex); for (int i = 0; i < CHANNEL_COUNT; ++i) { if (streamchannels[i].stream == stream) { streamchannels[i].stream = NULL; @@ -199,11 +199,11 @@ void kinc_a1_stop_sound_stream(kinc_a1_sound_stream_t *stream) { break; } } - kinc_mutex_unlock(&mutex); + iron_mutex_unlock(&mutex); } -void kinc_internal_play_video_sound_stream(struct kinc_internal_video_sound_stream *stream) { - kinc_mutex_lock(&mutex); +void iron_internal_play_video_sound_stream(struct iron_internal_video_sound_stream *stream) { + iron_mutex_lock(&mutex); for (int i = 0; i < CHANNEL_COUNT; ++i) { if (videos[i].stream == NULL) { videos[i].stream = stream; @@ -211,11 +211,11 @@ void kinc_internal_play_video_sound_stream(struct kinc_internal_video_sound_stre break; } } - kinc_mutex_unlock(&mutex); + iron_mutex_unlock(&mutex); } -void kinc_internal_stop_video_sound_stream(struct kinc_internal_video_sound_stream *stream) { - kinc_mutex_lock(&mutex); +void iron_internal_stop_video_sound_stream(struct iron_internal_video_sound_stream *stream) { + iron_mutex_lock(&mutex); for (int i = 0; i < CHANNEL_COUNT; ++i) { if (videos[i].stream == stream) { videos[i].stream = NULL; @@ -223,19 +223,19 @@ void kinc_internal_stop_video_sound_stream(struct kinc_internal_video_sound_stre break; } } - kinc_mutex_unlock(&mutex); + iron_mutex_unlock(&mutex); } -float kinc_a1_channel_get_volume(kinc_a1_channel_t *channel) { +float iron_a1_channel_get_volume(iron_a1_channel_t *channel) { return channel->volume; } -void kinc_a1_channel_set_volume(kinc_a1_channel_t *channel, float volume) { - KINC_ATOMIC_EXCHANGE_FLOAT(&channel->volume, volume); +void iron_a1_channel_set_volume(iron_a1_channel_t *channel, float volume) { + IRON_ATOMIC_EXCHANGE_FLOAT(&channel->volume, volume); } -void kinc_a1_channel_set_pitch(kinc_a1_channel_t *channel, float pitch) { - KINC_ATOMIC_EXCHANGE_FLOAT(&channel->pitch, pitch); +void iron_a1_channel_set_pitch(iron_a1_channel_t *channel, float pitch) { + IRON_ATOMIC_EXCHANGE_FLOAT(&channel->pitch, pitch); } #define STB_VORBIS_HEADER_ONLY @@ -268,14 +268,14 @@ static void readFOURCC(uint8_t **data, char *fourcc) { static void readChunk(uint8_t **data, struct WaveData *wave) { char fourcc[5]; readFOURCC(data, fourcc); - uint32_t chunksize = kinc_read_u32le(*data); + uint32_t chunksize = iron_read_u32le(*data); *data += 4; if (strcmp(fourcc, "fmt ") == 0) { - wave->audioFormat = kinc_read_u16le(*data + 0); - wave->numChannels = kinc_read_u16le(*data + 2); - wave->sampleRate = kinc_read_u32le(*data + 4); - wave->bytesPerSecond = kinc_read_u32le(*data + 8); - wave->bitsPerSample = kinc_read_u16le(*data + 14); + wave->audioFormat = iron_read_u16le(*data + 0); + wave->numChannels = iron_read_u16le(*data + 2); + wave->sampleRate = iron_read_u32le(*data + 4); + wave->bytesPerSecond = iron_read_u32le(*data + 8); + wave->bitsPerSample = iron_read_u16le(*data + 14); *data += chunksize; } else if (strcmp(fourcc, "data") == 0) { @@ -322,9 +322,9 @@ static void splitMono16(int16_t *data, int size, int16_t *left, int16_t *right) } #define MAXIMUM_SOUNDS 1024 -static kinc_a1_sound_t sounds[MAXIMUM_SOUNDS] = {0}; +static iron_a1_sound_t sounds[MAXIMUM_SOUNDS] = {0}; -static kinc_a1_sound_t *find_sound(void) { +static iron_a1_sound_t *find_sound(void) { for (int i = 0; i < MAXIMUM_SOUNDS; ++i) { if (!sounds[i].in_use) { return &sounds[i]; @@ -333,8 +333,8 @@ static kinc_a1_sound_t *find_sound(void) { return NULL; } -kinc_a1_sound_t *kinc_a1_sound_create(const char *filename) { - kinc_a1_sound_t *sound = find_sound(); +iron_a1_sound_t *iron_a1_sound_create(const char *filename) { + iron_a1_sound_t *sound = find_sound(); assert(sound != NULL); sound->in_use = true; sound->volume = 1.0f; @@ -345,17 +345,17 @@ kinc_a1_sound_t *kinc_a1_sound_create(const char *filename) { uint8_t *data = NULL; if (strncmp(&filename[filenameLength - 4], ".ogg", 4) == 0) { - kinc_file_reader_t file; - if (!kinc_file_reader_open(&file, filename, KINC_FILE_TYPE_ASSET)) { + iron_file_reader_t file; + if (!iron_file_reader_open(&file, filename, IRON_FILE_TYPE_ASSET)) { sound->in_use = false; return NULL; } - uint8_t *filedata = (uint8_t *)malloc(kinc_file_reader_size(&file)); - kinc_file_reader_read(&file, filedata, kinc_file_reader_size(&file)); - kinc_file_reader_close(&file); + uint8_t *filedata = (uint8_t *)malloc(iron_file_reader_size(&file)); + iron_file_reader_read(&file, filedata, iron_file_reader_size(&file)); + iron_file_reader_close(&file); int channels, sample_rate; - int samples = stb_vorbis_decode_memory(filedata, (int)kinc_file_reader_size(&file), &channels, &sample_rate, (short **)&data); + int samples = stb_vorbis_decode_memory(filedata, (int)iron_file_reader_size(&file), &channels, &sample_rate, (short **)&data); sound->channel_count = (uint8_t)channels; sound->samples_per_second = (uint32_t)sample_rate; sound->size = samples * 2 * sound->channel_count; @@ -365,18 +365,18 @@ kinc_a1_sound_t *kinc_a1_sound_create(const char *filename) { else if (strncmp(&filename[filenameLength - 4], ".wav", 4) == 0) { struct WaveData wave = {0}; { - kinc_file_reader_t file; - if (!kinc_file_reader_open(&file, filename, KINC_FILE_TYPE_ASSET)) { + iron_file_reader_t file; + if (!iron_file_reader_open(&file, filename, IRON_FILE_TYPE_ASSET)) { sound->in_use = false; return NULL; } - uint8_t *filedata = (uint8_t *)malloc(kinc_file_reader_size(&file)); - kinc_file_reader_read(&file, filedata, kinc_file_reader_size(&file)); - kinc_file_reader_close(&file); + uint8_t *filedata = (uint8_t *)malloc(iron_file_reader_size(&file)); + iron_file_reader_read(&file, filedata, iron_file_reader_size(&file)); + iron_file_reader_close(&file); uint8_t *data = filedata; checkFOURCC(&data, "RIFF"); - uint32_t filesize = kinc_read_u32le(data); + uint32_t filesize = iron_read_u32le(data); data += 4; checkFOURCC(&data, "WAVE"); while (data + 8 - filedata < (intptr_t)filesize) { @@ -430,7 +430,7 @@ kinc_a1_sound_t *kinc_a1_sound_create(const char *filename) { return sound; } -void kinc_a1_sound_destroy(kinc_a1_sound_t *sound) { +void iron_a1_sound_destroy(iron_a1_sound_t *sound) { free(sound->left); free(sound->right); sound->left = NULL; @@ -438,35 +438,35 @@ void kinc_a1_sound_destroy(kinc_a1_sound_t *sound) { sound->in_use = false; } -float kinc_a1_sound_volume(kinc_a1_sound_t *sound) { +float iron_a1_sound_volume(iron_a1_sound_t *sound) { return sound->volume; } -void kinc_a1_sound_set_volume(kinc_a1_sound_t *sound, float value) { +void iron_a1_sound_set_volume(iron_a1_sound_t *sound, float value) { sound->volume = value; } -static kinc_a1_sound_stream_t streams[256]; +static iron_a1_sound_stream_t streams[256]; static int nextStream = 0; static uint8_t buffer[1024 * 10]; static int bufferIndex; -kinc_a1_sound_stream_t *kinc_a1_sound_stream_create(const char *filename, bool looping) { - kinc_a1_sound_stream_t *stream = &streams[nextStream]; +iron_a1_sound_stream_t *iron_a1_sound_stream_create(const char *filename, bool looping) { + iron_a1_sound_stream_t *stream = &streams[nextStream]; stream->myLooping = looping; stream->myVolume = 1; stream->rateDecodedHack = false; stream->end = false; - kinc_file_reader_t file; - kinc_file_reader_open(&file, filename, KINC_FILE_TYPE_ASSET); + iron_file_reader_t file; + iron_file_reader_open(&file, filename, IRON_FILE_TYPE_ASSET); stream->buffer = &buffer[bufferIndex]; - bufferIndex += (int)kinc_file_reader_size(&file); - uint8_t *filecontent = (uint8_t *)malloc(kinc_file_reader_size(&file)); - kinc_file_reader_read(&file, filecontent, kinc_file_reader_size(&file)); - kinc_file_reader_close(&file); - memcpy(stream->buffer, filecontent, kinc_file_reader_size(&file)); + bufferIndex += (int)iron_file_reader_size(&file); + uint8_t *filecontent = (uint8_t *)malloc(iron_file_reader_size(&file)); + iron_file_reader_read(&file, filecontent, iron_file_reader_size(&file)); + iron_file_reader_close(&file); + memcpy(stream->buffer, filecontent, iron_file_reader_size(&file)); free(filecontent); - stream->vorbis = stb_vorbis_open_memory(buffer, (int)kinc_file_reader_size(&file), NULL, NULL); + stream->vorbis = stb_vorbis_open_memory(buffer, (int)iron_file_reader_size(&file), NULL, NULL); if (stream->vorbis != NULL) { stb_vorbis_info info = stb_vorbis_get_info(stream->vorbis); stream->chans = info.channels; @@ -480,54 +480,54 @@ kinc_a1_sound_stream_t *kinc_a1_sound_stream_create(const char *filename, bool l return stream; } -int kinc_a1_sound_stream_channels(kinc_a1_sound_stream_t *stream) { +int iron_a1_sound_stream_channels(iron_a1_sound_stream_t *stream) { return stream->chans; } -int kinc_a1_sound_stream_sample_rate(kinc_a1_sound_stream_t *stream) { +int iron_a1_sound_stream_sample_rate(iron_a1_sound_stream_t *stream) { return stream->rate; } -bool kinc_a1_sound_stream_looping(kinc_a1_sound_stream_t *stream) { +bool iron_a1_sound_stream_looping(iron_a1_sound_stream_t *stream) { return stream->myLooping; } -void kinc_a1_sound_stream_set_looping(kinc_a1_sound_stream_t *stream, bool loop) { +void iron_a1_sound_stream_set_looping(iron_a1_sound_stream_t *stream, bool loop) { stream->myLooping = loop; } -float kinc_a1_sound_stream_volume(kinc_a1_sound_stream_t *stream) { +float iron_a1_sound_stream_volume(iron_a1_sound_stream_t *stream) { return stream->myVolume; } -void kinc_a1_sound_stream_set_volume(kinc_a1_sound_stream_t *stream, float value) { +void iron_a1_sound_stream_set_volume(iron_a1_sound_stream_t *stream, float value) { stream->myVolume = value; } -bool kinc_a1_sound_stream_ended(kinc_a1_sound_stream_t *stream) { +bool iron_a1_sound_stream_ended(iron_a1_sound_stream_t *stream) { return stream->end; } -float kinc_a1_sound_stream_length(kinc_a1_sound_stream_t *stream) { +float iron_a1_sound_stream_length(iron_a1_sound_stream_t *stream) { if (stream->vorbis == NULL) return 0; return stb_vorbis_stream_length_in_seconds(stream->vorbis); } -float kinc_a1_sound_stream_position(kinc_a1_sound_stream_t *stream) { +float iron_a1_sound_stream_position(iron_a1_sound_stream_t *stream) { if (stream->vorbis == NULL) return 0; - return stb_vorbis_get_sample_offset(stream->vorbis) / stb_vorbis_stream_length_in_samples(stream->vorbis) * kinc_a1_sound_stream_length(stream); + return stb_vorbis_get_sample_offset(stream->vorbis) / stb_vorbis_stream_length_in_samples(stream->vorbis) * iron_a1_sound_stream_length(stream); } -void kinc_a1_sound_stream_reset(kinc_a1_sound_stream_t *stream) { +void iron_a1_sound_stream_reset(iron_a1_sound_stream_t *stream) { if (stream->vorbis != NULL) stb_vorbis_seek_start(stream->vorbis); stream->end = false; stream->rateDecodedHack = false; } -float *kinc_a1_sound_stream_next_frame(kinc_a1_sound_stream_t *stream) { +float *iron_a1_sound_stream_next_frame(iron_a1_sound_stream_t *stream) { if (stream->vorbis == NULL) { for (int i = 0; i < stream->chans; ++i) { stream->samples[i] = 0; @@ -545,7 +545,7 @@ float *kinc_a1_sound_stream_next_frame(kinc_a1_sound_stream_t *stream) { float *samples_array[2] = {&left, &right}; int read = stb_vorbis_get_samples_float(stream->vorbis, stream->chans, samples_array, 1); if (read == 0) { - if (kinc_a1_sound_stream_looping(stream)) { + if (iron_a1_sound_stream_looping(stream)) { stb_vorbis_seek_start(stream->vorbis); stb_vorbis_get_samples_float(stream->vorbis, stream->chans, samples_array, 1); } @@ -567,6 +567,6 @@ float *kinc_a1_sound_stream_next_frame(kinc_a1_sound_stream_t *stream) { #endif -#define KINC_IMPLEMENTATION_AUDIO2 +#define IRON_IMPLEMENTATION_AUDIO2 #include "iron_audio.h" diff --git a/base/sources/iron_audio.h b/base/sources/iron_audio.h index 82b03bac..68e4f72a 100644 --- a/base/sources/iron_audio.h +++ b/base/sources/iron_audio.h @@ -1,6 +1,6 @@ #pragma once -#ifdef KINC_A1 +#ifdef IRON_A1 #include #include @@ -10,31 +10,31 @@ system audio-API or is implemented based on Audio2. */ -struct kinc_internal_video_sound_stream; +struct iron_internal_video_sound_stream; -struct kinc_a1_channel; -typedef struct kinc_a1_channel kinc_a1_channel_t; +struct iron_a1_channel; +typedef struct iron_a1_channel iron_a1_channel_t; -struct kinc_a1_stream_channel; -typedef struct kinc_a1_stream_channel kinc_a1_stream_channel_t; +struct iron_a1_stream_channel; +typedef struct iron_a1_stream_channel iron_a1_stream_channel_t; -struct kinc_internal_video_channel; -typedef struct kinc_internal_video_channel kinc_internal_video_channel_t; +struct iron_internal_video_channel; +typedef struct iron_internal_video_channel iron_internal_video_channel_t; -void kinc_a1_init(void); -kinc_a1_channel_t *kinc_a1_play_sound(kinc_a1_sound_t *sound, bool loop, float pitch, bool unique); -void kinc_a1_stop_sound(kinc_a1_sound_t *sound); -void kinc_a1_play_sound_stream(kinc_a1_sound_stream_t *stream); -void kinc_a1_stop_sound_stream(kinc_a1_sound_stream_t *stream); -float kinc_a1_channel_get_volume(kinc_a1_channel_t *channel); -void kinc_a1_channel_set_volume(kinc_a1_channel_t *channel, float volume); -void kinc_a1_channel_set_pitch(kinc_a1_channel_t *channel, float pitch); -void kinc_a1_mix(kinc_a2_buffer_t *buffer, uint32_t samples); +void iron_a1_init(void); +iron_a1_channel_t *iron_a1_play_sound(iron_a1_sound_t *sound, bool loop, float pitch, bool unique); +void iron_a1_stop_sound(iron_a1_sound_t *sound); +void iron_a1_play_sound_stream(iron_a1_sound_stream_t *stream); +void iron_a1_stop_sound_stream(iron_a1_sound_stream_t *stream); +float iron_a1_channel_get_volume(iron_a1_channel_t *channel); +void iron_a1_channel_set_volume(iron_a1_channel_t *channel, float volume); +void iron_a1_channel_set_pitch(iron_a1_channel_t *channel, float pitch); +void iron_a1_mix(iron_a2_buffer_t *buffer, uint32_t samples); -void kinc_internal_play_video_sound_stream(struct kinc_internal_video_sound_stream *stream); -void kinc_internal_stop_video_sound_stream(struct kinc_internal_video_sound_stream *stream); +void iron_internal_play_video_sound_stream(struct iron_internal_video_sound_stream *stream); +void iron_internal_stop_video_sound_stream(struct iron_internal_video_sound_stream *stream); -typedef struct kinc_a1_sound { +typedef struct iron_a1_sound { uint8_t channel_count; uint8_t bits_per_sample; uint32_t samples_per_second; @@ -44,16 +44,16 @@ typedef struct kinc_a1_sound { float sample_rate_pos; float volume; bool in_use; -} kinc_a1_sound_t; +} iron_a1_sound_t; -kinc_a1_sound_t *kinc_a1_sound_create(const char *filename); -void kinc_a1_sound_destroy(kinc_a1_sound_t *sound); -float kinc_a1_sound_volume(kinc_a1_sound_t *sound); -void kinc_a1_sound_set_volume(kinc_a1_sound_t *sound, float value); +iron_a1_sound_t *iron_a1_sound_create(const char *filename); +void iron_a1_sound_destroy(iron_a1_sound_t *sound); +float iron_a1_sound_volume(iron_a1_sound_t *sound); +void iron_a1_sound_set_volume(iron_a1_sound_t *sound, float value); struct stb_vorbis; -typedef struct kinc_a1_sound_stream { +typedef struct iron_a1_sound_stream { struct stb_vorbis *vorbis; int chans; int rate; @@ -63,24 +63,24 @@ typedef struct kinc_a1_sound_stream { bool end; float samples[2]; uint8_t *buffer; -} kinc_a1_sound_stream_t; +} iron_a1_sound_stream_t; -kinc_a1_sound_stream_t *kinc_a1_sound_stream_create(const char *filename, bool looping); -float *kinc_a1_sound_stream_next_frame(kinc_a1_sound_stream_t *stream); -int kinc_a1_sound_stream_channels(kinc_a1_sound_stream_t *stream); -int kinc_a1_sound_stream_sample_rate(kinc_a1_sound_stream_t *stream); -bool kinc_a1_sound_stream_looping(kinc_a1_sound_stream_t *stream); -void kinc_a1_sound_stream_set_looping(kinc_a1_sound_stream_t *stream, bool loop); -bool kinc_a1_sound_stream_ended(kinc_a1_sound_stream_t *stream); -float kinc_a1_sound_stream_length(kinc_a1_sound_stream_t *stream); -float kinc_a1_sound_stream_position(kinc_a1_sound_stream_t *stream); -void kinc_a1_sound_stream_reset(kinc_a1_sound_stream_t *stream); -float kinc_a1_sound_stream_volume(kinc_a1_sound_stream_t *stream); -void kinc_a1_sound_stream_set_volume(kinc_a1_sound_stream_t *stream, float value); +iron_a1_sound_stream_t *iron_a1_sound_stream_create(const char *filename, bool looping); +float *iron_a1_sound_stream_next_frame(iron_a1_sound_stream_t *stream); +int iron_a1_sound_stream_channels(iron_a1_sound_stream_t *stream); +int iron_a1_sound_stream_sample_rate(iron_a1_sound_stream_t *stream); +bool iron_a1_sound_stream_looping(iron_a1_sound_stream_t *stream); +void iron_a1_sound_stream_set_looping(iron_a1_sound_stream_t *stream, bool loop); +bool iron_a1_sound_stream_ended(iron_a1_sound_stream_t *stream); +float iron_a1_sound_stream_length(iron_a1_sound_stream_t *stream); +float iron_a1_sound_stream_position(iron_a1_sound_stream_t *stream); +void iron_a1_sound_stream_reset(iron_a1_sound_stream_t *stream); +float iron_a1_sound_stream_volume(iron_a1_sound_stream_t *stream); +void iron_a1_sound_stream_set_volume(iron_a1_sound_stream_t *stream, float value); #endif -#ifdef KINC_A2 +#ifdef IRON_A2 #include @@ -90,79 +90,79 @@ void kinc_a1_sound_stream_set_volume(kinc_a1_sound_stream_t *stream, float value \brief Audio2 is a low-level audio-API that allows you to directly provide a stream of audio-samples. */ -#define KINC_A2_MAX_CHANNELS 8 +#define IRON_A2_MAX_CHANNELS 8 -typedef struct kinc_a2_buffer { +typedef struct iron_a2_buffer { uint8_t channel_count; - float *channels[KINC_A2_MAX_CHANNELS]; + float *channels[IRON_A2_MAX_CHANNELS]; uint32_t data_size; uint32_t read_location; uint32_t write_location; -} kinc_a2_buffer_t; +} iron_a2_buffer_t; -void kinc_a2_init(void); -void kinc_a2_set_callback(void (*kinc_a2_audio_callback)(kinc_a2_buffer_t *buffer, uint32_t samples, void *userdata), void *userdata); -uint32_t kinc_a2_samples_per_second(void); -void kinc_a2_set_sample_rate_callback(void (*kinc_a2_sample_rate_callback)(void *userdata), void *userdata); -void kinc_a2_update(void); -void kinc_a2_shutdown(void); +void iron_a2_init(void); +void iron_a2_set_callback(void (*iron_a2_audio_callback)(iron_a2_buffer_t *buffer, uint32_t samples, void *userdata), void *userdata); +uint32_t iron_a2_samples_per_second(void); +void iron_a2_set_sample_rate_callback(void (*iron_a2_sample_rate_callback)(void *userdata), void *userdata); +void iron_a2_update(void); +void iron_a2_shutdown(void); -void kinc_a2_internal_init(void); -bool kinc_a2_internal_callback(kinc_a2_buffer_t *buffer, int samples); -void kinc_a2_internal_sample_rate_callback(void); +void iron_a2_internal_init(void); +bool iron_a2_internal_callback(iron_a2_buffer_t *buffer, int samples); +void iron_a2_internal_sample_rate_callback(void); -#ifdef KINC_IMPLEMENTATION_AUDIO2 -#define KINC_IMPLEMENTATION +#ifdef IRON_IMPLEMENTATION_AUDIO2 +#define IRON_IMPLEMENTATION #endif -#ifdef KINC_IMPLEMENTATION +#ifdef IRON_IMPLEMENTATION #include #include #include -static kinc_mutex_t mutex; +static iron_mutex_t mutex; -static void (*a2_callback)(kinc_a2_buffer_t *buffer, uint32_t samples, void *userdata) = NULL; +static void (*a2_callback)(iron_a2_buffer_t *buffer, uint32_t samples, void *userdata) = NULL; static void *a2_userdata = NULL; -void kinc_a2_set_callback(void (*kinc_a2_audio_callback)(kinc_a2_buffer_t *buffer, uint32_t samples, void *userdata), void *userdata) { - kinc_mutex_lock(&mutex); - a2_callback = kinc_a2_audio_callback; +void iron_a2_set_callback(void (*iron_a2_audio_callback)(iron_a2_buffer_t *buffer, uint32_t samples, void *userdata), void *userdata) { + iron_mutex_lock(&mutex); + a2_callback = iron_a2_audio_callback; a2_userdata = userdata; - kinc_mutex_unlock(&mutex); + iron_mutex_unlock(&mutex); } static void (*a2_sample_rate_callback)(void *userdata) = NULL; static void *a2_sample_rate_userdata = NULL; -void kinc_a2_set_sample_rate_callback(void (*kinc_a2_sample_rate_callback)(void *userdata), void *userdata) { - kinc_mutex_lock(&mutex); - a2_sample_rate_callback = kinc_a2_sample_rate_callback; +void iron_a2_set_sample_rate_callback(void (*iron_a2_sample_rate_callback)(void *userdata), void *userdata) { + iron_mutex_lock(&mutex); + a2_sample_rate_callback = iron_a2_sample_rate_callback; a2_sample_rate_userdata = userdata; - kinc_mutex_unlock(&mutex); + iron_mutex_unlock(&mutex); } -void kinc_a2_internal_init(void) { - kinc_mutex_init(&mutex); +void iron_a2_internal_init(void) { + iron_mutex_init(&mutex); } -bool kinc_a2_internal_callback(kinc_a2_buffer_t *buffer, int samples) { - kinc_mutex_lock(&mutex); +bool iron_a2_internal_callback(iron_a2_buffer_t *buffer, int samples) { + iron_mutex_lock(&mutex); bool has_callback = a2_callback != NULL; if (has_callback) { a2_callback(buffer, samples, a2_userdata); } - kinc_mutex_unlock(&mutex); + iron_mutex_unlock(&mutex); return has_callback; } -void kinc_a2_internal_sample_rate_callback(void) { - kinc_mutex_lock(&mutex); +void iron_a2_internal_sample_rate_callback(void) { + iron_mutex_lock(&mutex); if (a2_sample_rate_callback != NULL) { a2_sample_rate_callback(a2_sample_rate_userdata); } - kinc_mutex_unlock(&mutex); + iron_mutex_unlock(&mutex); } #endif diff --git a/base/sources/iron_draw.c b/base/sources/iron_draw.c index cb57cac3..5adc3cc7 100644 --- a/base/sources/iron_draw.c +++ b/base/sources/iron_draw.c @@ -9,7 +9,7 @@ #include #include #include "iron_vec2.h" -#ifdef KINC_DIRECT3D12 +#ifdef IRON_DIRECT3D12 extern bool waitAfterNextDraw; #endif @@ -19,34 +19,34 @@ extern bool waitAfterNextDraw; draw_font_t *draw_font = NULL; int draw_font_size; -static kinc_matrix4x4_t draw_projection_matrix; +static iron_matrix4x4_t draw_projection_matrix; static bool draw_bilinear_filter = true; static uint32_t draw_color = 0; static bool draw_is_render_target = false; -static kinc_g5_pipeline_t *draw_last_pipeline = NULL; -static kinc_g5_pipeline_t *draw_custom_pipeline = NULL; -static kinc_matrix3x3_t draw_transform; +static iron_g5_pipeline_t *draw_last_pipeline = NULL; +static iron_g5_pipeline_t *draw_custom_pipeline = NULL; +static iron_matrix3x3_t draw_transform; -static kinc_g4_vertex_buffer_t image_vertex_buffer; -static kinc_g5_index_buffer_t image_index_buffer; -static kinc_g5_shader_t image_vert_shader; -static kinc_g5_shader_t image_frag_shader; -static kinc_g5_pipeline_t image_pipeline; -static kinc_g5_texture_unit_t image_tex_unit; -static kinc_g5_constant_location_t image_proj_loc; +static iron_g4_vertex_buffer_t image_vertex_buffer; +static iron_g5_index_buffer_t image_index_buffer; +static iron_g5_shader_t image_vert_shader; +static iron_g5_shader_t image_frag_shader; +static iron_g5_pipeline_t image_pipeline; +static iron_g5_texture_unit_t image_tex_unit; +static iron_g5_constant_location_t image_proj_loc; static float *image_rect_verts = NULL; static int image_buffer_index = 0; static int image_buffer_start = 0; -static kinc_g5_texture_t *image_last_texture = NULL; +static iron_g5_texture_t *image_last_texture = NULL; -static kinc_g4_vertex_buffer_t colored_rect_vertex_buffer; -static kinc_g5_index_buffer_t colored_rect_index_buffer; -static kinc_g4_vertex_buffer_t colored_tris_vertex_buffer; -static kinc_g5_index_buffer_t colored_tris_index_buffer; -static kinc_g5_shader_t colored_vert_shader; -static kinc_g5_shader_t colored_frag_shader; -static kinc_g5_pipeline_t colored_pipeline; -static kinc_g5_constant_location_t colored_proj_loc; +static iron_g4_vertex_buffer_t colored_rect_vertex_buffer; +static iron_g5_index_buffer_t colored_rect_index_buffer; +static iron_g4_vertex_buffer_t colored_tris_vertex_buffer; +static iron_g5_index_buffer_t colored_tris_index_buffer; +static iron_g5_shader_t colored_vert_shader; +static iron_g5_shader_t colored_frag_shader; +static iron_g5_pipeline_t colored_pipeline; +static iron_g5_constant_location_t colored_proj_loc; static float *colored_rect_verts = NULL; static float *colored_tris_verts = NULL; static int colored_rect_buffer_index = 0; @@ -54,18 +54,18 @@ static int colored_rect_buffer_start = 0; static int colored_tris_buffer_index = 0; static int colored_tris_buffer_start = 0; -static kinc_g4_vertex_buffer_t text_vertex_buffer; -static kinc_g5_index_buffer_t text_index_buffer; -static kinc_g5_shader_t text_vert_shader; -static kinc_g5_shader_t text_frag_shader; -static kinc_g5_pipeline_t text_pipeline; -static kinc_g5_pipeline_t text_pipeline_rt; -static kinc_g5_texture_unit_t text_tex_unit; -static kinc_g5_constant_location_t text_proj_loc; +static iron_g4_vertex_buffer_t text_vertex_buffer; +static iron_g5_index_buffer_t text_index_buffer; +static iron_g5_shader_t text_vert_shader; +static iron_g5_shader_t text_frag_shader; +static iron_g5_pipeline_t text_pipeline; +static iron_g5_pipeline_t text_pipeline_rt; +static iron_g5_texture_unit_t text_tex_unit; +static iron_g5_constant_location_t text_proj_loc; static float *text_rect_verts = NULL; static int text_buffer_index = 0; static int text_buffer_start = 0; -static kinc_g5_texture_t *text_last_texture = NULL; +static iron_g5_texture_t *text_last_texture = NULL; static int *draw_font_glyph_blocks = NULL; static int *draw_font_glyphs = NULL; @@ -78,11 +78,11 @@ void draw_colored_rect_end(bool tris_done); void draw_colored_tris_end(bool rects_done); void draw_text_end(void); -kinc_matrix4x4_t draw_matrix4x4_orthogonal_projection(float left, float right, float bottom, float top, float zn, float zf) { +iron_matrix4x4_t draw_matrix4x4_orthogonal_projection(float left, float right, float bottom, float top, float zn, float zf) { float tx = -(right + left) / (right - left); float ty = -(top + bottom) / (top - bottom); float tz = -(zf + zn) / (zf - zn); - return (kinc_matrix4x4_t) { + return (iron_matrix4x4_t) { 2.0f / (right - left), 0.0f, 0.0f, 0.0f, 0.0f, 2.0f / (top - bottom), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f / (zf - zn), 0.0f, @@ -90,78 +90,78 @@ kinc_matrix4x4_t draw_matrix4x4_orthogonal_projection(float left, float right, f }; } -void draw_matrix3x3_multquad(kinc_matrix3x3_t *m, float qx, float qy, float qw, float qh, kinc_vector2_t *out) { - kinc_float32x4_t xx = kinc_float32x4_load(qx, qx, qx + qw, qx + qw); - kinc_float32x4_t yy = kinc_float32x4_load(qy + qh, qy, qy, qy + qh); +void draw_matrix3x3_multquad(iron_matrix3x3_t *m, float qx, float qy, float qw, float qh, iron_vector2_t *out) { + iron_float32x4_t xx = iron_float32x4_load(qx, qx, qx + qw, qx + qw); + iron_float32x4_t yy = iron_float32x4_load(qy + qh, qy, qy, qy + qh); - kinc_float32x4_t m00 = kinc_float32x4_load_all(m->m[0]); - kinc_float32x4_t m01 = kinc_float32x4_load_all(m->m[1]); - kinc_float32x4_t m02 = kinc_float32x4_load_all(m->m[2]); - kinc_float32x4_t m10 = kinc_float32x4_load_all(m->m[3]); - kinc_float32x4_t m11 = kinc_float32x4_load_all(m->m[4]); - kinc_float32x4_t m12 = kinc_float32x4_load_all(m->m[5]); - kinc_float32x4_t m20 = kinc_float32x4_load_all(m->m[6]); - kinc_float32x4_t m21 = kinc_float32x4_load_all(m->m[7]); - kinc_float32x4_t m22 = kinc_float32x4_load_all(m->m[8]); + iron_float32x4_t m00 = iron_float32x4_load_all(m->m[0]); + iron_float32x4_t m01 = iron_float32x4_load_all(m->m[1]); + iron_float32x4_t m02 = iron_float32x4_load_all(m->m[2]); + iron_float32x4_t m10 = iron_float32x4_load_all(m->m[3]); + iron_float32x4_t m11 = iron_float32x4_load_all(m->m[4]); + iron_float32x4_t m12 = iron_float32x4_load_all(m->m[5]); + iron_float32x4_t m20 = iron_float32x4_load_all(m->m[6]); + iron_float32x4_t m21 = iron_float32x4_load_all(m->m[7]); + iron_float32x4_t m22 = iron_float32x4_load_all(m->m[8]); - kinc_float32x4_t w = kinc_float32x4_add(kinc_float32x4_add(kinc_float32x4_mul(m02, xx), kinc_float32x4_mul(m12, yy)), m22); - kinc_float32x4_t px = kinc_float32x4_div(kinc_float32x4_add(kinc_float32x4_add(kinc_float32x4_mul(m00, xx), kinc_float32x4_mul(m10, yy)), m20), w); - kinc_float32x4_t py = kinc_float32x4_div(kinc_float32x4_add(kinc_float32x4_add(kinc_float32x4_mul(m01, xx), kinc_float32x4_mul(m11, yy)), m21), w); + iron_float32x4_t w = iron_float32x4_add(iron_float32x4_add(iron_float32x4_mul(m02, xx), iron_float32x4_mul(m12, yy)), m22); + iron_float32x4_t px = iron_float32x4_div(iron_float32x4_add(iron_float32x4_add(iron_float32x4_mul(m00, xx), iron_float32x4_mul(m10, yy)), m20), w); + iron_float32x4_t py = iron_float32x4_div(iron_float32x4_add(iron_float32x4_add(iron_float32x4_mul(m01, xx), iron_float32x4_mul(m11, yy)), m21), w); - out[0] = (kinc_vector2_t){kinc_float32x4_get(px, 0), kinc_float32x4_get(py, 0)}; - out[1] = (kinc_vector2_t){kinc_float32x4_get(px, 1), kinc_float32x4_get(py, 1)}; - out[2] = (kinc_vector2_t){kinc_float32x4_get(px, 2), kinc_float32x4_get(py, 2)}; - out[3] = (kinc_vector2_t){kinc_float32x4_get(px, 3), kinc_float32x4_get(py, 3)}; + out[0] = (iron_vector2_t){iron_float32x4_get(px, 0), iron_float32x4_get(py, 0)}; + out[1] = (iron_vector2_t){iron_float32x4_get(px, 1), iron_float32x4_get(py, 1)}; + out[2] = (iron_vector2_t){iron_float32x4_get(px, 2), iron_float32x4_get(py, 2)}; + out[3] = (iron_vector2_t){iron_float32x4_get(px, 3), iron_float32x4_get(py, 3)}; } -kinc_vector2_t draw_matrix3x3_multvec(kinc_matrix3x3_t *m, kinc_vector2_t v) { +iron_vector2_t draw_matrix3x3_multvec(iron_matrix3x3_t *m, iron_vector2_t v) { float w = m->m[2] * v.x + m->m[5] * v.y + m->m[8] * 1.0f; float x = (m->m[0] * v.x + m->m[3] * v.y + m->m[6] * 1.0f) / w; float y = (m->m[1] * v.x + m->m[4] * v.y + m->m[7] * 1.0f) / w; - return (kinc_vector2_t){x, y}; + return (iron_vector2_t){x, y}; } -void draw_internal_set_projection_matrix(kinc_g5_texture_t *target) { +void draw_internal_set_projection_matrix(iron_g5_texture_t *target) { if (target != NULL) { draw_projection_matrix = draw_matrix4x4_orthogonal_projection(0.0f, (float)target->width, (float)target->height, 0.0f, 0.1f, 1000.0f); } else { - draw_projection_matrix = draw_matrix4x4_orthogonal_projection(0.0f, (float)kinc_window_width(), (float)kinc_window_height(), 0.0f, 0.1f, 1000.0f); + draw_projection_matrix = draw_matrix4x4_orthogonal_projection(0.0f, (float)iron_window_width(), (float)iron_window_height(), 0.0f, 0.1f, 1000.0f); } } void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *colored_vert, buffer_t *colored_frag, buffer_t *text_vert, buffer_t *text_frag) { draw_internal_set_projection_matrix(NULL); - draw_transform = kinc_matrix3x3_identity(); + draw_transform = iron_matrix3x3_identity(); // Image painter - kinc_g5_shader_init(&image_vert_shader, image_vert->buffer, image_vert->length, KINC_G5_SHADER_TYPE_VERTEX); - kinc_g5_shader_init(&image_frag_shader, image_frag->buffer, image_frag->length, KINC_G5_SHADER_TYPE_FRAGMENT); + iron_g5_shader_init(&image_vert_shader, image_vert->buffer, image_vert->length, IRON_G5_SHADER_TYPE_VERTEX); + iron_g5_shader_init(&image_frag_shader, image_frag->buffer, image_frag->length, IRON_G5_SHADER_TYPE_FRAGMENT); { - kinc_g5_vertex_structure_t structure; - kinc_g5_vertex_structure_init(&structure); - kinc_g5_vertex_structure_add(&structure, "pos", KINC_G5_VERTEX_DATA_F32_3X); - kinc_g5_vertex_structure_add(&structure, "tex", KINC_G5_VERTEX_DATA_F32_2X); - kinc_g5_vertex_structure_add(&structure, "col", KINC_G5_VERTEX_DATA_U8_4X_NORM); - kinc_g5_pipeline_init(&image_pipeline); + iron_g5_vertex_structure_t structure; + iron_g5_vertex_structure_init(&structure); + iron_g5_vertex_structure_add(&structure, "pos", IRON_G5_VERTEX_DATA_F32_3X); + iron_g5_vertex_structure_add(&structure, "tex", IRON_G5_VERTEX_DATA_F32_2X); + iron_g5_vertex_structure_add(&structure, "col", IRON_G5_VERTEX_DATA_U8_4X_NORM); + iron_g5_pipeline_init(&image_pipeline); image_pipeline.input_layout = &structure; image_pipeline.vertex_shader = &image_vert_shader; image_pipeline.fragment_shader = &image_frag_shader; - image_pipeline.blend_source = KINC_G5_BLEND_ONE; - image_pipeline.blend_destination = KINC_G5_BLEND_INV_SOURCE_ALPHA; - image_pipeline.alpha_blend_source = KINC_G5_BLEND_ONE; - image_pipeline.alpha_blend_destination = KINC_G5_BLEND_INV_SOURCE_ALPHA; - kinc_g5_pipeline_compile(&image_pipeline); + image_pipeline.blend_source = IRON_G5_BLEND_ONE; + image_pipeline.blend_destination = IRON_G5_BLEND_INV_SOURCE_ALPHA; + image_pipeline.alpha_blend_source = IRON_G5_BLEND_ONE; + image_pipeline.alpha_blend_destination = IRON_G5_BLEND_INV_SOURCE_ALPHA; + iron_g5_pipeline_compile(&image_pipeline); - image_tex_unit = kinc_g5_pipeline_get_texture_unit(&image_pipeline, "tex"); - image_proj_loc = kinc_g5_pipeline_get_constant_location(&image_pipeline, "P"); + image_tex_unit = iron_g5_pipeline_get_texture_unit(&image_pipeline, "tex"); + image_proj_loc = iron_g5_pipeline_get_constant_location(&image_pipeline, "P"); - kinc_g4_vertex_buffer_init(&image_vertex_buffer, DRAW_BUFFER_SIZE * 4, &structure, KINC_G4_USAGE_DYNAMIC); - image_rect_verts = kinc_g4_vertex_buffer_lock_all(&image_vertex_buffer); + iron_g4_vertex_buffer_init(&image_vertex_buffer, DRAW_BUFFER_SIZE * 4, &structure, IRON_G4_USAGE_DYNAMIC); + image_rect_verts = iron_g4_vertex_buffer_lock_all(&image_vertex_buffer); - kinc_g5_index_buffer_init(&image_index_buffer, DRAW_BUFFER_SIZE * 3 * 2, true); - int *indices = kinc_g5_index_buffer_lock_all(&image_index_buffer); + iron_g5_index_buffer_init(&image_index_buffer, DRAW_BUFFER_SIZE * 3 * 2, true); + int *indices = iron_g5_index_buffer_lock_all(&image_index_buffer); for (int i = 0; i < DRAW_BUFFER_SIZE; ++i) { indices[i * 3 * 2 + 0] = i * 4 + 0; indices[i * 3 * 2 + 1] = i * 4 + 1; @@ -170,36 +170,36 @@ void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *colored_ver indices[i * 3 * 2 + 4] = i * 4 + 2; indices[i * 3 * 2 + 5] = i * 4 + 3; } - kinc_g4_index_buffer_unlock_all(&image_index_buffer); + iron_g4_index_buffer_unlock_all(&image_index_buffer); } // Colored painter - kinc_g5_shader_init(&colored_vert_shader, colored_vert->buffer, colored_vert->length, KINC_G5_SHADER_TYPE_VERTEX); - kinc_g5_shader_init(&colored_frag_shader, colored_frag->buffer, colored_frag->length, KINC_G5_SHADER_TYPE_FRAGMENT); + iron_g5_shader_init(&colored_vert_shader, colored_vert->buffer, colored_vert->length, IRON_G5_SHADER_TYPE_VERTEX); + iron_g5_shader_init(&colored_frag_shader, colored_frag->buffer, colored_frag->length, IRON_G5_SHADER_TYPE_FRAGMENT); { - kinc_g5_vertex_structure_t structure; - kinc_g5_vertex_structure_init(&structure); - kinc_g5_vertex_structure_add(&structure, "pos", KINC_G5_VERTEX_DATA_F32_3X); - kinc_g5_vertex_structure_add(&structure, "col", KINC_G5_VERTEX_DATA_U8_4X_NORM); - kinc_g5_pipeline_init(&colored_pipeline); + iron_g5_vertex_structure_t structure; + iron_g5_vertex_structure_init(&structure); + iron_g5_vertex_structure_add(&structure, "pos", IRON_G5_VERTEX_DATA_F32_3X); + iron_g5_vertex_structure_add(&structure, "col", IRON_G5_VERTEX_DATA_U8_4X_NORM); + iron_g5_pipeline_init(&colored_pipeline); colored_pipeline.input_layout = &structure; colored_pipeline.vertex_shader = &colored_vert_shader; colored_pipeline.fragment_shader = &colored_frag_shader; - // colored_pipeline.blend_source = KINC_G5_BLEND_ONE; - colored_pipeline.blend_source = KINC_G5_BLEND_SOURCE_ALPHA; - colored_pipeline.blend_destination = KINC_G5_BLEND_INV_SOURCE_ALPHA; - colored_pipeline.alpha_blend_source = KINC_G5_BLEND_ONE; - colored_pipeline.alpha_blend_destination = KINC_G5_BLEND_INV_SOURCE_ALPHA; - kinc_g5_pipeline_compile(&colored_pipeline); + // colored_pipeline.blend_source = IRON_G5_BLEND_ONE; + colored_pipeline.blend_source = IRON_G5_BLEND_SOURCE_ALPHA; + colored_pipeline.blend_destination = IRON_G5_BLEND_INV_SOURCE_ALPHA; + colored_pipeline.alpha_blend_source = IRON_G5_BLEND_ONE; + colored_pipeline.alpha_blend_destination = IRON_G5_BLEND_INV_SOURCE_ALPHA; + iron_g5_pipeline_compile(&colored_pipeline); - colored_proj_loc = kinc_g5_pipeline_get_constant_location(&colored_pipeline, "P"); + colored_proj_loc = iron_g5_pipeline_get_constant_location(&colored_pipeline, "P"); - kinc_g4_vertex_buffer_init(&colored_rect_vertex_buffer, DRAW_BUFFER_SIZE * 4, &structure, KINC_G4_USAGE_DYNAMIC); - colored_rect_verts = kinc_g4_vertex_buffer_lock_all(&colored_rect_vertex_buffer); + iron_g4_vertex_buffer_init(&colored_rect_vertex_buffer, DRAW_BUFFER_SIZE * 4, &structure, IRON_G4_USAGE_DYNAMIC); + colored_rect_verts = iron_g4_vertex_buffer_lock_all(&colored_rect_vertex_buffer); - kinc_g5_index_buffer_init(&colored_rect_index_buffer, DRAW_BUFFER_SIZE * 3 * 2, true); - int *indices = kinc_g5_index_buffer_lock_all(&colored_rect_index_buffer); + iron_g5_index_buffer_init(&colored_rect_index_buffer, DRAW_BUFFER_SIZE * 3 * 2, true); + int *indices = iron_g5_index_buffer_lock_all(&colored_rect_index_buffer); for (int i = 0; i < DRAW_BUFFER_SIZE; ++i) { indices[i * 3 * 2 + 0] = i * 4 + 0; indices[i * 3 * 2 + 1] = i * 4 + 1; @@ -208,59 +208,59 @@ void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *colored_ver indices[i * 3 * 2 + 4] = i * 4 + 2; indices[i * 3 * 2 + 5] = i * 4 + 3; } - kinc_g4_index_buffer_unlock_all(&colored_rect_index_buffer); + iron_g4_index_buffer_unlock_all(&colored_rect_index_buffer); - kinc_g4_vertex_buffer_init(&colored_tris_vertex_buffer, DRAW_BUFFER_SIZE * 3, &structure, KINC_G4_USAGE_DYNAMIC); - colored_tris_verts = kinc_g4_vertex_buffer_lock_all(&colored_tris_vertex_buffer); + iron_g4_vertex_buffer_init(&colored_tris_vertex_buffer, DRAW_BUFFER_SIZE * 3, &structure, IRON_G4_USAGE_DYNAMIC); + colored_tris_verts = iron_g4_vertex_buffer_lock_all(&colored_tris_vertex_buffer); - kinc_g5_index_buffer_init(&colored_tris_index_buffer, DRAW_BUFFER_SIZE * 3, true); - indices = kinc_g5_index_buffer_lock_all(&colored_tris_index_buffer); + iron_g5_index_buffer_init(&colored_tris_index_buffer, DRAW_BUFFER_SIZE * 3, true); + indices = iron_g5_index_buffer_lock_all(&colored_tris_index_buffer); for (int i = 0; i < DRAW_BUFFER_SIZE; ++i) { indices[i * 3 + 0] = i * 3 + 0; indices[i * 3 + 1] = i * 3 + 1; indices[i * 3 + 2] = i * 3 + 2; } - kinc_g4_index_buffer_unlock_all(&colored_tris_index_buffer); + iron_g4_index_buffer_unlock_all(&colored_tris_index_buffer); } // Text painter - kinc_g5_shader_init(&text_vert_shader, text_vert->buffer, text_vert->length, KINC_G5_SHADER_TYPE_VERTEX); - kinc_g5_shader_init(&text_frag_shader, text_frag->buffer, text_frag->length, KINC_G5_SHADER_TYPE_FRAGMENT); + iron_g5_shader_init(&text_vert_shader, text_vert->buffer, text_vert->length, IRON_G5_SHADER_TYPE_VERTEX); + iron_g5_shader_init(&text_frag_shader, text_frag->buffer, text_frag->length, IRON_G5_SHADER_TYPE_FRAGMENT); { - kinc_g5_vertex_structure_t structure; - kinc_g5_vertex_structure_init(&structure); - kinc_g5_vertex_structure_add(&structure, "pos", KINC_G5_VERTEX_DATA_F32_3X); - kinc_g5_vertex_structure_add(&structure, "tex", KINC_G5_VERTEX_DATA_F32_2X); - kinc_g5_vertex_structure_add(&structure, "col", KINC_G5_VERTEX_DATA_U8_4X_NORM); + iron_g5_vertex_structure_t structure; + iron_g5_vertex_structure_init(&structure); + iron_g5_vertex_structure_add(&structure, "pos", IRON_G5_VERTEX_DATA_F32_3X); + iron_g5_vertex_structure_add(&structure, "tex", IRON_G5_VERTEX_DATA_F32_2X); + iron_g5_vertex_structure_add(&structure, "col", IRON_G5_VERTEX_DATA_U8_4X_NORM); - kinc_g5_pipeline_init(&text_pipeline); + iron_g5_pipeline_init(&text_pipeline); text_pipeline.input_layout = &structure; text_pipeline.vertex_shader = &text_vert_shader; text_pipeline.fragment_shader = &text_frag_shader; - text_pipeline.blend_source = KINC_G5_BLEND_SOURCE_ALPHA; - text_pipeline.blend_destination = KINC_G5_BLEND_INV_SOURCE_ALPHA; - text_pipeline.alpha_blend_source = KINC_G5_BLEND_SOURCE_ALPHA; - text_pipeline.alpha_blend_destination = KINC_G5_BLEND_INV_SOURCE_ALPHA; - kinc_g5_pipeline_compile(&text_pipeline); - text_tex_unit = kinc_g5_pipeline_get_texture_unit(&text_pipeline, "tex"); - text_proj_loc = kinc_g5_pipeline_get_constant_location(&text_pipeline, "P"); + text_pipeline.blend_source = IRON_G5_BLEND_SOURCE_ALPHA; + text_pipeline.blend_destination = IRON_G5_BLEND_INV_SOURCE_ALPHA; + text_pipeline.alpha_blend_source = IRON_G5_BLEND_SOURCE_ALPHA; + text_pipeline.alpha_blend_destination = IRON_G5_BLEND_INV_SOURCE_ALPHA; + iron_g5_pipeline_compile(&text_pipeline); + text_tex_unit = iron_g5_pipeline_get_texture_unit(&text_pipeline, "tex"); + text_proj_loc = iron_g5_pipeline_get_constant_location(&text_pipeline, "P"); - kinc_g5_pipeline_init(&text_pipeline_rt); + iron_g5_pipeline_init(&text_pipeline_rt); text_pipeline_rt.input_layout = &structure; text_pipeline_rt.vertex_shader = &text_vert_shader; text_pipeline_rt.fragment_shader = &text_frag_shader; - text_pipeline_rt.blend_source = KINC_G5_BLEND_SOURCE_ALPHA; - text_pipeline_rt.blend_destination = KINC_G5_BLEND_INV_SOURCE_ALPHA; - text_pipeline_rt.alpha_blend_source = KINC_G5_BLEND_ONE; - text_pipeline_rt.alpha_blend_destination = KINC_G5_BLEND_INV_SOURCE_ALPHA; - kinc_g5_pipeline_compile(&text_pipeline_rt); + text_pipeline_rt.blend_source = IRON_G5_BLEND_SOURCE_ALPHA; + text_pipeline_rt.blend_destination = IRON_G5_BLEND_INV_SOURCE_ALPHA; + text_pipeline_rt.alpha_blend_source = IRON_G5_BLEND_ONE; + text_pipeline_rt.alpha_blend_destination = IRON_G5_BLEND_INV_SOURCE_ALPHA; + iron_g5_pipeline_compile(&text_pipeline_rt); - kinc_g4_vertex_buffer_init(&text_vertex_buffer, DRAW_BUFFER_SIZE * 4, &structure, KINC_G4_USAGE_DYNAMIC); - text_rect_verts = kinc_g4_vertex_buffer_lock_all(&text_vertex_buffer); + iron_g4_vertex_buffer_init(&text_vertex_buffer, DRAW_BUFFER_SIZE * 4, &structure, IRON_G4_USAGE_DYNAMIC); + text_rect_verts = iron_g4_vertex_buffer_lock_all(&text_vertex_buffer); - kinc_g5_index_buffer_init(&text_index_buffer, DRAW_BUFFER_SIZE * 3 * 2, true); - int *indices = kinc_g5_index_buffer_lock_all(&text_index_buffer); + iron_g5_index_buffer_init(&text_index_buffer, DRAW_BUFFER_SIZE * 3 * 2, true); + int *indices = iron_g5_index_buffer_lock_all(&text_index_buffer); for (int i = 0; i < DRAW_BUFFER_SIZE; ++i) { indices[i * 3 * 2 + 0] = i * 4 + 0; indices[i * 3 * 2 + 1] = i * 4 + 1; @@ -269,7 +269,7 @@ void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *colored_ver indices[i * 3 * 2 + 4] = i * 4 + 2; indices[i * 3 * 2 + 5] = i * 4 + 3; } - kinc_g4_index_buffer_unlock_all(&text_index_buffer); + iron_g4_index_buffer_unlock_all(&text_index_buffer); } } @@ -322,32 +322,32 @@ void draw_set_image_rect_colors(uint32_t color) { void draw_image_buffer(bool end) { if (image_buffer_index - image_buffer_start == 0) return; - kinc_g4_vertex_buffer_unlock(&image_vertex_buffer, (image_buffer_index - image_buffer_start) * 4); - kinc_g5_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &image_pipeline); - kinc_g4_set_matrix4(image_proj_loc, &draw_projection_matrix); - kinc_g4_set_vertex_buffer(&image_vertex_buffer); - kinc_g4_set_index_buffer(&image_index_buffer); - kinc_g4_set_texture(image_tex_unit, image_last_texture); - kinc_g4_set_texture_addressing(image_tex_unit, KINC_G4_TEXTURE_DIRECTION_U, KINC_G4_TEXTURE_ADDRESSING_CLAMP); - kinc_g4_set_texture_addressing(image_tex_unit, KINC_G4_TEXTURE_DIRECTION_V, KINC_G4_TEXTURE_ADDRESSING_CLAMP); - // kinc_g4_set_texture_mipmap_filter(image_tex_unit, draw_bilinear_filter ? KINC_G4_MIPMAP_FILTER_LINEAR : KINC_G4_MIPMAP_FILTER_NONE); - kinc_g4_set_texture_mipmap_filter(image_tex_unit, KINC_G4_MIPMAP_FILTER_NONE); - kinc_g4_set_texture_minification_filter(image_tex_unit, draw_bilinear_filter ? KINC_G4_TEXTURE_FILTER_LINEAR : KINC_G4_TEXTURE_FILTER_POINT); - kinc_g4_set_texture_magnification_filter(image_tex_unit, draw_bilinear_filter ? KINC_G4_TEXTURE_FILTER_LINEAR : KINC_G4_TEXTURE_FILTER_POINT); - kinc_g5_draw_indexed_vertices_from_to(image_buffer_start * 2 * 3, (image_buffer_index - image_buffer_start) * 2 * 3); + iron_g4_vertex_buffer_unlock(&image_vertex_buffer, (image_buffer_index - image_buffer_start) * 4); + iron_g5_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &image_pipeline); + iron_g4_set_matrix4(image_proj_loc, &draw_projection_matrix); + iron_g4_set_vertex_buffer(&image_vertex_buffer); + iron_g4_set_index_buffer(&image_index_buffer); + iron_g4_set_texture(image_tex_unit, image_last_texture); + iron_g4_set_texture_addressing(image_tex_unit, IRON_G4_TEXTURE_DIRECTION_U, IRON_G4_TEXTURE_ADDRESSING_CLAMP); + iron_g4_set_texture_addressing(image_tex_unit, IRON_G4_TEXTURE_DIRECTION_V, IRON_G4_TEXTURE_ADDRESSING_CLAMP); + // iron_g4_set_texture_mipmap_filter(image_tex_unit, draw_bilinear_filter ? IRON_G4_MIPMAP_FILTER_LINEAR : IRON_G4_MIPMAP_FILTER_NONE); + iron_g4_set_texture_mipmap_filter(image_tex_unit, IRON_G4_MIPMAP_FILTER_NONE); + iron_g4_set_texture_minification_filter(image_tex_unit, draw_bilinear_filter ? IRON_G4_TEXTURE_FILTER_LINEAR : IRON_G4_TEXTURE_FILTER_POINT); + iron_g4_set_texture_magnification_filter(image_tex_unit, draw_bilinear_filter ? IRON_G4_TEXTURE_FILTER_LINEAR : IRON_G4_TEXTURE_FILTER_POINT); + iron_g5_draw_indexed_vertices_from_to(image_buffer_start * 2 * 3, (image_buffer_index - image_buffer_start) * 2 * 3); if (end || image_buffer_index + 1 >= DRAW_BUFFER_SIZE) { image_buffer_start = 0; image_buffer_index = 0; - image_rect_verts = kinc_g4_vertex_buffer_lock(&image_vertex_buffer, 0, DRAW_BUFFER_SIZE * 4); + image_rect_verts = iron_g4_vertex_buffer_lock(&image_vertex_buffer, 0, DRAW_BUFFER_SIZE * 4); } else { image_buffer_start = image_buffer_index; - image_rect_verts = kinc_g4_vertex_buffer_lock(&image_vertex_buffer, image_buffer_start * 4, (DRAW_BUFFER_SIZE - image_buffer_start) * 4); + image_rect_verts = iron_g4_vertex_buffer_lock(&image_vertex_buffer, image_buffer_start * 4, (DRAW_BUFFER_SIZE - image_buffer_start) * 4); } } -void draw_scaled_sub_texture(kinc_g5_texture_t *tex, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { +void draw_scaled_sub_texture(iron_g5_texture_t *tex, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { draw_colored_end(); draw_text_end(); if (image_buffer_start + image_buffer_index + 1 >= DRAW_BUFFER_SIZE || @@ -357,7 +357,7 @@ void draw_scaled_sub_texture(kinc_g5_texture_t *tex, float sx, float sy, float s draw_set_image_rect_tex_coords(sx / tex->width, sy / tex->height, (sx + sw) / tex->width, (sy + sh) / tex->height); draw_set_image_rect_colors(draw_color); - kinc_vector2_t p[4]; + iron_vector2_t p[4]; draw_matrix3x3_multquad(&draw_transform, dx, dy, dw, dh, p); draw_set_image_rect_verts(p[0].x, p[0].y, p[1].x, p[1].y, p[2].x, p[2].y, p[3].x, p[3].y); @@ -365,34 +365,34 @@ void draw_scaled_sub_texture(kinc_g5_texture_t *tex, float sx, float sy, float s image_last_texture = tex; } -void draw_scaled_texture(kinc_g5_texture_t *tex, float dx, float dy, float dw, float dh) { +void draw_scaled_texture(iron_g5_texture_t *tex, float dx, float dy, float dw, float dh) { draw_scaled_sub_texture(tex, 0, 0, (float)tex->width, (float)tex->height, dx, dy, dw, dh); } -void draw_sub_texture(kinc_g5_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y) { +void draw_sub_texture(iron_g5_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y) { draw_scaled_sub_texture(tex, sx, sy, sw, sh, x, y, sw, sh); } -void draw_texture(kinc_g5_texture_t *tex, float x, float y) { +void draw_texture(iron_g5_texture_t *tex, float x, float y) { draw_scaled_sub_texture(tex, 0, 0, (float)tex->width, (float)tex->height, x, y, (float)tex->width, (float)tex->height); } -void draw_scaled_sub_image(kinc_g5_texture_t *image, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { - #ifdef KINC_DIRECT3D12 +void draw_scaled_sub_image(iron_g5_texture_t *image, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { + #ifdef IRON_DIRECT3D12 waitAfterNextDraw = true; #endif draw_scaled_sub_texture(image, sx, sy, sw, sh, dx, dy, dw, dh); } -void draw_scaled_image(kinc_g5_texture_t *tex, float dx, float dy, float dw, float dh) { +void draw_scaled_image(iron_g5_texture_t *tex, float dx, float dy, float dw, float dh) { draw_scaled_sub_image(tex, 0, 0, (float)tex->width, (float)tex->height, dx, dy, dw, dh); } -void draw_sub_image(kinc_g5_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y) { +void draw_sub_image(iron_g5_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y) { draw_scaled_sub_image(tex, sx, sy, sw, sh, x, y, sw, sh); } -void draw_image(kinc_g5_texture_t *tex, float x, float y) { +void draw_image(iron_g5_texture_t *tex, float x, float y) { draw_scaled_sub_image(tex, 0, 0, (float)tex->width, (float)tex->height, x, y, (float)tex->width, (float)tex->height); } @@ -431,21 +431,21 @@ void draw_colored_rect_draw_buffer(bool tris_done) { if (!tris_done) draw_colored_tris_end(true); - kinc_g4_vertex_buffer_unlock(&colored_rect_vertex_buffer, (colored_rect_buffer_index - colored_rect_buffer_start) * 4); - kinc_g5_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &colored_pipeline); - kinc_g4_set_matrix4(colored_proj_loc, &draw_projection_matrix); - kinc_g4_set_vertex_buffer(&colored_rect_vertex_buffer); - kinc_g4_set_index_buffer(&colored_rect_index_buffer); - kinc_g5_draw_indexed_vertices_from_to(colored_rect_buffer_start * 2 * 3, (colored_rect_buffer_index - colored_rect_buffer_start) * 2 * 3); + iron_g4_vertex_buffer_unlock(&colored_rect_vertex_buffer, (colored_rect_buffer_index - colored_rect_buffer_start) * 4); + iron_g5_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &colored_pipeline); + iron_g4_set_matrix4(colored_proj_loc, &draw_projection_matrix); + iron_g4_set_vertex_buffer(&colored_rect_vertex_buffer); + iron_g4_set_index_buffer(&colored_rect_index_buffer); + iron_g5_draw_indexed_vertices_from_to(colored_rect_buffer_start * 2 * 3, (colored_rect_buffer_index - colored_rect_buffer_start) * 2 * 3); if (colored_rect_buffer_index + 1 >= DRAW_BUFFER_SIZE) { colored_rect_buffer_start = 0; colored_rect_buffer_index = 0; - colored_rect_verts = kinc_g4_vertex_buffer_lock(&colored_rect_vertex_buffer, 0, DRAW_BUFFER_SIZE * 4); + colored_rect_verts = iron_g4_vertex_buffer_lock(&colored_rect_vertex_buffer, 0, DRAW_BUFFER_SIZE * 4); } else { colored_rect_buffer_start = colored_rect_buffer_index; - colored_rect_verts = kinc_g4_vertex_buffer_lock(&colored_rect_vertex_buffer, colored_rect_buffer_start * 4, (DRAW_BUFFER_SIZE - colored_rect_buffer_start) * 4); + colored_rect_verts = iron_g4_vertex_buffer_lock(&colored_rect_vertex_buffer, colored_rect_buffer_start * 4, (DRAW_BUFFER_SIZE - colored_rect_buffer_start) * 4); } } @@ -479,21 +479,21 @@ void draw_colored_tris_draw_buffer(bool rect_done) { if (!rect_done) draw_colored_rect_end(true); - kinc_g4_vertex_buffer_unlock(&colored_tris_vertex_buffer, (colored_tris_buffer_index - colored_tris_buffer_start) * 3); - kinc_g5_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &colored_pipeline); - kinc_g4_set_matrix4(colored_proj_loc, &draw_projection_matrix); - kinc_g4_set_vertex_buffer(&colored_tris_vertex_buffer); - kinc_g4_set_index_buffer(&colored_tris_index_buffer); - kinc_g5_draw_indexed_vertices_from_to(colored_tris_buffer_start * 3, (colored_tris_buffer_index - colored_tris_buffer_start) * 3); + iron_g4_vertex_buffer_unlock(&colored_tris_vertex_buffer, (colored_tris_buffer_index - colored_tris_buffer_start) * 3); + iron_g5_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &colored_pipeline); + iron_g4_set_matrix4(colored_proj_loc, &draw_projection_matrix); + iron_g4_set_vertex_buffer(&colored_tris_vertex_buffer); + iron_g4_set_index_buffer(&colored_tris_index_buffer); + iron_g5_draw_indexed_vertices_from_to(colored_tris_buffer_start * 3, (colored_tris_buffer_index - colored_tris_buffer_start) * 3); if (colored_tris_buffer_index + 1 >= DRAW_BUFFER_SIZE) { colored_tris_buffer_start = 0; colored_tris_buffer_index = 0; - colored_tris_verts = kinc_g4_vertex_buffer_lock(&colored_tris_vertex_buffer, 0, DRAW_BUFFER_SIZE * 3); + colored_tris_verts = iron_g4_vertex_buffer_lock(&colored_tris_vertex_buffer, 0, DRAW_BUFFER_SIZE * 3); } else { colored_tris_buffer_start = colored_tris_buffer_index; - colored_tris_verts = kinc_g4_vertex_buffer_lock(&colored_tris_vertex_buffer, colored_tris_buffer_start * 3, (DRAW_BUFFER_SIZE - colored_tris_buffer_start) * 3); + colored_tris_verts = iron_g4_vertex_buffer_lock(&colored_tris_vertex_buffer, colored_tris_buffer_start * 3, (DRAW_BUFFER_SIZE - colored_tris_buffer_start) * 3); } } @@ -513,9 +513,9 @@ void draw_filled_triangle(float x0, float y0, float x1, float y1, float x2, floa draw_colored_tris_set_colors(draw_color); - kinc_vector2_t p0 = draw_matrix3x3_multvec(&draw_transform, (kinc_vector2_t){x0, y0}); // Bottom-left - kinc_vector2_t p1 = draw_matrix3x3_multvec(&draw_transform, (kinc_vector2_t){x1, y1}); // Top-left - kinc_vector2_t p2 = draw_matrix3x3_multvec(&draw_transform, (kinc_vector2_t){x2, y2}); // Top-right + iron_vector2_t p0 = draw_matrix3x3_multvec(&draw_transform, (iron_vector2_t){x0, y0}); // Bottom-left + iron_vector2_t p1 = draw_matrix3x3_multvec(&draw_transform, (iron_vector2_t){x1, y1}); // Top-left + iron_vector2_t p2 = draw_matrix3x3_multvec(&draw_transform, (iron_vector2_t){x2, y2}); // Top-right draw_colored_tris_set_verts(p0.x, p0.y, p1.x, p1.y, p2.x, p2.y); ++colored_tris_buffer_index; @@ -529,7 +529,7 @@ void draw_filled_rect(float x, float y, float width, float height) { draw_colored_rect_set_colors(draw_color); - kinc_vector2_t p[4]; + iron_vector2_t p[4]; draw_matrix3x3_multquad(&draw_transform, x, y, width, height, p); draw_colored_rect_set_verts(p[0].x, p[0].y, p[1].x, p[1].y, p[2].x, p[2].y, p[3].x, p[3].y); @@ -545,12 +545,12 @@ void draw_rect(float x, float y, float width, float height, float strength) { } void draw_line(float x0, float y0, float x1, float y1, float strength) { - kinc_vector2_t vec; + iron_vector2_t vec; if (y1 == y0) { - vec = (kinc_vector2_t){0.0f, -1.0f}; + vec = (iron_vector2_t){0.0f, -1.0f}; } else { - vec = (kinc_vector2_t){1.0f, -(x1 - x0) / (y1 - y0)}; + vec = (iron_vector2_t){1.0f, -(x1 - x0) / (y1 - y0)}; } float current_length = sqrtf(vec.x * vec.x + vec.y * vec.y); @@ -560,10 +560,10 @@ void draw_line(float x0, float y0, float x1, float y1, float strength) { vec.y *= mul; } - kinc_vector2_t p0 = (kinc_vector2_t){x0 + 0.5f * vec.x, y0 + 0.5f * vec.y}; - kinc_vector2_t p1 = (kinc_vector2_t){x1 + 0.5f * vec.x, y1 + 0.5f * vec.y}; - kinc_vector2_t p2 = (kinc_vector2_t){p0.x - vec.x, p0.y - vec.y}; - kinc_vector2_t p3 = (kinc_vector2_t){p1.x - vec.x, p1.y - vec.y}; + iron_vector2_t p0 = (iron_vector2_t){x0 + 0.5f * vec.x, y0 + 0.5f * vec.y}; + iron_vector2_t p1 = (iron_vector2_t){x1 + 0.5f * vec.x, y1 + 0.5f * vec.y}; + iron_vector2_t p2 = (iron_vector2_t){p0.x - vec.x, p0.y - vec.y}; + iron_vector2_t p3 = (iron_vector2_t){p1.x - vec.x, p1.y - vec.y}; draw_filled_triangle(p0.x, p0.y, p1.x, p1.y, p2.x, p2.y); draw_filled_triangle(p2.x, p2.y, p1.x, p1.y, p3.x, p3.y); } @@ -644,27 +644,27 @@ void draw_text_set_rect_colors(uint32_t color) { void draw_text_draw_buffer(bool end) { if (text_buffer_index - text_buffer_start == 0) return; - kinc_g4_vertex_buffer_unlock(&text_vertex_buffer, text_buffer_index * 4); - kinc_g5_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : draw_is_render_target ? &text_pipeline_rt : &text_pipeline); - kinc_g4_set_matrix4(text_proj_loc, &draw_projection_matrix); - kinc_g4_set_vertex_buffer(&text_vertex_buffer); - kinc_g4_set_index_buffer(&text_index_buffer); - kinc_g4_set_texture(text_tex_unit, text_last_texture); - kinc_g4_set_texture_addressing(text_tex_unit, KINC_G4_TEXTURE_DIRECTION_U, KINC_G4_TEXTURE_ADDRESSING_CLAMP); - kinc_g4_set_texture_addressing(text_tex_unit, KINC_G4_TEXTURE_DIRECTION_V, KINC_G4_TEXTURE_ADDRESSING_CLAMP); - kinc_g4_set_texture_mipmap_filter(text_tex_unit, KINC_G4_MIPMAP_FILTER_NONE); - kinc_g4_set_texture_minification_filter(text_tex_unit, draw_bilinear_filter ? KINC_G4_TEXTURE_FILTER_LINEAR : KINC_G4_TEXTURE_FILTER_POINT); - kinc_g4_set_texture_magnification_filter(text_tex_unit, draw_bilinear_filter ? KINC_G4_TEXTURE_FILTER_LINEAR : KINC_G4_TEXTURE_FILTER_POINT); - kinc_g5_draw_indexed_vertices_from_to(text_buffer_start * 2 * 3, (text_buffer_index - text_buffer_start) * 2 * 3); + iron_g4_vertex_buffer_unlock(&text_vertex_buffer, text_buffer_index * 4); + iron_g5_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : draw_is_render_target ? &text_pipeline_rt : &text_pipeline); + iron_g4_set_matrix4(text_proj_loc, &draw_projection_matrix); + iron_g4_set_vertex_buffer(&text_vertex_buffer); + iron_g4_set_index_buffer(&text_index_buffer); + iron_g4_set_texture(text_tex_unit, text_last_texture); + iron_g4_set_texture_addressing(text_tex_unit, IRON_G4_TEXTURE_DIRECTION_U, IRON_G4_TEXTURE_ADDRESSING_CLAMP); + iron_g4_set_texture_addressing(text_tex_unit, IRON_G4_TEXTURE_DIRECTION_V, IRON_G4_TEXTURE_ADDRESSING_CLAMP); + iron_g4_set_texture_mipmap_filter(text_tex_unit, IRON_G4_MIPMAP_FILTER_NONE); + iron_g4_set_texture_minification_filter(text_tex_unit, draw_bilinear_filter ? IRON_G4_TEXTURE_FILTER_LINEAR : IRON_G4_TEXTURE_FILTER_POINT); + iron_g4_set_texture_magnification_filter(text_tex_unit, draw_bilinear_filter ? IRON_G4_TEXTURE_FILTER_LINEAR : IRON_G4_TEXTURE_FILTER_POINT); + iron_g5_draw_indexed_vertices_from_to(text_buffer_start * 2 * 3, (text_buffer_index - text_buffer_start) * 2 * 3); if (end || text_buffer_index + 1 >= DRAW_BUFFER_SIZE) { text_buffer_start = 0; text_buffer_index = 0; - text_rect_verts = kinc_g4_vertex_buffer_lock(&text_vertex_buffer, 0, DRAW_BUFFER_SIZE * 4); + text_rect_verts = iron_g4_vertex_buffer_lock(&text_vertex_buffer, 0, DRAW_BUFFER_SIZE * 4); } else { text_buffer_start = text_buffer_index; - text_rect_verts = kinc_g4_vertex_buffer_lock(&text_vertex_buffer, text_buffer_start * 4, (DRAW_BUFFER_SIZE - text_buffer_start) * 4); + text_rect_verts = iron_g4_vertex_buffer_lock(&text_vertex_buffer, text_buffer_start * 4, (DRAW_BUFFER_SIZE - text_buffer_start) * 4); } } @@ -680,7 +680,7 @@ typedef struct draw_font_aligned_quad { typedef struct draw_font_image { float m_size; stbtt_bakedchar *chars; - kinc_g5_texture_t *tex; + iron_g5_texture_t *tex; int width, height, first_unused_y; float baseline, descent, line_gap; } draw_font_image_t; @@ -796,13 +796,13 @@ bool draw_font_load(draw_font_t *font, int size) { img->height = height; img->chars = baked; img->first_unused_y = status; - img->tex = (kinc_g5_texture_t *)malloc(sizeof(kinc_g5_texture_t)); - kinc_g5_texture_init_from_bytes(img->tex, pixels, width, height, KINC_IMAGE_FORMAT_R8); + img->tex = (iron_g5_texture_t *)malloc(sizeof(iron_g5_texture_t)); + iron_g5_texture_init_from_bytes(img->tex, pixels, width, height, IRON_IMAGE_FORMAT_R8); free(pixels); return true; } -kinc_g5_texture_t *draw_font_get_texture(draw_font_t *font, int size) { +iron_g5_texture_t *draw_font_get_texture(draw_font_t *font, int size) { draw_font_image_t *img = draw_font_get_image_internal(font, size); return img->tex; } @@ -860,7 +860,7 @@ void draw_string(const char *text, float x, float y) { draw_colored_end(); draw_font_image_t *img = draw_font_get_image_internal(draw_font, draw_font_size); - kinc_g5_texture_t *tex = img->tex; + iron_g5_texture_t *tex = img->tex; if (text_last_texture != NULL && tex != text_last_texture) draw_text_draw_buffer(false); text_last_texture = tex; @@ -878,7 +878,7 @@ void draw_string(const char *text, float x, float y) { draw_text_set_rect_colors(draw_color); draw_text_set_rect_tex_coords(q.s0, q.t0, q.s1, q.t1); - kinc_vector2_t p[4]; + iron_vector2_t p[4]; draw_matrix3x3_multquad(&draw_transform, q.x0, q.y0, q.x1 - q.x0, q.y1 - q.y0, p); draw_text_set_rect_verts(p[0].x, p[0].y, p[1].x, p[1].y, p[2].x, p[2].y, p[3].x, p[3].y); @@ -934,8 +934,8 @@ void draw_font_13(draw_font_t *font, void *blob) { img->width = 128; img->height = 128; img->first_unused_y = 0; - img->tex = (kinc_g5_texture_t *)malloc(sizeof(kinc_g5_texture_t)); - kinc_g5_texture_init_from_bytes(img->tex, (void *)iron_font_13_pixels, 128, 128, KINC_IMAGE_FORMAT_R8); + img->tex = (iron_g5_texture_t *)malloc(sizeof(iron_g5_texture_t)); + iron_g5_texture_init_from_bytes(img->tex, (void *)iron_font_13_pixels, 128, 128, IRON_IMAGE_FORMAT_R8); stbtt_bakedchar *baked = (stbtt_bakedchar *)malloc(95 * sizeof(stbtt_bakedchar)); for (int i = 0; i < 95; ++i) { @@ -1070,7 +1070,7 @@ uint32_t draw_get_color() { return draw_color; } -void draw_set_pipeline(kinc_g5_pipeline_t *pipeline) { +void draw_set_pipeline(iron_g5_pipeline_t *pipeline) { if (pipeline == draw_last_pipeline) return; draw_last_pipeline = pipeline; draw_end(); // flush @@ -1078,9 +1078,9 @@ void draw_set_pipeline(kinc_g5_pipeline_t *pipeline) { } void draw_set_transform(buffer_t *matrix) { - kinc_matrix3x3_t *m = matrix != NULL ? (kinc_matrix3x3_t *)matrix->buffer : NULL; + iron_matrix3x3_t *m = matrix != NULL ? (iron_matrix3x3_t *)matrix->buffer : NULL; if (m == NULL) { - draw_transform = kinc_matrix3x3_identity(); + draw_transform = iron_matrix3x3_identity(); } else { for (int i = 0; i < 3 * 3; ++i) { @@ -1106,16 +1106,16 @@ void draw_restore_render_target(void) { draw_is_render_target = false; draw_end(); draw_begin(); - kinc_g4_restore_render_target(); + iron_g4_restore_render_target(); draw_internal_set_projection_matrix(NULL); } -void draw_set_render_target(kinc_g5_texture_t *target) { +void draw_set_render_target(iron_g5_texture_t *target) { draw_is_render_target = true; draw_end(); draw_begin(); - kinc_g5_texture_t *render_targets[1] = { target }; - kinc_g4_set_render_targets(render_targets, 1); + iron_g5_texture_t *render_targets[1] = { target }; + iron_g4_set_render_targets(render_targets, 1); draw_internal_set_projection_matrix(target); } @@ -1149,7 +1149,7 @@ void draw_inner_line(float x1, float y1, float x2, float y2, float strength) { side = x2 - x1 > 0 ? 1 : 0; } - kinc_vector2_t vec; + iron_vector2_t vec; if (y2 == y1) { vec = vec2_create(0, -1); } @@ -1157,10 +1157,10 @@ void draw_inner_line(float x1, float y1, float x2, float y2, float strength) { vec = vec2_create(1, -(x2 - x1) / (y2 - y1)); } vec = vec2_set_len(vec, strength); - kinc_vector2_t p1 = {x1 + side * vec.x, y1 + side * vec.y}; - kinc_vector2_t p2 = {x2 + side * vec.x, y2 + side * vec.y}; - kinc_vector2_t p3 = vec2_sub(p1, vec); - kinc_vector2_t p4 = vec2_sub(p2, vec); + iron_vector2_t p1 = {x1 + side * vec.x, y1 + side * vec.y}; + iron_vector2_t p2 = {x2 + side * vec.x, y2 + side * vec.y}; + iron_vector2_t p3 = vec2_sub(p1, vec); + iron_vector2_t p4 = vec2_sub(p2, vec); draw_filled_triangle(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y); draw_filled_triangle(p3.x, p3.y, p2.x, p2.y, p4.x, p4.y); } diff --git a/base/sources/iron_draw.h b/base/sources/iron_draw.h index 60f207cd..927d77d8 100644 --- a/base/sources/iron_draw.h +++ b/base/sources/iron_draw.h @@ -27,14 +27,14 @@ typedef struct draw_font { void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *colored_vert, buffer_t *colored_frag, buffer_t *text_vert, buffer_t *text_frag); void draw_begin(void); -void draw_scaled_sub_image(kinc_g5_texture_t *img, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh); -void draw_scaled_sub_texture(kinc_g5_texture_t *tex, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh); -void draw_scaled_image(kinc_g5_texture_t *tex, float dx, float dy, float dw, float dh); -void draw_sub_image(kinc_g5_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y); -void draw_image(kinc_g5_texture_t *tex, float x, float y); -void draw_scaled_texture(kinc_g5_texture_t *tex, float dx, float dy, float dw, float dh); -void draw_sub_texture(kinc_g5_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y); -void draw_texture(kinc_g5_texture_t *tex, float x, float y); +void draw_scaled_sub_image(iron_g5_texture_t *img, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh); +void draw_scaled_sub_texture(iron_g5_texture_t *tex, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh); +void draw_scaled_image(iron_g5_texture_t *tex, float dx, float dy, float dw, float dh); +void draw_sub_image(iron_g5_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y); +void draw_image(iron_g5_texture_t *tex, float x, float y); +void draw_scaled_texture(iron_g5_texture_t *tex, float dx, float dy, float dw, float dh); +void draw_sub_texture(iron_g5_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y); +void draw_texture(iron_g5_texture_t *tex, float x, float y); void draw_filled_triangle(float x0, float y0, float x1, float y1, float x2, float y2); void draw_filled_rect(float x, float y, float width, float height); void draw_rect(float x, float y, float width, float height, float strength); @@ -44,7 +44,7 @@ void draw_string(const char *text, float x, float y); void draw_end(void); void draw_set_color(uint32_t color); uint32_t draw_get_color(); -void draw_set_pipeline(kinc_g5_pipeline_t *pipeline); +void draw_set_pipeline(iron_g5_pipeline_t *pipeline); void draw_set_transform(buffer_t *matrix); bool draw_set_font(draw_font_t *font, int size); void draw_font_init(draw_font_t *font, void *blob, int font_index); @@ -58,7 +58,7 @@ float draw_sub_string_width(draw_font_t *font, int font_size, const char *text, int draw_string_width(draw_font_t *font, int font_size, const char *text); void draw_set_bilinear_filter(bool bilinear); void draw_restore_render_target(void); -void draw_set_render_target(kinc_g5_texture_t *target); +void draw_set_render_target(iron_g5_texture_t *target); void draw_filled_circle(float cx, float cy, float radius, int segments); void draw_circle(float cx, float cy, float radius, int segments, float strength); diff --git a/base/sources/iron_file.c b/base/sources/iron_file.c index b774e0a4..ddfc106e 100644 --- a/base/sources/iron_file.c +++ b/base/sources/iron_file.c @@ -1,39 +1,39 @@ #include "iron_file.h" #include -#ifdef KINC_ANDROID +#ifdef IRON_ANDROID #include #endif #include #include #include -#ifdef KINC_WINDOWS +#ifdef IRON_WINDOWS #include #include #endif -static bool memory_close_callback(kinc_file_reader_t *reader) { +static bool memory_close_callback(iron_file_reader_t *reader) { return true; } -static size_t memory_read_callback(kinc_file_reader_t *reader, void *data, size_t size) { +static size_t memory_read_callback(iron_file_reader_t *reader, void *data, size_t size) { size_t read_size = reader->size - reader->offset < size ? reader->size - reader->offset : size; memcpy(data, (uint8_t *)reader->data + reader->offset, read_size); reader->offset += read_size; return read_size; } -static size_t memory_pos_callback(kinc_file_reader_t *reader) { +static size_t memory_pos_callback(iron_file_reader_t *reader) { return reader->offset; } -static bool memory_seek_callback(kinc_file_reader_t *reader, size_t pos) { +static bool memory_seek_callback(iron_file_reader_t *reader, size_t pos) { reader->offset = pos; return true; } -bool kinc_file_reader_from_memory(kinc_file_reader_t *reader, void *data, size_t size) { - memset(reader, 0, sizeof(kinc_file_reader_t)); +bool iron_file_reader_from_memory(iron_file_reader_t *reader, void *data, size_t size) { + memset(reader, 0, sizeof(iron_file_reader_t)); reader->data = data; reader->size = size; reader->read = memory_read_callback; @@ -43,38 +43,38 @@ bool kinc_file_reader_from_memory(kinc_file_reader_t *reader, void *data, size_t return true; } -#ifdef KINC_IOS +#ifdef IRON_IOS const char *iphonegetresourcepath(void); #endif -#ifdef KINC_MACOS +#ifdef IRON_MACOS const char *macgetresourcepath(void); #endif -#ifdef KINC_WINDOWS +#ifdef IRON_WINDOWS #include #endif static char *fileslocation = NULL; -static bool (*file_reader_callback)(kinc_file_reader_t *reader, const char *filename, int type) = NULL; -#ifdef KINC_WINDOWS +static bool (*file_reader_callback)(iron_file_reader_t *reader, const char *filename, int type) = NULL; +#ifdef IRON_WINDOWS static wchar_t wfilepath[1001]; #endif -void kinc_internal_set_files_location(char *dir) { +void iron_internal_set_files_location(char *dir) { fileslocation = dir; } -char *kinc_internal_get_files_location(void) { +char *iron_internal_get_files_location(void) { return fileslocation; } -bool kinc_internal_file_reader_callback(kinc_file_reader_t *reader, const char *filename, int type) { +bool iron_internal_file_reader_callback(iron_file_reader_t *reader, const char *filename, int type) { return file_reader_callback ? file_reader_callback(reader, filename, type) : false; } -#ifdef KINC_WINDOWS -static size_t kinc_libc_file_reader_read(kinc_file_reader_t *reader, void *data, size_t size) { +#ifdef IRON_WINDOWS +static size_t iron_libc_file_reader_read(iron_file_reader_t *reader, void *data, size_t size) { DWORD readBytes = 0; if (ReadFile(reader->data, data, (DWORD)size, &readBytes, NULL)) { return (size_t)readBytes; @@ -84,32 +84,32 @@ static size_t kinc_libc_file_reader_read(kinc_file_reader_t *reader, void *data, } } -static bool kinc_libc_file_reader_seek(kinc_file_reader_t *reader, size_t pos) { +static bool iron_libc_file_reader_seek(iron_file_reader_t *reader, size_t pos) { // TODO: make this 64-bit compliant SetFilePointer(reader->data, (LONG)pos, NULL, FILE_BEGIN); return true; } -static bool kinc_libc_file_reader_close(kinc_file_reader_t *reader) { +static bool iron_libc_file_reader_close(iron_file_reader_t *reader) { CloseHandle(reader->data); return true; } -static size_t kinc_libc_file_reader_pos(kinc_file_reader_t *reader) { +static size_t iron_libc_file_reader_pos(iron_file_reader_t *reader) { // TODO: make this 64-bit compliant return (size_t)SetFilePointer(reader->data, 0, NULL, FILE_CURRENT); } #else -static size_t kinc_libc_file_reader_read(kinc_file_reader_t *reader, void *data, size_t size) { +static size_t iron_libc_file_reader_read(iron_file_reader_t *reader, void *data, size_t size) { return fread(data, 1, size, (FILE *)reader->data); } -static bool kinc_libc_file_reader_seek(kinc_file_reader_t *reader, size_t pos) { +static bool iron_libc_file_reader_seek(iron_file_reader_t *reader, size_t pos) { fseek((FILE *)reader->data, pos, SEEK_SET); return true; } -static bool kinc_libc_file_reader_close(kinc_file_reader_t *reader) { +static bool iron_libc_file_reader_close(iron_file_reader_t *reader) { if (reader->data != NULL) { fclose((FILE *)reader->data); reader->data = NULL; @@ -117,35 +117,35 @@ static bool kinc_libc_file_reader_close(kinc_file_reader_t *reader) { return true; } -static size_t kinc_libc_file_reader_pos(kinc_file_reader_t *reader) { +static size_t iron_libc_file_reader_pos(iron_file_reader_t *reader) { return ftell((FILE *)reader->data); } #endif -bool kinc_internal_file_reader_open(kinc_file_reader_t *reader, const char *filename, int type) { +bool iron_internal_file_reader_open(iron_file_reader_t *reader, const char *filename, int type) { char filepath[1001]; -#ifdef KINC_IOS - strcpy(filepath, type == KINC_FILE_TYPE_SAVE ? kinc_internal_save_path() : iphonegetresourcepath()); - if (type != KINC_FILE_TYPE_SAVE) { +#ifdef IRON_IOS + strcpy(filepath, type == IRON_FILE_TYPE_SAVE ? iron_internal_save_path() : iphonegetresourcepath()); + if (type != IRON_FILE_TYPE_SAVE) { strcat(filepath, "/"); - strcat(filepath, KINC_OUTDIR); + strcat(filepath, IRON_OUTDIR); strcat(filepath, "/"); } strcat(filepath, filename); #endif -#ifdef KINC_MACOS - strcpy(filepath, type == KINC_FILE_TYPE_SAVE ? kinc_internal_save_path() : macgetresourcepath()); - if (type != KINC_FILE_TYPE_SAVE) { +#ifdef IRON_MACOS + strcpy(filepath, type == IRON_FILE_TYPE_SAVE ? iron_internal_save_path() : macgetresourcepath()); + if (type != IRON_FILE_TYPE_SAVE) { strcat(filepath, "/"); - strcat(filepath, KINC_OUTDIR); + strcat(filepath, IRON_OUTDIR); strcat(filepath, "/"); } strcat(filepath, filename); #endif -#ifdef KINC_WINDOWS - if (type == KINC_FILE_TYPE_SAVE) { - strcpy(filepath, kinc_internal_save_path()); +#ifdef IRON_WINDOWS + if (type == IRON_FILE_TYPE_SAVE) { + strcpy(filepath, iron_internal_save_path()); strcat(filepath, filename); } else { @@ -156,20 +156,20 @@ bool kinc_internal_file_reader_open(kinc_file_reader_t *reader, const char *file if (filepath[i] == '/') filepath[i] = '\\'; #endif -#if defined(KINC_LINUX) || defined(KINC_ANDROID) - if (type == KINC_FILE_TYPE_SAVE) { - strcpy(filepath, kinc_internal_save_path()); +#if defined(IRON_LINUX) || defined(IRON_ANDROID) + if (type == IRON_FILE_TYPE_SAVE) { + strcpy(filepath, iron_internal_save_path()); strcat(filepath, filename); } else { strcpy(filepath, filename); } #endif -#ifdef KINC_WASM +#ifdef IRON_WASM strcpy(filepath, filename); #endif -#ifdef KINC_WINDOWS +#ifdef IRON_WINDOWS // Drive letter or network bool isAbsolute = (filename[1] == ':' && filename[2] == '\\') || (filename[0] == '\\' && filename[1] == '\\'); #else @@ -179,13 +179,13 @@ bool kinc_internal_file_reader_open(kinc_file_reader_t *reader, const char *file if (isAbsolute) { strcpy(filepath, filename); } - else if (fileslocation != NULL && type != KINC_FILE_TYPE_SAVE) { + else if (fileslocation != NULL && type != IRON_FILE_TYPE_SAVE) { strcpy(filepath, fileslocation); strcat(filepath, "/"); strcat(filepath, filename); } -#ifdef KINC_WINDOWS +#ifdef IRON_WINDOWS MultiByteToWideChar(CP_UTF8, 0, filepath, -1, wfilepath, 1000); reader->data = CreateFileW(wfilepath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (reader->data == INVALID_HANDLE_VALUE) { @@ -198,7 +198,7 @@ bool kinc_internal_file_reader_open(kinc_file_reader_t *reader, const char *file } #endif -#ifdef KINC_WINDOWS +#ifdef IRON_WINDOWS // TODO: make this 64-bit compliant reader->size = (size_t)GetFileSize(reader->data, NULL); #else @@ -207,90 +207,90 @@ bool kinc_internal_file_reader_open(kinc_file_reader_t *reader, const char *file fseek((FILE *)reader->data, 0, SEEK_SET); #endif - reader->read = kinc_libc_file_reader_read; - reader->seek = kinc_libc_file_reader_seek; - reader->close = kinc_libc_file_reader_close; - reader->pos = kinc_libc_file_reader_pos; + reader->read = iron_libc_file_reader_read; + reader->seek = iron_libc_file_reader_seek; + reader->close = iron_libc_file_reader_close; + reader->pos = iron_libc_file_reader_pos; return true; } -#if !defined(KINC_ANDROID) -bool kinc_file_reader_open(kinc_file_reader_t *reader, const char *filename, int type) { +#if !defined(IRON_ANDROID) +bool iron_file_reader_open(iron_file_reader_t *reader, const char *filename, int type) { memset(reader, 0, sizeof(*reader)); - return kinc_internal_file_reader_callback(reader, filename, type) || - kinc_internal_file_reader_open(reader, filename, type); + return iron_internal_file_reader_callback(reader, filename, type) || + iron_internal_file_reader_open(reader, filename, type); } #endif -void kinc_file_reader_set_callback(bool (*callback)(kinc_file_reader_t *reader, const char *filename, int type)) { +void iron_file_reader_set_callback(bool (*callback)(iron_file_reader_t *reader, const char *filename, int type)) { file_reader_callback = callback; } -size_t kinc_file_reader_read(kinc_file_reader_t *reader, void *data, size_t size) { +size_t iron_file_reader_read(iron_file_reader_t *reader, void *data, size_t size) { return reader->read(reader, data, size); } -bool kinc_file_reader_seek(kinc_file_reader_t *reader, size_t pos) { +bool iron_file_reader_seek(iron_file_reader_t *reader, size_t pos) { return reader->seek(reader, pos); } -bool kinc_file_reader_close(kinc_file_reader_t *reader) { +bool iron_file_reader_close(iron_file_reader_t *reader) { return reader->close(reader); } -size_t kinc_file_reader_pos(kinc_file_reader_t *reader) { +size_t iron_file_reader_pos(iron_file_reader_t *reader) { return reader->pos(reader); } -size_t kinc_file_reader_size(kinc_file_reader_t *reader) { +size_t iron_file_reader_size(iron_file_reader_t *reader) { return reader->size; } -float kinc_read_f32le(uint8_t *data) { +float iron_read_f32le(uint8_t *data) { return *(float *)data; } -uint64_t kinc_read_u64le(uint8_t *data) { +uint64_t iron_read_u64le(uint8_t *data) { return *(uint64_t *)data; } -int64_t kinc_read_s64le(uint8_t *data) { +int64_t iron_read_s64le(uint8_t *data) { return *(int64_t *)data; } -uint32_t kinc_read_u32le(uint8_t *data) { +uint32_t iron_read_u32le(uint8_t *data) { return *(uint32_t *)data; } -int32_t kinc_read_s32le(uint8_t *data) { +int32_t iron_read_s32le(uint8_t *data) { return *(int32_t *)data; } -uint16_t kinc_read_u16le(uint8_t *data) { +uint16_t iron_read_u16le(uint8_t *data) { return *(uint16_t *)data; } -int16_t kinc_read_s16le(uint8_t *data) { +int16_t iron_read_s16le(uint8_t *data) { return *(int16_t *)data; } -uint8_t kinc_read_u8(uint8_t *data) { +uint8_t iron_read_u8(uint8_t *data) { return *data; } -int8_t kinc_read_s8(uint8_t *data) { +int8_t iron_read_s8(uint8_t *data) { return *(int8_t *)data; } -bool kinc_file_writer_open(kinc_file_writer_t *writer, const char *filepath) { +bool iron_file_writer_open(iron_file_writer_t *writer, const char *filepath) { writer->file = NULL; char path[1001]; - strcpy(path, kinc_internal_save_path()); + strcpy(path, iron_internal_save_path()); strcat(path, filepath); -#ifdef KINC_WINDOWS +#ifdef IRON_WINDOWS wchar_t wpath[MAX_PATH]; MultiByteToWideChar(CP_UTF8, 0, path, -1, wpath, MAX_PATH); writer->file = CreateFileW(wpath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); @@ -298,15 +298,15 @@ bool kinc_file_writer_open(kinc_file_writer_t *writer, const char *filepath) { writer->file = fopen(path, "wb"); #endif if (writer->file == NULL) { - kinc_log("Could not open file %s.", filepath); + iron_log("Could not open file %s.", filepath); return false; } return true; } -void kinc_file_writer_close(kinc_file_writer_t *writer) { +void iron_file_writer_close(iron_file_writer_t *writer) { if (writer->file != NULL) { -#ifdef KINC_WINDOWS +#ifdef IRON_WINDOWS CloseHandle(writer->file); #else fclose((FILE *)writer->file); @@ -315,8 +315,8 @@ void kinc_file_writer_close(kinc_file_writer_t *writer) { } } -void kinc_file_writer_write(kinc_file_writer_t *writer, void *data, int size) { -#ifdef KINC_WINDOWS +void iron_file_writer_write(iron_file_writer_t *writer, void *data, int size) { +#ifdef IRON_WINDOWS DWORD written = 0; WriteFile(writer->file, data, (DWORD)size, &written, NULL); #else diff --git a/base/sources/iron_file.h b/base/sources/iron_file.h index b37619fe..2a383d2f 100644 --- a/base/sources/iron_file.h +++ b/base/sources/iron_file.h @@ -5,62 +5,62 @@ #include #include -#define KINC_OUTDIR "out" -#ifdef KINC_ANDROID +#define IRON_OUTDIR "out" +#ifdef IRON_ANDROID struct AAsset; struct __sFILE; typedef struct __sFILE FILE; #endif -#define KINC_FILE_TYPE_ASSET 0 -#define KINC_FILE_TYPE_SAVE 1 +#define IRON_FILE_TYPE_ASSET 0 +#define IRON_FILE_TYPE_SAVE 1 -typedef struct kinc_file_reader { +typedef struct iron_file_reader { void *data; // A file handle or a more complex structure size_t size; size_t offset; // Needed by some implementations - bool (*close)(struct kinc_file_reader *reader); - size_t (*read)(struct kinc_file_reader *reader, void *data, size_t size); - size_t (*pos)(struct kinc_file_reader *reader); - bool (*seek)(struct kinc_file_reader *reader, size_t pos); -} kinc_file_reader_t; + bool (*close)(struct iron_file_reader *reader); + size_t (*read)(struct iron_file_reader *reader, void *data, size_t size); + size_t (*pos)(struct iron_file_reader *reader); + bool (*seek)(struct iron_file_reader *reader, size_t pos); +} iron_file_reader_t; -bool kinc_file_reader_open(kinc_file_reader_t *reader, const char *filepath, int type); -bool kinc_file_reader_from_memory(kinc_file_reader_t *reader, void *data, size_t size); -void kinc_file_reader_set_callback(bool (*callback)(kinc_file_reader_t *reader, const char *filename, int type)); -bool kinc_file_reader_close(kinc_file_reader_t *reader); -size_t kinc_file_reader_read(kinc_file_reader_t *reader, void *data, size_t size); -size_t kinc_file_reader_size(kinc_file_reader_t *reader); -size_t kinc_file_reader_pos(kinc_file_reader_t *reader); -bool kinc_file_reader_seek(kinc_file_reader_t *reader, size_t pos); -float kinc_read_f32le(uint8_t *data); -float kinc_read_f32be(uint8_t *data); -uint64_t kinc_read_u64le(uint8_t *data); -uint64_t kinc_read_u64be(uint8_t *data); -int64_t kinc_read_s64le(uint8_t *data); -int64_t kinc_read_s64be(uint8_t *data); -uint32_t kinc_read_u32le(uint8_t *data); -uint32_t kinc_read_u32be(uint8_t *data); -int32_t kinc_read_s32le(uint8_t *data); -int32_t kinc_read_s32be(uint8_t *data); -uint16_t kinc_read_u16le(uint8_t *data); -uint16_t kinc_read_u16be(uint8_t *data); -int16_t kinc_read_s16le(uint8_t *data); -int16_t kinc_read_s16be(uint8_t *data); -uint8_t kinc_read_u8(uint8_t *data); -int8_t kinc_read_s8(uint8_t *data); +bool iron_file_reader_open(iron_file_reader_t *reader, const char *filepath, int type); +bool iron_file_reader_from_memory(iron_file_reader_t *reader, void *data, size_t size); +void iron_file_reader_set_callback(bool (*callback)(iron_file_reader_t *reader, const char *filename, int type)); +bool iron_file_reader_close(iron_file_reader_t *reader); +size_t iron_file_reader_read(iron_file_reader_t *reader, void *data, size_t size); +size_t iron_file_reader_size(iron_file_reader_t *reader); +size_t iron_file_reader_pos(iron_file_reader_t *reader); +bool iron_file_reader_seek(iron_file_reader_t *reader, size_t pos); +float iron_read_f32le(uint8_t *data); +float iron_read_f32be(uint8_t *data); +uint64_t iron_read_u64le(uint8_t *data); +uint64_t iron_read_u64be(uint8_t *data); +int64_t iron_read_s64le(uint8_t *data); +int64_t iron_read_s64be(uint8_t *data); +uint32_t iron_read_u32le(uint8_t *data); +uint32_t iron_read_u32be(uint8_t *data); +int32_t iron_read_s32le(uint8_t *data); +int32_t iron_read_s32be(uint8_t *data); +uint16_t iron_read_u16le(uint8_t *data); +uint16_t iron_read_u16be(uint8_t *data); +int16_t iron_read_s16le(uint8_t *data); +int16_t iron_read_s16be(uint8_t *data); +uint8_t iron_read_u8(uint8_t *data); +int8_t iron_read_s8(uint8_t *data); -void kinc_internal_set_files_location(char *dir); -char *kinc_internal_get_files_location(void); -bool kinc_internal_file_reader_callback(kinc_file_reader_t *reader, const char *filename, int type); -bool kinc_internal_file_reader_open(kinc_file_reader_t *reader, const char *filename, int type); +void iron_internal_set_files_location(char *dir); +char *iron_internal_get_files_location(void); +bool iron_internal_file_reader_callback(iron_file_reader_t *reader, const char *filename, int type); +bool iron_internal_file_reader_open(iron_file_reader_t *reader, const char *filename, int type); -typedef struct kinc_file_writer { +typedef struct iron_file_writer { void *file; const char *filename; -} kinc_file_writer_t; +} iron_file_writer_t; -bool kinc_file_writer_open(kinc_file_writer_t *writer, const char *filepath); -void kinc_file_writer_write(kinc_file_writer_t *writer, void *data, int size); -void kinc_file_writer_close(kinc_file_writer_t *writer); +bool iron_file_writer_open(iron_file_writer_t *writer, const char *filepath); +void iron_file_writer_write(iron_file_writer_t *writer, void *data, int size); +void iron_file_writer_close(iron_file_writer_t *writer); diff --git a/base/sources/iron_global.h b/base/sources/iron_global.h index 0b1fd40f..f38c0bb8 100644 --- a/base/sources/iron_global.h +++ b/base/sources/iron_global.h @@ -4,24 +4,24 @@ #include #if defined(_WIN32) -#define KINC_WINDOWS +#define IRON_WINDOWS #elif defined(__APPLE__) #include #if TARGET_OS_IPHONE -#define KINC_IOS -#define KINC_APPLE_SOC +#define IRON_IOS +#define IRON_APPLE_SOC #else -#define KINC_MACOS +#define IRON_MACOS #if defined(__arm64__) -#define KINC_APPLE_SOC +#define IRON_APPLE_SOC #endif #endif -#define KINC_POSIX +#define IRON_POSIX #elif defined(__linux__) -#if !defined(KINC_ANDROID) -#define KINC_LINUX +#if !defined(IRON_ANDROID) +#define IRON_LINUX #endif -#define KINC_POSIX +#define IRON_POSIX #endif int kickstart(int argc, char **argv); diff --git a/base/sources/iron_gpu.c b/base/sources/iron_gpu.c index 66a1a35e..53e71328 100644 --- a/base/sources/iron_gpu.c +++ b/base/sources/iron_gpu.c @@ -13,41 +13,41 @@ #define MAX_SAMPLERS_PER_STAGE 16 #define MAX_SAMPLER_CACHE_SIZE 256 -static kinc_g5_sampler_options_t sampler_options[KINC_G5_SHADER_TYPE_COUNT][MAX_SAMPLERS_PER_STAGE]; +static iron_g5_sampler_options_t sampler_options[IRON_G5_SHADER_TYPE_COUNT][MAX_SAMPLERS_PER_STAGE]; struct sampler_cache_entry { - kinc_g5_sampler_options_t options; - kinc_g5_sampler_t sampler; + iron_g5_sampler_options_t options; + iron_g5_sampler_t sampler; }; static struct sampler_cache_entry sampler_cache[MAX_SAMPLER_CACHE_SIZE]; static int sampler_cache_size = 0; -void kinc_internal_samplers_reset(void); -kinc_g5_sampler_t *kinc_internal_get_current_sampler(int stage, int unit); +void iron_internal_samplers_reset(void); +iron_g5_sampler_t *iron_internal_get_current_sampler(int stage, int unit); -kinc_g5_command_list_t commandList; +iron_g5_command_list_t commandList; bool waitAfterNextDraw = false; -static kinc_g5_constant_buffer_t vertexConstantBuffer; -static kinc_g5_constant_buffer_t fragmentConstantBuffer; -static kinc_g5_constant_buffer_t computeConstantBuffer; +static iron_g5_constant_buffer_t vertexConstantBuffer; +static iron_g5_constant_buffer_t fragmentConstantBuffer; +static iron_g5_constant_buffer_t computeConstantBuffer; static int constantBufferIndex = 0; static struct { int currentBuffer; - kinc_g5_texture_t framebuffers[FRAMEBUFFER_COUNT]; - kinc_g5_texture_t *current_render_targets[8]; + iron_g5_texture_t framebuffers[FRAMEBUFFER_COUNT]; + iron_g5_texture_t *current_render_targets[8]; int current_render_target_count; bool resized; } windows[1] = {0}; typedef struct render_state { - kinc_g5_pipeline_t *pipeline; - kinc_g5_compute_shader *compute_shader; + iron_g5_pipeline_t *pipeline; + iron_g5_compute_shader *compute_shader; - kinc_g5_index_buffer_t *index_buffer; - kinc_g5_vertex_buffer_t *vertex_buffer; + iron_g5_index_buffer_t *index_buffer; + iron_g5_vertex_buffer_t *vertex_buffer; bool viewport_set; int viewport_x; @@ -61,12 +61,12 @@ typedef struct render_state { int scissor_width; int scissor_height; - kinc_g5_texture_t *textures[MAX_TEXTURES]; - kinc_g5_texture_unit_t texture_units[MAX_TEXTURES]; + iron_g5_texture_t *textures[MAX_TEXTURES]; + iron_g5_texture_unit_t texture_units[MAX_TEXTURES]; int texture_count; - kinc_g5_texture_t *depth_render_targets[MAX_TEXTURES]; - kinc_g5_texture_unit_t depth_render_target_units[MAX_TEXTURES]; + iron_g5_texture_t *depth_render_targets[MAX_TEXTURES]; + iron_g5_texture_unit_t depth_render_target_units[MAX_TEXTURES]; int depth_render_target_count; uint8_t vertex_constant_data[CONSTANT_BUFFER_SIZE]; @@ -76,8 +76,8 @@ typedef struct render_state { static render_state current_state; -bool kinc_g5_texture_unit_equals(kinc_g5_texture_unit_t *unit1, kinc_g5_texture_unit_t *unit2) { - for (int i = 0; i < KINC_G5_SHADER_TYPE_COUNT; ++i) { +bool iron_g5_texture_unit_equals(iron_g5_texture_unit_t *unit1, iron_g5_texture_unit_t *unit2) { + for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { if (unit1->stages[i] != unit2->stages[i]) { return false; } @@ -85,184 +85,184 @@ bool kinc_g5_texture_unit_equals(kinc_g5_texture_unit_t *unit1, kinc_g5_texture_ return true; } -void kinc_g5_internal_resize(int width, int height) { +void iron_g5_internal_resize(int width, int height) { windows[0].resized = true; } -void kinc_g5_internal_restore_render_target(void) { +void iron_g5_internal_restore_render_target(void) { windows[0].current_render_targets[0] = NULL; - kinc_g5_texture_t *render_target = &windows[0].framebuffers[windows[0].currentBuffer]; - kinc_g5_command_list_set_render_targets(&commandList, &render_target, 1); + iron_g5_texture_t *render_target = &windows[0].framebuffers[windows[0].currentBuffer]; + iron_g5_command_list_set_render_targets(&commandList, &render_target, 1); windows[0].current_render_target_count = 1; } -void kinc_g4_internal_init_window(int depthBufferBits, bool vsync) { - kinc_g5_internal_init_window(depthBufferBits, vsync); +void iron_g4_internal_init_window(int depthBufferBits, bool vsync) { + iron_g5_internal_init_window(depthBufferBits, vsync); - kinc_g5_command_list_init(&commandList); + iron_g5_command_list_init(&commandList); windows[0].currentBuffer = -1; for (int i = 0; i < FRAMEBUFFER_COUNT; ++i) { - kinc_g5_render_target_init_framebuffer(&windows[0].framebuffers[i], kinc_window_width(), kinc_window_height(), - KINC_IMAGE_FORMAT_RGBA32, depthBufferBits); + iron_g5_render_target_init_framebuffer(&windows[0].framebuffers[i], iron_window_width(), iron_window_height(), + IRON_IMAGE_FORMAT_RGBA32, depthBufferBits); } - kinc_g5_constant_buffer_init(&vertexConstantBuffer, CONSTANT_BUFFER_SIZE * CONSTANT_BUFFER_MULTIPLY); - kinc_g5_constant_buffer_init(&fragmentConstantBuffer, CONSTANT_BUFFER_SIZE * CONSTANT_BUFFER_MULTIPLY); - kinc_g5_constant_buffer_init(&computeConstantBuffer, CONSTANT_BUFFER_SIZE * CONSTANT_BUFFER_MULTIPLY); + iron_g5_constant_buffer_init(&vertexConstantBuffer, CONSTANT_BUFFER_SIZE * CONSTANT_BUFFER_MULTIPLY); + iron_g5_constant_buffer_init(&fragmentConstantBuffer, CONSTANT_BUFFER_SIZE * CONSTANT_BUFFER_MULTIPLY); + iron_g5_constant_buffer_init(&computeConstantBuffer, CONSTANT_BUFFER_SIZE * CONSTANT_BUFFER_MULTIPLY); - // to support doing work after kinc_g4_end and before kinc_g4_begin - kinc_g5_command_list_begin(&commandList); + // to support doing work after iron_g4_end and before iron_g4_begin + iron_g5_command_list_begin(&commandList); } -void kinc_g5_internal_set_samplers(int count, kinc_g5_texture_unit_t *texture_units) { +void iron_g5_internal_set_samplers(int count, iron_g5_texture_unit_t *texture_units) { for (int i = 0; i < count; ++i) { - for (int j = 0; j < KINC_G5_SHADER_TYPE_COUNT; ++j) { + for (int j = 0; j < IRON_G5_SHADER_TYPE_COUNT; ++j) { if (texture_units[i].stages[j] >= 0) { - kinc_g5_sampler_t *sampler = kinc_internal_get_current_sampler(j, texture_units[i].stages[j]); - kinc_g5_texture_unit_t unit; - for (int k = 0; k < KINC_G5_SHADER_TYPE_COUNT; ++k) { + iron_g5_sampler_t *sampler = iron_internal_get_current_sampler(j, texture_units[i].stages[j]); + iron_g5_texture_unit_t unit; + for (int k = 0; k < IRON_G5_SHADER_TYPE_COUNT; ++k) { unit.stages[k] = -1; } unit.stages[j] = texture_units[i].stages[j]; - kinc_g5_command_list_set_sampler(&commandList, unit, sampler); + iron_g5_command_list_set_sampler(&commandList, unit, sampler); } } } } -static void kinc_internal_start_draw(bool compute) { +static void iron_internal_start_draw(bool compute) { if ((constantBufferIndex + 1) >= CONSTANT_BUFFER_MULTIPLY || waitAfterNextDraw) { memcpy(current_state.vertex_constant_data, vertexConstantBuffer.data, CONSTANT_BUFFER_SIZE); memcpy(current_state.fragment_constant_data, fragmentConstantBuffer.data, CONSTANT_BUFFER_SIZE); memcpy(current_state.compute_constant_data, computeConstantBuffer.data, CONSTANT_BUFFER_SIZE); } - kinc_g5_constant_buffer_unlock(&vertexConstantBuffer); - kinc_g5_constant_buffer_unlock(&fragmentConstantBuffer); - kinc_g5_constant_buffer_unlock(&computeConstantBuffer); + iron_g5_constant_buffer_unlock(&vertexConstantBuffer); + iron_g5_constant_buffer_unlock(&fragmentConstantBuffer); + iron_g5_constant_buffer_unlock(&computeConstantBuffer); - kinc_g5_internal_set_samplers(current_state.texture_count, current_state.texture_units); - kinc_g5_internal_set_samplers(current_state.depth_render_target_count, current_state.depth_render_target_units); + iron_g5_internal_set_samplers(current_state.texture_count, current_state.texture_units); + iron_g5_internal_set_samplers(current_state.depth_render_target_count, current_state.depth_render_target_units); if (compute) { - kinc_g5_command_list_set_compute_constant_buffer(&commandList, &computeConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); + iron_g5_command_list_set_compute_constant_buffer(&commandList, &computeConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); } else { - kinc_g5_command_list_set_vertex_constant_buffer(&commandList, &vertexConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); - kinc_g5_command_list_set_fragment_constant_buffer(&commandList, &fragmentConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); + iron_g5_command_list_set_vertex_constant_buffer(&commandList, &vertexConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); + iron_g5_command_list_set_fragment_constant_buffer(&commandList, &fragmentConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); } } -static void kinc_internal_end_draw(bool compute) { +static void iron_internal_end_draw(bool compute) { ++constantBufferIndex; if (constantBufferIndex >= CONSTANT_BUFFER_MULTIPLY || waitAfterNextDraw) { - kinc_g5_command_list_end(&commandList); - kinc_g5_command_list_execute(&commandList); - kinc_g5_command_list_wait_for_execution_to_finish(&commandList); - kinc_g5_command_list_begin(&commandList); + iron_g5_command_list_end(&commandList); + iron_g5_command_list_execute(&commandList); + iron_g5_command_list_wait_for_execution_to_finish(&commandList); + iron_g5_command_list_begin(&commandList); if (windows[0].current_render_targets[0] == NULL) { - kinc_g5_internal_restore_render_target(); + iron_g5_internal_restore_render_target(); } else { const int count = windows[0].current_render_target_count; - kinc_g5_texture_t *render_targets[16]; + iron_g5_texture_t *render_targets[16]; for (int i = 0; i < count; ++i) { render_targets[i] = windows[0].current_render_targets[i]; } - kinc_g5_command_list_set_render_targets(&commandList, render_targets, count); + iron_g5_command_list_set_render_targets(&commandList, render_targets, count); } if (current_state.pipeline != NULL) { - kinc_g5_command_list_set_pipeline(&commandList, current_state.pipeline); + iron_g5_command_list_set_pipeline(&commandList, current_state.pipeline); } if (current_state.compute_shader != NULL) { - kinc_g5_command_list_set_compute_shader(&commandList, current_state.compute_shader); + iron_g5_command_list_set_compute_shader(&commandList, current_state.compute_shader); } if (current_state.index_buffer != NULL) { - kinc_g5_command_list_set_index_buffer(&commandList, current_state.index_buffer); + iron_g5_command_list_set_index_buffer(&commandList, current_state.index_buffer); } if (current_state.vertex_buffer != NULL) { - kinc_g5_command_list_set_vertex_buffer(&commandList, current_state.vertex_buffer); + iron_g5_command_list_set_vertex_buffer(&commandList, current_state.vertex_buffer); } if (current_state.viewport_set) { - kinc_g5_command_list_viewport(&commandList, current_state.viewport_x, current_state.viewport_y, current_state.viewport_width, + iron_g5_command_list_viewport(&commandList, current_state.viewport_x, current_state.viewport_y, current_state.viewport_width, current_state.viewport_height); } if (current_state.scissor_set) { - kinc_g5_command_list_scissor(&commandList, current_state.scissor_x, current_state.scissor_y, current_state.scissor_width, + iron_g5_command_list_scissor(&commandList, current_state.scissor_x, current_state.scissor_y, current_state.scissor_width, current_state.scissor_height); } for (int i = 0; i < current_state.texture_count; ++i) { - kinc_g5_command_list_set_texture(&commandList, current_state.texture_units[i], current_state.textures[i]); + iron_g5_command_list_set_texture(&commandList, current_state.texture_units[i], current_state.textures[i]); } for (int i = 0; i < current_state.depth_render_target_count; ++i) { - kinc_g5_command_list_set_texture_from_render_target_depth(&commandList, current_state.depth_render_target_units[i], + iron_g5_command_list_set_texture_from_render_target_depth(&commandList, current_state.depth_render_target_units[i], current_state.depth_render_targets[i]); } constantBufferIndex = 0; waitAfterNextDraw = false; - kinc_g5_constant_buffer_lock(&vertexConstantBuffer, 0, CONSTANT_BUFFER_SIZE); - kinc_g5_constant_buffer_lock(&fragmentConstantBuffer, 0, CONSTANT_BUFFER_SIZE); - kinc_g5_constant_buffer_lock(&computeConstantBuffer, 0, CONSTANT_BUFFER_SIZE); + iron_g5_constant_buffer_lock(&vertexConstantBuffer, 0, CONSTANT_BUFFER_SIZE); + iron_g5_constant_buffer_lock(&fragmentConstantBuffer, 0, CONSTANT_BUFFER_SIZE); + iron_g5_constant_buffer_lock(&computeConstantBuffer, 0, CONSTANT_BUFFER_SIZE); memcpy(vertexConstantBuffer.data, current_state.vertex_constant_data, CONSTANT_BUFFER_SIZE); memcpy(fragmentConstantBuffer.data, current_state.fragment_constant_data, CONSTANT_BUFFER_SIZE); memcpy(computeConstantBuffer.data, current_state.compute_constant_data, CONSTANT_BUFFER_SIZE); } else { - kinc_g5_constant_buffer_lock(&vertexConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); - kinc_g5_constant_buffer_lock(&fragmentConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); - kinc_g5_constant_buffer_lock(&computeConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); + iron_g5_constant_buffer_lock(&vertexConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); + iron_g5_constant_buffer_lock(&fragmentConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); + iron_g5_constant_buffer_lock(&computeConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); } } -void kinc_g5_draw_indexed_vertices(void) { - kinc_internal_start_draw(false); - kinc_g5_command_list_draw_indexed_vertices(&commandList); - kinc_internal_end_draw(false); +void iron_g5_draw_indexed_vertices(void) { + iron_internal_start_draw(false); + iron_g5_command_list_draw_indexed_vertices(&commandList); + iron_internal_end_draw(false); } -void kinc_g5_draw_indexed_vertices_from_to(int start, int count) { - kinc_internal_start_draw(false); - kinc_g5_command_list_draw_indexed_vertices_from_to(&commandList, start, count); - kinc_internal_end_draw(false); +void iron_g5_draw_indexed_vertices_from_to(int start, int count) { + iron_internal_start_draw(false); + iron_g5_command_list_draw_indexed_vertices_from_to(&commandList, start, count); + iron_internal_end_draw(false); } -void kinc_g5_clear(unsigned color, float depth, unsigned flags) { +void iron_g5_clear(unsigned color, float depth, unsigned flags) { if (windows[0].current_render_target_count > 0) { if (windows[0].current_render_targets[0] == NULL) { - kinc_g5_command_list_clear(&commandList, &windows[0].framebuffers[windows[0].currentBuffer], flags, color, depth); + iron_g5_command_list_clear(&commandList, &windows[0].framebuffers[windows[0].currentBuffer], flags, color, depth); } else { - if (windows[0].current_render_targets[0]->state != KINC_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET) { - kinc_g5_command_list_texture_to_render_target_barrier(&commandList, windows[0].current_render_targets[0]); - windows[0].current_render_targets[0]->state = KINC_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; + if (windows[0].current_render_targets[0]->state != IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET) { + iron_g5_command_list_texture_to_render_target_barrier(&commandList, windows[0].current_render_targets[0]); + windows[0].current_render_targets[0]->state = IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; } - kinc_g5_command_list_clear(&commandList, windows[0].current_render_targets[0], flags, color, depth); + iron_g5_command_list_clear(&commandList, windows[0].current_render_targets[0], flags, color, depth); } } } -void kinc_g4_begin() { - // to support doing work after kinc_g4_end and before kinc_g4_begin - kinc_g5_command_list_end(&commandList); - kinc_g5_command_list_execute(&commandList); +void iron_g4_begin() { + // to support doing work after iron_g4_end and before iron_g4_begin + iron_g5_command_list_end(&commandList); + iron_g5_command_list_execute(&commandList); windows[0].currentBuffer = (windows[0].currentBuffer + 1) % FRAMEBUFFER_COUNT; bool resized = windows[0].resized; if (resized) { for (int i = 0; i < FRAMEBUFFER_COUNT; ++i) { - kinc_g5_texture_destroy(&windows[0].framebuffers[i]); + iron_g5_texture_destroy(&windows[0].framebuffers[i]); } windows[0].currentBuffer = 0; } - kinc_g5_begin(&windows[0].framebuffers[windows[0].currentBuffer]); + iron_g5_begin(&windows[0].framebuffers[windows[0].currentBuffer]); if (resized) { for (int i = 0; i < FRAMEBUFFER_COUNT; ++i) { - kinc_g5_render_target_init_framebuffer(&windows[0].framebuffers[i], kinc_window_width(), kinc_window_height(), - KINC_IMAGE_FORMAT_RGBA32, 16); + iron_g5_render_target_init_framebuffer(&windows[0].framebuffers[i], iron_window_width(), iron_window_height(), + IRON_IMAGE_FORMAT_RGBA32, 16); } windows[0].resized = false; } @@ -279,268 +279,268 @@ void kinc_g4_begin() { current_state.texture_count = 0; current_state.depth_render_target_count = 0; - kinc_internal_samplers_reset(); + iron_internal_samplers_reset(); - kinc_g5_command_list_begin(&commandList); + iron_g5_command_list_begin(&commandList); - // Currently we do not necessarily wait at the end of a frame so for now it's kinc_internal_end_draw - kinc_internal_end_draw(false); + // Currently we do not necessarily wait at the end of a frame so for now it's iron_internal_end_draw + iron_internal_end_draw(false); - kinc_g5_command_list_framebuffer_to_render_target_barrier(&commandList, &windows[0].framebuffers[windows[0].currentBuffer]); - kinc_g4_restore_render_target(); + iron_g5_command_list_framebuffer_to_render_target_barrier(&commandList, &windows[0].framebuffers[windows[0].currentBuffer]); + iron_g4_restore_render_target(); } -void kinc_g4_viewport(int x, int y, int width, int height) { +void iron_g4_viewport(int x, int y, int width, int height) { current_state.viewport_x = x; current_state.viewport_y = y; current_state.viewport_width = width; current_state.viewport_height = height; current_state.viewport_set = true; - kinc_g5_command_list_viewport(&commandList, x, y, width, height); + iron_g5_command_list_viewport(&commandList, x, y, width, height); } -void kinc_g4_scissor(int x, int y, int width, int height) { +void iron_g4_scissor(int x, int y, int width, int height) { current_state.scissor_x = x; current_state.scissor_y = y; current_state.scissor_width = width; current_state.scissor_height = height; current_state.scissor_set = true; - kinc_g5_command_list_scissor(&commandList, x, y, width, height); + iron_g5_command_list_scissor(&commandList, x, y, width, height); } -void kinc_g4_disable_scissor(void) { +void iron_g4_disable_scissor(void) { current_state.scissor_set = false; - kinc_g5_command_list_disable_scissor(&commandList); + iron_g5_command_list_disable_scissor(&commandList); } -void kinc_g4_end() { - kinc_g5_constant_buffer_unlock(&vertexConstantBuffer); - kinc_g5_constant_buffer_unlock(&fragmentConstantBuffer); - kinc_g5_constant_buffer_unlock(&computeConstantBuffer); +void iron_g4_end() { + iron_g5_constant_buffer_unlock(&vertexConstantBuffer); + iron_g5_constant_buffer_unlock(&fragmentConstantBuffer); + iron_g5_constant_buffer_unlock(&computeConstantBuffer); - kinc_g5_command_list_render_target_to_framebuffer_barrier(&commandList, &windows[0].framebuffers[windows[0].currentBuffer]); - kinc_g5_command_list_end(&commandList); - kinc_g5_command_list_execute(&commandList); + iron_g5_command_list_render_target_to_framebuffer_barrier(&commandList, &windows[0].framebuffers[windows[0].currentBuffer]); + iron_g5_command_list_end(&commandList); + iron_g5_command_list_execute(&commandList); - kinc_g5_end(); + iron_g5_end(); - // to support doing work after kinc_g4_end and before kinc_g4_begin - kinc_g5_command_list_begin(&commandList); + // to support doing work after iron_g4_end and before iron_g4_begin + iron_g5_command_list_begin(&commandList); } -void kinc_g4_set_int(kinc_g5_constant_location_t location, int value) { +void iron_g4_set_int(iron_g5_constant_location_t location, int value) { if (location.impl.vertexOffset >= 0) - kinc_g5_constant_buffer_set_int(&vertexConstantBuffer, location.impl.vertexOffset, value); + iron_g5_constant_buffer_set_int(&vertexConstantBuffer, location.impl.vertexOffset, value); if (location.impl.fragmentOffset >= 0) - kinc_g5_constant_buffer_set_int(&fragmentConstantBuffer, location.impl.fragmentOffset, value); + iron_g5_constant_buffer_set_int(&fragmentConstantBuffer, location.impl.fragmentOffset, value); if (location.impl.computeOffset >= 0) - kinc_g5_constant_buffer_set_int(&computeConstantBuffer, location.impl.computeOffset, value); + iron_g5_constant_buffer_set_int(&computeConstantBuffer, location.impl.computeOffset, value); } -void kinc_g4_set_int2(kinc_g5_constant_location_t location, int value1, int value2) { +void iron_g4_set_int2(iron_g5_constant_location_t location, int value1, int value2) { if (location.impl.vertexOffset >= 0) - kinc_g5_constant_buffer_set_int2(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2); + iron_g5_constant_buffer_set_int2(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2); if (location.impl.fragmentOffset >= 0) - kinc_g5_constant_buffer_set_int2(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2); + iron_g5_constant_buffer_set_int2(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2); if (location.impl.computeOffset >= 0) - kinc_g5_constant_buffer_set_int2(&computeConstantBuffer, location.impl.computeOffset, value1, value2); + iron_g5_constant_buffer_set_int2(&computeConstantBuffer, location.impl.computeOffset, value1, value2); } -void kinc_g4_set_int3(kinc_g5_constant_location_t location, int value1, int value2, int value3) { +void iron_g4_set_int3(iron_g5_constant_location_t location, int value1, int value2, int value3) { if (location.impl.vertexOffset >= 0) - kinc_g5_constant_buffer_set_int3(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2, value3); + iron_g5_constant_buffer_set_int3(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2, value3); if (location.impl.fragmentOffset >= 0) - kinc_g5_constant_buffer_set_int3(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2, value3); + iron_g5_constant_buffer_set_int3(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2, value3); if (location.impl.computeOffset >= 0) - kinc_g5_constant_buffer_set_int3(&computeConstantBuffer, location.impl.computeOffset, value1, value2, value3); + iron_g5_constant_buffer_set_int3(&computeConstantBuffer, location.impl.computeOffset, value1, value2, value3); } -void kinc_g4_set_int4(kinc_g5_constant_location_t location, int value1, int value2, int value3, int value4) { +void iron_g4_set_int4(iron_g5_constant_location_t location, int value1, int value2, int value3, int value4) { if (location.impl.vertexOffset >= 0) - kinc_g5_constant_buffer_set_int4(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2, value3, value4); + iron_g5_constant_buffer_set_int4(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2, value3, value4); if (location.impl.fragmentOffset >= 0) - kinc_g5_constant_buffer_set_int4(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2, value3, value4); + iron_g5_constant_buffer_set_int4(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2, value3, value4); if (location.impl.computeOffset >= 0) - kinc_g5_constant_buffer_set_int4(&computeConstantBuffer, location.impl.computeOffset, value1, value2, value3, value4); + iron_g5_constant_buffer_set_int4(&computeConstantBuffer, location.impl.computeOffset, value1, value2, value3, value4); } -void kinc_g4_set_ints(kinc_g5_constant_location_t location, int *values, int count) { +void iron_g4_set_ints(iron_g5_constant_location_t location, int *values, int count) { if (location.impl.vertexOffset >= 0) - kinc_g5_constant_buffer_set_ints(&vertexConstantBuffer, location.impl.vertexOffset, values, count); + iron_g5_constant_buffer_set_ints(&vertexConstantBuffer, location.impl.vertexOffset, values, count); if (location.impl.fragmentOffset >= 0) - kinc_g5_constant_buffer_set_ints(&fragmentConstantBuffer, location.impl.fragmentOffset, values, count); + iron_g5_constant_buffer_set_ints(&fragmentConstantBuffer, location.impl.fragmentOffset, values, count); if (location.impl.computeOffset >= 0) - kinc_g5_constant_buffer_set_ints(&computeConstantBuffer, location.impl.computeOffset, values, count); + iron_g5_constant_buffer_set_ints(&computeConstantBuffer, location.impl.computeOffset, values, count); } -void kinc_g4_set_float(kinc_g5_constant_location_t location, float value) { +void iron_g4_set_float(iron_g5_constant_location_t location, float value) { if (location.impl.vertexOffset >= 0) - kinc_g5_constant_buffer_set_float(&vertexConstantBuffer, location.impl.vertexOffset, value); + iron_g5_constant_buffer_set_float(&vertexConstantBuffer, location.impl.vertexOffset, value); if (location.impl.fragmentOffset >= 0) - kinc_g5_constant_buffer_set_float(&fragmentConstantBuffer, location.impl.fragmentOffset, value); + iron_g5_constant_buffer_set_float(&fragmentConstantBuffer, location.impl.fragmentOffset, value); if (location.impl.computeOffset >= 0) - kinc_g5_constant_buffer_set_float(&computeConstantBuffer, location.impl.computeOffset, value); + iron_g5_constant_buffer_set_float(&computeConstantBuffer, location.impl.computeOffset, value); } -void kinc_g4_set_float2(kinc_g5_constant_location_t location, float value1, float value2) { +void iron_g4_set_float2(iron_g5_constant_location_t location, float value1, float value2) { if (location.impl.vertexOffset >= 0) - kinc_g5_constant_buffer_set_float2(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2); + iron_g5_constant_buffer_set_float2(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2); if (location.impl.fragmentOffset >= 0) - kinc_g5_constant_buffer_set_float2(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2); + iron_g5_constant_buffer_set_float2(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2); if (location.impl.computeOffset >= 0) - kinc_g5_constant_buffer_set_float2(&computeConstantBuffer, location.impl.computeOffset, value1, value2); + iron_g5_constant_buffer_set_float2(&computeConstantBuffer, location.impl.computeOffset, value1, value2); } -void kinc_g4_set_float3(kinc_g5_constant_location_t location, float value1, float value2, float value3) { +void iron_g4_set_float3(iron_g5_constant_location_t location, float value1, float value2, float value3) { if (location.impl.vertexOffset >= 0) - kinc_g5_constant_buffer_set_float3(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2, value3); + iron_g5_constant_buffer_set_float3(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2, value3); if (location.impl.fragmentOffset >= 0) - kinc_g5_constant_buffer_set_float3(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2, value3); + iron_g5_constant_buffer_set_float3(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2, value3); if (location.impl.computeOffset >= 0) - kinc_g5_constant_buffer_set_float3(&computeConstantBuffer, location.impl.computeOffset, value1, value2, value3); + iron_g5_constant_buffer_set_float3(&computeConstantBuffer, location.impl.computeOffset, value1, value2, value3); } -void kinc_g4_set_float4(kinc_g5_constant_location_t location, float value1, float value2, float value3, float value4) { +void iron_g4_set_float4(iron_g5_constant_location_t location, float value1, float value2, float value3, float value4) { if (location.impl.vertexOffset >= 0) - kinc_g5_constant_buffer_set_float4(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2, value3, value4); + iron_g5_constant_buffer_set_float4(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2, value3, value4); if (location.impl.fragmentOffset >= 0) - kinc_g5_constant_buffer_set_float4(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2, value3, value4); + iron_g5_constant_buffer_set_float4(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2, value3, value4); if (location.impl.computeOffset >= 0) - kinc_g5_constant_buffer_set_float4(&computeConstantBuffer, location.impl.computeOffset, value1, value2, value3, value4); + iron_g5_constant_buffer_set_float4(&computeConstantBuffer, location.impl.computeOffset, value1, value2, value3, value4); } -void kinc_g4_set_floats(kinc_g5_constant_location_t location, float *values, int count) { +void iron_g4_set_floats(iron_g5_constant_location_t location, float *values, int count) { if (location.impl.vertexOffset >= 0) - kinc_g5_constant_buffer_set_floats(&vertexConstantBuffer, location.impl.vertexOffset, values, count); + iron_g5_constant_buffer_set_floats(&vertexConstantBuffer, location.impl.vertexOffset, values, count); if (location.impl.fragmentOffset >= 0) - kinc_g5_constant_buffer_set_floats(&fragmentConstantBuffer, location.impl.fragmentOffset, values, count); + iron_g5_constant_buffer_set_floats(&fragmentConstantBuffer, location.impl.fragmentOffset, values, count); if (location.impl.computeOffset >= 0) - kinc_g5_constant_buffer_set_floats(&computeConstantBuffer, location.impl.computeOffset, values, count); + iron_g5_constant_buffer_set_floats(&computeConstantBuffer, location.impl.computeOffset, values, count); } -void kinc_g4_set_bool(kinc_g5_constant_location_t location, bool value) { +void iron_g4_set_bool(iron_g5_constant_location_t location, bool value) { if (location.impl.vertexOffset >= 0) - kinc_g5_constant_buffer_set_bool(&vertexConstantBuffer, location.impl.vertexOffset, value); + iron_g5_constant_buffer_set_bool(&vertexConstantBuffer, location.impl.vertexOffset, value); if (location.impl.fragmentOffset >= 0) - kinc_g5_constant_buffer_set_bool(&fragmentConstantBuffer, location.impl.fragmentOffset, value); + iron_g5_constant_buffer_set_bool(&fragmentConstantBuffer, location.impl.fragmentOffset, value); if (location.impl.computeOffset >= 0) - kinc_g5_constant_buffer_set_bool(&computeConstantBuffer, location.impl.computeOffset, value); + iron_g5_constant_buffer_set_bool(&computeConstantBuffer, location.impl.computeOffset, value); } -void kinc_g4_set_matrix4(kinc_g5_constant_location_t location, kinc_matrix4x4_t *value) { +void iron_g4_set_matrix4(iron_g5_constant_location_t location, iron_matrix4x4_t *value) { if (location.impl.vertexOffset >= 0) - kinc_g5_constant_buffer_set_matrix4(&vertexConstantBuffer, location.impl.vertexOffset, value); + iron_g5_constant_buffer_set_matrix4(&vertexConstantBuffer, location.impl.vertexOffset, value); if (location.impl.fragmentOffset >= 0) - kinc_g5_constant_buffer_set_matrix4(&fragmentConstantBuffer, location.impl.fragmentOffset, value); + iron_g5_constant_buffer_set_matrix4(&fragmentConstantBuffer, location.impl.fragmentOffset, value); if (location.impl.computeOffset >= 0) - kinc_g5_constant_buffer_set_matrix4(&computeConstantBuffer, location.impl.computeOffset, value); + iron_g5_constant_buffer_set_matrix4(&computeConstantBuffer, location.impl.computeOffset, value); } -void kinc_g4_set_matrix3(kinc_g5_constant_location_t location, kinc_matrix3x3_t *value) { +void iron_g4_set_matrix3(iron_g5_constant_location_t location, iron_matrix3x3_t *value) { if (location.impl.vertexOffset >= 0) - kinc_g5_constant_buffer_set_matrix3(&vertexConstantBuffer, location.impl.vertexOffset, value); + iron_g5_constant_buffer_set_matrix3(&vertexConstantBuffer, location.impl.vertexOffset, value); if (location.impl.fragmentOffset >= 0) - kinc_g5_constant_buffer_set_matrix3(&fragmentConstantBuffer, location.impl.fragmentOffset, value); + iron_g5_constant_buffer_set_matrix3(&fragmentConstantBuffer, location.impl.fragmentOffset, value); if (location.impl.computeOffset >= 0) - kinc_g5_constant_buffer_set_matrix3(&computeConstantBuffer, location.impl.computeOffset, value); + iron_g5_constant_buffer_set_matrix3(&computeConstantBuffer, location.impl.computeOffset, value); } -void kinc_g4_set_texture_addressing(kinc_g5_texture_unit_t unit, kinc_g4_texture_direction_t dir, kinc_g4_texture_addressing_t addressing) { - for (int i = 0; i < KINC_G5_SHADER_TYPE_COUNT; ++i) { +void iron_g4_set_texture_addressing(iron_g5_texture_unit_t unit, iron_g4_texture_direction_t dir, iron_g4_texture_addressing_t addressing) { + for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { if (unit.stages[i] >= 0) { - if (dir == KINC_G4_TEXTURE_DIRECTION_U) { - sampler_options[i][unit.stages[i]].u_addressing = (kinc_g5_texture_addressing_t)addressing; + if (dir == IRON_G4_TEXTURE_DIRECTION_U) { + sampler_options[i][unit.stages[i]].u_addressing = (iron_g5_texture_addressing_t)addressing; } - if (dir == KINC_G4_TEXTURE_DIRECTION_V) { - sampler_options[i][unit.stages[i]].v_addressing = (kinc_g5_texture_addressing_t)addressing; + if (dir == IRON_G4_TEXTURE_DIRECTION_V) { + sampler_options[i][unit.stages[i]].v_addressing = (iron_g5_texture_addressing_t)addressing; } } } } -void kinc_g4_set_texture_magnification_filter(kinc_g5_texture_unit_t texunit, kinc_g4_texture_filter_t filter) { - for (int i = 0; i < KINC_G5_SHADER_TYPE_COUNT; ++i) { +void iron_g4_set_texture_magnification_filter(iron_g5_texture_unit_t texunit, iron_g4_texture_filter_t filter) { + for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { if (texunit.stages[i] >= 0) { - sampler_options[i][texunit.stages[i]].magnification_filter = (kinc_g5_texture_filter_t)filter; + sampler_options[i][texunit.stages[i]].magnification_filter = (iron_g5_texture_filter_t)filter; } } } -void kinc_g4_set_texture_minification_filter(kinc_g5_texture_unit_t texunit, kinc_g4_texture_filter_t filter) { - for (int i = 0; i < KINC_G5_SHADER_TYPE_COUNT; ++i) { +void iron_g4_set_texture_minification_filter(iron_g5_texture_unit_t texunit, iron_g4_texture_filter_t filter) { + for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { if (texunit.stages[i] >= 0) { - sampler_options[i][texunit.stages[i]].minification_filter = (kinc_g5_texture_filter_t)filter; + sampler_options[i][texunit.stages[i]].minification_filter = (iron_g5_texture_filter_t)filter; } } } -void kinc_g4_set_texture_mipmap_filter(kinc_g5_texture_unit_t texunit, kinc_g4_mipmap_filter_t filter) { - for (int i = 0; i < KINC_G5_SHADER_TYPE_COUNT; ++i) { +void iron_g4_set_texture_mipmap_filter(iron_g5_texture_unit_t texunit, iron_g4_mipmap_filter_t filter) { + for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { if (texunit.stages[i] >= 0) { - sampler_options[i][texunit.stages[i]].mipmap_filter = (kinc_g5_mipmap_filter_t)filter; + sampler_options[i][texunit.stages[i]].mipmap_filter = (iron_g5_mipmap_filter_t)filter; } } } -void kinc_g4_restore_render_target(void) { - kinc_g5_internal_restore_render_target(); +void iron_g4_restore_render_target(void) { + iron_g5_internal_restore_render_target(); current_state.viewport_set = false; current_state.scissor_set = false; } -void kinc_g4_set_render_targets(kinc_g5_texture_t **targets, int count) { +void iron_g4_set_render_targets(iron_g5_texture_t **targets, int count) { for (int i = 0; i < count; ++i) { windows[0].current_render_targets[i] = targets[i]; - if (windows[0].current_render_targets[i]->state != KINC_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET) { - kinc_g5_command_list_texture_to_render_target_barrier(&commandList, windows[0].current_render_targets[i]); - windows[0].current_render_targets[i]->state = KINC_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; + if (windows[0].current_render_targets[i]->state != IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET) { + iron_g5_command_list_texture_to_render_target_barrier(&commandList, windows[0].current_render_targets[i]); + windows[0].current_render_targets[i]->state = IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; } } windows[0].current_render_target_count = count; - kinc_g5_texture_t *render_targets[16]; + iron_g5_texture_t *render_targets[16]; for (int i = 0; i < count; ++i) { render_targets[i] = targets[i]; } - kinc_g5_command_list_set_render_targets(&commandList, render_targets, count); + iron_g5_command_list_set_render_targets(&commandList, render_targets, count); current_state.viewport_set = false; current_state.scissor_set = false; } -void kinc_g4_set_vertex_buffer(kinc_g4_vertex_buffer_t *buffer) { - kinc_g5_vertex_buffer_t *g5_vertex_buffer = &buffer->impl._buffer[buffer->impl._currentIndex]; +void iron_g4_set_vertex_buffer(iron_g4_vertex_buffer_t *buffer) { + iron_g5_vertex_buffer_t *g5_vertex_buffer = &buffer->impl._buffer[buffer->impl._currentIndex]; current_state.vertex_buffer = g5_vertex_buffer; - kinc_g5_command_list_set_vertex_buffer(&commandList, g5_vertex_buffer); + iron_g5_command_list_set_vertex_buffer(&commandList, g5_vertex_buffer); } -void kinc_g4_set_index_buffer(kinc_g5_index_buffer_t *buffer) { +void iron_g4_set_index_buffer(iron_g5_index_buffer_t *buffer) { current_state.index_buffer = buffer; - kinc_g5_command_list_set_index_buffer(&commandList, buffer); + iron_g5_command_list_set_index_buffer(&commandList, buffer); } -void kinc_g5_set_pipeline(kinc_g5_pipeline_t *pipeline) { +void iron_g5_set_pipeline(iron_g5_pipeline_t *pipeline) { current_state.pipeline = pipeline; - kinc_g5_command_list_set_pipeline(&commandList, pipeline); + iron_g5_command_list_set_pipeline(&commandList, pipeline); } -void kinc_g4_set_texture(kinc_g5_texture_unit_t unit, kinc_g5_texture_t *render_target) { +void iron_g4_set_texture(iron_g5_texture_unit_t unit, iron_g5_texture_t *render_target) { if (!render_target->_uploaded) { - kinc_g5_command_list_upload_texture(&commandList, render_target); + iron_g5_command_list_upload_texture(&commandList, render_target); render_target->_uploaded = true; } - if (render_target->state != KINC_INTERNAL_RENDER_TARGET_STATE_TEXTURE) { - kinc_g5_command_list_render_target_to_texture_barrier(&commandList, render_target); - render_target->state = KINC_INTERNAL_RENDER_TARGET_STATE_TEXTURE; + if (render_target->state != IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE) { + iron_g5_command_list_render_target_to_texture_barrier(&commandList, render_target); + render_target->state = IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE; } - kinc_g5_texture_unit_t g5_unit; - memcpy(&g5_unit.stages[0], &unit.stages[0], KINC_G5_SHADER_TYPE_COUNT * sizeof(int)); + iron_g5_texture_unit_t g5_unit; + memcpy(&g5_unit.stages[0], &unit.stages[0], IRON_G5_SHADER_TYPE_COUNT * sizeof(int)); bool found = false; for (int i = 0; i < current_state.texture_count; ++i) { - if (kinc_g5_texture_unit_equals(¤t_state.texture_units[i], &g5_unit)) { + if (iron_g5_texture_unit_equals(¤t_state.texture_units[i], &g5_unit)) { current_state.textures[i] = render_target; current_state.texture_units[i] = g5_unit; found = true; @@ -553,21 +553,21 @@ void kinc_g4_set_texture(kinc_g5_texture_unit_t unit, kinc_g5_texture_t *render_ current_state.texture_count += 1; } - kinc_g5_command_list_set_texture(&commandList, g5_unit, render_target); + iron_g5_command_list_set_texture(&commandList, g5_unit, render_target); } -void kinc_g4_render_target_use_depth_as_texture(kinc_g5_texture_t *render_target, kinc_g5_texture_unit_t unit) { - if (render_target->state != KINC_INTERNAL_RENDER_TARGET_STATE_TEXTURE) { - kinc_g5_command_list_render_target_to_texture_barrier(&commandList, render_target); - render_target->state = KINC_INTERNAL_RENDER_TARGET_STATE_TEXTURE; +void iron_g4_render_target_use_depth_as_texture(iron_g5_texture_t *render_target, iron_g5_texture_unit_t unit) { + if (render_target->state != IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE) { + iron_g5_command_list_render_target_to_texture_barrier(&commandList, render_target); + render_target->state = IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE; } - kinc_g5_texture_unit_t g5_unit; - memcpy(&g5_unit.stages[0], &unit.stages[0], KINC_G5_SHADER_TYPE_COUNT * sizeof(int)); + iron_g5_texture_unit_t g5_unit; + memcpy(&g5_unit.stages[0], &unit.stages[0], IRON_G5_SHADER_TYPE_COUNT * sizeof(int)); bool found = false; for (int i = 0; i < current_state.depth_render_target_count; ++i) { - if (kinc_g5_texture_unit_equals(¤t_state.depth_render_target_units[i], &g5_unit)) { + if (iron_g5_texture_unit_equals(¤t_state.depth_render_target_units[i], &g5_unit)) { current_state.depth_render_targets[i] = render_target; current_state.depth_render_target_units[i] = g5_unit; found = true; @@ -581,60 +581,60 @@ void kinc_g4_render_target_use_depth_as_texture(kinc_g5_texture_t *render_target current_state.depth_render_target_count += 1; } - kinc_g5_command_list_set_texture_from_render_target_depth(&commandList, g5_unit, render_target); + iron_g5_command_list_set_texture_from_render_target_depth(&commandList, g5_unit, render_target); } -void kinc_g5_set_compute_shader(kinc_g5_compute_shader *shader) { +void iron_g5_set_compute_shader(iron_g5_compute_shader *shader) { current_state.compute_shader = shader; - kinc_g5_command_list_set_compute_shader(&commandList, shader); + iron_g5_command_list_set_compute_shader(&commandList, shader); } -void kinc_g4_compute(int x, int y, int z) { - kinc_internal_start_draw(true); - kinc_g5_command_list_compute(&commandList, x, y, z); - kinc_internal_end_draw(true); +void iron_g4_compute(int x, int y, int z) { + iron_internal_start_draw(true); + iron_g5_command_list_compute(&commandList, x, y, z); + iron_internal_end_draw(true); } -void kinc_g5_render_target_get_pixels(kinc_g5_texture_t *render_target, uint8_t *data) { - kinc_g5_command_list_get_render_target_pixels(&commandList, render_target, data); +void iron_g5_render_target_get_pixels(iron_g5_texture_t *render_target, uint8_t *data) { + iron_g5_command_list_get_render_target_pixels(&commandList, render_target, data); } -void kinc_g4_index_buffer_unlock_all(kinc_g5_index_buffer_t *buffer) { - kinc_g5_index_buffer_unlock_all(buffer); - kinc_g5_command_list_upload_index_buffer(&commandList, buffer); +void iron_g4_index_buffer_unlock_all(iron_g5_index_buffer_t *buffer) { + iron_g5_index_buffer_unlock_all(buffer); + iron_g5_command_list_upload_index_buffer(&commandList, buffer); } -void kinc_g4_index_buffer_unlock(kinc_g5_index_buffer_t *buffer, int count) { - kinc_g5_index_buffer_unlock(buffer, count); - kinc_g5_command_list_upload_index_buffer(&commandList, buffer); +void iron_g4_index_buffer_unlock(iron_g5_index_buffer_t *buffer, int count) { + iron_g5_index_buffer_unlock(buffer, count); + iron_g5_command_list_upload_index_buffer(&commandList, buffer); } -void kinc_g5_vertex_structure_init(kinc_g5_vertex_structure_t *structure) { +void iron_g5_vertex_structure_init(iron_g5_vertex_structure_t *structure) { structure->size = 0; } -void kinc_g5_vertex_structure_add(kinc_g5_vertex_structure_t *structure, const char *name, kinc_g5_vertex_data_t data) { +void iron_g5_vertex_structure_add(iron_g5_vertex_structure_t *structure, const char *name, iron_g5_vertex_data_t data) { structure->elements[structure->size].name = name; structure->elements[structure->size].data = data; structure->size++; } -void kinc_g4_vertex_buffer_init(kinc_g4_vertex_buffer_t *buffer, int count, kinc_g5_vertex_structure_t *structure, kinc_g4_usage_t usage) { - buffer->impl._multiple = usage == KINC_G4_USAGE_STATIC ? 1 : 2; +void iron_g4_vertex_buffer_init(iron_g4_vertex_buffer_t *buffer, int count, iron_g5_vertex_structure_t *structure, iron_g4_usage_t usage) { + buffer->impl._multiple = usage == IRON_G4_USAGE_STATIC ? 1 : 2; buffer->impl._currentIndex = 0; buffer->impl.myCount = count; for (int i = 0; i < buffer->impl._multiple; ++i) { - kinc_g5_vertex_buffer_init(&buffer->impl._buffer[i], count, structure, usage == KINC_G4_USAGE_STATIC); + iron_g5_vertex_buffer_init(&buffer->impl._buffer[i], count, structure, usage == IRON_G4_USAGE_STATIC); } } -void kinc_g4_vertex_buffer_destroy(kinc_g4_vertex_buffer_t *buffer) { +void iron_g4_vertex_buffer_destroy(iron_g4_vertex_buffer_t *buffer) { for (int i = 0; i < buffer->impl._multiple; ++i) { - kinc_g5_vertex_buffer_destroy(&buffer->impl._buffer[i]); + iron_g5_vertex_buffer_destroy(&buffer->impl._buffer[i]); } } -static void kinc_internal_prepare_lock(kinc_g4_vertex_buffer_t *buffer) { +static void iron_internal_prepare_lock(iron_g4_vertex_buffer_t *buffer) { ++buffer->impl._currentIndex; if (buffer->impl._currentIndex >= buffer->impl._multiple - 1) { waitAfterNextDraw = true; @@ -644,51 +644,51 @@ static void kinc_internal_prepare_lock(kinc_g4_vertex_buffer_t *buffer) { } } -float *kinc_g4_vertex_buffer_lock_all(kinc_g4_vertex_buffer_t *buffer) { - kinc_internal_prepare_lock(buffer); - return kinc_g5_vertex_buffer_lock_all(&buffer->impl._buffer[buffer->impl._currentIndex]); +float *iron_g4_vertex_buffer_lock_all(iron_g4_vertex_buffer_t *buffer) { + iron_internal_prepare_lock(buffer); + return iron_g5_vertex_buffer_lock_all(&buffer->impl._buffer[buffer->impl._currentIndex]); } -float *kinc_g4_vertex_buffer_lock(kinc_g4_vertex_buffer_t *buffer, int start, int count) { - kinc_internal_prepare_lock(buffer); - return kinc_g5_vertex_buffer_lock(&buffer->impl._buffer[buffer->impl._currentIndex], start, count); +float *iron_g4_vertex_buffer_lock(iron_g4_vertex_buffer_t *buffer, int start, int count) { + iron_internal_prepare_lock(buffer); + return iron_g5_vertex_buffer_lock(&buffer->impl._buffer[buffer->impl._currentIndex], start, count); } -void kinc_g4_vertex_buffer_unlock_all(kinc_g4_vertex_buffer_t *buffer) { - kinc_g5_vertex_buffer_unlock_all(&buffer->impl._buffer[buffer->impl._currentIndex]); +void iron_g4_vertex_buffer_unlock_all(iron_g4_vertex_buffer_t *buffer) { + iron_g5_vertex_buffer_unlock_all(&buffer->impl._buffer[buffer->impl._currentIndex]); } -void kinc_g4_vertex_buffer_unlock(kinc_g4_vertex_buffer_t *buffer, int count) { - kinc_g5_vertex_buffer_unlock(&buffer->impl._buffer[buffer->impl._currentIndex], count); +void iron_g4_vertex_buffer_unlock(iron_g4_vertex_buffer_t *buffer, int count) { + iron_g5_vertex_buffer_unlock(&buffer->impl._buffer[buffer->impl._currentIndex], count); } -int kinc_g4_vertex_buffer_count(kinc_g4_vertex_buffer_t *buffer) { +int iron_g4_vertex_buffer_count(iron_g4_vertex_buffer_t *buffer) { return buffer->impl.myCount; } -int kinc_g4_vertex_buffer_stride(kinc_g4_vertex_buffer_t *buffer) { - return kinc_g5_vertex_buffer_stride(&buffer->impl._buffer[buffer->impl._currentIndex]); +int iron_g4_vertex_buffer_stride(iron_g4_vertex_buffer_t *buffer) { + return iron_g5_vertex_buffer_stride(&buffer->impl._buffer[buffer->impl._currentIndex]); } -void kinc_g5_constant_buffer_set_int(kinc_g5_constant_buffer_t *buffer, int offset, int value) { +void iron_g5_constant_buffer_set_int(iron_g5_constant_buffer_t *buffer, int offset, int value) { int *ints = (int *)(&buffer->data[offset]); ints[0] = value; } -void kinc_g5_constant_buffer_set_int2(kinc_g5_constant_buffer_t *buffer, int offset, int value1, int value2) { +void iron_g5_constant_buffer_set_int2(iron_g5_constant_buffer_t *buffer, int offset, int value1, int value2) { int *ints = (int *)(&buffer->data[offset]); ints[0] = value1; ints[1] = value2; } -void kinc_g5_constant_buffer_set_int3(kinc_g5_constant_buffer_t *buffer, int offset, int value1, int value2, int value3) { +void iron_g5_constant_buffer_set_int3(iron_g5_constant_buffer_t *buffer, int offset, int value1, int value2, int value3) { int *ints = (int *)(&buffer->data[offset]); ints[0] = value1; ints[1] = value2; ints[2] = value3; } -void kinc_g5_constant_buffer_set_int4(kinc_g5_constant_buffer_t *buffer, int offset, int value1, int value2, int value3, int value4) { +void iron_g5_constant_buffer_set_int4(iron_g5_constant_buffer_t *buffer, int offset, int value1, int value2, int value3, int value4) { int *ints = (int *)(&buffer->data[offset]); ints[0] = value1; ints[1] = value2; @@ -696,32 +696,32 @@ void kinc_g5_constant_buffer_set_int4(kinc_g5_constant_buffer_t *buffer, int off ints[3] = value4; } -void kinc_g5_constant_buffer_set_ints(kinc_g5_constant_buffer_t *buffer, int offset, int *values, int count) { +void iron_g5_constant_buffer_set_ints(iron_g5_constant_buffer_t *buffer, int offset, int *values, int count) { int *ints = (int *)(&buffer->data[offset]); for (int i = 0; i < count; ++i) { ints[i] = values[i]; } } -void kinc_g5_constant_buffer_set_float(kinc_g5_constant_buffer_t *buffer, int offset, float value) { +void iron_g5_constant_buffer_set_float(iron_g5_constant_buffer_t *buffer, int offset, float value) { float *floats = (float *)(&buffer->data[offset]); floats[0] = value; } -void kinc_g5_constant_buffer_set_float2(kinc_g5_constant_buffer_t *buffer, int offset, float value1, float value2) { +void iron_g5_constant_buffer_set_float2(iron_g5_constant_buffer_t *buffer, int offset, float value1, float value2) { float *floats = (float *)(&buffer->data[offset]); floats[0] = value1; floats[1] = value2; } -void kinc_g5_constant_buffer_set_float3(kinc_g5_constant_buffer_t *buffer, int offset, float value1, float value2, float value3) { +void iron_g5_constant_buffer_set_float3(iron_g5_constant_buffer_t *buffer, int offset, float value1, float value2, float value3) { float *floats = (float *)(&buffer->data[offset]); floats[0] = value1; floats[1] = value2; floats[2] = value3; } -void kinc_g5_constant_buffer_set_float4(kinc_g5_constant_buffer_t *buffer, int offset, float value1, float value2, float value3, float value4) { +void iron_g5_constant_buffer_set_float4(iron_g5_constant_buffer_t *buffer, int offset, float value1, float value2, float value3, float value4) { float *floats = (float *)(&buffer->data[offset]); floats[0] = value1; floats[1] = value2; @@ -729,132 +729,132 @@ void kinc_g5_constant_buffer_set_float4(kinc_g5_constant_buffer_t *buffer, int o floats[3] = value4; } -void kinc_g5_constant_buffer_set_floats(kinc_g5_constant_buffer_t *buffer, int offset, float *values, int count) { +void iron_g5_constant_buffer_set_floats(iron_g5_constant_buffer_t *buffer, int offset, float *values, int count) { float *floats = (float *)(&buffer->data[offset]); for (int i = 0; i < count; ++i) { floats[i] = values[i]; } } -void kinc_g5_constant_buffer_set_bool(kinc_g5_constant_buffer_t *buffer, int offset, bool value) { +void iron_g5_constant_buffer_set_bool(iron_g5_constant_buffer_t *buffer, int offset, bool value) { int *ints = (int *)(&buffer->data[offset]); ints[0] = value ? 1 : 0; } -static void kinc_internal_set_matrix3(uint8_t *constants, int offset, kinc_matrix3x3_t *value) { +static void iron_internal_set_matrix3(uint8_t *constants, int offset, iron_matrix3x3_t *value) { float *floats = (float *)(&constants[offset]); for (int y = 0; y < 3; ++y) { for (int x = 0; x < 3; ++x) { - floats[x + y * 4] = kinc_matrix3x3_get(value, x, y); + floats[x + y * 4] = iron_matrix3x3_get(value, x, y); } } } -void kinc_g5_constant_buffer_set_matrix3(kinc_g5_constant_buffer_t *buffer, int offset, kinc_matrix3x3_t *value) { - if (kinc_g5_transpose_mat) { - kinc_matrix3x3_t m = *value; - kinc_matrix3x3_transpose(&m); - kinc_internal_set_matrix3(buffer->data, offset, &m); +void iron_g5_constant_buffer_set_matrix3(iron_g5_constant_buffer_t *buffer, int offset, iron_matrix3x3_t *value) { + if (iron_g5_transpose_mat) { + iron_matrix3x3_t m = *value; + iron_matrix3x3_transpose(&m); + iron_internal_set_matrix3(buffer->data, offset, &m); } else { - kinc_internal_set_matrix3(buffer->data, offset, value); + iron_internal_set_matrix3(buffer->data, offset, value); } } -static void kinc_internal_set_matrix4(uint8_t *constants, int offset, kinc_matrix4x4_t *value) { +static void iron_internal_set_matrix4(uint8_t *constants, int offset, iron_matrix4x4_t *value) { float *floats = (float *)(&constants[offset]); for (int y = 0; y < 4; ++y) { for (int x = 0; x < 4; ++x) { - floats[x + y * 4] = kinc_matrix4x4_get(value, x, y); + floats[x + y * 4] = iron_matrix4x4_get(value, x, y); } } } -void kinc_g5_constant_buffer_set_matrix4(kinc_g5_constant_buffer_t *buffer, int offset, kinc_matrix4x4_t *value) { - if (kinc_g5_transpose_mat) { - kinc_matrix4x4_t m = *value; - kinc_matrix4x4_transpose(&m); - kinc_internal_set_matrix4(buffer->data, offset, &m); +void iron_g5_constant_buffer_set_matrix4(iron_g5_constant_buffer_t *buffer, int offset, iron_matrix4x4_t *value) { + if (iron_g5_transpose_mat) { + iron_matrix4x4_t m = *value; + iron_matrix4x4_transpose(&m); + iron_internal_set_matrix4(buffer->data, offset, &m); } else { - kinc_internal_set_matrix4(buffer->data, offset, value); + iron_internal_set_matrix4(buffer->data, offset, value); } } -void kinc_g5_internal_pipeline_init(kinc_g5_pipeline_t *pipe) { +void iron_g5_internal_pipeline_init(iron_g5_pipeline_t *pipe) { pipe->input_layout = NULL; pipe->vertex_shader = NULL; pipe->fragment_shader = NULL; - pipe->cull_mode = KINC_G5_CULL_MODE_NEVER; + pipe->cull_mode = IRON_G5_CULL_MODE_NEVER; pipe->depth_write = false; - pipe->depth_mode = KINC_G5_COMPARE_MODE_ALWAYS; + pipe->depth_mode = IRON_G5_COMPARE_MODE_ALWAYS; - pipe->blend_source = KINC_G5_BLEND_ONE; - pipe->blend_destination = KINC_G5_BLEND_ZERO; - pipe->blend_operation = KINC_G5_BLENDOP_ADD; - pipe->alpha_blend_source = KINC_G5_BLEND_ONE; - pipe->alpha_blend_destination = KINC_G5_BLEND_ZERO; - pipe->alpha_blend_operation = KINC_G5_BLENDOP_ADD; + pipe->blend_source = IRON_G5_BLEND_ONE; + pipe->blend_destination = IRON_G5_BLEND_ZERO; + pipe->blend_operation = IRON_G5_BLENDOP_ADD; + pipe->alpha_blend_source = IRON_G5_BLEND_ONE; + pipe->alpha_blend_destination = IRON_G5_BLEND_ZERO; + pipe->alpha_blend_operation = IRON_G5_BLENDOP_ADD; for (int i = 0; i < 8; ++i) { pipe->color_write_mask_red[i] = true; pipe->color_write_mask_green[i] = true; pipe->color_write_mask_blue[i] = true; pipe->color_write_mask_alpha[i] = true; - pipe->color_attachment[i] = KINC_IMAGE_FORMAT_RGBA32; + pipe->color_attachment[i] = IRON_IMAGE_FORMAT_RGBA32; } pipe->color_attachment_count = 1; pipe->depth_attachment_bits = 0; } -void kinc_g5_internal_pipeline_set_defaults(kinc_g5_pipeline_t *state) { +void iron_g5_internal_pipeline_set_defaults(iron_g5_pipeline_t *state) { state->input_layout = NULL; state->vertex_shader = NULL; state->fragment_shader = NULL; - state->cull_mode = KINC_G5_CULL_MODE_NEVER; + state->cull_mode = IRON_G5_CULL_MODE_NEVER; state->depth_write = false; - state->depth_mode = KINC_G5_COMPARE_MODE_ALWAYS; + state->depth_mode = IRON_G5_COMPARE_MODE_ALWAYS; - state->blend_source = KINC_G5_BLEND_ONE; - state->blend_destination = KINC_G5_BLEND_ZERO; - state->blend_operation = KINC_G5_BLENDOP_ADD; - state->alpha_blend_source = KINC_G5_BLEND_ONE; - state->alpha_blend_destination = KINC_G5_BLEND_ZERO; - state->alpha_blend_operation = KINC_G5_BLENDOP_ADD; + state->blend_source = IRON_G5_BLEND_ONE; + state->blend_destination = IRON_G5_BLEND_ZERO; + state->blend_operation = IRON_G5_BLENDOP_ADD; + state->alpha_blend_source = IRON_G5_BLEND_ONE; + state->alpha_blend_destination = IRON_G5_BLEND_ZERO; + state->alpha_blend_operation = IRON_G5_BLENDOP_ADD; for (int i = 0; i < 8; ++i) { state->color_write_mask_red[i] = true; state->color_write_mask_green[i] = true; state->color_write_mask_blue[i] = true; state->color_write_mask_alpha[i] = true; - state->color_attachment[i] = KINC_IMAGE_FORMAT_RGBA32; + state->color_attachment[i] = IRON_IMAGE_FORMAT_RGBA32; } state->color_attachment_count = 1; state->depth_attachment_bits = 0; } -void kinc_g5_sampler_options_set_defaults(kinc_g5_sampler_options_t *options) { - options->u_addressing = KINC_G5_TEXTURE_ADDRESSING_CLAMP; - options->v_addressing = KINC_G5_TEXTURE_ADDRESSING_CLAMP; +void iron_g5_sampler_options_set_defaults(iron_g5_sampler_options_t *options) { + options->u_addressing = IRON_G5_TEXTURE_ADDRESSING_CLAMP; + options->v_addressing = IRON_G5_TEXTURE_ADDRESSING_CLAMP; - options->magnification_filter = KINC_G5_TEXTURE_FILTER_POINT; - options->minification_filter = KINC_G5_TEXTURE_FILTER_POINT; - options->mipmap_filter = KINC_G5_MIPMAP_FILTER_POINT; + options->magnification_filter = IRON_G5_TEXTURE_FILTER_POINT; + options->minification_filter = IRON_G5_TEXTURE_FILTER_POINT; + options->mipmap_filter = IRON_G5_MIPMAP_FILTER_POINT; } -void kinc_internal_samplers_reset(void) { - for (int i = 0; i < KINC_G5_SHADER_TYPE_COUNT; ++i) { +void iron_internal_samplers_reset(void) { + for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { for (int j = 0; j < MAX_SAMPLERS_PER_STAGE; ++j) { - kinc_g5_sampler_options_set_defaults(&sampler_options[i][j]); + iron_g5_sampler_options_set_defaults(&sampler_options[i][j]); } } } -bool sampler_options_equals(kinc_g5_sampler_options_t *options1, kinc_g5_sampler_options_t *options2) { +bool sampler_options_equals(iron_g5_sampler_options_t *options1, iron_g5_sampler_options_t *options2) { return options1->u_addressing == options2->u_addressing && options1->v_addressing == options2->v_addressing && options1->minification_filter == options2->minification_filter && @@ -862,7 +862,7 @@ bool sampler_options_equals(kinc_g5_sampler_options_t *options1, kinc_g5_sampler options1->mipmap_filter == options2->mipmap_filter; } -kinc_g5_sampler_t *kinc_internal_get_current_sampler(int stage, int unit) { +iron_g5_sampler_t *iron_internal_get_current_sampler(int stage, int unit) { // TODO: Please make this much faster for (int i = 0; i < sampler_cache_size; ++i) { if (sampler_options_equals(&sampler_cache[i].options, &sampler_options[stage][unit])) { @@ -871,8 +871,8 @@ kinc_g5_sampler_t *kinc_internal_get_current_sampler(int stage, int unit) { } assert(sampler_cache_size < MAX_SAMPLER_CACHE_SIZE); - kinc_g5_sampler_t *sampler = &sampler_cache[sampler_cache_size].sampler; - kinc_g5_sampler_init(sampler, &sampler_options[stage][unit]); + iron_g5_sampler_t *sampler = &sampler_cache[sampler_cache_size].sampler; + iron_g5_sampler_init(sampler, &sampler_options[stage][unit]); sampler_cache[sampler_cache_size].options = sampler_options[stage][unit]; sampler_cache_size += 1; diff --git a/base/sources/iron_gpu.h b/base/sources/iron_gpu.h index 6120123a..571f6d81 100644 --- a/base/sources/iron_gpu.h +++ b/base/sources/iron_gpu.h @@ -9,498 +9,498 @@ #include #include BACKEND_GPU_H -#define KINC_G5_CLEAR_COLOR 1 -#define KINC_G5_CLEAR_DEPTH 2 +#define IRON_G5_CLEAR_COLOR 1 +#define IRON_G5_CLEAR_DEPTH 2 -enum kinc_internal_render_target_state { - KINC_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET, - KINC_INTERNAL_RENDER_TARGET_STATE_TEXTURE +enum iron_internal_render_target_state { + IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET, + IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE }; -typedef enum kinc_image_compression { - KINC_IMAGE_COMPRESSION_NONE, - KINC_IMAGE_COMPRESSION_DXT5, - KINC_IMAGE_COMPRESSION_ASTC -} kinc_image_compression_t; +typedef enum iron_image_compression { + IRON_IMAGE_COMPRESSION_NONE, + IRON_IMAGE_COMPRESSION_DXT5, + IRON_IMAGE_COMPRESSION_ASTC +} iron_image_compression_t; -typedef enum kinc_image_format { - KINC_IMAGE_FORMAT_RGBA32, - KINC_IMAGE_FORMAT_RGBA64, - KINC_IMAGE_FORMAT_RGBA128, - KINC_IMAGE_FORMAT_R8, - KINC_IMAGE_FORMAT_R16, - KINC_IMAGE_FORMAT_R32, - KINC_IMAGE_FORMAT_BGRA32 -} kinc_image_format_t; +typedef enum iron_image_format { + IRON_IMAGE_FORMAT_RGBA32, + IRON_IMAGE_FORMAT_RGBA64, + IRON_IMAGE_FORMAT_RGBA128, + IRON_IMAGE_FORMAT_R8, + IRON_IMAGE_FORMAT_R16, + IRON_IMAGE_FORMAT_R32, + IRON_IMAGE_FORMAT_BGRA32 +} iron_image_format_t; -typedef struct kinc_g5_texture { +typedef struct iron_g5_texture { int width; int height; - kinc_image_format_t format; - kinc_image_compression_t compression; + iron_image_format_t format; + iron_image_compression_t compression; void *data; bool _uploaded; int framebuffer_index; bool isDepthAttachment; - enum kinc_internal_render_target_state state; + enum iron_internal_render_target_state state; buffer_t *buffer; Texture5Impl impl; -} kinc_g5_texture_t; +} iron_g5_texture_t; -int kinc_g5_max_bound_textures(void); -void kinc_g5_flush(void); -void kinc_g5_begin(kinc_g5_texture_t *renderTarget); -void kinc_g5_end(void); -bool kinc_g5_swap_buffers(void); +int iron_g5_max_bound_textures(void); +void iron_g5_flush(void); +void iron_g5_begin(iron_g5_texture_t *renderTarget); +void iron_g5_end(void); +bool iron_g5_swap_buffers(void); -void kinc_g5_internal_init(void); -void kinc_g5_internal_init_window(int depth_buffer_bits, bool vsync); -void kinc_g5_internal_destroy_window(void); -void kinc_g5_internal_destroy(void); +void iron_g5_internal_init(void); +void iron_g5_internal_init_window(int depth_buffer_bits, bool vsync); +void iron_g5_internal_destroy_window(void); +void iron_g5_internal_destroy(void); -struct kinc_g5_pipeline; -struct kinc_g5_texture; -struct kinc_g5_texture_unit; -struct kinc_g5_constant_location; -struct kinc_g5_index_buffer; +struct iron_g5_pipeline; +struct iron_g5_texture; +struct iron_g5_texture_unit; +struct iron_g5_constant_location; +struct iron_g5_index_buffer; typedef enum { - KINC_G4_TEXTURE_ADDRESSING_REPEAT, - KINC_G4_TEXTURE_ADDRESSING_MIRROR, - KINC_G4_TEXTURE_ADDRESSING_CLAMP, - KINC_G4_TEXTURE_ADDRESSING_BORDER -} kinc_g4_texture_addressing_t; + IRON_G4_TEXTURE_ADDRESSING_REPEAT, + IRON_G4_TEXTURE_ADDRESSING_MIRROR, + IRON_G4_TEXTURE_ADDRESSING_CLAMP, + IRON_G4_TEXTURE_ADDRESSING_BORDER +} iron_g4_texture_addressing_t; typedef enum { - KINC_G4_TEXTURE_DIRECTION_U, - KINC_G4_TEXTURE_DIRECTION_V -} kinc_g4_texture_direction_t; + IRON_G4_TEXTURE_DIRECTION_U, + IRON_G4_TEXTURE_DIRECTION_V +} iron_g4_texture_direction_t; typedef enum { - KINC_G4_TEXTURE_FILTER_POINT, - KINC_G4_TEXTURE_FILTER_LINEAR, - KINC_G4_TEXTURE_FILTER_ANISOTROPIC -} kinc_g4_texture_filter_t; + IRON_G4_TEXTURE_FILTER_POINT, + IRON_G4_TEXTURE_FILTER_LINEAR, + IRON_G4_TEXTURE_FILTER_ANISOTROPIC +} iron_g4_texture_filter_t; typedef enum { - KINC_G4_MIPMAP_FILTER_NONE, - KINC_G4_MIPMAP_FILTER_POINT, - KINC_G4_MIPMAP_FILTER_LINEAR // linear texture filter + linear mip filter -> trilinear filter -} kinc_g4_mipmap_filter_t; + IRON_G4_MIPMAP_FILTER_NONE, + IRON_G4_MIPMAP_FILTER_POINT, + IRON_G4_MIPMAP_FILTER_LINEAR // linear texture filter + linear mip filter -> trilinear filter +} iron_g4_mipmap_filter_t; -typedef enum kinc_g4_usage { - KINC_G4_USAGE_STATIC, - KINC_G4_USAGE_DYNAMIC, - KINC_G4_USAGE_READABLE -} kinc_g4_usage_t; +typedef enum iron_g4_usage { + IRON_G4_USAGE_STATIC, + IRON_G4_USAGE_DYNAMIC, + IRON_G4_USAGE_READABLE +} iron_g4_usage_t; -void kinc_g4_begin(); -void kinc_g4_end(); -void kinc_g5_clear(unsigned color, float depth, unsigned flags); -void kinc_g4_viewport(int x, int y, int width, int height); -void kinc_g4_scissor(int x, int y, int width, int height); -void kinc_g4_disable_scissor(void); -void kinc_g5_draw_indexed_vertices(void); -void kinc_g5_draw_indexed_vertices_from_to(int start, int count); -void kinc_g4_set_texture_addressing(struct kinc_g5_texture_unit unit, kinc_g4_texture_direction_t dir, kinc_g4_texture_addressing_t addressing); -void kinc_g5_set_pipeline(struct kinc_g5_pipeline *pipeline); -void kinc_g4_set_int(struct kinc_g5_constant_location location, int value); -void kinc_g4_set_int2(struct kinc_g5_constant_location location, int value1, int value2); -void kinc_g4_set_int3(struct kinc_g5_constant_location location, int value1, int value2, int value3); -void kinc_g4_set_int4(struct kinc_g5_constant_location location, int value1, int value2, int value3, int value4); -void kinc_g4_set_ints(struct kinc_g5_constant_location location, int *values, int count); -void kinc_g4_set_float(struct kinc_g5_constant_location location, float value); -void kinc_g4_set_float2(struct kinc_g5_constant_location location, float value1, float value2); -void kinc_g4_set_float3(struct kinc_g5_constant_location location, float value1, float value2, float value3); -void kinc_g4_set_float4(struct kinc_g5_constant_location location, float value1, float value2, float value3, float value4); -void kinc_g4_set_floats(struct kinc_g5_constant_location location, float *values, int count); -void kinc_g4_set_bool(struct kinc_g5_constant_location location, bool value); -void kinc_g4_set_matrix3(struct kinc_g5_constant_location location, kinc_matrix3x3_t *value); -void kinc_g4_set_matrix4(struct kinc_g5_constant_location location, kinc_matrix4x4_t *value); -void kinc_g4_set_texture_magnification_filter(struct kinc_g5_texture_unit unit, kinc_g4_texture_filter_t filter); -void kinc_g4_set_texture_minification_filter(struct kinc_g5_texture_unit unit, kinc_g4_texture_filter_t filter); -void kinc_g4_set_texture_mipmap_filter(struct kinc_g5_texture_unit unit, kinc_g4_mipmap_filter_t filter); -void kinc_g4_restore_render_target(void); -void kinc_g4_set_render_targets(struct kinc_g5_texture **targets, int count); -void kinc_g4_set_texture(struct kinc_g5_texture_unit unit, struct kinc_g5_texture *texture); -void kinc_g4_compute(int x, int y, int z); -void kinc_g4_set_index_buffer(struct kinc_g5_index_buffer *buffer); +void iron_g4_begin(); +void iron_g4_end(); +void iron_g5_clear(unsigned color, float depth, unsigned flags); +void iron_g4_viewport(int x, int y, int width, int height); +void iron_g4_scissor(int x, int y, int width, int height); +void iron_g4_disable_scissor(void); +void iron_g5_draw_indexed_vertices(void); +void iron_g5_draw_indexed_vertices_from_to(int start, int count); +void iron_g4_set_texture_addressing(struct iron_g5_texture_unit unit, iron_g4_texture_direction_t dir, iron_g4_texture_addressing_t addressing); +void iron_g5_set_pipeline(struct iron_g5_pipeline *pipeline); +void iron_g4_set_int(struct iron_g5_constant_location location, int value); +void iron_g4_set_int2(struct iron_g5_constant_location location, int value1, int value2); +void iron_g4_set_int3(struct iron_g5_constant_location location, int value1, int value2, int value3); +void iron_g4_set_int4(struct iron_g5_constant_location location, int value1, int value2, int value3, int value4); +void iron_g4_set_ints(struct iron_g5_constant_location location, int *values, int count); +void iron_g4_set_float(struct iron_g5_constant_location location, float value); +void iron_g4_set_float2(struct iron_g5_constant_location location, float value1, float value2); +void iron_g4_set_float3(struct iron_g5_constant_location location, float value1, float value2, float value3); +void iron_g4_set_float4(struct iron_g5_constant_location location, float value1, float value2, float value3, float value4); +void iron_g4_set_floats(struct iron_g5_constant_location location, float *values, int count); +void iron_g4_set_bool(struct iron_g5_constant_location location, bool value); +void iron_g4_set_matrix3(struct iron_g5_constant_location location, iron_matrix3x3_t *value); +void iron_g4_set_matrix4(struct iron_g5_constant_location location, iron_matrix4x4_t *value); +void iron_g4_set_texture_magnification_filter(struct iron_g5_texture_unit unit, iron_g4_texture_filter_t filter); +void iron_g4_set_texture_minification_filter(struct iron_g5_texture_unit unit, iron_g4_texture_filter_t filter); +void iron_g4_set_texture_mipmap_filter(struct iron_g5_texture_unit unit, iron_g4_mipmap_filter_t filter); +void iron_g4_restore_render_target(void); +void iron_g4_set_render_targets(struct iron_g5_texture **targets, int count); +void iron_g4_set_texture(struct iron_g5_texture_unit unit, struct iron_g5_texture *texture); +void iron_g4_compute(int x, int y, int z); +void iron_g4_set_index_buffer(struct iron_g5_index_buffer *buffer); -void kinc_g4_internal_init_window(int depth_buffer_bits, bool vsync); +void iron_g4_internal_init_window(int depth_buffer_bits, bool vsync); -void kinc_g4_render_target_use_depth_as_texture(struct kinc_g5_texture *renderTarget, struct kinc_g5_texture_unit unit); +void iron_g4_render_target_use_depth_as_texture(struct iron_g5_texture *renderTarget, struct iron_g5_texture_unit unit); -void kinc_g4_index_buffer_unlock_all(struct kinc_g5_index_buffer *buffer); -void kinc_g4_index_buffer_unlock(struct kinc_g5_index_buffer *buffer, int count); +void iron_g4_index_buffer_unlock_all(struct iron_g5_index_buffer *buffer); +void iron_g4_index_buffer_unlock(struct iron_g5_index_buffer *buffer, int count); -#define KINC_G5_MAX_VERTEX_ELEMENTS 16 +#define IRON_G5_MAX_VERTEX_ELEMENTS 16 -typedef enum kinc_g5_vertex_data { - KINC_G5_VERTEX_DATA_F32_1X = 0, - KINC_G5_VERTEX_DATA_F32_2X = 1, - KINC_G5_VERTEX_DATA_F32_3X = 2, - KINC_G5_VERTEX_DATA_F32_4X = 3, - KINC_G5_VERTEX_DATA_U8_4X_NORM = 4, - KINC_G5_VERTEX_DATA_I16_2X_NORM = 5, - KINC_G5_VERTEX_DATA_I16_4X_NORM = 6, -} kinc_g5_vertex_data_t; +typedef enum iron_g5_vertex_data { + IRON_G5_VERTEX_DATA_F32_1X = 0, + IRON_G5_VERTEX_DATA_F32_2X = 1, + IRON_G5_VERTEX_DATA_F32_3X = 2, + IRON_G5_VERTEX_DATA_F32_4X = 3, + IRON_G5_VERTEX_DATA_U8_4X_NORM = 4, + IRON_G5_VERTEX_DATA_I16_2X_NORM = 5, + IRON_G5_VERTEX_DATA_I16_4X_NORM = 6, +} iron_g5_vertex_data_t; -typedef struct kinc_g5_vertex_element { +typedef struct iron_g5_vertex_element { const char *name; - kinc_g5_vertex_data_t data; -} kinc_g5_vertex_element_t; + iron_g5_vertex_data_t data; +} iron_g5_vertex_element_t; -typedef struct kinc_g5_vertex_structure { - kinc_g5_vertex_element_t elements[KINC_G5_MAX_VERTEX_ELEMENTS]; +typedef struct iron_g5_vertex_structure { + iron_g5_vertex_element_t elements[IRON_G5_MAX_VERTEX_ELEMENTS]; int size; -} kinc_g5_vertex_structure_t; +} iron_g5_vertex_structure_t; -static inline int kinc_g5_vertex_data_size(kinc_g5_vertex_data_t data) { +static inline int iron_g5_vertex_data_size(iron_g5_vertex_data_t data) { switch (data) { - case KINC_G5_VERTEX_DATA_F32_1X: + case IRON_G5_VERTEX_DATA_F32_1X: return 1 * 4; - case KINC_G5_VERTEX_DATA_F32_2X: + case IRON_G5_VERTEX_DATA_F32_2X: return 2 * 4; - case KINC_G5_VERTEX_DATA_F32_3X: + case IRON_G5_VERTEX_DATA_F32_3X: return 3 * 4; - case KINC_G5_VERTEX_DATA_F32_4X: + case IRON_G5_VERTEX_DATA_F32_4X: return 4 * 4; - case KINC_G5_VERTEX_DATA_U8_4X_NORM: + case IRON_G5_VERTEX_DATA_U8_4X_NORM: return 4 * 1; - case KINC_G5_VERTEX_DATA_I16_2X_NORM: + case IRON_G5_VERTEX_DATA_I16_2X_NORM: return 2 * 2; - case KINC_G5_VERTEX_DATA_I16_4X_NORM: + case IRON_G5_VERTEX_DATA_I16_4X_NORM: return 4 * 2; } } -static inline int kinc_g5_vertex_struct_size(kinc_g5_vertex_structure_t *s) { +static inline int iron_g5_vertex_struct_size(iron_g5_vertex_structure_t *s) { int size = 0; for (int i = 0; i < s->size; ++i) { - size += kinc_g5_vertex_data_size(s->elements[i].data); + size += iron_g5_vertex_data_size(s->elements[i].data); } return size; } -void kinc_g5_vertex_structure_init(kinc_g5_vertex_structure_t *structure); -void kinc_g5_vertex_structure_add(kinc_g5_vertex_structure_t *structure, const char *name, kinc_g5_vertex_data_t data); +void iron_g5_vertex_structure_init(iron_g5_vertex_structure_t *structure); +void iron_g5_vertex_structure_add(iron_g5_vertex_structure_t *structure, const char *name, iron_g5_vertex_data_t data); -void kinc_g5_texture_init(kinc_g5_texture_t *texture, int width, int height, kinc_image_format_t format); -void kinc_g5_texture_init_from_bytes(kinc_g5_texture_t *texture, void *data, int width, int height, kinc_image_format_t format); -void kinc_g5_texture_init_non_sampled_access(kinc_g5_texture_t *texture, int width, int height, kinc_image_format_t format); -void kinc_g5_texture_destroy(kinc_g5_texture_t *texture); -void kinc_g5_texture_generate_mipmaps(kinc_g5_texture_t *texture, int levels); -void kinc_g5_texture_set_mipmap(kinc_g5_texture_t *texture, kinc_g5_texture_t *mipmap, int level); -int kinc_g5_texture_stride(kinc_g5_texture_t *texture); +void iron_g5_texture_init(iron_g5_texture_t *texture, int width, int height, iron_image_format_t format); +void iron_g5_texture_init_from_bytes(iron_g5_texture_t *texture, void *data, int width, int height, iron_image_format_t format); +void iron_g5_texture_init_non_sampled_access(iron_g5_texture_t *texture, int width, int height, iron_image_format_t format); +void iron_g5_texture_destroy(iron_g5_texture_t *texture); +void iron_g5_texture_generate_mipmaps(iron_g5_texture_t *texture, int levels); +void iron_g5_texture_set_mipmap(iron_g5_texture_t *texture, iron_g5_texture_t *mipmap, int level); +int iron_g5_texture_stride(iron_g5_texture_t *texture); -struct kinc_g5_texture_unit; +struct iron_g5_texture_unit; -void kinc_g5_render_target_init(kinc_g5_texture_t *target, int width, int height, kinc_image_format_t format, int depthBufferBits); -void kinc_g5_render_target_init_framebuffer(kinc_g5_texture_t *target, int width, int height, kinc_image_format_t format, int depthBufferBits); -void kinc_g5_render_target_set_depth_from(kinc_g5_texture_t *target, kinc_g5_texture_t *source); +void iron_g5_render_target_init(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits); +void iron_g5_render_target_init_framebuffer(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits); +void iron_g5_render_target_set_depth_from(iron_g5_texture_t *target, iron_g5_texture_t *source); -typedef struct kinc_g5_vertex_buffer { +typedef struct iron_g5_vertex_buffer { VertexBuffer5Impl impl; -} kinc_g5_vertex_buffer_t; +} iron_g5_vertex_buffer_t; typedef struct { int myCount; - kinc_g5_vertex_buffer_t _buffer[2]; + iron_g5_vertex_buffer_t _buffer[2]; int _currentIndex; int _multiple; -} kinc_g4_vertex_buffer_impl_t; +} iron_g4_vertex_buffer_impl_t; -typedef struct kinc_g4_vertex_buffer { - kinc_g4_vertex_buffer_impl_t impl; -} kinc_g4_vertex_buffer_t; +typedef struct iron_g4_vertex_buffer { + iron_g4_vertex_buffer_impl_t impl; +} iron_g4_vertex_buffer_t; -void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int count, kinc_g5_vertex_structure_t *structure, bool gpu_memory); -void kinc_g5_vertex_buffer_destroy(kinc_g5_vertex_buffer_t *buffer); -float *kinc_g5_vertex_buffer_lock_all(kinc_g5_vertex_buffer_t *buffer); -float *kinc_g5_vertex_buffer_lock(kinc_g5_vertex_buffer_t *buffer, int start, int count); -void kinc_g5_vertex_buffer_unlock_all(kinc_g5_vertex_buffer_t *buffer); -void kinc_g5_vertex_buffer_unlock(kinc_g5_vertex_buffer_t *buffer, int count); -int kinc_g5_vertex_buffer_count(kinc_g5_vertex_buffer_t *buffer); -int kinc_g5_vertex_buffer_stride(kinc_g5_vertex_buffer_t *buffer); +void iron_g5_vertex_buffer_init(iron_g5_vertex_buffer_t *buffer, int count, iron_g5_vertex_structure_t *structure, bool gpu_memory); +void iron_g5_vertex_buffer_destroy(iron_g5_vertex_buffer_t *buffer); +float *iron_g5_vertex_buffer_lock_all(iron_g5_vertex_buffer_t *buffer); +float *iron_g5_vertex_buffer_lock(iron_g5_vertex_buffer_t *buffer, int start, int count); +void iron_g5_vertex_buffer_unlock_all(iron_g5_vertex_buffer_t *buffer); +void iron_g5_vertex_buffer_unlock(iron_g5_vertex_buffer_t *buffer, int count); +int iron_g5_vertex_buffer_count(iron_g5_vertex_buffer_t *buffer); +int iron_g5_vertex_buffer_stride(iron_g5_vertex_buffer_t *buffer); -int kinc_g5_internal_vertex_buffer_set(kinc_g5_vertex_buffer_t *buffer); +int iron_g5_internal_vertex_buffer_set(iron_g5_vertex_buffer_t *buffer); -void kinc_g4_vertex_buffer_init(kinc_g4_vertex_buffer_t *buffer, int count, kinc_g5_vertex_structure_t *structure, kinc_g4_usage_t usage); -void kinc_g4_vertex_buffer_destroy(kinc_g4_vertex_buffer_t *buffer); -float *kinc_g4_vertex_buffer_lock_all(kinc_g4_vertex_buffer_t *buffer); -float *kinc_g4_vertex_buffer_lock(kinc_g4_vertex_buffer_t *buffer, int start, int count); -void kinc_g4_vertex_buffer_unlock_all(kinc_g4_vertex_buffer_t *buffer); -void kinc_g4_vertex_buffer_unlock(kinc_g4_vertex_buffer_t *buffer, int count); -int kinc_g4_vertex_buffer_count(kinc_g4_vertex_buffer_t *buffer); -int kinc_g4_vertex_buffer_stride(kinc_g4_vertex_buffer_t *buffer); -void kinc_g4_set_vertex_buffer(kinc_g4_vertex_buffer_t *buffer); +void iron_g4_vertex_buffer_init(iron_g4_vertex_buffer_t *buffer, int count, iron_g5_vertex_structure_t *structure, iron_g4_usage_t usage); +void iron_g4_vertex_buffer_destroy(iron_g4_vertex_buffer_t *buffer); +float *iron_g4_vertex_buffer_lock_all(iron_g4_vertex_buffer_t *buffer); +float *iron_g4_vertex_buffer_lock(iron_g4_vertex_buffer_t *buffer, int start, int count); +void iron_g4_vertex_buffer_unlock_all(iron_g4_vertex_buffer_t *buffer); +void iron_g4_vertex_buffer_unlock(iron_g4_vertex_buffer_t *buffer, int count); +int iron_g4_vertex_buffer_count(iron_g4_vertex_buffer_t *buffer); +int iron_g4_vertex_buffer_stride(iron_g4_vertex_buffer_t *buffer); +void iron_g4_set_vertex_buffer(iron_g4_vertex_buffer_t *buffer); -typedef struct kinc_g5_constant_buffer { +typedef struct iron_g5_constant_buffer { uint8_t *data; ConstantBuffer5Impl impl; -} kinc_g5_constant_buffer_t; +} iron_g5_constant_buffer_t; -void kinc_g5_constant_buffer_init(kinc_g5_constant_buffer_t *buffer, int size); -void kinc_g5_constant_buffer_destroy(kinc_g5_constant_buffer_t *buffer); -void kinc_g5_constant_buffer_lock_all(kinc_g5_constant_buffer_t *buffer); -void kinc_g5_constant_buffer_lock(kinc_g5_constant_buffer_t *buffer, int start, int count); -void kinc_g5_constant_buffer_unlock(kinc_g5_constant_buffer_t *buffer); -int kinc_g5_constant_buffer_size(kinc_g5_constant_buffer_t *buffer); -void kinc_g5_constant_buffer_set_bool(kinc_g5_constant_buffer_t *buffer, int offset, bool value); -void kinc_g5_constant_buffer_set_int(kinc_g5_constant_buffer_t *buffer, int offset, int value); -void kinc_g5_constant_buffer_set_int2(kinc_g5_constant_buffer_t *buffer, int offset, int value1, int value2); -void kinc_g5_constant_buffer_set_int3(kinc_g5_constant_buffer_t *buffer, int offset, int value1, int value2, int value3); -void kinc_g5_constant_buffer_set_int4(kinc_g5_constant_buffer_t *buffer, int offset, int value1, int value2, int value3, int value4); -void kinc_g5_constant_buffer_set_ints(kinc_g5_constant_buffer_t *buffer, int offset, int *values, int count); -void kinc_g5_constant_buffer_set_float(kinc_g5_constant_buffer_t *buffer, int offset, float value); -void kinc_g5_constant_buffer_set_float2(kinc_g5_constant_buffer_t *buffer, int offset, float value1, float value2); -void kinc_g5_constant_buffer_set_float3(kinc_g5_constant_buffer_t *buffer, int offset, float value1, float value2, float value3); -void kinc_g5_constant_buffer_set_float4(kinc_g5_constant_buffer_t *buffer, int offset, float value1, float value2, float value3, float value4); -void kinc_g5_constant_buffer_set_floats(kinc_g5_constant_buffer_t *buffer, int offset, float *values, int count); -void kinc_g5_constant_buffer_set_matrix3(kinc_g5_constant_buffer_t *buffer, int offset, kinc_matrix3x3_t *value); -void kinc_g5_constant_buffer_set_matrix4(kinc_g5_constant_buffer_t *buffer, int offset, kinc_matrix4x4_t *value); +void iron_g5_constant_buffer_init(iron_g5_constant_buffer_t *buffer, int size); +void iron_g5_constant_buffer_destroy(iron_g5_constant_buffer_t *buffer); +void iron_g5_constant_buffer_lock_all(iron_g5_constant_buffer_t *buffer); +void iron_g5_constant_buffer_lock(iron_g5_constant_buffer_t *buffer, int start, int count); +void iron_g5_constant_buffer_unlock(iron_g5_constant_buffer_t *buffer); +int iron_g5_constant_buffer_size(iron_g5_constant_buffer_t *buffer); +void iron_g5_constant_buffer_set_bool(iron_g5_constant_buffer_t *buffer, int offset, bool value); +void iron_g5_constant_buffer_set_int(iron_g5_constant_buffer_t *buffer, int offset, int value); +void iron_g5_constant_buffer_set_int2(iron_g5_constant_buffer_t *buffer, int offset, int value1, int value2); +void iron_g5_constant_buffer_set_int3(iron_g5_constant_buffer_t *buffer, int offset, int value1, int value2, int value3); +void iron_g5_constant_buffer_set_int4(iron_g5_constant_buffer_t *buffer, int offset, int value1, int value2, int value3, int value4); +void iron_g5_constant_buffer_set_ints(iron_g5_constant_buffer_t *buffer, int offset, int *values, int count); +void iron_g5_constant_buffer_set_float(iron_g5_constant_buffer_t *buffer, int offset, float value); +void iron_g5_constant_buffer_set_float2(iron_g5_constant_buffer_t *buffer, int offset, float value1, float value2); +void iron_g5_constant_buffer_set_float3(iron_g5_constant_buffer_t *buffer, int offset, float value1, float value2, float value3); +void iron_g5_constant_buffer_set_float4(iron_g5_constant_buffer_t *buffer, int offset, float value1, float value2, float value3, float value4); +void iron_g5_constant_buffer_set_floats(iron_g5_constant_buffer_t *buffer, int offset, float *values, int count); +void iron_g5_constant_buffer_set_matrix3(iron_g5_constant_buffer_t *buffer, int offset, iron_matrix3x3_t *value); +void iron_g5_constant_buffer_set_matrix4(iron_g5_constant_buffer_t *buffer, int offset, iron_matrix4x4_t *value); -extern bool kinc_g5_transpose_mat; +extern bool iron_g5_transpose_mat; -typedef struct kinc_g5_index_buffer { +typedef struct iron_g5_index_buffer { IndexBuffer5Impl impl; -} kinc_g5_index_buffer_t; +} iron_g5_index_buffer_t; -void kinc_g5_index_buffer_init(kinc_g5_index_buffer_t *buffer, int count, bool gpu_memory); -void kinc_g5_index_buffer_destroy(kinc_g5_index_buffer_t *buffer); -void *kinc_g5_index_buffer_lock_all(kinc_g5_index_buffer_t *buffer); -void *kinc_g5_index_buffer_lock(kinc_g5_index_buffer_t *buffer, int start, int count); -void kinc_g5_index_buffer_unlock_all(kinc_g5_index_buffer_t *buffer); -void kinc_g5_index_buffer_unlock(kinc_g5_index_buffer_t *buffer, int count); -int kinc_g5_index_buffer_count(kinc_g5_index_buffer_t *buffer); +void iron_g5_index_buffer_init(iron_g5_index_buffer_t *buffer, int count, bool gpu_memory); +void iron_g5_index_buffer_destroy(iron_g5_index_buffer_t *buffer); +void *iron_g5_index_buffer_lock_all(iron_g5_index_buffer_t *buffer); +void *iron_g5_index_buffer_lock(iron_g5_index_buffer_t *buffer, int start, int count); +void iron_g5_index_buffer_unlock_all(iron_g5_index_buffer_t *buffer); +void iron_g5_index_buffer_unlock(iron_g5_index_buffer_t *buffer, int count); +int iron_g5_index_buffer_count(iron_g5_index_buffer_t *buffer); -typedef enum kinc_g5_shader_type { - KINC_G5_SHADER_TYPE_FRAGMENT, - KINC_G5_SHADER_TYPE_VERTEX, - KINC_G5_SHADER_TYPE_COMPUTE, - KINC_G5_SHADER_TYPE_COUNT -} kinc_g5_shader_type_t; +typedef enum iron_g5_shader_type { + IRON_G5_SHADER_TYPE_FRAGMENT, + IRON_G5_SHADER_TYPE_VERTEX, + IRON_G5_SHADER_TYPE_COMPUTE, + IRON_G5_SHADER_TYPE_COUNT +} iron_g5_shader_type_t; typedef enum { - KINC_G5_BLEND_ONE, - KINC_G5_BLEND_ZERO, - KINC_G5_BLEND_SOURCE_ALPHA, - KINC_G5_BLEND_DEST_ALPHA, - KINC_G5_BLEND_INV_SOURCE_ALPHA, - KINC_G5_BLEND_INV_DEST_ALPHA, - KINC_G5_BLEND_SOURCE_COLOR, - KINC_G5_BLEND_DEST_COLOR, - KINC_G5_BLEND_INV_SOURCE_COLOR, - KINC_G5_BLEND_INV_DEST_COLOR, - KINC_G5_BLEND_CONSTANT, - KINC_G5_BLEND_INV_CONSTANT -} kinc_g5_blending_factor_t; + IRON_G5_BLEND_ONE, + IRON_G5_BLEND_ZERO, + IRON_G5_BLEND_SOURCE_ALPHA, + IRON_G5_BLEND_DEST_ALPHA, + IRON_G5_BLEND_INV_SOURCE_ALPHA, + IRON_G5_BLEND_INV_DEST_ALPHA, + IRON_G5_BLEND_SOURCE_COLOR, + IRON_G5_BLEND_DEST_COLOR, + IRON_G5_BLEND_INV_SOURCE_COLOR, + IRON_G5_BLEND_INV_DEST_COLOR, + IRON_G5_BLEND_CONSTANT, + IRON_G5_BLEND_INV_CONSTANT +} iron_g5_blending_factor_t; typedef enum { - KINC_G5_BLENDOP_ADD, - KINC_G5_BLENDOP_SUBTRACT, - KINC_G5_BLENDOP_REVERSE_SUBTRACT, - KINC_G5_BLENDOP_MIN, - KINC_G5_BLENDOP_MAX -} kinc_g5_blending_operation_t; + IRON_G5_BLENDOP_ADD, + IRON_G5_BLENDOP_SUBTRACT, + IRON_G5_BLENDOP_REVERSE_SUBTRACT, + IRON_G5_BLENDOP_MIN, + IRON_G5_BLENDOP_MAX +} iron_g5_blending_operation_t; -typedef enum kinc_g5_cull_mode { - KINC_G5_CULL_MODE_CLOCKWISE, - KINC_G5_CULL_MODE_COUNTERCLOCKWISE, - KINC_G5_CULL_MODE_NEVER -} kinc_g5_cull_mode_t; +typedef enum iron_g5_cull_mode { + IRON_G5_CULL_MODE_CLOCKWISE, + IRON_G5_CULL_MODE_COUNTERCLOCKWISE, + IRON_G5_CULL_MODE_NEVER +} iron_g5_cull_mode_t; -typedef enum kinc_g5_compare_mode { - KINC_G5_COMPARE_MODE_ALWAYS, - KINC_G5_COMPARE_MODE_NEVER, - KINC_G5_COMPARE_MODE_EQUAL, - KINC_G5_COMPARE_MODE_NOT_EQUAL, - KINC_G5_COMPARE_MODE_LESS, - KINC_G5_COMPARE_MODE_LESS_EQUAL, - KINC_G5_COMPARE_MODE_GREATER, - KINC_G5_COMPARE_MODE_GREATER_EQUAL -} kinc_g5_compare_mode_t; +typedef enum iron_g5_compare_mode { + IRON_G5_COMPARE_MODE_ALWAYS, + IRON_G5_COMPARE_MODE_NEVER, + IRON_G5_COMPARE_MODE_EQUAL, + IRON_G5_COMPARE_MODE_NOT_EQUAL, + IRON_G5_COMPARE_MODE_LESS, + IRON_G5_COMPARE_MODE_LESS_EQUAL, + IRON_G5_COMPARE_MODE_GREATER, + IRON_G5_COMPARE_MODE_GREATER_EQUAL +} iron_g5_compare_mode_t; -typedef enum kinc_g5_texture_addressing { - KINC_G5_TEXTURE_ADDRESSING_REPEAT, - KINC_G5_TEXTURE_ADDRESSING_MIRROR, - KINC_G5_TEXTURE_ADDRESSING_CLAMP, - KINC_G5_TEXTURE_ADDRESSING_BORDER -} kinc_g5_texture_addressing_t; +typedef enum iron_g5_texture_addressing { + IRON_G5_TEXTURE_ADDRESSING_REPEAT, + IRON_G5_TEXTURE_ADDRESSING_MIRROR, + IRON_G5_TEXTURE_ADDRESSING_CLAMP, + IRON_G5_TEXTURE_ADDRESSING_BORDER +} iron_g5_texture_addressing_t; -typedef enum kinc_g5_texture_filter { - KINC_G5_TEXTURE_FILTER_POINT, - KINC_G5_TEXTURE_FILTER_LINEAR, - KINC_G5_TEXTURE_FILTER_ANISOTROPIC -} kinc_g5_texture_filter_t; +typedef enum iron_g5_texture_filter { + IRON_G5_TEXTURE_FILTER_POINT, + IRON_G5_TEXTURE_FILTER_LINEAR, + IRON_G5_TEXTURE_FILTER_ANISOTROPIC +} iron_g5_texture_filter_t; -typedef enum kinc_g5_mipmap_filter { - KINC_G5_MIPMAP_FILTER_NONE, - KINC_G5_MIPMAP_FILTER_POINT, - KINC_G5_MIPMAP_FILTER_LINEAR // linear texture filter + linear mip filter -> trilinear filter -} kinc_g5_mipmap_filter_t; +typedef enum iron_g5_mipmap_filter { + IRON_G5_MIPMAP_FILTER_NONE, + IRON_G5_MIPMAP_FILTER_POINT, + IRON_G5_MIPMAP_FILTER_LINEAR // linear texture filter + linear mip filter -> trilinear filter +} iron_g5_mipmap_filter_t; -typedef struct kinc_g5_constant_location { +typedef struct iron_g5_constant_location { ConstantLocation5Impl impl; -} kinc_g5_constant_location_t; +} iron_g5_constant_location_t; -typedef struct kinc_g5_texture_unit { - int stages[KINC_G5_SHADER_TYPE_COUNT]; -} kinc_g5_texture_unit_t; +typedef struct iron_g5_texture_unit { + int stages[IRON_G5_SHADER_TYPE_COUNT]; +} iron_g5_texture_unit_t; -typedef struct kinc_g5_shader { +typedef struct iron_g5_shader { Shader5Impl impl; -} kinc_g5_shader_t; +} iron_g5_shader_t; -typedef struct kinc_g5_pipeline { - kinc_g5_vertex_structure_t *input_layout; - kinc_g5_shader_t *vertex_shader; - kinc_g5_shader_t *fragment_shader; +typedef struct iron_g5_pipeline { + iron_g5_vertex_structure_t *input_layout; + iron_g5_shader_t *vertex_shader; + iron_g5_shader_t *fragment_shader; - kinc_g5_cull_mode_t cull_mode; + iron_g5_cull_mode_t cull_mode; bool depth_write; - kinc_g5_compare_mode_t depth_mode; + iron_g5_compare_mode_t depth_mode; // One, Zero deactivates blending - kinc_g5_blending_factor_t blend_source; - kinc_g5_blending_factor_t blend_destination; - kinc_g5_blending_operation_t blend_operation; - kinc_g5_blending_factor_t alpha_blend_source; - kinc_g5_blending_factor_t alpha_blend_destination; - kinc_g5_blending_operation_t alpha_blend_operation; + iron_g5_blending_factor_t blend_source; + iron_g5_blending_factor_t blend_destination; + iron_g5_blending_operation_t blend_operation; + iron_g5_blending_factor_t alpha_blend_source; + iron_g5_blending_factor_t alpha_blend_destination; + iron_g5_blending_operation_t alpha_blend_operation; bool color_write_mask_red[8]; // Per render target bool color_write_mask_green[8]; bool color_write_mask_blue[8]; bool color_write_mask_alpha[8]; - kinc_image_format_t color_attachment[8]; + iron_image_format_t color_attachment[8]; int color_attachment_count; int depth_attachment_bits; PipelineState5Impl impl; -} kinc_g5_pipeline_t; +} iron_g5_pipeline_t; -typedef struct kinc_g5_sampler_options { - kinc_g5_texture_addressing_t u_addressing; - kinc_g5_texture_addressing_t v_addressing; +typedef struct iron_g5_sampler_options { + iron_g5_texture_addressing_t u_addressing; + iron_g5_texture_addressing_t v_addressing; - kinc_g5_texture_filter_t minification_filter; - kinc_g5_texture_filter_t magnification_filter; - kinc_g5_mipmap_filter_t mipmap_filter; + iron_g5_texture_filter_t minification_filter; + iron_g5_texture_filter_t magnification_filter; + iron_g5_mipmap_filter_t mipmap_filter; -} kinc_g5_sampler_options_t; +} iron_g5_sampler_options_t; -typedef struct kinc_g5_sampler { - kinc_g5_sampler_impl_t impl; -} kinc_g5_sampler_t; +typedef struct iron_g5_sampler { + iron_g5_sampler_impl_t impl; +} iron_g5_sampler_t; -void kinc_g5_pipeline_init(kinc_g5_pipeline_t *pipeline); -void kinc_g5_internal_pipeline_init(kinc_g5_pipeline_t *pipeline); -void kinc_g5_pipeline_destroy(kinc_g5_pipeline_t *pipeline); -void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipeline); -kinc_g5_constant_location_t kinc_g5_pipeline_get_constant_location(kinc_g5_pipeline_t *pipeline, const char *name); -kinc_g5_texture_unit_t kinc_g5_pipeline_get_texture_unit(kinc_g5_pipeline_t *pipeline, const char *name); +void iron_g5_pipeline_init(iron_g5_pipeline_t *pipeline); +void iron_g5_internal_pipeline_init(iron_g5_pipeline_t *pipeline); +void iron_g5_pipeline_destroy(iron_g5_pipeline_t *pipeline); +void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipeline); +iron_g5_constant_location_t iron_g5_pipeline_get_constant_location(iron_g5_pipeline_t *pipeline, const char *name); +iron_g5_texture_unit_t iron_g5_pipeline_get_texture_unit(iron_g5_pipeline_t *pipeline, const char *name); -void kinc_g5_shader_init(kinc_g5_shader_t *shader, const void *source, size_t length, kinc_g5_shader_type_t type); -void kinc_g5_shader_destroy(kinc_g5_shader_t *shader); +void iron_g5_shader_init(iron_g5_shader_t *shader, const void *source, size_t length, iron_g5_shader_type_t type); +void iron_g5_shader_destroy(iron_g5_shader_t *shader); -void kinc_g5_sampler_options_set_defaults(kinc_g5_sampler_options_t *options); -void kinc_g5_sampler_init(kinc_g5_sampler_t *sampler, const kinc_g5_sampler_options_t *options); -void kinc_g5_sampler_destroy(kinc_g5_sampler_t *sampler); +void iron_g5_sampler_options_set_defaults(iron_g5_sampler_options_t *options); +void iron_g5_sampler_init(iron_g5_sampler_t *sampler, const iron_g5_sampler_options_t *options); +void iron_g5_sampler_destroy(iron_g5_sampler_t *sampler); -void kinc_g5_internal_pipeline_set_defaults(kinc_g5_pipeline_t *pipeline); +void iron_g5_internal_pipeline_set_defaults(iron_g5_pipeline_t *pipeline); -struct kinc_g5_compute_shader; -struct kinc_g5_constant_buffer; -struct kinc_g5_index_buffer; -struct kinc_g5_vertex_buffer; -struct kinc_g5_pipeline; -struct kinc_g5_texture; -struct kinc_g5_texture; +struct iron_g5_compute_shader; +struct iron_g5_constant_buffer; +struct iron_g5_index_buffer; +struct iron_g5_vertex_buffer; +struct iron_g5_pipeline; +struct iron_g5_texture; +struct iron_g5_texture; -typedef struct kinc_g5_command_list { +typedef struct iron_g5_command_list { CommandList5Impl impl; -} kinc_g5_command_list_t; +} iron_g5_command_list_t; -void kinc_g5_command_list_init(kinc_g5_command_list_t *list); -void kinc_g5_command_list_destroy(kinc_g5_command_list_t *list); -void kinc_g5_command_list_begin(kinc_g5_command_list_t *list); -void kinc_g5_command_list_end(kinc_g5_command_list_t *list); -void kinc_g5_command_list_clear(kinc_g5_command_list_t *list, struct kinc_g5_texture *render_target, unsigned flags, unsigned color, float depth); -void kinc_g5_command_list_render_target_to_framebuffer_barrier(kinc_g5_command_list_t *list, struct kinc_g5_texture *renderTarget); -void kinc_g5_command_list_framebuffer_to_render_target_barrier(kinc_g5_command_list_t *list, struct kinc_g5_texture *renderTarget); -void kinc_g5_command_list_texture_to_render_target_barrier(kinc_g5_command_list_t *list, struct kinc_g5_texture *renderTarget); -void kinc_g5_command_list_render_target_to_texture_barrier(kinc_g5_command_list_t *list, struct kinc_g5_texture *renderTarget); -void kinc_g5_command_list_draw_indexed_vertices(kinc_g5_command_list_t *list); -void kinc_g5_command_list_draw_indexed_vertices_from_to(kinc_g5_command_list_t *list, int start, int count); -void kinc_g5_command_list_viewport(kinc_g5_command_list_t *list, int x, int y, int width, int height); -void kinc_g5_command_list_scissor(kinc_g5_command_list_t *list, int x, int y, int width, int height); -void kinc_g5_command_list_disable_scissor(kinc_g5_command_list_t *list); -void kinc_g5_command_list_set_pipeline(kinc_g5_command_list_t *list, struct kinc_g5_pipeline *pipeline); -void kinc_g5_command_list_set_compute_shader(kinc_g5_command_list_t *list, struct kinc_g5_compute_shader *shader); -void kinc_g5_command_list_set_vertex_buffer(kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer *buffer); -void kinc_g5_command_list_set_index_buffer(kinc_g5_command_list_t *list, struct kinc_g5_index_buffer *buffer); -void kinc_g5_command_list_set_render_targets(kinc_g5_command_list_t *list, struct kinc_g5_texture **targets, int count); -void kinc_g5_command_list_upload_index_buffer(kinc_g5_command_list_t *list, struct kinc_g5_index_buffer *buffer); -void kinc_g5_command_list_upload_vertex_buffer(kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer *buffer); -void kinc_g5_command_list_upload_texture(kinc_g5_command_list_t *list, struct kinc_g5_texture *texture); -void kinc_g5_command_list_set_vertex_constant_buffer(kinc_g5_command_list_t *list, struct kinc_g5_constant_buffer *buffer, int offset, size_t size); -void kinc_g5_command_list_set_fragment_constant_buffer(kinc_g5_command_list_t *list, struct kinc_g5_constant_buffer *buffer, int offset, size_t size); -void kinc_g5_command_list_set_compute_constant_buffer(kinc_g5_command_list_t *list, struct kinc_g5_constant_buffer *buffer, int offset, size_t size); -void kinc_g5_command_list_execute(kinc_g5_command_list_t *list); -void kinc_g5_command_list_wait_for_execution_to_finish(kinc_g5_command_list_t *list); -void kinc_g5_command_list_get_render_target_pixels(kinc_g5_command_list_t *list, struct kinc_g5_texture *render_target, uint8_t *data); -void kinc_g5_command_list_compute(kinc_g5_command_list_t *list, int x, int y, int z); -void kinc_g5_command_list_set_texture(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_texture_t *texture); -void kinc_g5_command_list_set_texture_from_render_target_depth(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_texture_t *target); -void kinc_g5_command_list_set_sampler(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_sampler_t *sampler); +void iron_g5_command_list_init(iron_g5_command_list_t *list); +void iron_g5_command_list_destroy(iron_g5_command_list_t *list); +void iron_g5_command_list_begin(iron_g5_command_list_t *list); +void iron_g5_command_list_end(iron_g5_command_list_t *list); +void iron_g5_command_list_clear(iron_g5_command_list_t *list, struct iron_g5_texture *render_target, unsigned flags, unsigned color, float depth); +void iron_g5_command_list_render_target_to_framebuffer_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget); +void iron_g5_command_list_framebuffer_to_render_target_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget); +void iron_g5_command_list_texture_to_render_target_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget); +void iron_g5_command_list_render_target_to_texture_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget); +void iron_g5_command_list_draw_indexed_vertices(iron_g5_command_list_t *list); +void iron_g5_command_list_draw_indexed_vertices_from_to(iron_g5_command_list_t *list, int start, int count); +void iron_g5_command_list_viewport(iron_g5_command_list_t *list, int x, int y, int width, int height); +void iron_g5_command_list_scissor(iron_g5_command_list_t *list, int x, int y, int width, int height); +void iron_g5_command_list_disable_scissor(iron_g5_command_list_t *list); +void iron_g5_command_list_set_pipeline(iron_g5_command_list_t *list, struct iron_g5_pipeline *pipeline); +void iron_g5_command_list_set_compute_shader(iron_g5_command_list_t *list, struct iron_g5_compute_shader *shader); +void iron_g5_command_list_set_vertex_buffer(iron_g5_command_list_t *list, struct iron_g5_vertex_buffer *buffer); +void iron_g5_command_list_set_index_buffer(iron_g5_command_list_t *list, struct iron_g5_index_buffer *buffer); +void iron_g5_command_list_set_render_targets(iron_g5_command_list_t *list, struct iron_g5_texture **targets, int count); +void iron_g5_command_list_upload_index_buffer(iron_g5_command_list_t *list, struct iron_g5_index_buffer *buffer); +void iron_g5_command_list_upload_vertex_buffer(iron_g5_command_list_t *list, struct iron_g5_vertex_buffer *buffer); +void iron_g5_command_list_upload_texture(iron_g5_command_list_t *list, struct iron_g5_texture *texture); +void iron_g5_command_list_set_vertex_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size); +void iron_g5_command_list_set_fragment_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size); +void iron_g5_command_list_set_compute_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size); +void iron_g5_command_list_execute(iron_g5_command_list_t *list); +void iron_g5_command_list_wait_for_execution_to_finish(iron_g5_command_list_t *list); +void iron_g5_command_list_get_render_target_pixels(iron_g5_command_list_t *list, struct iron_g5_texture *render_target, uint8_t *data); +void iron_g5_command_list_compute(iron_g5_command_list_t *list, int x, int y, int z); +void iron_g5_command_list_set_texture(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *texture); +void iron_g5_command_list_set_texture_from_render_target_depth(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *target); +void iron_g5_command_list_set_sampler(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_sampler_t *sampler); -void kinc_g5_render_target_get_pixels(kinc_g5_texture_t *render_target, uint8_t *data); +void iron_g5_render_target_get_pixels(iron_g5_texture_t *render_target, uint8_t *data); -typedef struct kinc_g5_compute_shader { - kinc_g5_compute_shader_impl impl; -} kinc_g5_compute_shader; +typedef struct iron_g5_compute_shader { + iron_g5_compute_shader_impl impl; +} iron_g5_compute_shader; -void kinc_g5_compute_shader_init(kinc_g5_compute_shader *shader, void *source, int length); -void kinc_g5_compute_shader_destroy(kinc_g5_compute_shader *shader); -kinc_g5_constant_location_t kinc_g5_compute_shader_get_constant_location(kinc_g5_compute_shader *shader, const char *name); -kinc_g5_texture_unit_t kinc_g5_compute_shader_get_texture_unit(kinc_g5_compute_shader *shader, const char *name); +void iron_g5_compute_shader_init(iron_g5_compute_shader *shader, void *source, int length); +void iron_g5_compute_shader_destroy(iron_g5_compute_shader *shader); +iron_g5_constant_location_t iron_g5_compute_shader_get_constant_location(iron_g5_compute_shader *shader, const char *name); +iron_g5_texture_unit_t iron_g5_compute_shader_get_texture_unit(iron_g5_compute_shader *shader, const char *name); -struct kinc_g5_command_list; -struct kinc_g5_constant_buffer; -struct kinc_g5_index_buffer; -struct kinc_g5_texture; -struct kinc_g5_texture; -struct kinc_g5_vertex_buffer; +struct iron_g5_command_list; +struct iron_g5_constant_buffer; +struct iron_g5_index_buffer; +struct iron_g5_texture; +struct iron_g5_texture; +struct iron_g5_vertex_buffer; -typedef struct kinc_g5_raytrace_pipeline { - struct kinc_g5_constant_buffer *_constant_buffer; - kinc_g5_raytrace_pipeline_impl_t impl; -} kinc_g5_raytrace_pipeline_t; +typedef struct iron_g5_raytrace_pipeline { + struct iron_g5_constant_buffer *_constant_buffer; + iron_g5_raytrace_pipeline_impl_t impl; +} iron_g5_raytrace_pipeline_t; -typedef struct kinc_g5_raytrace_acceleration_structure { - kinc_g5_raytrace_acceleration_structure_impl_t impl; -} kinc_g5_raytrace_acceleration_structure_t; +typedef struct iron_g5_raytrace_acceleration_structure { + iron_g5_raytrace_acceleration_structure_impl_t impl; +} iron_g5_raytrace_acceleration_structure_t; -bool kinc_g5_raytrace_supported(void); -void kinc_g5_raytrace_pipeline_init(kinc_g5_raytrace_pipeline_t *pipeline, struct kinc_g5_command_list *command_list, - void *ray_shader, int ray_shader_size, struct kinc_g5_constant_buffer *constant_buffer); -void kinc_g5_raytrace_pipeline_destroy(kinc_g5_raytrace_pipeline_t *pipeline); +bool iron_g5_raytrace_supported(void); +void iron_g5_raytrace_pipeline_init(iron_g5_raytrace_pipeline_t *pipeline, struct iron_g5_command_list *command_list, + void *ray_shader, int ray_shader_size, struct iron_g5_constant_buffer *constant_buffer); +void iron_g5_raytrace_pipeline_destroy(iron_g5_raytrace_pipeline_t *pipeline); -void kinc_g5_raytrace_acceleration_structure_init(kinc_g5_raytrace_acceleration_structure_t *accel); -void kinc_g5_raytrace_acceleration_structure_add(kinc_g5_raytrace_acceleration_structure_t *accel, struct kinc_g5_vertex_buffer *vb, struct kinc_g5_index_buffer *ib, kinc_matrix4x4_t transform); -void kinc_g5_raytrace_acceleration_structure_build(kinc_g5_raytrace_acceleration_structure_t *accel, struct kinc_g5_command_list *command_list, - struct kinc_g5_vertex_buffer *_vb_full, struct kinc_g5_index_buffer *_ib_full); -void kinc_g5_raytrace_acceleration_structure_destroy(kinc_g5_raytrace_acceleration_structure_t *accel); +void iron_g5_raytrace_acceleration_structure_init(iron_g5_raytrace_acceleration_structure_t *accel); +void iron_g5_raytrace_acceleration_structure_add(iron_g5_raytrace_acceleration_structure_t *accel, struct iron_g5_vertex_buffer *vb, struct iron_g5_index_buffer *ib, iron_matrix4x4_t transform); +void iron_g5_raytrace_acceleration_structure_build(iron_g5_raytrace_acceleration_structure_t *accel, struct iron_g5_command_list *command_list, + struct iron_g5_vertex_buffer *_vb_full, struct iron_g5_index_buffer *_ib_full); +void iron_g5_raytrace_acceleration_structure_destroy(iron_g5_raytrace_acceleration_structure_t *accel); -void kinc_g5_raytrace_set_textures(struct kinc_g5_texture *texpaint0, struct kinc_g5_texture *texpaint1, struct kinc_g5_texture *texpaint2, - struct kinc_g5_texture *texenv, struct kinc_g5_texture *texsobol, struct kinc_g5_texture *texscramble, struct kinc_g5_texture *texrank); -void kinc_g5_raytrace_set_acceleration_structure(kinc_g5_raytrace_acceleration_structure_t *accel); -void kinc_g5_raytrace_set_pipeline(kinc_g5_raytrace_pipeline_t *pipeline); -void kinc_g5_raytrace_set_target(struct kinc_g5_texture *output); -void kinc_g5_raytrace_dispatch_rays(struct kinc_g5_command_list *command_list); +void iron_g5_raytrace_set_textures(struct iron_g5_texture *texpaint0, struct iron_g5_texture *texpaint1, struct iron_g5_texture *texpaint2, + struct iron_g5_texture *texenv, struct iron_g5_texture *texsobol, struct iron_g5_texture *texscramble, struct iron_g5_texture *texrank); +void iron_g5_raytrace_set_acceleration_structure(iron_g5_raytrace_acceleration_structure_t *accel); +void iron_g5_raytrace_set_pipeline(iron_g5_raytrace_pipeline_t *pipeline); +void iron_g5_raytrace_set_target(struct iron_g5_texture *output); +void iron_g5_raytrace_dispatch_rays(struct iron_g5_command_list *command_list); diff --git a/base/sources/iron_math.c b/base/sources/iron_math.c index 19a28b0b..9cefdb54 100644 --- a/base/sources/iron_math.c +++ b/base/sources/iron_math.c @@ -5,102 +5,102 @@ #include #include -float kinc_cot(float x) { +float iron_cot(float x) { return cosf(x) / sinf(x); } -float kinc_round(float value) { +float iron_round(float value) { return floorf(value + 0.5f); } -float kinc_abs(float value) { +float iron_abs(float value) { return value < 0 ? -value : value; } -float kinc_min(float a, float b) { +float iron_min(float a, float b) { return a > b ? b : a; } -float kinc_max(float a, float b) { +float iron_max(float a, float b) { return a > b ? a : b; } -int kinc_mini(int a, int b) { +int iron_mini(int a, int b) { return a > b ? b : a; } -int kinc_maxi(int a, int b) { +int iron_maxi(int a, int b) { return a > b ? a : b; } -float kinc_clamp(float value, float minValue, float maxValue) { - return kinc_max(minValue, kinc_min(maxValue, value)); +float iron_clamp(float value, float minValue, float maxValue) { + return iron_max(minValue, iron_min(maxValue, value)); } -float kinc_matrix3x3_get(kinc_matrix3x3_t *matrix, int x, int y) { +float iron_matrix3x3_get(iron_matrix3x3_t *matrix, int x, int y) { return matrix->m[x * 3 + y]; } -void kinc_matrix3x3_set(kinc_matrix3x3_t *matrix, int x, int y, float value) { +void iron_matrix3x3_set(iron_matrix3x3_t *matrix, int x, int y, float value) { matrix->m[x * 3 + y] = value; } -void kinc_matrix3x3_transpose(kinc_matrix3x3_t *matrix) { - kinc_matrix3x3_t transposed; +void iron_matrix3x3_transpose(iron_matrix3x3_t *matrix) { + iron_matrix3x3_t transposed; for (int y = 0; y < 3; ++y) { for (int x = 0; x < 3; ++x) { - kinc_matrix3x3_set(&transposed, x, y, kinc_matrix3x3_get(matrix, y, x)); + iron_matrix3x3_set(&transposed, x, y, iron_matrix3x3_get(matrix, y, x)); } } memcpy(matrix->m, transposed.m, sizeof(transposed.m)); } -kinc_matrix3x3_t kinc_matrix3x3_identity(void) { - kinc_matrix3x3_t m; +iron_matrix3x3_t iron_matrix3x3_identity(void) { + iron_matrix3x3_t m; memset(m.m, 0, sizeof(m.m)); for (unsigned x = 0; x < 3; ++x) { - kinc_matrix3x3_set(&m, x, x, 1.0f); + iron_matrix3x3_set(&m, x, x, 1.0f); } return m; } -kinc_matrix3x3_t kinc_matrix3x3_rotation_x(float alpha) { - kinc_matrix3x3_t m = kinc_matrix3x3_identity(); +iron_matrix3x3_t iron_matrix3x3_rotation_x(float alpha) { + iron_matrix3x3_t m = iron_matrix3x3_identity(); float ca = cosf(alpha); float sa = sinf(alpha); - kinc_matrix3x3_set(&m, 1, 1, ca); - kinc_matrix3x3_set(&m, 2, 1, -sa); - kinc_matrix3x3_set(&m, 1, 2, sa); - kinc_matrix3x3_set(&m, 2, 2, ca); + iron_matrix3x3_set(&m, 1, 1, ca); + iron_matrix3x3_set(&m, 2, 1, -sa); + iron_matrix3x3_set(&m, 1, 2, sa); + iron_matrix3x3_set(&m, 2, 2, ca); return m; } -kinc_matrix3x3_t kinc_matrix3x3_rotation_y(float alpha) { - kinc_matrix3x3_t m = kinc_matrix3x3_identity(); +iron_matrix3x3_t iron_matrix3x3_rotation_y(float alpha) { + iron_matrix3x3_t m = iron_matrix3x3_identity(); float ca = cosf(alpha); float sa = sinf(alpha); - kinc_matrix3x3_set(&m, 0, 0, ca); - kinc_matrix3x3_set(&m, 2, 0, sa); - kinc_matrix3x3_set(&m, 0, 2, -sa); - kinc_matrix3x3_set(&m, 2, 2, ca); + iron_matrix3x3_set(&m, 0, 0, ca); + iron_matrix3x3_set(&m, 2, 0, sa); + iron_matrix3x3_set(&m, 0, 2, -sa); + iron_matrix3x3_set(&m, 2, 2, ca); return m; } -kinc_matrix3x3_t kinc_matrix3x3_rotation_z(float alpha) { - kinc_matrix3x3_t m = kinc_matrix3x3_identity(); +iron_matrix3x3_t iron_matrix3x3_rotation_z(float alpha) { + iron_matrix3x3_t m = iron_matrix3x3_identity(); float ca = cosf(alpha); float sa = sinf(alpha); - kinc_matrix3x3_set(&m, 0, 0, ca); - kinc_matrix3x3_set(&m, 1, 0, -sa); - kinc_matrix3x3_set(&m, 0, 1, sa); - kinc_matrix3x3_set(&m, 1, 1, ca); + iron_matrix3x3_set(&m, 0, 0, ca); + iron_matrix3x3_set(&m, 1, 0, -sa); + iron_matrix3x3_set(&m, 0, 1, sa); + iron_matrix3x3_set(&m, 1, 1, ca); return m; } -kinc_matrix3x3_t kinc_matrix3x3_translation(float x, float y) { - kinc_matrix3x3_t m = kinc_matrix3x3_identity(); - kinc_matrix3x3_set(&m, 2, 0, x); - kinc_matrix3x3_set(&m, 2, 1, y); +iron_matrix3x3_t iron_matrix3x3_translation(float x, float y) { + iron_matrix3x3_t m = iron_matrix3x3_identity(); + iron_matrix3x3_set(&m, 2, 0, x); + iron_matrix3x3_set(&m, 2, 1, y); return m; } @@ -108,74 +108,74 @@ kinc_matrix3x3_t kinc_matrix3x3_translation(float x, float y) { #pragma clang diagnostic ignored "-Wconditional-uninitialized" #endif -kinc_matrix3x3_t kinc_matrix3x3_multiply(kinc_matrix3x3_t *a, kinc_matrix3x3_t *b) { - kinc_matrix3x3_t result; +iron_matrix3x3_t iron_matrix3x3_multiply(iron_matrix3x3_t *a, iron_matrix3x3_t *b) { + iron_matrix3x3_t result; for (unsigned x = 0; x < 3; ++x) { for (unsigned y = 0; y < 3; ++y) { - float t = kinc_matrix3x3_get(a, 0, y) * kinc_matrix3x3_get(b, x, 0); + float t = iron_matrix3x3_get(a, 0, y) * iron_matrix3x3_get(b, x, 0); for (unsigned i = 1; i < 3; ++i) { - t += kinc_matrix3x3_get(a, i, y) * kinc_matrix3x3_get(b, x, i); + t += iron_matrix3x3_get(a, i, y) * iron_matrix3x3_get(b, x, i); } - kinc_matrix3x3_set(&result, x, y, t); + iron_matrix3x3_set(&result, x, y, t); } } return result; } -static float vector3_get(kinc_vector3_t vec, int index) { +static float vector3_get(iron_vector3_t vec, int index) { float *values = (float *)&vec; return values[index]; } -static void vector3_set(kinc_vector3_t *vec, int index, float value) { +static void vector3_set(iron_vector3_t *vec, int index, float value) { float *values = (float *)vec; values[index] = value; } -kinc_vector3_t kinc_matrix3x3_multiply_vector(kinc_matrix3x3_t *a, kinc_vector3_t b) { - kinc_vector3_t product; +iron_vector3_t iron_matrix3x3_multiply_vector(iron_matrix3x3_t *a, iron_vector3_t b) { + iron_vector3_t product; for (unsigned y = 0; y < 3; ++y) { float t = 0; for (unsigned x = 0; x < 3; ++x) { - t += kinc_matrix3x3_get(a, x, y) * vector3_get(b, x); + t += iron_matrix3x3_get(a, x, y) * vector3_get(b, x); } vector3_set(&product, y, t); } return product; } -float kinc_matrix4x4_get(kinc_matrix4x4_t *matrix, int x, int y) { +float iron_matrix4x4_get(iron_matrix4x4_t *matrix, int x, int y) { return matrix->m[x * 4 + y]; } -void kinc_matrix4x4_set(kinc_matrix4x4_t *matrix, int x, int y, float value) { +void iron_matrix4x4_set(iron_matrix4x4_t *matrix, int x, int y, float value) { matrix->m[x * 4 + y] = value; } -void kinc_matrix4x4_transpose(kinc_matrix4x4_t *matrix) { - kinc_matrix4x4_t transposed; +void iron_matrix4x4_transpose(iron_matrix4x4_t *matrix) { + iron_matrix4x4_t transposed; for (int y = 0; y < 4; ++y) { for (int x = 0; x < 4; ++x) { - kinc_matrix4x4_set(&transposed, x, y, kinc_matrix4x4_get(matrix, y, x)); + iron_matrix4x4_set(&transposed, x, y, iron_matrix4x4_get(matrix, y, x)); } } memcpy(matrix->m, transposed.m, sizeof(transposed.m)); } -kinc_matrix4x4_t kinc_matrix4x4_multiply(kinc_matrix4x4_t *a, kinc_matrix4x4_t *b) { - kinc_matrix4x4_t result; +iron_matrix4x4_t iron_matrix4x4_multiply(iron_matrix4x4_t *a, iron_matrix4x4_t *b) { + iron_matrix4x4_t result; for (unsigned x = 0; x < 4; ++x) for (unsigned y = 0; y < 4; ++y) { - float t = kinc_matrix4x4_get(a, 0, y) * kinc_matrix4x4_get(b, x, 0); + float t = iron_matrix4x4_get(a, 0, y) * iron_matrix4x4_get(b, x, 0); for (unsigned i = 1; i < 4; ++i) { - t += kinc_matrix4x4_get(a, i, y) * kinc_matrix4x4_get(b, x, i); + t += iron_matrix4x4_get(a, i, y) * iron_matrix4x4_get(b, x, i); } - kinc_matrix4x4_set(&result, x, y, t); + iron_matrix4x4_set(&result, x, y, t); } return result; } -void kinc_color_components(uint32_t color, float *red, float *green, float *blue, float *alpha) { +void iron_color_components(uint32_t color, float *red, float *green, float *blue, float *alpha) { *alpha = ((color & 0xff000000) >> 24) / 255.0f; *red = ((color & 0x00ff0000) >> 16) / 255.0f; *green = ((color & 0x0000ff00) >> 8) / 255.0f; @@ -206,7 +206,7 @@ uint64_t next(void) { return result; } -void kinc_random_init(int64_t seed) { +void iron_random_init(int64_t seed) { s[0] = (uint64_t)seed; s[1] = 2; s[2] = 3; @@ -216,15 +216,15 @@ void kinc_random_init(int64_t seed) { s[3] = next(); } -int64_t kinc_random_get(void) { +int64_t iron_random_get(void) { return (int64_t)next(); } -int64_t kinc_random_get_max(int64_t max) { - return kinc_random_get() % (max + 1); +int64_t iron_random_get_max(int64_t max) { + return iron_random_get() % (max + 1); } -int64_t kinc_random_get_in(int64_t min, int64_t max) { - int64_t value = kinc_random_get(); +int64_t iron_random_get_in(int64_t min, int64_t max) { + int64_t value = iron_random_get(); return (value < -LLONG_MAX ? LLONG_MAX : llabs(value)) % (max + 1 - min) + min; } diff --git a/base/sources/iron_math.h b/base/sources/iron_math.h index 4b494316..f61363f1 100644 --- a/base/sources/iron_math.h +++ b/base/sources/iron_math.h @@ -3,44 +3,44 @@ #include #include -#define KINC_PI 3.141592654 -#define KINC_TAU 6.283185307 +#define IRON_PI 3.141592654 +#define IRON_TAU 6.283185307 -float kinc_cot(float x); -float kinc_round(float value); -float kinc_abs(float value); -float kinc_min(float a, float b); -float kinc_max(float a, float b); -int kinc_mini(int a, int b); -int kinc_maxi(int a, int b); -float kinc_clamp(float value, float minValue, float maxValue); +float iron_cot(float x); +float iron_round(float value); +float iron_abs(float value); +float iron_min(float a, float b); +float iron_max(float a, float b); +int iron_mini(int a, int b); +int iron_maxi(int a, int b); +float iron_clamp(float value, float minValue, float maxValue); -typedef struct kinc_vector2 { +typedef struct iron_vector2 { float x; float y; -} kinc_vector2_t; +} iron_vector2_t; -typedef struct kinc_vector3 { +typedef struct iron_vector3 { float x; float y; float z; -} kinc_vector3_t; +} iron_vector3_t; -typedef struct kinc_vector4 { +typedef struct iron_vector4 { float x; float y; float z; float w; -} kinc_vector4_t; +} iron_vector4_t; -typedef struct kinc_quaternion { +typedef struct iron_quaternion { float x; float y; float z; float w; -} kinc_quaternion_t; +} iron_quaternion_t; -typedef union kinc_matrix3x3 { +typedef union iron_matrix3x3 { float m[3 * 3]; struct { float m00; @@ -53,20 +53,20 @@ typedef union kinc_matrix3x3 { float m21; float m22; }; -} kinc_matrix3x3_t; +} iron_matrix3x3_t; -float kinc_matrix3x3_get(kinc_matrix3x3_t *matrix, int x, int y); -void kinc_matrix3x3_set(kinc_matrix3x3_t *matrix, int x, int y, float value); -void kinc_matrix3x3_transpose(kinc_matrix3x3_t *matrix); -kinc_matrix3x3_t kinc_matrix3x3_identity(void); -kinc_matrix3x3_t kinc_matrix3x3_rotation_x(float alpha); -kinc_matrix3x3_t kinc_matrix3x3_rotation_y(float alpha); -kinc_matrix3x3_t kinc_matrix3x3_rotation_z(float alpha); -kinc_matrix3x3_t kinc_matrix3x3_translation(float x, float y); -kinc_matrix3x3_t kinc_matrix3x3_multiply(kinc_matrix3x3_t *a, kinc_matrix3x3_t *b); -kinc_vector3_t kinc_matrix3x3_multiply_vector(kinc_matrix3x3_t *a, kinc_vector3_t b); +float iron_matrix3x3_get(iron_matrix3x3_t *matrix, int x, int y); +void iron_matrix3x3_set(iron_matrix3x3_t *matrix, int x, int y, float value); +void iron_matrix3x3_transpose(iron_matrix3x3_t *matrix); +iron_matrix3x3_t iron_matrix3x3_identity(void); +iron_matrix3x3_t iron_matrix3x3_rotation_x(float alpha); +iron_matrix3x3_t iron_matrix3x3_rotation_y(float alpha); +iron_matrix3x3_t iron_matrix3x3_rotation_z(float alpha); +iron_matrix3x3_t iron_matrix3x3_translation(float x, float y); +iron_matrix3x3_t iron_matrix3x3_multiply(iron_matrix3x3_t *a, iron_matrix3x3_t *b); +iron_vector3_t iron_matrix3x3_multiply_vector(iron_matrix3x3_t *a, iron_vector3_t b); -typedef union kinc_matrix4x4 { +typedef union iron_matrix4x4 { float m[4 * 4]; struct { float m00; @@ -86,16 +86,16 @@ typedef union kinc_matrix4x4 { float m32; float m33; }; -} kinc_matrix4x4_t; +} iron_matrix4x4_t; -float kinc_matrix4x4_get(kinc_matrix4x4_t *matrix, int x, int y); -void kinc_matrix4x4_set(kinc_matrix4x4_t *matrix, int x, int y, float value); -void kinc_matrix4x4_transpose(kinc_matrix4x4_t *matrix); -kinc_matrix4x4_t kinc_matrix4x4_multiply(kinc_matrix4x4_t *a, kinc_matrix4x4_t *b); +float iron_matrix4x4_get(iron_matrix4x4_t *matrix, int x, int y); +void iron_matrix4x4_set(iron_matrix4x4_t *matrix, int x, int y, float value); +void iron_matrix4x4_transpose(iron_matrix4x4_t *matrix); +iron_matrix4x4_t iron_matrix4x4_multiply(iron_matrix4x4_t *a, iron_matrix4x4_t *b); -void kinc_color_components(uint32_t color, float *red, float *green, float *blue, float *alpha); +void iron_color_components(uint32_t color, float *red, float *green, float *blue, float *alpha); -void kinc_random_init(int64_t seed); -int64_t kinc_random_get(void); -int64_t kinc_random_get_max(int64_t max); -int64_t kinc_random_get_in(int64_t min, int64_t max); +void iron_random_init(int64_t seed); +int64_t iron_random_get(void); +int64_t iron_random_get_max(int64_t max); +int64_t iron_random_get_in(int64_t min, int64_t max); diff --git a/base/sources/iron_net.h b/base/sources/iron_net.h index 5e8120e9..8f3f5ae9 100644 --- a/base/sources/iron_net.h +++ b/base/sources/iron_net.h @@ -3,89 +3,89 @@ #include #include -#define KINC_HTTP_GET 0 -#define KINC_HTTP_POST 1 -#define KINC_HTTP_PUT 2 -#define KINC_HTTP_DELETE 3 +#define IRON_HTTP_GET 0 +#define IRON_HTTP_POST 1 +#define IRON_HTTP_PUT 2 +#define IRON_HTTP_DELETE 3 -typedef void (*kinc_http_callback_t)(int error, int response, const char *body, void *callbackdata); +typedef void (*iron_http_callback_t)(int error, int response, const char *body, void *callbackdata); -void kinc_http_request(const char *url, const char *path, const char *data, int port, bool secure, int method, const char *header, - kinc_http_callback_t callback, void *callbackdata); +void iron_http_request(const char *url, const char *path, const char *data, int port, bool secure, int method, const char *header, + iron_http_callback_t callback, void *callbackdata); -// typedef enum kinc_socket_protocol { -// KINC_SOCKET_PROTOCOL_UDP, -// KINC_SOCKET_PROTOCOL_TCP -// } kinc_socket_protocol_t; +// typedef enum iron_socket_protocol { +// IRON_SOCKET_PROTOCOL_UDP, +// IRON_SOCKET_PROTOCOL_TCP +// } iron_socket_protocol_t; -// typedef enum kinc_socket_family { -// KINC_SOCKET_FAMILY_IP4, -// KINC_SOCKET_FAMILY_IP6 -// } kinc_socket_family_t; +// typedef enum iron_socket_family { +// IRON_SOCKET_FAMILY_IP4, +// IRON_SOCKET_FAMILY_IP6 +// } iron_socket_family_t; -// #ifdef KINC_WINDOWS +// #ifdef IRON_WINDOWS // typedef unsigned __int64 UINT_PTR, *PUINT_PTR; // typedef UINT_PTR SOCKET; // #endif -// typedef struct kinc_socket { -// #ifdef KINC_WINDOWS +// typedef struct iron_socket { +// #ifdef IRON_WINDOWS // SOCKET handle; // #else // int handle; // #endif // uint32_t host; // uint32_t port; -// kinc_socket_protocol_t protocol; -// kinc_socket_family_t family; +// iron_socket_protocol_t protocol; +// iron_socket_family_t family; // bool connected; -// } kinc_socket_t; +// } iron_socket_t; -// typedef struct kinc_socket_options { +// typedef struct iron_socket_options { // bool non_blocking; // bool broadcast; // bool tcp_no_delay; -// } kinc_socket_options_t; +// } iron_socket_options_t; -// void kinc_socket_options_set_defaults(kinc_socket_options_t *options); -// void kinc_socket_init(kinc_socket_t *socket); -// bool kinc_socket_set(kinc_socket_t *socket, const char *host, int port, kinc_socket_family_t family, kinc_socket_protocol_t protocol); -// void kinc_socket_destroy(kinc_socket_t *socket); -// bool kinc_socket_open(kinc_socket_t *socket, kinc_socket_options_t *options); -// bool kinc_socket_select(kinc_socket_t *socket, uint32_t waittime, bool read, bool write); +// void iron_socket_options_set_defaults(iron_socket_options_t *options); +// void iron_socket_init(iron_socket_t *socket); +// bool iron_socket_set(iron_socket_t *socket, const char *host, int port, iron_socket_family_t family, iron_socket_protocol_t protocol); +// void iron_socket_destroy(iron_socket_t *socket); +// bool iron_socket_open(iron_socket_t *socket, iron_socket_options_t *options); +// bool iron_socket_select(iron_socket_t *socket, uint32_t waittime, bool read, bool write); // /*Typically these are server actions.*/ -// bool kinc_socket_bind(kinc_socket_t *socket); -// bool kinc_socket_listen(kinc_socket_t *socket, int backlog); -// bool kinc_socket_accept(kinc_socket_t *socket, kinc_socket_t *new_socket, unsigned *remote_address, unsigned *remote_port); +// bool iron_socket_bind(iron_socket_t *socket); +// bool iron_socket_listen(iron_socket_t *socket, int backlog); +// bool iron_socket_accept(iron_socket_t *socket, iron_socket_t *new_socket, unsigned *remote_address, unsigned *remote_port); // /*Typically this is a client action.*/ -// bool kinc_socket_connect(kinc_socket_t *socket); +// bool iron_socket_connect(iron_socket_t *socket); -// int kinc_socket_send(kinc_socket_t *socket, const uint8_t *data, int size); -// int kinc_socket_send_address(kinc_socket_t *socket, unsigned address, int port, const uint8_t *data, int size); -// int kinc_socket_send_url(kinc_socket_t *socket, const char *url, int port, const uint8_t *data, int size); -// int kinc_socket_receive(kinc_socket_t *socket, uint8_t *data, int maxSize, unsigned *from_address, unsigned *from_port); +// int iron_socket_send(iron_socket_t *socket, const uint8_t *data, int size); +// int iron_socket_send_address(iron_socket_t *socket, unsigned address, int port, const uint8_t *data, int size); +// int iron_socket_send_url(iron_socket_t *socket, const char *url, int port, const uint8_t *data, int size); +// int iron_socket_receive(iron_socket_t *socket, uint8_t *data, int maxSize, unsigned *from_address, unsigned *from_port); -// unsigned kinc_url_to_int(const char *url, int port); +// unsigned iron_url_to_int(const char *url, int port); -// #ifdef KINC_IMPLEMENTATION_ROOT -// #define KINC_IMPLEMENTATION +// #ifdef IRON_IMPLEMENTATION_ROOT +// #define IRON_IMPLEMENTATION // #endif -// #ifdef KINC_IMPLEMENTATION +// #ifdef IRON_IMPLEMENTATION -// #undef KINC_IMPLEMENTATION +// #undef IRON_IMPLEMENTATION // #include // #include -// #define KINC_IMPLEMENTATION +// #define IRON_IMPLEMENTATION // #include // #include // #include // #include -// #if defined(KINC_WINDOWS) +// #if defined(IRON_WINDOWS) // // Windows 7 // #define WINVER 0x0601 @@ -132,7 +132,7 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // #include // #include -// #elif defined(KINC_POSIX) +// #elif defined(IRON_POSIX) // #include // for inet_addr() // #include // #include @@ -144,13 +144,13 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // #include // #endif -// #if defined(KINC_POSIX) +// #if defined(IRON_POSIX) // #include // #endif // static int counter = 0; -// #if defined(KINC_WINDOWS) || defined(KINC_POSIX) +// #if defined(IRON_WINDOWS) || defined(IRON_POSIX) // // Important: Must be cleaned with freeaddrinfo(address) later if the result is 0 in order to prevent memory leaks // static int resolveAddress(const char *url, int port, struct addrinfo **result) { // struct addrinfo hints = {0}; @@ -165,14 +165,14 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // } // #endif -// bool kinc_socket_bind(kinc_socket_t *sock) { -// #if defined(KINC_WINDOWS) || defined(KINC_POSIX) +// bool iron_socket_bind(iron_socket_t *sock) { +// #if defined(IRON_WINDOWS) || defined(IRON_POSIX) // struct sockaddr_in address; -// address.sin_family = sock->family == KINC_SOCKET_FAMILY_IP4 ? AF_INET : AF_INET6; +// address.sin_family = sock->family == IRON_SOCKET_FAMILY_IP4 ? AF_INET : AF_INET6; // address.sin_addr.s_addr = sock->host; // address.sin_port = sock->port; // if (bind(sock->handle, (const struct sockaddr *)&address, sizeof(struct sockaddr_in)) < 0) { -// kinc_error("Could not bind socket: %s", strerror(errno)); +// iron_error("Could not bind socket: %s", strerror(errno)); // return false; // } // return true; @@ -181,24 +181,24 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // #endif // } -// void kinc_socket_options_set_defaults(kinc_socket_options_t *options) { +// void iron_socket_options_set_defaults(iron_socket_options_t *options) { // options->non_blocking = true; // options->broadcast = false; // options->tcp_no_delay = false; // } -// void kinc_socket_init(kinc_socket_t *sock) { +// void iron_socket_init(iron_socket_t *sock) { // sock->handle = 0; -// #if defined(KINC_WINDOWS) || defined(KINC_POSIX) +// #if defined(IRON_WINDOWS) || defined(IRON_POSIX) // sock->host = INADDR_ANY; // sock->port = htons((unsigned short)8080); -// sock->protocol = KINC_SOCKET_PROTOCOL_TCP; -// sock->family = KINC_SOCKET_FAMILY_IP4; +// sock->protocol = IRON_SOCKET_PROTOCOL_TCP; +// sock->family = IRON_SOCKET_FAMILY_IP4; // #endif // sock->connected = false; -// #if defined(KINC_WINDOWS) +// #if defined(IRON_WINDOWS) // if (counter == 0) { // WSADATA WsaData; // WSAStartup(MAKEWORD(2, 2), &WsaData); @@ -207,76 +207,76 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // ++counter; // } -// bool kinc_socket_open(kinc_socket_t *sock, struct kinc_socket_options *options) { -// #if defined(KINC_WINDOWS) || defined(KINC_POSIX) +// bool iron_socket_open(iron_socket_t *sock, struct iron_socket_options *options) { +// #if defined(IRON_WINDOWS) || defined(IRON_POSIX) // switch (sock->protocol) { -// case KINC_SOCKET_PROTOCOL_UDP: -// sock->handle = socket(sock->family == KINC_SOCKET_FAMILY_IP4 ? AF_INET : AF_INET6, SOCK_DGRAM, IPPROTO_UDP); +// case IRON_SOCKET_PROTOCOL_UDP: +// sock->handle = socket(sock->family == IRON_SOCKET_FAMILY_IP4 ? AF_INET : AF_INET6, SOCK_DGRAM, IPPROTO_UDP); // break; -// case KINC_SOCKET_PROTOCOL_TCP: -// sock->handle = socket(sock->family == KINC_SOCKET_FAMILY_IP4 ? AF_INET : AF_INET6, SOCK_STREAM, IPPROTO_TCP); +// case IRON_SOCKET_PROTOCOL_TCP: +// sock->handle = socket(sock->family == IRON_SOCKET_FAMILY_IP4 ? AF_INET : AF_INET6, SOCK_STREAM, IPPROTO_TCP); // break; // default: -// kinc_error("Unsupported socket protocol."); +// iron_error("Unsupported socket protocol."); // return false; // } // if (sock->handle <= 0) { -// kinc_error("Could not create socket."); -// #if defined(KINC_WINDOWS) +// iron_error("Could not create socket."); +// #if defined(IRON_WINDOWS) // int errorCode = WSAGetLastError(); // switch (errorCode) { // case (WSANOTINITIALISED): -// kinc_error("A successful WSAStartup call must occur before using this function."); +// iron_error("A successful WSAStartup call must occur before using this function."); // break; // case (WSAENETDOWN): -// kinc_error("The network subsystem or the associated service provider has failed."); +// iron_error("The network subsystem or the associated service provider has failed."); // break; // case (WSAEAFNOSUPPORT): -// kinc_error( +// iron_error( // "The specified address family is not supported.For example, an application tried to create a socket for the AF_IRDA address " // "family but an infrared adapter and device driver is not installed on the local computer."); // break; // case (WSAEINPROGRESS): -// kinc_error( +// iron_error( // "A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function."); // break; // case (WSAEMFILE): -// kinc_error("No more socket descriptors are available."); +// iron_error("No more socket descriptors are available."); // break; // case (WSAEINVAL): -// kinc_error( +// iron_error( // "An invalid argument was supplied.This error is returned if the af parameter is set to AF_UNSPEC and the type and protocol " // "parameter are unspecified."); // break; // case (WSAENOBUFS): -// kinc_error("No buffer space is available.The socket cannot be created."); +// iron_error("No buffer space is available.The socket cannot be created."); // break; // case (WSAEPROTONOSUPPORT): -// kinc_error("The specified protocol is not supported."); +// iron_error("The specified protocol is not supported."); // break; // case (WSAEPROTOTYPE): -// kinc_error("The specified protocol is the wrong type for this socket."); +// iron_error("The specified protocol is the wrong type for this socket."); // break; // case (WSAEPROVIDERFAILEDINIT): -// kinc_error( +// iron_error( // "The service provider failed to initialize.This error is returned if a layered service provider(LSP) or namespace provider was " // "improperly installed or the provider fails to operate correctly."); // break; // case (WSAESOCKTNOSUPPORT): -// kinc_error("The specified socket type is not supported in this address family."); +// iron_error("The specified socket type is not supported in this address family."); // break; // case (WSAEINVALIDPROVIDER): -// kinc_error("The service provider returned a version other than 2.2."); +// iron_error("The service provider returned a version other than 2.2."); // break; // case (WSAEINVALIDPROCTABLE): -// kinc_error("The service provider returned an invalid or incomplete procedure table to the WSPStartup."); +// iron_error("The service provider returned an invalid or incomplete procedure table to the WSPStartup."); // break; // default: -// kinc_error("Unknown error."); +// iron_error("Unknown error."); // } -// #elif defined(KINC_POSIX) -// kinc_error("%s", strerror(errno)); +// #elif defined(IRON_POSIX) +// iron_error("%s", strerror(errno)); // #endif // return false; // } @@ -284,36 +284,36 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // if (options) { // if (options->non_blocking) { -// #if defined(KINC_WINDOWS) +// #if defined(IRON_WINDOWS) // DWORD value = 1; // if (ioctlsocket(sock->handle, FIONBIO, &value) != 0) { -// kinc_error("Could not set non-blocking mode."); +// iron_error("Could not set non-blocking mode."); // return false; // } -// #elif defined(KINC_POSIX) +// #elif defined(IRON_POSIX) // int value = 1; // if (fcntl(sock->handle, F_SETFL, O_NONBLOCK, value) == -1) { -// kinc_error("Could not set non-blocking mode."); +// iron_error("Could not set non-blocking mode."); // return false; // } // #endif // } // if (options->broadcast) { -// #if defined(KINC_WINDOWS) || defined(KINC_POSIX) +// #if defined(IRON_WINDOWS) || defined(IRON_POSIX) // int value = 1; // if (setsockopt(sock->handle, SOL_SOCKET, SO_BROADCAST, (const char *)&value, sizeof(value)) < 0) { -// kinc_error("Could not set broadcast mode."); +// iron_error("Could not set broadcast mode."); // return false; // } // #endif // } // if (options->tcp_no_delay) { -// #if defined(KINC_WINDOWS) || defined(KINC_POSIX) +// #if defined(IRON_WINDOWS) || defined(IRON_POSIX) // int value = 1; // if (setsockopt(sock->handle, IPPROTO_TCP, TCP_NODELAY, (const char *)&value, sizeof(value)) != 0) { -// kinc_error("Could not set no-delay mode."); +// iron_error("Could not set no-delay mode."); // return false; // } // #endif @@ -323,25 +323,25 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // return true; // } -// void kinc_socket_destroy(kinc_socket_t *sock) { -// #if defined(KINC_WINDOWS) +// void iron_socket_destroy(iron_socket_t *sock) { +// #if defined(IRON_WINDOWS) // closesocket(sock->handle); -// #elif defined(KINC_POSIX) +// #elif defined(IRON_POSIX) // close(sock->handle); // #endif -// memset(sock, 0, sizeof(kinc_socket_t)); +// memset(sock, 0, sizeof(iron_socket_t)); // --counter; -// #if defined(KINC_WINDOWS) +// #if defined(IRON_WINDOWS) // if (counter == 0) { // WSACleanup(); // } // #endif // } -// bool kinc_socket_select(kinc_socket_t *sock, uint32_t waittime, bool read, bool write) { -// #if (defined(KINC_WINDOWS) || defined(KINC_POSIX)) +// bool iron_socket_select(iron_socket_t *sock, uint32_t waittime, bool read, bool write) { +// #if (defined(IRON_WINDOWS) || defined(IRON_POSIX)) // fd_set r_fds, w_fds; // struct timeval timeout; @@ -355,7 +355,7 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // timeout.tv_usec = 0; // if (select(0, &r_fds, &w_fds, NULL, &timeout) < 0) { -// kinc_error("kinc_socket_select didn't work: %s", strerror(errno)); +// iron_error("iron_socket_select didn't work: %s", strerror(errno)); // return false; // } @@ -369,7 +369,7 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // return FD_ISSET(sock->handle, &w_fds); // } // else { -// kinc_error("Calling kinc_socket_select with both read and write set to false is useless."); +// iron_error("Calling iron_socket_select with both read and write set to false is useless."); // return false; // } // #else @@ -377,8 +377,8 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // #endif // } -// bool kinc_socket_set(kinc_socket_t *sock, const char *host, int port, kinc_socket_family_t family, kinc_socket_protocol_t protocol) { -// #if defined(KINC_WINDOWS) || defined(KINC_POSIX) +// bool iron_socket_set(iron_socket_t *sock, const char *host, int port, iron_socket_family_t family, iron_socket_protocol_t protocol) { +// #if defined(IRON_WINDOWS) || defined(IRON_POSIX) // sock->family = family; // sock->protocol = protocol; @@ -387,11 +387,11 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // if (host == NULL) // return true; -// if (isdigit(host[0]) || (family == KINC_SOCKET_FAMILY_IP6 && host[4] == ':')) { // Is IPv4 or IPv6 string +// if (isdigit(host[0]) || (family == IRON_SOCKET_FAMILY_IP6 && host[4] == ':')) { // Is IPv4 or IPv6 string // struct in_addr addr; -// if (inet_pton(sock->family == KINC_SOCKET_FAMILY_IP4 ? AF_INET : AF_INET6, host, &addr) == 0) { -// kinc_error("Invalid %s address: %s\n", sock->family == KINC_SOCKET_FAMILY_IP4 ? "IPv4" : "IPv6", host); +// if (inet_pton(sock->family == IRON_SOCKET_FAMILY_IP4 ? AF_INET : AF_INET6, host, &addr) == 0) { +// iron_error("Invalid %s address: %s\n", sock->family == IRON_SOCKET_FAMILY_IP4 ? "IPv4" : "IPv6", host); // return false; // } // sock->host = addr.s_addr; @@ -401,10 +401,10 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // struct addrinfo *address = NULL; // int res = resolveAddress(host, port, &address); // if (res != 0) { -// kinc_error("Could not resolve address."); +// iron_error("Could not resolve address."); // return false; // } -// #if defined(KINC_POSIX) +// #if defined(IRON_POSIX) // sock->host = ((struct sockaddr_in *)address->ai_addr)->sin_addr.s_addr; // #else // sock->host = ((struct sockaddr_in *)address->ai_addr)->sin_addr.S_un.S_addr; @@ -418,8 +418,8 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // #endif // } -// bool kinc_socket_listen(kinc_socket_t *socket, int backlog) { -// #if defined(KINC_WINDOWS) || defined(KINC_POSIX) +// bool iron_socket_listen(iron_socket_t *socket, int backlog) { +// #if defined(IRON_WINDOWS) || defined(IRON_POSIX) // int res = listen(socket->handle, backlog); // return (res == 0); // #else @@ -427,11 +427,11 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // #endif // } -// bool kinc_socket_accept(kinc_socket_t *sock, kinc_socket_t *newSocket, unsigned *remoteAddress, unsigned *remotePort) { -// #if defined(KINC_WINDOWS) +// bool iron_socket_accept(iron_socket_t *sock, iron_socket_t *newSocket, unsigned *remoteAddress, unsigned *remotePort) { +// #if defined(IRON_WINDOWS) // typedef int socklen_t; // #endif -// #if defined(KINC_WINDOWS) || defined(KINC_POSIX) +// #if defined(IRON_WINDOWS) || defined(IRON_POSIX) // struct sockaddr_in addr; // socklen_t addrLength = sizeof(addr); // newSocket->handle = accept(sock->handle, (struct sockaddr *)&addr, &addrLength); @@ -452,10 +452,10 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // #endif // } -// bool kinc_socket_connect(kinc_socket_t *sock) { -// #if defined(KINC_WINDOWS) || defined(KINC_POSIX) +// bool iron_socket_connect(iron_socket_t *sock) { +// #if defined(IRON_WINDOWS) || defined(IRON_POSIX) // struct sockaddr_in addr; -// addr.sin_family = sock->family == KINC_SOCKET_FAMILY_IP4 ? AF_INET : AF_INET6; +// addr.sin_family = sock->family == IRON_SOCKET_FAMILY_IP4 ? AF_INET : AF_INET6; // addr.sin_addr.s_addr = sock->host; // addr.sin_port = sock->port; @@ -466,33 +466,33 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // #endif // } -// int kinc_socket_send(kinc_socket_t *sock, const uint8_t *data, int size) { -// #if defined(KINC_WINDOWS) +// int iron_socket_send(iron_socket_t *sock, const uint8_t *data, int size) { +// #if defined(IRON_WINDOWS) // typedef int socklen_t; // #endif -// #if defined(KINC_WINDOWS) || defined(KINC_POSIX) -// if (sock->protocol == KINC_SOCKET_PROTOCOL_UDP) { +// #if defined(IRON_WINDOWS) || defined(IRON_POSIX) +// if (sock->protocol == IRON_SOCKET_PROTOCOL_UDP) { // struct sockaddr_in addr; -// addr.sin_family = sock->family == KINC_SOCKET_FAMILY_IP4 ? AF_INET : AF_INET6; +// addr.sin_family = sock->family == IRON_SOCKET_FAMILY_IP4 ? AF_INET : AF_INET6; // addr.sin_addr.s_addr = sock->host; // addr.sin_port = sock->port; // size_t sent = sendto(sock->handle, (const char *)data, size, 0, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)); // if (sent != size) { -// kinc_error("Could not send packet."); +// iron_error("Could not send packet."); // return -1; // } // return (int)sent; // } // else { // if (!sock->connected) { -// kinc_error("Call kinc_sockect_connect/bind before send/recv can be called for TCP sockets."); +// iron_error("Call iron_sockect_connect/bind before send/recv can be called for TCP sockets."); // return -1; // } // size_t sent = send(sock->handle, (const char *)data, size, 0); // if (sent != size) { -// kinc_error("Could not send packet."); +// iron_error("Could not send packet."); // } // return (int)sent; // } @@ -501,8 +501,8 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // #endif // } -// int kinc_socket_send_address(kinc_socket_t *sock, unsigned address, int port, const uint8_t *data, int size) { -// #if defined(KINC_WINDOWS) || defined(KINC_POSIX) +// int iron_socket_send_address(iron_socket_t *sock, unsigned address, int port, const uint8_t *data, int size) { +// #if defined(IRON_WINDOWS) || defined(IRON_POSIX) // struct sockaddr_in addr; // addr.sin_family = AF_INET; // addr.sin_addr.s_addr = htonl(address); @@ -510,7 +510,7 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // size_t sent = sendto(sock->handle, (const char *)data, size, 0, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)); // if (sent != size) { -// kinc_error("Could not send packet."); +// iron_error("Could not send packet."); // } // return (int)sent; // #else @@ -518,18 +518,18 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // #endif // } -// int kinc_socket_send_url(kinc_socket_t *sock, const char *url, int port, const uint8_t *data, int size) { -// #if defined(KINC_WINDOWS) || defined(KINC_POSIX) +// int iron_socket_send_url(iron_socket_t *sock, const char *url, int port, const uint8_t *data, int size) { +// #if defined(IRON_WINDOWS) || defined(IRON_POSIX) // struct addrinfo *address = NULL; // int res = resolveAddress(url, port, &address); // if (res != 0) { -// kinc_error("Could not resolve address."); +// iron_error("Could not resolve address."); // return 0; // } // size_t sent = sendto(sock->handle, (const char *)data, size, 0, address->ai_addr, sizeof(struct sockaddr_in)); // if (sent != size) { -// kinc_error("Could not send packet."); +// iron_error("Could not send packet."); // } // freeaddrinfo(address); // return (int)sent; @@ -538,14 +538,14 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // #endif // } -// int kinc_socket_receive(kinc_socket_t *sock, uint8_t *data, int maxSize, unsigned *fromAddress, unsigned *fromPort) { -// #if defined(KINC_WINDOWS) +// int iron_socket_receive(iron_socket_t *sock, uint8_t *data, int maxSize, unsigned *fromAddress, unsigned *fromPort) { +// #if defined(IRON_WINDOWS) // typedef int socklen_t; // typedef int ssize_t; // #endif -// #if defined(KINC_WINDOWS) || defined(KINC_POSIX) +// #if defined(IRON_WINDOWS) || defined(IRON_POSIX) -// if (sock->protocol == KINC_SOCKET_PROTOCOL_UDP) { +// if (sock->protocol == IRON_SOCKET_PROTOCOL_UDP) { // struct sockaddr_in from; // socklen_t fromLength = sizeof(from); // ssize_t bytes = recvfrom(sock->handle, (char *)data, maxSize, 0, (struct sockaddr *)&from, &fromLength); @@ -559,7 +559,7 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // else { // if (!sock->connected) { -// kinc_error("Call kinc_sockect_connect/bind before send/recv can be called for TCP sockets."); +// iron_error("Call iron_sockect_connect/bind before send/recv can be called for TCP sockets."); // return -1; // } // ssize_t bytes = recv(sock->handle, (char *)data, maxSize, 0); @@ -572,12 +572,12 @@ void kinc_http_request(const char *url, const char *path, const char *data, int // #endif // } -// unsigned kinc_url_to_int(const char *url, int port) { -// #if defined(KINC_WINDOWS) +// unsigned iron_url_to_int(const char *url, int port) { +// #if defined(IRON_WINDOWS) // struct addrinfo *address = NULL; // int res = resolveAddress(url, port, &address); // if (res != 0) { -// kinc_error("Could not resolve address."); +// iron_error("Could not resolve address."); // return -1; // } diff --git a/base/sources/iron_obj.c b/base/sources/iron_obj.c index 9b51e11f..61088663 100644 --- a/base/sources/iron_obj.c +++ b/base/sources/iron_obj.c @@ -206,9 +206,9 @@ static bool pnpoly(float v0x, float v0y, float v1x, float v1y, float v2x, float return c; } -kinc_vector4_t calc_normal(kinc_vector4_t a, kinc_vector4_t b, kinc_vector4_t c) { - kinc_vector4_t cb = vec4_sub(c, b); - kinc_vector4_t ab = vec4_sub(a, b); +iron_vector4_t calc_normal(iron_vector4_t a, iron_vector4_t b, iron_vector4_t c) { + iron_vector4_t cb = vec4_sub(c, b); + iron_vector4_t ab = vec4_sub(a, b); cb = vec4_cross(cb, ab); cb = vec4_norm(cb); return cb; @@ -344,7 +344,7 @@ raw_mesh_t *obj_parse(buffer_t *file_bytes, char split_code, uint64_t start_pos, nz = nor_temp.buffer[(na[0] - _nind_off) * 3 + 2]; } else { - kinc_vector4_t n = calc_normal( + iron_vector4_t n = calc_normal( vec4_create(pos_temp.buffer[(va[0] - _vind_off) * 3], pos_temp.buffer[(va[0] - _vind_off) * 3 + 1], pos_temp.buffer[(va[0] - _vind_off) * 3 + 2], 1.0f), vec4_create(pos_temp.buffer[(va[1] - _vind_off) * 3], pos_temp.buffer[(va[1] - _vind_off) * 3 + 1], pos_temp.buffer[(va[1] - _vind_off) * 3 + 2], 1.0f), vec4_create(pos_temp.buffer[(va[2] - _vind_off) * 3], pos_temp.buffer[(va[2] - _vind_off) * 3 + 1], pos_temp.buffer[(va[2] - _vind_off) * 3 + 2], 1.0f) @@ -524,7 +524,7 @@ raw_mesh_t *obj_parse(buffer_t *file_bytes, char split_code, uint64_t start_pos, int i1 = part->inda->buffer[i * 3 ]; int i2 = part->inda->buffer[i * 3 + 1]; int i3 = part->inda->buffer[i * 3 + 2]; - kinc_vector4_t n = calc_normal( + iron_vector4_t n = calc_normal( vec4_create(part->posa->buffer[i1 * 4], part->posa->buffer[i1 * 4 + 1], part->posa->buffer[i1 * 4 + 2], 1.0), vec4_create(part->posa->buffer[i2 * 4], part->posa->buffer[i2 * 4 + 1], part->posa->buffer[i2 * 4 + 2], 1.0), vec4_create(part->posa->buffer[i3 * 4], part->posa->buffer[i3 * 4 + 1], part->posa->buffer[i3 * 4 + 2], 1.0) diff --git a/base/sources/iron_simd.h b/base/sources/iron_simd.h index 85916eb7..4523d33d 100644 --- a/base/sources/iron_simd.h +++ b/base/sources/iron_simd.h @@ -13,104 +13,104 @@ // Unfortunate situation here // MSVC does not provide compiletime macros for the following instruction sets // but their existence is implied by AVX and higher -#define KINC_SSE4_2 -#define KINC_SSE4_1 -#define KINC_SSSE3 -#define KINC_SSE3 +#define IRON_SSE4_2 +#define IRON_SSE4_1 +#define IRON_SSSE3 +#define IRON_SSE3 #endif // SSE2 Capability check // Note for Windows: // _M_IX86_FP checks SSE2 and SSE for 32bit Windows programs only, and is unset if not a 32bit program. // SSE2 and earlier is --guaranteed-- to be active for any 64bit Windows program -#if defined(__SSE2__) || (_M_IX86_FP == 2) || (defined(KINC_WINDOWS) && defined(KINC_64)) -#define KINC_SSE2 +#if defined(__SSE2__) || (_M_IX86_FP == 2) || (defined(IRON_WINDOWS) && defined(IRON_64)) +#define IRON_SSE2 #endif // SSE Capability check -#if defined(__SSE__) || _M_IX86_FP == 2 || _M_IX86_FP == 1 || (defined(KINC_WINDOWS) && !defined(__aarch64__)) || \ - (defined(KINC_WINDOWSAPP) && !defined(__aarch64__)) || (defined(KINC_MACOS) && __x86_64) +#if defined(__SSE__) || _M_IX86_FP == 2 || _M_IX86_FP == 1 || (defined(IRON_WINDOWS) && !defined(__aarch64__)) || \ + (defined(IRON_WINDOWSAPP) && !defined(__aarch64__)) || (defined(IRON_MACOS) && __x86_64) -#define KINC_SSE +#define IRON_SSE #endif // NEON Capability check -#if defined(KINC_IOS) || defined(__aarch64__) || defined(KINC_NEON) -#define KINC_NEON +#if defined(IRON_IOS) || defined(__aarch64__) || defined(IRON_NEON) +#define IRON_NEON #endif // No SIMD Capabilities -#if !defined(KINC_SSE4_2) && !defined(KINC_SSE4_1) && !defined(KINC_SSSE3) && !defined(KINC_SSE3) && !defined(KINC_SSE2) && !defined(KINC_SSE) && \ - !defined(KINC_NEON) +#if !defined(IRON_SSE4_2) && !defined(IRON_SSE4_1) && !defined(IRON_SSSE3) && !defined(IRON_SSE3) && !defined(IRON_SSE2) && !defined(IRON_SSE) && \ + !defined(IRON_NEON) -#define KINC_NOSIMD +#define IRON_NOSIMD #endif -#define KINC_SHUFFLE_TABLE(LANE_A1, LANE_A2, LANE_B1, LANE_B2) \ +#define IRON_SHUFFLE_TABLE(LANE_A1, LANE_A2, LANE_B1, LANE_B2) \ ((((LANE_B2)&0x3) << 6) | (((LANE_B1)&0x3) << 4) | (((LANE_A2)&0x3) << 2) | (((LANE_A1)&0x3) << 0)) -#if defined(KINC_SSE2) +#if defined(IRON_SSE2) // SSE_## related headers include earlier revisions, IE // SSE2 contains all of SSE #include -typedef __m128 kinc_float32x4_t; -typedef __m128 kinc_float32x4_mask_t; +typedef __m128 iron_float32x4_t; +typedef __m128 iron_float32x4_mask_t; -#elif defined(KINC_SSE) +#elif defined(IRON_SSE) #include -typedef __m128 kinc_float32x4_t; -typedef __m128 kinc_float32x4_mask_t; +typedef __m128 iron_float32x4_t; +typedef __m128 iron_float32x4_mask_t; -#elif defined(KINC_NEON) +#elif defined(IRON_NEON) #include -typedef float32x4_t kinc_float32x4_t; -typedef uint32x4_t kinc_float32x4_mask_t; +typedef float32x4_t iron_float32x4_t; +typedef uint32x4_t iron_float32x4_mask_t; -#elif defined(KINC_NOSIMD) +#elif defined(IRON_NOSIMD) #include -typedef struct kinc_float32x4 { +typedef struct iron_float32x4 { float values[4]; -} kinc_float32x4_t; +} iron_float32x4_t; -typedef kinc_float32x4_t kinc_float32x4_mask_t; +typedef iron_float32x4_t iron_float32x4_mask_t; #endif -#if defined(KINC_SSE) +#if defined(IRON_SSE) -static inline kinc_float32x4_t kinc_float32x4_intrin_load(const float *values) { +static inline iron_float32x4_t iron_float32x4_intrin_load(const float *values) { return _mm_load_ps(values); } -static inline kinc_float32x4_t kinc_float32x4_intrin_load_unaligned(const float *values) { +static inline iron_float32x4_t iron_float32x4_intrin_load_unaligned(const float *values) { return _mm_loadu_ps(values); } -static inline kinc_float32x4_t kinc_float32x4_load(float a, float b, float c, float d) { +static inline iron_float32x4_t iron_float32x4_load(float a, float b, float c, float d) { return _mm_set_ps(d, c, b, a); } -static inline kinc_float32x4_t kinc_float32x4_load_all(float t) { +static inline iron_float32x4_t iron_float32x4_load_all(float t) { return _mm_set_ps1(t); } -static inline void kinc_float32x4_store(float *destination, kinc_float32x4_t value) { +static inline void iron_float32x4_store(float *destination, iron_float32x4_t value) { _mm_store_ps(destination, value); } -static inline void kinc_float32x4_store_unaligned(float *destination, kinc_float32x4_t value) { +static inline void iron_float32x4_store_unaligned(float *destination, iron_float32x4_t value) { _mm_storeu_ps(destination, value); } -static inline float kinc_float32x4_get(kinc_float32x4_t t, int index) { +static inline float iron_float32x4_get(iron_float32x4_t t, int index) { union { __m128 value; float elements[4]; @@ -119,159 +119,159 @@ static inline float kinc_float32x4_get(kinc_float32x4_t t, int index) { return converter.elements[index]; } -static inline kinc_float32x4_t kinc_float32x4_abs(kinc_float32x4_t t) { +static inline iron_float32x4_t iron_float32x4_abs(iron_float32x4_t t) { __m128 mask = _mm_set_ps1(-0.f); return _mm_andnot_ps(mask, t); } -static inline kinc_float32x4_t kinc_float32x4_add(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_add(iron_float32x4_t a, iron_float32x4_t b) { return _mm_add_ps(a, b); } -static inline kinc_float32x4_t kinc_float32x4_div(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_div(iron_float32x4_t a, iron_float32x4_t b) { return _mm_div_ps(a, b); } -static inline kinc_float32x4_t kinc_float32x4_mul(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_mul(iron_float32x4_t a, iron_float32x4_t b) { return _mm_mul_ps(a, b); } -static inline kinc_float32x4_t kinc_float32x4_neg(kinc_float32x4_t t) { +static inline iron_float32x4_t iron_float32x4_neg(iron_float32x4_t t) { __m128 negative = _mm_set_ps1(-1.0f); return _mm_mul_ps(t, negative); } -static inline kinc_float32x4_t kinc_float32x4_reciprocal_approximation(kinc_float32x4_t t) { +static inline iron_float32x4_t iron_float32x4_reciprocal_approximation(iron_float32x4_t t) { return _mm_rcp_ps(t); } -static inline kinc_float32x4_t kinc_float32x4_reciprocal_sqrt_approximation(kinc_float32x4_t t) { +static inline iron_float32x4_t iron_float32x4_reciprocal_sqrt_approximation(iron_float32x4_t t) { return _mm_rsqrt_ps(t); } -static inline kinc_float32x4_t kinc_float32x4_sub(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_sub(iron_float32x4_t a, iron_float32x4_t b) { return _mm_sub_ps(a, b); } -static inline kinc_float32x4_t kinc_float32x4_sqrt(kinc_float32x4_t t) { +static inline iron_float32x4_t iron_float32x4_sqrt(iron_float32x4_t t) { return _mm_sqrt_ps(t); } -static inline kinc_float32x4_t kinc_float32x4_max(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_max(iron_float32x4_t a, iron_float32x4_t b) { return _mm_max_ps(a, b); } -static inline kinc_float32x4_t kinc_float32x4_min(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_min(iron_float32x4_t a, iron_float32x4_t b) { return _mm_min_ps(a, b); } -static inline kinc_float32x4_mask_t kinc_float32x4_cmpeq(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_mask_t iron_float32x4_cmpeq(iron_float32x4_t a, iron_float32x4_t b) { return _mm_cmpeq_ps(a, b); } -static inline kinc_float32x4_mask_t kinc_float32x4_cmpge(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_mask_t iron_float32x4_cmpge(iron_float32x4_t a, iron_float32x4_t b) { return _mm_cmpge_ps(a, b); } -static inline kinc_float32x4_mask_t kinc_float32x4_cmpgt(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_mask_t iron_float32x4_cmpgt(iron_float32x4_t a, iron_float32x4_t b) { return _mm_cmpgt_ps(a, b); } -static inline kinc_float32x4_mask_t kinc_float32x4_cmple(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_mask_t iron_float32x4_cmple(iron_float32x4_t a, iron_float32x4_t b) { return _mm_cmple_ps(a, b); } -static inline kinc_float32x4_mask_t kinc_float32x4_cmplt(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_mask_t iron_float32x4_cmplt(iron_float32x4_t a, iron_float32x4_t b) { return _mm_cmplt_ps(a, b); } -static inline kinc_float32x4_mask_t kinc_float32x4_cmpneq(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_mask_t iron_float32x4_cmpneq(iron_float32x4_t a, iron_float32x4_t b) { return _mm_cmpneq_ps(a, b); } -static inline kinc_float32x4_t kinc_float32x4_sel(kinc_float32x4_t a, kinc_float32x4_t b, kinc_float32x4_mask_t mask) { +static inline iron_float32x4_t iron_float32x4_sel(iron_float32x4_t a, iron_float32x4_t b, iron_float32x4_mask_t mask) { return _mm_xor_ps(b, _mm_and_ps(mask, _mm_xor_ps(a, b))); } -static inline kinc_float32x4_t kinc_float32x4_or(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_or(iron_float32x4_t a, iron_float32x4_t b) { return _mm_or_ps(a, b); } -static inline kinc_float32x4_t kinc_float32x4_and(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_and(iron_float32x4_t a, iron_float32x4_t b) { return _mm_and_ps(a, b); } -static inline kinc_float32x4_t kinc_float32x4_xor(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_xor(iron_float32x4_t a, iron_float32x4_t b) { return _mm_xor_ps(a, b); } -static inline kinc_float32x4_t kinc_float32x4_not(kinc_float32x4_t t) { +static inline iron_float32x4_t iron_float32x4_not(iron_float32x4_t t) { __m128 zeroes = _mm_setzero_ps(); return _mm_xor_ps(t, _mm_cmpeq_ps(zeroes, zeroes)); } -#define kinc_float32x4_shuffle_custom(abcd, efgh, left_1, left_2, right_1, right_2) \ - _mm_shuffle_ps((abcd), (efgh), KINC_SHUFFLE_TABLE((left_1), (left_2), (right_1), (right_2))) +#define iron_float32x4_shuffle_custom(abcd, efgh, left_1, left_2, right_1, right_2) \ + _mm_shuffle_ps((abcd), (efgh), IRON_SHUFFLE_TABLE((left_1), (left_2), (right_1), (right_2))) -static inline kinc_float32x4_t kinc_float32x4_shuffle_aebf(kinc_float32x4_t abcd, kinc_float32x4_t efgh) { +static inline iron_float32x4_t iron_float32x4_shuffle_aebf(iron_float32x4_t abcd, iron_float32x4_t efgh) { // aka unpacklo aka zip1 aka interleave low return _mm_unpacklo_ps(abcd, efgh); } -static inline kinc_float32x4_t kinc_float32x4_shuffle_cgdh(kinc_float32x4_t abcd, kinc_float32x4_t efgh) { +static inline iron_float32x4_t iron_float32x4_shuffle_cgdh(iron_float32x4_t abcd, iron_float32x4_t efgh) { // aka unpackhi aka zip2 aka interleave high return _mm_unpackhi_ps(abcd, efgh); } -static inline kinc_float32x4_t kinc_float32x4_shuffle_abef(kinc_float32x4_t abcd, kinc_float32x4_t efgh) { +static inline iron_float32x4_t iron_float32x4_shuffle_abef(iron_float32x4_t abcd, iron_float32x4_t efgh) { // aka movelh return _mm_movelh_ps(abcd, efgh); } -static inline kinc_float32x4_t kinc_float32x4_shuffle_ghcd(kinc_float32x4_t abcd, kinc_float32x4_t efgh) { +static inline iron_float32x4_t iron_float32x4_shuffle_ghcd(iron_float32x4_t abcd, iron_float32x4_t efgh) { // aka movehl return _mm_movehl_ps(abcd, efgh); } -#elif defined(KINC_NEON) +#elif defined(IRON_NEON) -static inline kinc_float32x4_t kinc_float32x4_intrin_load(const float *values) { +static inline iron_float32x4_t iron_float32x4_intrin_load(const float *values) { return vld1q_f32(values); } -static inline kinc_float32x4_t kinc_float32x4_intrin_load_unaligned(const float *values) { - return kinc_float32x4_intrin_load(values); +static inline iron_float32x4_t iron_float32x4_intrin_load_unaligned(const float *values) { + return iron_float32x4_intrin_load(values); } -static inline kinc_float32x4_t kinc_float32x4_load(float a, float b, float c, float d) { - return (kinc_float32x4_t){a, b, c, d}; +static inline iron_float32x4_t iron_float32x4_load(float a, float b, float c, float d) { + return (iron_float32x4_t){a, b, c, d}; } -static inline kinc_float32x4_t kinc_float32x4_load_all(float t) { - return (kinc_float32x4_t){t, t, t, t}; +static inline iron_float32x4_t iron_float32x4_load_all(float t) { + return (iron_float32x4_t){t, t, t, t}; } -static inline void kinc_float32x4_store(float *destination, kinc_float32x4_t value) { +static inline void iron_float32x4_store(float *destination, iron_float32x4_t value) { vst1q_f32(destination, value); } -static inline void kinc_float32x4_store_unaligned(float *destination, kinc_float32x4_t value) { - kinc_float32x4_store(destination, value); +static inline void iron_float32x4_store_unaligned(float *destination, iron_float32x4_t value) { + iron_float32x4_store(destination, value); } -static inline float kinc_float32x4_get(kinc_float32x4_t t, int index) { +static inline float iron_float32x4_get(iron_float32x4_t t, int index) { return t[index]; } -static inline kinc_float32x4_t kinc_float32x4_abs(kinc_float32x4_t t) { +static inline iron_float32x4_t iron_float32x4_abs(iron_float32x4_t t) { return vabsq_f32(t); } -static inline kinc_float32x4_t kinc_float32x4_add(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_add(iron_float32x4_t a, iron_float32x4_t b) { return vaddq_f32(a, b); } -static inline kinc_float32x4_t kinc_float32x4_div(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_div(iron_float32x4_t a, iron_float32x4_t b) { #if defined(__aarch64__) return vdivq_f32(a, b); #else @@ -282,27 +282,27 @@ static inline kinc_float32x4_t kinc_float32x4_div(kinc_float32x4_t a, kinc_float #endif } -static inline kinc_float32x4_t kinc_float32x4_mul(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_mul(iron_float32x4_t a, iron_float32x4_t b) { return vmulq_f32(a, b); } -static inline kinc_float32x4_t kinc_float32x4_neg(kinc_float32x4_t t) { +static inline iron_float32x4_t iron_float32x4_neg(iron_float32x4_t t) { return vnegq_f32(t); } -static inline kinc_float32x4_t kinc_float32x4_reciprocal_approximation(kinc_float32x4_t t) { +static inline iron_float32x4_t iron_float32x4_reciprocal_approximation(iron_float32x4_t t) { return vrecpeq_f32(t); } -static inline kinc_float32x4_t kinc_float32x4_reciprocal_sqrt_approximation(kinc_float32x4_t t) { +static inline iron_float32x4_t iron_float32x4_reciprocal_sqrt_approximation(iron_float32x4_t t) { return vrsqrteq_f32(t); } -static inline kinc_float32x4_t kinc_float32x4_sub(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_sub(iron_float32x4_t a, iron_float32x4_t b) { return vsubq_f32(a, b); } -static inline kinc_float32x4_t kinc_float32x4_sqrt(kinc_float32x4_t t) { +static inline iron_float32x4_t iron_float32x4_sqrt(iron_float32x4_t t) { #if defined(__aarch64__) return vsqrtq_f32(t); #else @@ -310,76 +310,76 @@ static inline kinc_float32x4_t kinc_float32x4_sqrt(kinc_float32x4_t t) { #endif } -static inline kinc_float32x4_t kinc_float32x4_max(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_max(iron_float32x4_t a, iron_float32x4_t b) { return vmaxq_f32(a, b); } -static inline kinc_float32x4_t kinc_float32x4_min(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_min(iron_float32x4_t a, iron_float32x4_t b) { return vminq_f32(a, b); } -static inline kinc_float32x4_mask_t kinc_float32x4_cmpeq(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_mask_t iron_float32x4_cmpeq(iron_float32x4_t a, iron_float32x4_t b) { return vceqq_f32(a, b); } -static inline kinc_float32x4_mask_t kinc_float32x4_cmpge(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_mask_t iron_float32x4_cmpge(iron_float32x4_t a, iron_float32x4_t b) { return vcgeq_f32(a, b); } -static inline kinc_float32x4_mask_t kinc_float32x4_cmpgt(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_mask_t iron_float32x4_cmpgt(iron_float32x4_t a, iron_float32x4_t b) { return vcgtq_f32(a, b); } -static inline kinc_float32x4_mask_t kinc_float32x4_cmple(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_mask_t iron_float32x4_cmple(iron_float32x4_t a, iron_float32x4_t b) { return vcleq_f32(a, b); } -static inline kinc_float32x4_mask_t kinc_float32x4_cmplt(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_mask_t iron_float32x4_cmplt(iron_float32x4_t a, iron_float32x4_t b) { return vcltq_f32(a, b); } -static inline kinc_float32x4_mask_t kinc_float32x4_cmpneq(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_mask_t iron_float32x4_cmpneq(iron_float32x4_t a, iron_float32x4_t b) { return vmvnq_u32(vceqq_f32(a, b)); } -static inline kinc_float32x4_t kinc_float32x4_sel(kinc_float32x4_t a, kinc_float32x4_t b, kinc_float32x4_mask_t mask) { +static inline iron_float32x4_t iron_float32x4_sel(iron_float32x4_t a, iron_float32x4_t b, iron_float32x4_mask_t mask) { return vbslq_f32(mask, a, b); } -static inline kinc_float32x4_t kinc_float32x4_or(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_or(iron_float32x4_t a, iron_float32x4_t b) { uint32x4_t acvt = vreinterpretq_u32_f32(a); uint32x4_t bcvt = vreinterpretq_u32_f32(b); return vreinterpretq_f32_u32(vorrq_u32(acvt, bcvt)); } -static inline kinc_float32x4_t kinc_float32x4_and(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_and(iron_float32x4_t a, iron_float32x4_t b) { uint32x4_t acvt = vreinterpretq_u32_f32(a); uint32x4_t bcvt = vreinterpretq_u32_f32(b); return vreinterpretq_f32_u32(vandq_u32(acvt, bcvt)); } -static inline kinc_float32x4_t kinc_float32x4_xor(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_xor(iron_float32x4_t a, iron_float32x4_t b) { uint32x4_t acvt = vreinterpretq_u32_f32(a); uint32x4_t bcvt = vreinterpretq_u32_f32(b); return vreinterpretq_f32_u32(veorq_u32(acvt, bcvt)); } -static inline kinc_float32x4_t kinc_float32x4_not(kinc_float32x4_t t) { +static inline iron_float32x4_t iron_float32x4_not(iron_float32x4_t t) { uint32x4_t tcvt = vreinterpretq_u32_f32(t); return vreinterpretq_f32_u32(vmvnq_u32(tcvt)); } -#define kinc_float32x4_shuffle_custom(abcd, efgh, left_1, left_2, right_1, right_2) \ - (kinc_float32x4_t) { \ +#define iron_float32x4_shuffle_custom(abcd, efgh, left_1, left_2, right_1, right_2) \ + (iron_float32x4_t) { \ vgetq_lane_f32((abcd), ((left_1)&0x3)), vgetq_lane_f32((abcd), ((left_2)&0x3)), vgetq_lane_f32((efgh), ((right_1)&0x3)), \ vgetq_lane_f32((efgh), ((right_2)&0x3)) \ } -static inline kinc_float32x4_t kinc_float32x4_shuffle_aebf(kinc_float32x4_t abcd, kinc_float32x4_t efgh) { +static inline iron_float32x4_t iron_float32x4_shuffle_aebf(iron_float32x4_t abcd, iron_float32x4_t efgh) { #if defined(__aarch64__) return vzip1q_f32(abcd, efgh); @@ -391,12 +391,12 @@ static inline kinc_float32x4_t kinc_float32x4_shuffle_aebf(kinc_float32x4_t abcd float e = vgetq_lane_f32(efgh, 0); float f = vgetq_lane_f32(efgh, 1); - return (kinc_float32x4_t){a, e, b, f}; + return (iron_float32x4_t){a, e, b, f}; #endif } -static inline kinc_float32x4_t kinc_float32x4_shuffle_cgdh(kinc_float32x4_t abcd, kinc_float32x4_t efgh) { +static inline iron_float32x4_t iron_float32x4_shuffle_cgdh(iron_float32x4_t abcd, iron_float32x4_t efgh) { #if defined(__aarch64__) return vzip2q_f32(abcd, efgh); @@ -408,19 +408,19 @@ static inline kinc_float32x4_t kinc_float32x4_shuffle_cgdh(kinc_float32x4_t abcd float g = vgetq_lane_f32(efgh, 2); float h = vgetq_lane_f32(efgh, 3); - return (kinc_float32x4_t){c, g, d, h}; + return (iron_float32x4_t){c, g, d, h}; #endif } -static inline kinc_float32x4_t kinc_float32x4_shuffle_abef(kinc_float32x4_t abcd, kinc_float32x4_t efgh) { +static inline iron_float32x4_t iron_float32x4_shuffle_abef(iron_float32x4_t abcd, iron_float32x4_t efgh) { float32x2_t ab = vget_low_f32(abcd); float32x2_t ef = vget_low_f32(efgh); return vcombine_f32(ab, ef); } -static inline kinc_float32x4_t kinc_float32x4_shuffle_ghcd(kinc_float32x4_t abcd, kinc_float32x4_t efgh) { +static inline iron_float32x4_t iron_float32x4_shuffle_ghcd(iron_float32x4_t abcd, iron_float32x4_t efgh) { float32x2_t cd = vget_high_f32(abcd); float32x2_t gh = vget_high_f32(efgh); @@ -431,8 +431,8 @@ static inline kinc_float32x4_t kinc_float32x4_shuffle_ghcd(kinc_float32x4_t abcd #include -static inline kinc_float32x4_t kinc_float32x4_intrin_load(const float *values) { - kinc_float32x4_t value; +static inline iron_float32x4_t iron_float32x4_intrin_load(const float *values) { + iron_float32x4_t value; value.values[0] = values[0]; value.values[1] = values[1]; value.values[2] = values[2]; @@ -440,12 +440,12 @@ static inline kinc_float32x4_t kinc_float32x4_intrin_load(const float *values) { return value; } -static inline kinc_float32x4_t kinc_float32x4_intrin_load_unaligned(const float *values) { - return kinc_float32x4_intrin_load(values); +static inline iron_float32x4_t iron_float32x4_intrin_load_unaligned(const float *values) { + return iron_float32x4_intrin_load(values); } -static inline kinc_float32x4_t kinc_float32x4_load(float a, float b, float c, float d) { - kinc_float32x4_t value; +static inline iron_float32x4_t iron_float32x4_load(float a, float b, float c, float d) { + iron_float32x4_t value; value.values[0] = a; value.values[1] = b; value.values[2] = c; @@ -453,8 +453,8 @@ static inline kinc_float32x4_t kinc_float32x4_load(float a, float b, float c, fl return value; } -static inline kinc_float32x4_t kinc_float32x4_load_all(float t) { - kinc_float32x4_t value; +static inline iron_float32x4_t iron_float32x4_load_all(float t) { + iron_float32x4_t value; value.values[0] = t; value.values[1] = t; value.values[2] = t; @@ -462,32 +462,32 @@ static inline kinc_float32x4_t kinc_float32x4_load_all(float t) { return value; } -static inline void kinc_float32x4_store(float *destination, kinc_float32x4_t value) { +static inline void iron_float32x4_store(float *destination, iron_float32x4_t value) { destination[0] = value.values[0]; destination[1] = value.values[1]; destination[2] = value.values[2]; destination[3] = value.values[3]; } -static inline void kinc_float32x4_store_unaligned(float *destination, kinc_float32x4_t value) { - kinc_float32x4_store(destination, value); +static inline void iron_float32x4_store_unaligned(float *destination, iron_float32x4_t value) { + iron_float32x4_store(destination, value); } -static inline float kinc_float32x4_get(kinc_float32x4_t t, int index) { +static inline float iron_float32x4_get(iron_float32x4_t t, int index) { return t.values[index]; } -static inline kinc_float32x4_t kinc_float32x4_abs(kinc_float32x4_t t) { - kinc_float32x4_t value; - value.values[0] = kinc_abs(t.values[0]); - value.values[1] = kinc_abs(t.values[1]); - value.values[2] = kinc_abs(t.values[2]); - value.values[3] = kinc_abs(t.values[3]); +static inline iron_float32x4_t iron_float32x4_abs(iron_float32x4_t t) { + iron_float32x4_t value; + value.values[0] = iron_abs(t.values[0]); + value.values[1] = iron_abs(t.values[1]); + value.values[2] = iron_abs(t.values[2]); + value.values[3] = iron_abs(t.values[3]); return value; } -static inline kinc_float32x4_t kinc_float32x4_add(kinc_float32x4_t a, kinc_float32x4_t b) { - kinc_float32x4_t value; +static inline iron_float32x4_t iron_float32x4_add(iron_float32x4_t a, iron_float32x4_t b) { + iron_float32x4_t value; value.values[0] = a.values[0] + b.values[0]; value.values[1] = a.values[1] + b.values[1]; value.values[2] = a.values[2] + b.values[2]; @@ -495,8 +495,8 @@ static inline kinc_float32x4_t kinc_float32x4_add(kinc_float32x4_t a, kinc_float return value; } -static inline kinc_float32x4_t kinc_float32x4_div(kinc_float32x4_t a, kinc_float32x4_t b) { - kinc_float32x4_t value; +static inline iron_float32x4_t iron_float32x4_div(iron_float32x4_t a, iron_float32x4_t b) { + iron_float32x4_t value; value.values[0] = a.values[0] / b.values[0]; value.values[1] = a.values[1] / b.values[1]; value.values[2] = a.values[2] / b.values[2]; @@ -504,8 +504,8 @@ static inline kinc_float32x4_t kinc_float32x4_div(kinc_float32x4_t a, kinc_float return value; } -static inline kinc_float32x4_t kinc_float32x4_mul(kinc_float32x4_t a, kinc_float32x4_t b) { - kinc_float32x4_t value; +static inline iron_float32x4_t iron_float32x4_mul(iron_float32x4_t a, iron_float32x4_t b) { + iron_float32x4_t value; value.values[0] = a.values[0] * b.values[0]; value.values[1] = a.values[1] * b.values[1]; value.values[2] = a.values[2] * b.values[2]; @@ -513,8 +513,8 @@ static inline kinc_float32x4_t kinc_float32x4_mul(kinc_float32x4_t a, kinc_float return value; } -static inline kinc_float32x4_t kinc_float32x4_neg(kinc_float32x4_t t) { - kinc_float32x4_t value; +static inline iron_float32x4_t iron_float32x4_neg(iron_float32x4_t t) { + iron_float32x4_t value; value.values[0] = -t.values[0]; value.values[1] = -t.values[1]; value.values[2] = -t.values[2]; @@ -522,8 +522,8 @@ static inline kinc_float32x4_t kinc_float32x4_neg(kinc_float32x4_t t) { return value; } -static inline kinc_float32x4_t kinc_float32x4_reciprocal_approximation(kinc_float32x4_t t) { - kinc_float32x4_t value; +static inline iron_float32x4_t iron_float32x4_reciprocal_approximation(iron_float32x4_t t) { + iron_float32x4_t value; value.values[0] = 1.0f / t.values[0]; value.values[1] = 1.0f / t.values[1]; value.values[2] = 1.0f / t.values[2]; @@ -531,8 +531,8 @@ static inline kinc_float32x4_t kinc_float32x4_reciprocal_approximation(kinc_floa return value; } -static inline kinc_float32x4_t kinc_float32x4_reciprocal_sqrt_approximation(kinc_float32x4_t t) { - kinc_float32x4_t value; +static inline iron_float32x4_t iron_float32x4_reciprocal_sqrt_approximation(iron_float32x4_t t) { + iron_float32x4_t value; value.values[0] = 1.0f / sqrtf(t.values[0]); value.values[1] = 1.0f / sqrtf(t.values[1]); value.values[2] = 1.0f / sqrtf(t.values[2]); @@ -540,8 +540,8 @@ static inline kinc_float32x4_t kinc_float32x4_reciprocal_sqrt_approximation(kinc return value; } -static inline kinc_float32x4_t kinc_float32x4_sub(kinc_float32x4_t a, kinc_float32x4_t b) { - kinc_float32x4_t value; +static inline iron_float32x4_t iron_float32x4_sub(iron_float32x4_t a, iron_float32x4_t b) { + iron_float32x4_t value; value.values[0] = a.values[0] - b.values[0]; value.values[1] = a.values[1] - b.values[1]; value.values[2] = a.values[2] - b.values[2]; @@ -549,8 +549,8 @@ static inline kinc_float32x4_t kinc_float32x4_sub(kinc_float32x4_t a, kinc_float return value; } -static inline kinc_float32x4_t kinc_float32x4_sqrt(kinc_float32x4_t t) { - kinc_float32x4_t value; +static inline iron_float32x4_t iron_float32x4_sqrt(iron_float32x4_t t) { + iron_float32x4_t value; value.values[0] = sqrtf(t.values[0]); value.values[1] = sqrtf(t.values[1]); value.values[2] = sqrtf(t.values[2]); @@ -558,104 +558,104 @@ static inline kinc_float32x4_t kinc_float32x4_sqrt(kinc_float32x4_t t) { return value; } -static inline kinc_float32x4_t kinc_float32x4_max(kinc_float32x4_t a, kinc_float32x4_t b) { - kinc_float32x4_t value; - value.values[0] = kinc_max(a.values[0], b.values[0]); - value.values[1] = kinc_max(a.values[1], b.values[1]); - value.values[2] = kinc_max(a.values[2], b.values[2]); - value.values[3] = kinc_max(a.values[3], b.values[3]); +static inline iron_float32x4_t iron_float32x4_max(iron_float32x4_t a, iron_float32x4_t b) { + iron_float32x4_t value; + value.values[0] = iron_max(a.values[0], b.values[0]); + value.values[1] = iron_max(a.values[1], b.values[1]); + value.values[2] = iron_max(a.values[2], b.values[2]); + value.values[3] = iron_max(a.values[3], b.values[3]); return value; } -static inline kinc_float32x4_t kinc_float32x4_min(kinc_float32x4_t a, kinc_float32x4_t b) { - kinc_float32x4_t value; - value.values[0] = kinc_min(a.values[0], b.values[0]); - value.values[1] = kinc_min(a.values[1], b.values[1]); - value.values[2] = kinc_min(a.values[2], b.values[2]); - value.values[3] = kinc_min(a.values[3], b.values[3]); +static inline iron_float32x4_t iron_float32x4_min(iron_float32x4_t a, iron_float32x4_t b) { + iron_float32x4_t value; + value.values[0] = iron_min(a.values[0], b.values[0]); + value.values[1] = iron_min(a.values[1], b.values[1]); + value.values[2] = iron_min(a.values[2], b.values[2]); + value.values[3] = iron_min(a.values[3], b.values[3]); return value; } -static inline kinc_float32x4_mask_t kinc_float32x4_cmpeq(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_mask_t iron_float32x4_cmpeq(iron_float32x4_t a, iron_float32x4_t b) { uint32_t mask_cvt[4]; mask_cvt[0] = a.values[0] == b.values[0] ? 0xffffffff : 0; mask_cvt[1] = a.values[1] == b.values[1] ? 0xffffffff : 0; mask_cvt[2] = a.values[2] == b.values[2] ? 0xffffffff : 0; mask_cvt[3] = a.values[3] == b.values[3] ? 0xffffffff : 0; - kinc_float32x4_mask_t mask; + iron_float32x4_mask_t mask; memcpy(&mask.values[0], &mask_cvt[0], sizeof(mask_cvt)); return mask; } -static inline kinc_float32x4_mask_t kinc_float32x4_cmpge(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_mask_t iron_float32x4_cmpge(iron_float32x4_t a, iron_float32x4_t b) { uint32_t mask_cvt[4]; mask_cvt[0] = a.values[0] >= b.values[0] ? 0xffffffff : 0; mask_cvt[1] = a.values[1] >= b.values[1] ? 0xffffffff : 0; mask_cvt[2] = a.values[2] >= b.values[2] ? 0xffffffff : 0; mask_cvt[3] = a.values[3] >= b.values[3] ? 0xffffffff : 0; - kinc_float32x4_mask_t mask; + iron_float32x4_mask_t mask; memcpy(&mask.values[0], &mask_cvt[0], sizeof(mask_cvt)); return mask; } -static inline kinc_float32x4_mask_t kinc_float32x4_cmpgt(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_mask_t iron_float32x4_cmpgt(iron_float32x4_t a, iron_float32x4_t b) { uint32_t mask_cvt[4]; mask_cvt[0] = a.values[0] > b.values[0] ? 0xffffffff : 0; mask_cvt[1] = a.values[1] > b.values[1] ? 0xffffffff : 0; mask_cvt[2] = a.values[2] > b.values[2] ? 0xffffffff : 0; mask_cvt[3] = a.values[3] > b.values[3] ? 0xffffffff : 0; - kinc_float32x4_mask_t mask; + iron_float32x4_mask_t mask; memcpy(&mask.values[0], &mask_cvt[0], sizeof(mask_cvt)); return mask; } -static inline kinc_float32x4_mask_t kinc_float32x4_cmple(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_mask_t iron_float32x4_cmple(iron_float32x4_t a, iron_float32x4_t b) { uint32_t mask_cvt[4]; mask_cvt[0] = a.values[0] <= b.values[0] ? 0xffffffff : 0; mask_cvt[1] = a.values[1] <= b.values[1] ? 0xffffffff : 0; mask_cvt[2] = a.values[2] <= b.values[2] ? 0xffffffff : 0; mask_cvt[3] = a.values[3] <= b.values[3] ? 0xffffffff : 0; - kinc_float32x4_mask_t mask; + iron_float32x4_mask_t mask; memcpy(&mask.values[0], &mask_cvt[0], sizeof(mask_cvt)); return mask; } -static inline kinc_float32x4_mask_t kinc_float32x4_cmplt(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_mask_t iron_float32x4_cmplt(iron_float32x4_t a, iron_float32x4_t b) { uint32_t mask_cvt[4]; mask_cvt[0] = a.values[0] < b.values[0] ? 0xffffffff : 0; mask_cvt[1] = a.values[1] < b.values[1] ? 0xffffffff : 0; mask_cvt[2] = a.values[2] < b.values[2] ? 0xffffffff : 0; mask_cvt[3] = a.values[3] < b.values[3] ? 0xffffffff : 0; - kinc_float32x4_mask_t mask; + iron_float32x4_mask_t mask; memcpy(&mask.values[0], &mask_cvt[0], sizeof(mask_cvt)); return mask; } -static inline kinc_float32x4_mask_t kinc_float32x4_cmpneq(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_mask_t iron_float32x4_cmpneq(iron_float32x4_t a, iron_float32x4_t b) { uint32_t mask_cvt[4]; mask_cvt[0] = a.values[0] != b.values[0] ? 0xffffffff : 0; mask_cvt[1] = a.values[1] != b.values[1] ? 0xffffffff : 0; mask_cvt[2] = a.values[2] != b.values[2] ? 0xffffffff : 0; mask_cvt[3] = a.values[3] != b.values[3] ? 0xffffffff : 0; - kinc_float32x4_mask_t mask; + iron_float32x4_mask_t mask; memcpy(&mask.values[0], &mask_cvt[0], sizeof(mask_cvt)); return mask; } -static inline kinc_float32x4_t kinc_float32x4_sel(kinc_float32x4_t a, kinc_float32x4_t b, kinc_float32x4_mask_t mask) { - kinc_float32x4_t value; +static inline iron_float32x4_t iron_float32x4_sel(iron_float32x4_t a, iron_float32x4_t b, iron_float32x4_mask_t mask) { + iron_float32x4_t value; value.values[0] = mask.values[0] != 0.0f ? a.values[0] : b.values[0]; value.values[1] = mask.values[1] != 0.0f ? a.values[1] : b.values[1]; value.values[2] = mask.values[2] != 0.0f ? a.values[2] : b.values[2]; @@ -663,7 +663,7 @@ static inline kinc_float32x4_t kinc_float32x4_sel(kinc_float32x4_t a, kinc_float return value; } -static inline kinc_float32x4_t kinc_float32x4_or(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_or(iron_float32x4_t a, iron_float32x4_t b) { uint32_t acvt[4]; uint32_t bcvt[4]; memcpy(&acvt[0], &a.values[0], sizeof(a)); @@ -674,13 +674,13 @@ static inline kinc_float32x4_t kinc_float32x4_or(kinc_float32x4_t a, kinc_float3 acvt[2] |= bcvt[2]; acvt[3] |= bcvt[3]; - kinc_float32x4_t value; + iron_float32x4_t value; memcpy(&value.values[0], &acvt[0], sizeof(acvt)); return value; } -static inline kinc_float32x4_t kinc_float32x4_and(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_and(iron_float32x4_t a, iron_float32x4_t b) { uint32_t acvt[4]; uint32_t bcvt[4]; memcpy(&acvt[0], &a.values[0], sizeof(a)); @@ -691,13 +691,13 @@ static inline kinc_float32x4_t kinc_float32x4_and(kinc_float32x4_t a, kinc_float acvt[2] &= bcvt[2]; acvt[3] &= bcvt[3]; - kinc_float32x4_t value; + iron_float32x4_t value; memcpy(&value.values[0], &acvt[0], sizeof(acvt)); return value; } -static inline kinc_float32x4_t kinc_float32x4_xor(kinc_float32x4_t a, kinc_float32x4_t b) { +static inline iron_float32x4_t iron_float32x4_xor(iron_float32x4_t a, iron_float32x4_t b) { uint32_t acvt[4]; uint32_t bcvt[4]; memcpy(&acvt[0], &a.values[0], sizeof(a)); @@ -708,13 +708,13 @@ static inline kinc_float32x4_t kinc_float32x4_xor(kinc_float32x4_t a, kinc_float acvt[2] ^= bcvt[2]; acvt[3] ^= bcvt[3]; - kinc_float32x4_t value; + iron_float32x4_t value; memcpy(&value.values[0], &acvt[0], sizeof(acvt)); return value; } -static inline kinc_float32x4_t kinc_float32x4_not(kinc_float32x4_t t) { +static inline iron_float32x4_t iron_float32x4_not(iron_float32x4_t t) { uint32_t tcvt[4]; memcpy(&tcvt[0], &t.values[0], sizeof(t)); @@ -723,15 +723,15 @@ static inline kinc_float32x4_t kinc_float32x4_not(kinc_float32x4_t t) { tcvt[2] = ~tcvt[2]; tcvt[3] = ~tcvt[3]; - kinc_float32x4_t value; + iron_float32x4_t value; memcpy(&value.values[0], &tcvt[0], sizeof(tcvt)); return value; } -static inline kinc_float32x4_t kinc_float32x4_shuffle_custom(kinc_float32x4_t abcd, kinc_float32x4_t efgh, const uint32_t left_1, const uint32_t left_2, +static inline iron_float32x4_t iron_float32x4_shuffle_custom(iron_float32x4_t abcd, iron_float32x4_t efgh, const uint32_t left_1, const uint32_t left_2, const uint32_t right_1, const uint32_t right_2) { - kinc_float32x4_t value; + iron_float32x4_t value; value.values[0] = abcd.values[left_1 & 0x3]; value.values[1] = abcd.values[left_2 & 0x3]; @@ -741,8 +741,8 @@ static inline kinc_float32x4_t kinc_float32x4_shuffle_custom(kinc_float32x4_t ab return value; } -static inline kinc_float32x4_t kinc_float32x4_shuffle_aebf(kinc_float32x4_t abcd, kinc_float32x4_t efgh) { - kinc_float32x4_t value; +static inline iron_float32x4_t iron_float32x4_shuffle_aebf(iron_float32x4_t abcd, iron_float32x4_t efgh) { + iron_float32x4_t value; value.values[0] = abcd.values[0]; value.values[1] = efgh.values[0]; @@ -752,8 +752,8 @@ static inline kinc_float32x4_t kinc_float32x4_shuffle_aebf(kinc_float32x4_t abcd return value; } -static inline kinc_float32x4_t kinc_float32x4_shuffle_cgdh(kinc_float32x4_t abcd, kinc_float32x4_t efgh) { - kinc_float32x4_t value; +static inline iron_float32x4_t iron_float32x4_shuffle_cgdh(iron_float32x4_t abcd, iron_float32x4_t efgh) { + iron_float32x4_t value; value.values[0] = abcd.values[2]; value.values[1] = efgh.values[2]; @@ -763,8 +763,8 @@ static inline kinc_float32x4_t kinc_float32x4_shuffle_cgdh(kinc_float32x4_t abcd return value; } -static inline kinc_float32x4_t kinc_float32x4_shuffle_abef(kinc_float32x4_t abcd, kinc_float32x4_t efgh) { - kinc_float32x4_t value; +static inline iron_float32x4_t iron_float32x4_shuffle_abef(iron_float32x4_t abcd, iron_float32x4_t efgh) { + iron_float32x4_t value; value.values[0] = abcd.values[0]; value.values[1] = abcd.values[1]; @@ -774,8 +774,8 @@ static inline kinc_float32x4_t kinc_float32x4_shuffle_abef(kinc_float32x4_t abcd return value; } -static inline kinc_float32x4_t kinc_float32x4_shuffle_ghcd(kinc_float32x4_t abcd, kinc_float32x4_t efgh) { - kinc_float32x4_t value; +static inline iron_float32x4_t iron_float32x4_shuffle_ghcd(iron_float32x4_t abcd, iron_float32x4_t efgh) { + iron_float32x4_t value; value.values[0] = efgh.values[2]; value.values[1] = efgh.values[3]; diff --git a/base/sources/iron_system.c b/base/sources/iron_system.c index 18fc1f36..3c353a38 100644 --- a/base/sources/iron_system.c +++ b/base/sources/iron_system.c @@ -4,11 +4,11 @@ #include #include #include -#ifdef KINC_WINDOWS +#ifdef IRON_WINDOWS #include #include #endif -#ifdef KINC_ANDROID +#ifdef IRON_ANDROID #include #endif #include @@ -16,78 +16,78 @@ #include typedef enum { - KINC_LOG_LEVEL_INFO, - KINC_LOG_LEVEL_ERROR -} kinc_log_level_t; + IRON_LOG_LEVEL_INFO, + IRON_LOG_LEVEL_ERROR +} iron_log_level_t; -void kinc_log_args(kinc_log_level_t level, const char *format, va_list args) { -#ifdef KINC_ANDROID +void iron_log_args(iron_log_level_t level, const char *format, va_list args) { +#ifdef IRON_ANDROID va_list args_android_copy; va_copy(args_android_copy, args); switch (level) { - case KINC_LOG_LEVEL_INFO: - __android_log_vprint(ANDROID_LOG_INFO, "Kinc", format, args_android_copy); + case IRON_LOG_LEVEL_INFO: + __android_log_vprint(ANDROID_LOG_INFO, "Iron", format, args_android_copy); break; - case KINC_LOG_LEVEL_ERROR: - __android_log_vprint(ANDROID_LOG_ERROR, "Kinc", format, args_android_copy); + case IRON_LOG_LEVEL_ERROR: + __android_log_vprint(ANDROID_LOG_ERROR, "Iron", format, args_android_copy); break; } va_end(args_android_copy); #endif -#ifdef KINC_WINDOWS +#ifdef IRON_WINDOWS wchar_t buffer[4096]; - kinc_microsoft_format(format, args, buffer); + iron_microsoft_format(format, args, buffer); wcscat(buffer, L"\r\n"); OutputDebugStringW(buffer); DWORD written; - WriteConsoleW(GetStdHandle(level == KINC_LOG_LEVEL_INFO ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE), buffer, (DWORD)wcslen(buffer), &written, NULL); + WriteConsoleW(GetStdHandle(level == IRON_LOG_LEVEL_INFO ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE), buffer, (DWORD)wcslen(buffer), &written, NULL); #else char buffer[4096]; vsnprintf(buffer, 4090, format, args); strcat(buffer, "\n"); - fprintf(level == KINC_LOG_LEVEL_INFO ? stdout : stderr, "%s", buffer); + fprintf(level == IRON_LOG_LEVEL_INFO ? stdout : stderr, "%s", buffer); #endif } -void kinc_log(const char *format, ...) { +void iron_log(const char *format, ...) { va_list args; va_start(args, format); - kinc_log_args(KINC_LOG_LEVEL_INFO, format == NULL ? "null" : format, args); + iron_log_args(IRON_LOG_LEVEL_INFO, format == NULL ? "null" : format, args); va_end(args); } -void kinc_error(const char *format, ...) { +void iron_error(const char *format, ...) { { va_list args; va_start(args, format); - kinc_log_args(KINC_LOG_LEVEL_ERROR, format, args); + iron_log_args(IRON_LOG_LEVEL_ERROR, format, args); va_end(args); } -#ifdef KINC_WINDOWS +#ifdef IRON_WINDOWS { va_list args; va_start(args, format); wchar_t buffer[4096]; - kinc_microsoft_format(format, args, buffer); + iron_microsoft_format(format, args, buffer); MessageBoxW(NULL, buffer, L"Error", 0); va_end(args); } #endif } -void kinc_window_options_set_defaults(kinc_window_options_t *win) { - kinc_display_init(); +void iron_window_options_set_defaults(iron_window_options_t *win) { + iron_display_init(); win->title = NULL; - win->display_index = kinc_primary_display(); - win->mode = KINC_WINDOW_MODE_WINDOW; + win->display_index = iron_primary_display(); + win->mode = IRON_WINDOW_MODE_WINDOW; win->x = -1; win->y = -1; win->width = 800; win->height = 600; win->visible = true; - win->features = KINC_WINDOW_FEATURE_RESIZEABLE | KINC_WINDOW_FEATURE_MINIMIZABLE | KINC_WINDOW_FEATURE_MAXIMIZABLE; + win->features = IRON_WINDOW_FEATURE_RESIZEABLE | IRON_WINDOW_FEATURE_MINIMIZABLE | IRON_WINDOW_FEATURE_MAXIMIZABLE; win->frequency = 60; win->vsync = true; @@ -95,9 +95,9 @@ void kinc_window_options_set_defaults(kinc_window_options_t *win) { win->depth_bits = 16; } -#if !defined(KINC_WASM) && !defined(KINC_ANDROID) && !defined(KINC_WINDOWS) -double kinc_time(void) { - return kinc_timestamp() / kinc_frequency(); +#if !defined(IRON_WASM) && !defined(IRON_ANDROID) && !defined(IRON_WINDOWS) +double iron_time(void) { + return iron_timestamp() / iron_frequency(); } #endif @@ -122,213 +122,214 @@ static void *copy_callback_data = NULL; static void (*paste_callback)(char *, void *) = NULL; static void *paste_callback_data = NULL; -#if defined(KINC_IOS) || defined(KINC_MACOS) +#if defined(IRON_IOS) || defined(IRON_MACOS) bool withAutoreleasepool(bool (*f)(void)); #endif -void kinc_set_update_callback(void (*callback)(void *), void *data) { +void iron_set_update_callback(void (*callback)(void *), void *data) { update_callback = callback; update_callback_data = data; } -void kinc_set_foreground_callback(void (*callback)(void *), void *data) { +void iron_set_foreground_callback(void (*callback)(void *), void *data) { foreground_callback = callback; foreground_callback_data = data; } -void kinc_set_resume_callback(void (*callback)(void *), void *data) { +void iron_set_resume_callback(void (*callback)(void *), void *data) { resume_callback = callback; resume_callback_data = data; } -void kinc_set_pause_callback(void (*callback)(void *), void *data) { +void iron_set_pause_callback(void (*callback)(void *), void *data) { pause_callback = callback; pause_callback_data = data; } -void kinc_set_background_callback(void (*callback)(void *), void *data) { +void iron_set_background_callback(void (*callback)(void *), void *data) { background_callback = callback; background_callback_data = data; } -void kinc_set_shutdown_callback(void (*callback)(void *), void *data) { +void iron_set_shutdown_callback(void (*callback)(void *), void *data) { shutdown_callback = callback; shutdown_callback_data = data; } -void kinc_set_drop_files_callback(void (*callback)(wchar_t *, void *), void *data) { +void iron_set_drop_files_callback(void (*callback)(wchar_t *, void *), void *data) { drop_files_callback = callback; drop_files_callback_data = data; } -void kinc_set_cut_callback(char *(*callback)(void *), void *data) { +void iron_set_cut_callback(char *(*callback)(void *), void *data) { cut_callback = callback; cut_callback_data = data; } -void kinc_set_copy_callback(char *(*callback)(void *), void *data) { +void iron_set_copy_callback(char *(*callback)(void *), void *data) { copy_callback = callback; copy_callback_data = data; } -void kinc_set_paste_callback(void (*callback)(char *, void *), void *data) { +void iron_set_paste_callback(void (*callback)(char *, void *), void *data) { paste_callback = callback; paste_callback_data = data; } -void kinc_internal_update_callback(void) { +void iron_internal_update_callback(void) { if (update_callback != NULL) { update_callback(update_callback_data); } } -void kinc_internal_foreground_callback(void) { +void iron_internal_foreground_callback(void) { if (foreground_callback != NULL) { foreground_callback(foreground_callback_data); } } -void kinc_internal_resume_callback(void) { +void iron_internal_resume_callback(void) { if (resume_callback != NULL) { resume_callback(resume_callback_data); } } -void kinc_internal_pause_callback(void) { +void iron_internal_pause_callback(void) { if (pause_callback != NULL) { pause_callback(pause_callback_data); } } -void kinc_internal_background_callback(void) { +void iron_internal_background_callback(void) { if (background_callback != NULL) { background_callback(background_callback_data); } } -void kinc_internal_shutdown_callback(void) { +void iron_internal_shutdown_callback(void) { if (shutdown_callback != NULL) { shutdown_callback(shutdown_callback_data); } } -void kinc_internal_drop_files_callback(wchar_t *filePath) { +void iron_internal_drop_files_callback(wchar_t *filePath) { if (drop_files_callback != NULL) { drop_files_callback(filePath, drop_files_callback_data); } } -char *kinc_internal_cut_callback(void) { +char *iron_internal_cut_callback(void) { if (cut_callback != NULL) { return cut_callback(cut_callback_data); } return NULL; } -char *kinc_internal_copy_callback(void) { +char *iron_internal_copy_callback(void) { if (copy_callback != NULL) { return copy_callback(copy_callback_data); } return NULL; } -void kinc_internal_paste_callback(char *value) { +void iron_internal_paste_callback(char *value) { if (paste_callback != NULL) { paste_callback(value, paste_callback_data); } } static bool running = false; -static char application_name[1024] = {"Kinc Application"}; +static char application_name[1024] = {"Iron Application"}; -const char *kinc_application_name(void) { +const char *iron_application_name(void) { return application_name; } -void kinc_set_app_name(const char *name) { +void iron_set_app_name(const char *name) { strcpy(application_name, name); } -void kinc_stop(void) { +void iron_stop(void) { running = false; } -bool kinc_internal_frame(void) { - kinc_internal_update_callback(); - kinc_internal_handle_messages(); +bool iron_internal_frame(void) { + iron_internal_update_callback(); + iron_internal_handle_messages(); return running; } +// void iron_start(void) { void kinc_start(void) { running = true; -#if !defined(KINC_WASM) +#if !defined(IRON_WASM) -#if defined(KINC_IOS) || defined(KINC_MACOS) - while (withAutoreleasepool(kinc_internal_frame)) { +#if defined(IRON_IOS) || defined(IRON_MACOS) + while (withAutoreleasepool(iron_internal_frame)) { } #else - while (kinc_internal_frame()) { + while (iron_internal_frame()) { } #endif - kinc_internal_shutdown(); + iron_internal_shutdown(); #endif } -int kinc_width(void) { - return kinc_window_width(); +int iron_width(void) { + return iron_window_width(); } -int kinc_height(void) { - return kinc_window_height(); +int iron_height(void) { + return iron_window_height(); } -void kinc_memory_emergency(void) {} +void iron_memory_emergency(void) {} static uint8_t *current_file = NULL; static size_t current_file_size = 0; -bool kinc_save_file_loaded(void) { +bool iron_save_file_loaded(void) { return true; } -uint8_t *kinc_get_save_file(void) { +uint8_t *iron_get_save_file(void) { return current_file; } -size_t kinc_get_save_file_size(void) { +size_t iron_get_save_file_size(void) { return current_file_size; } -void kinc_load_save_file(const char *filename) { +void iron_load_save_file(const char *filename) { free(current_file); current_file = NULL; current_file_size = 0; - kinc_file_reader_t reader; - if (kinc_file_reader_open(&reader, filename, KINC_FILE_TYPE_SAVE)) { - current_file_size = kinc_file_reader_size(&reader); + iron_file_reader_t reader; + if (iron_file_reader_open(&reader, filename, IRON_FILE_TYPE_SAVE)) { + current_file_size = iron_file_reader_size(&reader); current_file = (uint8_t *)malloc(current_file_size); - kinc_file_reader_read(&reader, current_file, current_file_size); - kinc_file_reader_close(&reader); + iron_file_reader_read(&reader, current_file, current_file_size); + iron_file_reader_close(&reader); } } -void kinc_save_save_file(const char *filename, uint8_t *data, size_t size) { - kinc_file_writer_t writer; - if (kinc_file_writer_open(&writer, filename)) { - kinc_file_writer_write(&writer, data, (int)size); - kinc_file_writer_close(&writer); +void iron_save_save_file(const char *filename, uint8_t *data, size_t size) { + iron_file_writer_t writer; + if (iron_file_writer_open(&writer, filename)) { + iron_file_writer_write(&writer, data, (int)size); + iron_file_writer_close(&writer); } } -bool kinc_save_is_saving(void) { +bool iron_save_is_saving(void) { return false; } -#if !defined(KINC_WINDOWS) && !defined(KINC_LINUX) && !defined(KINC_MACOS) -void kinc_copy_to_clipboard(const char *text) { - kinc_log("Oh no, kinc_copy_to_clipboard is not implemented for this system."); +#if !defined(IRON_WINDOWS) && !defined(IRON_LINUX) && !defined(IRON_MACOS) +void iron_copy_to_clipboard(const char *text) { + iron_log("Oh no, iron_copy_to_clipboard is not implemented for this system."); } #endif @@ -339,34 +340,34 @@ static void *keyboard_key_up_callback_data = NULL; static void (*keyboard_key_press_callback)(unsigned /*character*/, void * /*data*/) = NULL; static void *keyboard_key_press_callback_data = NULL; -void kinc_keyboard_set_key_down_callback(void (*value)(int /*key_code*/, void * /*data*/), void *data) { +void iron_keyboard_set_key_down_callback(void (*value)(int /*key_code*/, void * /*data*/), void *data) { keyboard_key_down_callback = value; keyboard_key_down_callback_data = data; } -void kinc_keyboard_set_key_up_callback(void (*value)(int /*key_code*/, void * /*data*/), void *data) { +void iron_keyboard_set_key_up_callback(void (*value)(int /*key_code*/, void * /*data*/), void *data) { keyboard_key_up_callback = value; keyboard_key_up_callback_data = data; } -void kinc_keyboard_set_key_press_callback(void (*value)(unsigned /*character*/, void * /*data*/), void *data) { +void iron_keyboard_set_key_press_callback(void (*value)(unsigned /*character*/, void * /*data*/), void *data) { keyboard_key_press_callback = value; keyboard_key_press_callback_data = data; } -void kinc_internal_keyboard_trigger_key_down(int key_code) { +void iron_internal_keyboard_trigger_key_down(int key_code) { if (keyboard_key_down_callback != NULL) { keyboard_key_down_callback(key_code, keyboard_key_down_callback_data); } } -void kinc_internal_keyboard_trigger_key_up(int key_code) { +void iron_internal_keyboard_trigger_key_up(int key_code) { if (keyboard_key_up_callback != NULL) { keyboard_key_up_callback(key_code, keyboard_key_up_callback_data); } } -void kinc_internal_keyboard_trigger_key_press(unsigned character) { +void iron_internal_keyboard_trigger_key_press(unsigned character) { if (keyboard_key_press_callback != NULL) { keyboard_key_press_callback(character, keyboard_key_press_callback_data); } @@ -381,46 +382,46 @@ static void *mouse_move_callback_data = NULL; static void (*mouse_scroll_callback)(int /*delta*/, void * /*data*/) = NULL; static void *mouse_scroll_callback_data = NULL; -void kinc_mouse_set_press_callback(void (*value)(int /*button*/, int /*x*/, int /*y*/, void * /*data*/), void *data) { +void iron_mouse_set_press_callback(void (*value)(int /*button*/, int /*x*/, int /*y*/, void * /*data*/), void *data) { mouse_press_callback = value; mouse_press_callback_data = data; } -void kinc_mouse_set_release_callback(void (*value)(int /*button*/, int /*x*/, int /*y*/, void * /*data*/), void *data) { +void iron_mouse_set_release_callback(void (*value)(int /*button*/, int /*x*/, int /*y*/, void * /*data*/), void *data) { mouse_release_callback = value; mouse_release_callback_data = data; } -void kinc_mouse_set_move_callback(void (*value)(int /*x*/, int /*y*/, int /*movement_x*/, int /*movement_y*/, void * /*data*/), void *data) { +void iron_mouse_set_move_callback(void (*value)(int /*x*/, int /*y*/, int /*movement_x*/, int /*movement_y*/, void * /*data*/), void *data) { mouse_move_callback = value; mouse_move_callback_data = data; } -void kinc_mouse_set_scroll_callback(void (*value)(int /*delta*/, void * /*data*/), void *data) { +void iron_mouse_set_scroll_callback(void (*value)(int /*delta*/, void * /*data*/), void *data) { mouse_scroll_callback = value; mouse_scroll_callback_data = data; } -void kinc_internal_mouse_trigger_release(int button, int x, int y) { +void iron_internal_mouse_trigger_release(int button, int x, int y) { if (mouse_release_callback != NULL) { mouse_release_callback(button, x, y, mouse_release_callback_data); } } -void kinc_internal_mouse_trigger_scroll(int delta) { +void iron_internal_mouse_trigger_scroll(int delta) { if (mouse_scroll_callback != NULL) { mouse_scroll_callback(delta, mouse_scroll_callback_data); } } -void kinc_internal_mouse_window_activated() { - if (kinc_mouse_is_locked()) { - kinc_internal_mouse_lock(); +void iron_internal_mouse_window_activated() { + if (iron_mouse_is_locked()) { + iron_internal_mouse_lock(); } } -void kinc_internal_mouse_window_deactivated() { - if (kinc_mouse_is_locked()) { - kinc_internal_mouse_unlock(); +void iron_internal_mouse_window_deactivated() { + if (iron_mouse_is_locked()) { + iron_internal_mouse_unlock(); } } @@ -434,7 +435,7 @@ static int centerY = 0; static int lastX = 0; static int lastY = 0; -void kinc_internal_mouse_trigger_press(int button, int x, int y) { +void iron_internal_mouse_trigger_press(int button, int x, int y) { lastX = x; lastY = y; if (mouse_press_callback != NULL) { @@ -442,14 +443,14 @@ void kinc_internal_mouse_trigger_press(int button, int x, int y) { } } -void kinc_internal_mouse_trigger_move(int x, int y) { +void iron_internal_mouse_trigger_move(int x, int y) { int movementX = 0; int movementY = 0; - if (kinc_mouse_is_locked()) { + if (iron_mouse_is_locked()) { movementX = x - centerX; movementY = y - centerY; if (movementX != 0 || movementY != 0) { - kinc_mouse_set_position(centerX, centerY); + iron_mouse_set_position(centerX, centerY); x = centerX; y = centerY; } @@ -467,36 +468,36 @@ void kinc_internal_mouse_trigger_move(int x, int y) { } } -bool kinc_mouse_is_locked(void) { +bool iron_mouse_is_locked(void) { return locked; } -void kinc_mouse_lock() { - if (kinc_mouse_is_locked()) { +void iron_mouse_lock() { + if (iron_mouse_is_locked()) { return; } - if (!kinc_mouse_can_lock()) { + if (!iron_mouse_can_lock()) { return; } locked = true; - kinc_internal_mouse_lock(); - kinc_mouse_get_position(&preLockX, &preLockY); - centerX = kinc_window_width() / 2; - centerY = kinc_window_height() / 2; - kinc_mouse_set_position(centerX, centerY); + iron_internal_mouse_lock(); + iron_mouse_get_position(&preLockX, &preLockY); + centerX = iron_window_width() / 2; + centerY = iron_window_height() / 2; + iron_mouse_set_position(centerX, centerY); } -void kinc_mouse_unlock(void) { - if (!kinc_mouse_is_locked()) { +void iron_mouse_unlock(void) { + if (!iron_mouse_is_locked()) { return; } - if (!kinc_mouse_can_lock()) { + if (!iron_mouse_can_lock()) { return; } moved = false; locked = false; - kinc_internal_mouse_unlock(); - kinc_mouse_set_position(preLockX, preLockY); + iron_internal_mouse_unlock(); + iron_mouse_set_position(preLockX, preLockY); } static void (*pen_press_callback)(int /*x*/, int /*y*/, float /*pressure*/) = NULL; @@ -507,61 +508,61 @@ static void (*eraser_press_callback)(int /*x*/, int /*y*/, float /*pressure*/) = static void (*eraser_move_callback)(int /*x*/, int /*y*/, float /*pressure*/) = NULL; static void (*eraser_release_callback)(int /*x*/, int /*y*/, float /*pressure*/) = NULL; -void kinc_pen_set_press_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)) { +void iron_pen_set_press_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)) { pen_press_callback = value; } -void kinc_pen_set_move_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)) { +void iron_pen_set_move_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)) { pen_move_callback = value; } -void kinc_pen_set_release_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)) { +void iron_pen_set_release_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)) { pen_release_callback = value; } -void kinc_eraser_set_press_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)) { +void iron_eraser_set_press_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)) { eraser_press_callback = value; } -void kinc_eraser_set_move_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)) { +void iron_eraser_set_move_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)) { eraser_move_callback = value; } -void kinc_eraser_set_release_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)) { +void iron_eraser_set_release_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)) { eraser_release_callback = value; } -void kinc_internal_pen_trigger_press(int x, int y, float pressure) { +void iron_internal_pen_trigger_press(int x, int y, float pressure) { if (pen_press_callback != NULL) { pen_press_callback(x, y, pressure); } } -void kinc_internal_pen_trigger_move(int x, int y, float pressure) { +void iron_internal_pen_trigger_move(int x, int y, float pressure) { if (pen_move_callback != NULL) { pen_move_callback(x, y, pressure); } } -void kinc_internal_pen_trigger_release(int x, int y, float pressure) { +void iron_internal_pen_trigger_release(int x, int y, float pressure) { if (pen_release_callback != NULL) { pen_release_callback(x, y, pressure); } } -void kinc_internal_eraser_trigger_press(int x, int y, float pressure) { +void iron_internal_eraser_trigger_press(int x, int y, float pressure) { if (eraser_press_callback != NULL) { eraser_press_callback(x, y, pressure); } } -void kinc_internal_eraser_trigger_move(int x, int y, float pressure) { +void iron_internal_eraser_trigger_move(int x, int y, float pressure) { if (eraser_move_callback != NULL) { eraser_move_callback(x, y, pressure); } } -void kinc_internal_eraser_trigger_release(int x, int y, float pressure) { +void iron_internal_eraser_trigger_release(int x, int y, float pressure) { if (eraser_release_callback != NULL) { eraser_release_callback(x, y, pressure); } @@ -571,31 +572,31 @@ static void (*surface_touch_start_callback)(int /*index*/, int /*x*/, int /*y*/) static void (*surface_move_callback)(int /*index*/, int /*x*/, int /*y*/) = NULL; static void (*surface_touch_end_callback)(int /*index*/, int /*x*/, int /*y*/) = NULL; -void kinc_surface_set_touch_start_callback(void (*value)(int /*index*/, int /*x*/, int /*y*/)) { +void iron_surface_set_touch_start_callback(void (*value)(int /*index*/, int /*x*/, int /*y*/)) { surface_touch_start_callback = value; } -void kinc_surface_set_move_callback(void (*value)(int /*index*/, int /*x*/, int /*y*/)) { +void iron_surface_set_move_callback(void (*value)(int /*index*/, int /*x*/, int /*y*/)) { surface_move_callback = value; } -void kinc_surface_set_touch_end_callback(void (*value)(int /*index*/, int /*x*/, int /*y*/)) { +void iron_surface_set_touch_end_callback(void (*value)(int /*index*/, int /*x*/, int /*y*/)) { surface_touch_end_callback = value; } -void kinc_internal_surface_trigger_touch_start(int index, int x, int y) { +void iron_internal_surface_trigger_touch_start(int index, int x, int y) { if (surface_touch_start_callback != NULL) { surface_touch_start_callback(index, x, y); } } -void kinc_internal_surface_trigger_move(int index, int x, int y) { +void iron_internal_surface_trigger_move(int index, int x, int y) { if (surface_move_callback != NULL) { surface_move_callback(index, x, y); } } -void kinc_internal_surface_trigger_touch_end(int index, int x, int y) { +void iron_internal_surface_trigger_touch_end(int index, int x, int y) { if (surface_touch_end_callback != NULL) { surface_touch_end_callback(index, x, y); } @@ -610,45 +611,45 @@ static void *gamepad_axis_callback_userdata = NULL; static void (*gamepad_button_callback)(int /*gamepad*/, int /*button*/, float /*value*/, void * /*userdata*/) = NULL; static void *gamepad_button_callback_userdata = NULL; -void kinc_gamepad_set_connect_callback(void (*value)(int /*gamepad*/, void * /*userdata*/), void *userdata) { +void iron_gamepad_set_connect_callback(void (*value)(int /*gamepad*/, void * /*userdata*/), void *userdata) { gamepad_connect_callback = value; gamepad_connect_callback_userdata = userdata; } -void kinc_gamepad_set_disconnect_callback(void (*value)(int /*gamepad*/, void * /*userdata*/), void *userdata) { +void iron_gamepad_set_disconnect_callback(void (*value)(int /*gamepad*/, void * /*userdata*/), void *userdata) { gamepad_disconnect_callback = value; gamepad_disconnect_callback_userdata = userdata; } -void kinc_gamepad_set_axis_callback(void (*value)(int /*gamepad*/, int /*axis*/, float /*value*/, void * /*userdata*/), void *userdata) { +void iron_gamepad_set_axis_callback(void (*value)(int /*gamepad*/, int /*axis*/, float /*value*/, void * /*userdata*/), void *userdata) { gamepad_axis_callback = value; gamepad_axis_callback_userdata = userdata; } -void kinc_gamepad_set_button_callback(void (*value)(int /*gamepad*/, int /*button*/, float /*value*/, void * /*userdata*/), void *userdata) { +void iron_gamepad_set_button_callback(void (*value)(int /*gamepad*/, int /*button*/, float /*value*/, void * /*userdata*/), void *userdata) { gamepad_button_callback = value; gamepad_button_callback_userdata = userdata; } -void kinc_internal_gamepad_trigger_connect(int gamepad) { +void iron_internal_gamepad_trigger_connect(int gamepad) { if (gamepad_connect_callback != NULL) { gamepad_connect_callback(gamepad, gamepad_connect_callback_userdata); } } -void kinc_internal_gamepad_trigger_disconnect(int gamepad) { +void iron_internal_gamepad_trigger_disconnect(int gamepad) { if (gamepad_disconnect_callback != NULL) { gamepad_disconnect_callback(gamepad, gamepad_disconnect_callback_userdata); } } -void kinc_internal_gamepad_trigger_axis(int gamepad, int axis, float value) { +void iron_internal_gamepad_trigger_axis(int gamepad, int axis, float value) { if (gamepad_axis_callback != NULL) { gamepad_axis_callback(gamepad, axis, value, gamepad_axis_callback_userdata); } } -void kinc_internal_gamepad_trigger_button(int gamepad, int button, float value) { +void iron_internal_gamepad_trigger_button(int gamepad, int button, float value) { if (gamepad_button_callback != NULL) { gamepad_button_callback(gamepad, button, value, gamepad_button_callback_userdata); } diff --git a/base/sources/iron_system.h b/base/sources/iron_system.h index 87bb0b6e..2b4444ea 100644 --- a/base/sources/iron_system.h +++ b/base/sources/iron_system.h @@ -6,10 +6,10 @@ #include #include -void kinc_log(const char *format, ...); -void kinc_error(const char *format, ...); +void iron_log(const char *format, ...); +void iron_error(const char *format, ...); -typedef struct kinc_display_mode { +typedef struct iron_display_mode { int x; int y; int width; @@ -17,36 +17,36 @@ typedef struct kinc_display_mode { int pixels_per_inch; int frequency; int bits_per_pixel; -} kinc_display_mode_t; +} iron_display_mode_t; -void kinc_display_init(void); -int kinc_primary_display(void); -int kinc_count_displays(void); -bool kinc_display_available(int display_index); -const char *kinc_display_name(int display_index); -kinc_display_mode_t kinc_display_current_mode(int display_index); -int kinc_display_count_available_modes(int display_index); -kinc_display_mode_t kinc_display_available_mode(int display_index, int mode_index); +void iron_display_init(void); +int iron_primary_display(void); +int iron_count_displays(void); +bool iron_display_available(int display_index); +const char *iron_display_name(int display_index); +iron_display_mode_t iron_display_current_mode(int display_index); +int iron_display_count_available_modes(int display_index); +iron_display_mode_t iron_display_available_mode(int display_index, int mode_index); typedef enum { - KINC_WINDOW_MODE_WINDOW, - KINC_WINDOW_MODE_FULLSCREEN -} kinc_window_mode_t; + IRON_WINDOW_MODE_WINDOW, + IRON_WINDOW_MODE_FULLSCREEN +} iron_window_mode_t; -#define KINC_WINDOW_FEATURE_RESIZEABLE 1 -#define KINC_WINDOW_FEATURE_MINIMIZABLE 2 -#define KINC_WINDOW_FEATURE_MAXIMIZABLE 4 -#define KINC_WINDOW_FEATURE_BORDERLESS 8 -#define KINC_WINDOW_FEATURE_ON_TOP 16 +#define IRON_WINDOW_FEATURE_RESIZEABLE 1 +#define IRON_WINDOW_FEATURE_MINIMIZABLE 2 +#define IRON_WINDOW_FEATURE_MAXIMIZABLE 4 +#define IRON_WINDOW_FEATURE_BORDERLESS 8 +#define IRON_WINDOW_FEATURE_ON_TOP 16 -typedef struct kinc_window_options { +typedef struct iron_window_options { const char *title; int x; int y; int width; int height; int features; - kinc_window_mode_t mode; + iron_window_mode_t mode; int frequency; bool vsync; @@ -57,345 +57,346 @@ typedef struct kinc_window_options { int color_bits; int depth_bits; -} kinc_window_options_t; +} iron_window_options_t; -void kinc_window_create(kinc_window_options_t *win); -void kinc_window_destroy(); -void kinc_window_options_set_defaults(kinc_window_options_t *win); -void kinc_window_resize(int width, int height); -void kinc_window_move(int x, int y); -void kinc_window_change_mode(kinc_window_mode_t mode); -void kinc_window_change_features(int features); -int kinc_window_x(); -int kinc_window_y(); -int kinc_window_width(); -int kinc_window_height(); -int kinc_window_display(); -kinc_window_mode_t kinc_window_get_mode(); -void kinc_window_show(); -void kinc_window_hide(); -void kinc_window_set_title(const char *title); -void kinc_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data); -void kinc_window_set_close_callback(bool (*callback)(void *data), void *data); +void iron_window_create(iron_window_options_t *win); +void iron_window_destroy(); +void iron_window_options_set_defaults(iron_window_options_t *win); +void iron_window_resize(int width, int height); +void iron_window_move(int x, int y); +void iron_window_change_mode(iron_window_mode_t mode); +void iron_window_change_features(int features); +int iron_window_x(); +int iron_window_y(); +int iron_window_width(); +int iron_window_height(); +int iron_window_display(); +iron_window_mode_t iron_window_get_mode(); +void iron_window_show(); +void iron_window_hide(); +void iron_window_set_title(const char *title); +void iron_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data); +void iron_window_set_close_callback(bool (*callback)(void *data), void *data); -void kinc_internal_call_resize_callback(int width, int height); -bool kinc_internal_call_close_callback(); +void iron_internal_call_resize_callback(int width, int height); +bool iron_internal_call_close_callback(); -struct kinc_window_options; +struct iron_window_options; -void kinc_init(const char *name, int width, int height, struct kinc_window_options *win); -const char *kinc_application_name(void); -void kinc_set_app_name(const char *name); -int kinc_width(void); -int kinc_height(void); -void kinc_load_url(const char *url); -const char *kinc_system_id(void); -const char *kinc_language(void); +void iron_init(const char *name, int width, int height, struct iron_window_options *win); +const char *iron_application_name(void); +void iron_set_app_name(const char *name); +int iron_width(void); +int iron_height(void); +void iron_load_url(const char *url); +const char *iron_system_id(void); +const char *iron_language(void); -typedef uint64_t kinc_ticks_t; +typedef uint64_t iron_ticks_t; -double kinc_frequency(void); -kinc_ticks_t kinc_timestamp(void); -int kinc_cpu_cores(void); -int kinc_hardware_threads(void); -double kinc_time(void); +double iron_frequency(void); +iron_ticks_t iron_timestamp(void); +int iron_cpu_cores(void); +int iron_hardware_threads(void); +double iron_time(void); +// void iron_start(void); void kinc_start(void); -void kinc_stop(void); -void kinc_set_keep_screen_on(bool on); +void iron_stop(void); +void iron_set_keep_screen_on(bool on); -void kinc_copy_to_clipboard(const char *text); -void kinc_set_update_callback(void (*callback)(void *), void *data); -void kinc_set_foreground_callback(void (*callback)(void *), void *data); -void kinc_set_resume_callback(void (*callback)(void *), void *data); -void kinc_set_pause_callback(void (*callback)(void *), void *data); -void kinc_set_background_callback(void (*callback)(void *), void *data); -void kinc_set_shutdown_callback(void (*callback)(void *), void *data); -void kinc_set_drop_files_callback(void (*callback)(wchar_t *, void *), void *data); -void kinc_set_cut_callback(char *(*callback)(void *), void *data); -void kinc_set_copy_callback(char *(*callback)(void *), void *data); -void kinc_set_paste_callback(void (*callback)(char *, void *), void *data); +void iron_copy_to_clipboard(const char *text); +void iron_set_update_callback(void (*callback)(void *), void *data); +void iron_set_foreground_callback(void (*callback)(void *), void *data); +void iron_set_resume_callback(void (*callback)(void *), void *data); +void iron_set_pause_callback(void (*callback)(void *), void *data); +void iron_set_background_callback(void (*callback)(void *), void *data); +void iron_set_shutdown_callback(void (*callback)(void *), void *data); +void iron_set_drop_files_callback(void (*callback)(wchar_t *, void *), void *data); +void iron_set_cut_callback(char *(*callback)(void *), void *data); +void iron_set_copy_callback(char *(*callback)(void *), void *data); +void iron_set_paste_callback(void (*callback)(char *, void *), void *data); -bool kinc_internal_frame(void); -const char *kinc_internal_save_path(void); -bool kinc_internal_handle_messages(void); -void kinc_internal_shutdown(void); -void kinc_internal_update_callback(void); -void kinc_internal_foreground_callback(void); -void kinc_internal_resume_callback(void); -void kinc_internal_pause_callback(void); -void kinc_internal_background_callback(void); -void kinc_internal_shutdown_callback(void); -void kinc_internal_drop_files_callback(wchar_t *); -char *kinc_internal_cut_callback(void); -char *kinc_internal_copy_callback(void); -void kinc_internal_paste_callback(char *); +bool iron_internal_frame(void); +const char *iron_internal_save_path(void); +bool iron_internal_handle_messages(void); +void iron_internal_shutdown(void); +void iron_internal_update_callback(void); +void iron_internal_foreground_callback(void); +void iron_internal_resume_callback(void); +void iron_internal_pause_callback(void); +void iron_internal_background_callback(void); +void iron_internal_shutdown_callback(void); +void iron_internal_drop_files_callback(wchar_t *); +char *iron_internal_cut_callback(void); +char *iron_internal_copy_callback(void); +void iron_internal_paste_callback(char *); -#define KINC_KEY_UNKNOWN 0 -#define KINC_KEY_BACK 1 // Android -#define KINC_KEY_CANCEL 3 -#define KINC_KEY_HELP 6 -#define KINC_KEY_BACKSPACE 8 -#define KINC_KEY_TAB 9 -#define KINC_KEY_CLEAR 12 -#define KINC_KEY_RETURN 13 -#define KINC_KEY_SHIFT 16 -#define KINC_KEY_CONTROL 17 -#define KINC_KEY_ALT 18 -#define KINC_KEY_PAUSE 19 -#define KINC_KEY_CAPS_LOCK 20 -#define KINC_KEY_KANA 21 -#define KINC_KEY_HANGUL 21 -#define KINC_KEY_EISU 22 -#define KINC_KEY_JUNJA 23 -#define KINC_KEY_FINAL 24 -#define KINC_KEY_HANJA 25 -#define KINC_KEY_KANJI 25 -#define KINC_KEY_ESCAPE 27 -#define KINC_KEY_CONVERT 28 -#define KINC_KEY_NON_CONVERT 29 -#define KINC_KEY_ACCEPT 30 -#define KINC_KEY_MODE_CHANGE 31 -#define KINC_KEY_SPACE 32 -#define KINC_KEY_PAGE_UP 33 -#define KINC_KEY_PAGE_DOWN 34 -#define KINC_KEY_END 35 -#define KINC_KEY_HOME 36 -#define KINC_KEY_LEFT 37 -#define KINC_KEY_UP 38 -#define KINC_KEY_RIGHT 39 -#define KINC_KEY_DOWN 40 -#define KINC_KEY_SELECT 41 -#define KINC_KEY_PRINT 42 -#define KINC_KEY_EXECUTE 43 -#define KINC_KEY_PRINT_SCREEN 44 -#define KINC_KEY_INSERT 45 -#define KINC_KEY_DELETE 46 -#define KINC_KEY_0 48 -#define KINC_KEY_1 49 -#define KINC_KEY_2 50 -#define KINC_KEY_3 51 -#define KINC_KEY_4 52 -#define KINC_KEY_5 53 -#define KINC_KEY_6 54 -#define KINC_KEY_7 55 -#define KINC_KEY_8 56 -#define KINC_KEY_9 57 -#define KINC_KEY_COLON 58 -#define KINC_KEY_SEMICOLON 59 -#define KINC_KEY_LESS_THAN 60 -#define KINC_KEY_EQUALS 61 -#define KINC_KEY_GREATER_THAN 62 -#define KINC_KEY_QUESTIONMARK 63 -#define KINC_KEY_AT 64 -#define KINC_KEY_A 65 -#define KINC_KEY_B 66 -#define KINC_KEY_C 67 -#define KINC_KEY_D 68 -#define KINC_KEY_E 69 -#define KINC_KEY_F 70 -#define KINC_KEY_G 71 -#define KINC_KEY_H 72 -#define KINC_KEY_I 73 -#define KINC_KEY_J 74 -#define KINC_KEY_K 75 -#define KINC_KEY_L 76 -#define KINC_KEY_M 77 -#define KINC_KEY_N 78 -#define KINC_KEY_O 79 -#define KINC_KEY_P 80 -#define KINC_KEY_Q 81 -#define KINC_KEY_R 82 -#define KINC_KEY_S 83 -#define KINC_KEY_T 84 -#define KINC_KEY_U 85 -#define KINC_KEY_V 86 -#define KINC_KEY_W 87 -#define KINC_KEY_X 88 -#define KINC_KEY_Y 89 -#define KINC_KEY_Z 90 -#define KINC_KEY_WIN 91 -#define KINC_KEY_CONTEXT_MENU 93 -#define KINC_KEY_SLEEP 95 -#define KINC_KEY_NUMPAD_0 96 -#define KINC_KEY_NUMPAD_1 97 -#define KINC_KEY_NUMPAD_2 98 -#define KINC_KEY_NUMPAD_3 99 -#define KINC_KEY_NUMPAD_4 100 -#define KINC_KEY_NUMPAD_5 101 -#define KINC_KEY_NUMPAD_6 102 -#define KINC_KEY_NUMPAD_7 103 -#define KINC_KEY_NUMPAD_8 104 -#define KINC_KEY_NUMPAD_9 105 -#define KINC_KEY_MULTIPLY 106 -#define KINC_KEY_ADD 107 -#define KINC_KEY_SEPARATOR 108 -#define KINC_KEY_SUBTRACT 109 -#define KINC_KEY_DECIMAL 110 -#define KINC_KEY_DIVIDE 111 -#define KINC_KEY_F1 112 -#define KINC_KEY_F2 113 -#define KINC_KEY_F3 114 -#define KINC_KEY_F4 115 -#define KINC_KEY_F5 116 -#define KINC_KEY_F6 117 -#define KINC_KEY_F7 118 -#define KINC_KEY_F8 119 -#define KINC_KEY_F9 120 -#define KINC_KEY_F10 121 -#define KINC_KEY_F11 122 -#define KINC_KEY_F12 123 -#define KINC_KEY_F13 124 -#define KINC_KEY_F14 125 -#define KINC_KEY_F15 126 -#define KINC_KEY_F16 127 -#define KINC_KEY_F17 128 -#define KINC_KEY_F18 129 -#define KINC_KEY_F19 130 -#define KINC_KEY_F20 131 -#define KINC_KEY_F21 132 -#define KINC_KEY_F22 133 -#define KINC_KEY_F23 134 -#define KINC_KEY_F24 135 -#define KINC_KEY_NUM_LOCK 144 -#define KINC_KEY_SCROLL_LOCK 145 -#define KINC_KEY_WIN_OEM_FJ_JISHO 146 -#define KINC_KEY_WIN_OEM_FJ_MASSHOU 147 -#define KINC_KEY_WIN_OEM_FJ_TOUROKU 148 -#define KINC_KEY_WIN_OEM_FJ_LOYA 149 -#define KINC_KEY_WIN_OEM_FJ_ROYA 150 -#define KINC_KEY_CIRCUMFLEX 160 -#define KINC_KEY_EXCLAMATION 161 -#define KINC_KEY_DOUBLE_QUOTE 162 -#define KINC_KEY_HASH 163 -#define KINC_KEY_DOLLAR 164 -#define KINC_KEY_PERCENT 165 -#define KINC_KEY_AMPERSAND 166 -#define KINC_KEY_UNDERSCORE 167 -#define KINC_KEY_OPEN_PAREN 168 -#define KINC_KEY_CLOSE_PAREN 169 -#define KINC_KEY_ASTERISK 170 -#define KINC_KEY_PLUS 171 -#define KINC_KEY_PIPE 172 -#define KINC_KEY_HYPHEN_MINUS 173 -#define KINC_KEY_OPEN_CURLY_BRACKET 174 -#define KINC_KEY_CLOSE_CURLY_BRACKET 175 -#define KINC_KEY_TILDE 176 -#define KINC_KEY_VOLUME_MUTE 181 -#define KINC_KEY_VOLUME_DOWN 182 -#define KINC_KEY_VOLUME_UP 183 -#define KINC_KEY_COMMA 188 -#define KINC_KEY_PERIOD 190 -#define KINC_KEY_SLASH 191 -#define KINC_KEY_BACK_QUOTE 192 -#define KINC_KEY_OPEN_BRACKET 219 -#define KINC_KEY_BACK_SLASH 220 -#define KINC_KEY_CLOSE_BRACKET 221 -#define KINC_KEY_QUOTE 222 -#define KINC_KEY_META 224 -#define KINC_KEY_ALT_GR 225 -#define KINC_KEY_WIN_ICO_HELP 227 -#define KINC_KEY_WIN_ICO_00 228 -#define KINC_KEY_WIN_ICO_CLEAR 230 -#define KINC_KEY_WIN_OEM_RESET 233 -#define KINC_KEY_WIN_OEM_JUMP 234 -#define KINC_KEY_WIN_OEM_PA1 235 -#define KINC_KEY_WIN_OEM_PA2 236 -#define KINC_KEY_WIN_OEM_PA3 237 -#define KINC_KEY_WIN_OEM_WSCTRL 238 -#define KINC_KEY_WIN_OEM_CUSEL 239 -#define KINC_KEY_WIN_OEM_ATTN 240 -#define KINC_KEY_WIN_OEM_FINISH 241 -#define KINC_KEY_WIN_OEM_COPY 242 -#define KINC_KEY_WIN_OEM_AUTO 243 -#define KINC_KEY_WIN_OEM_ENLW 244 -#define KINC_KEY_WIN_OEM_BACK_TAB 245 -#define KINC_KEY_ATTN 246 -#define KINC_KEY_CRSEL 247 -#define KINC_KEY_EXSEL 248 -#define KINC_KEY_EREOF 249 -#define KINC_KEY_PLAY 250 -#define KINC_KEY_ZOOM 251 -#define KINC_KEY_PA1 253 -#define KINC_KEY_WIN_OEM_CLEAR 254 +#define IRON_KEY_UNKNOWN 0 +#define IRON_KEY_BACK 1 // Android +#define IRON_KEY_CANCEL 3 +#define IRON_KEY_HELP 6 +#define IRON_KEY_BACKSPACE 8 +#define IRON_KEY_TAB 9 +#define IRON_KEY_CLEAR 12 +#define IRON_KEY_RETURN 13 +#define IRON_KEY_SHIFT 16 +#define IRON_KEY_CONTROL 17 +#define IRON_KEY_ALT 18 +#define IRON_KEY_PAUSE 19 +#define IRON_KEY_CAPS_LOCK 20 +#define IRON_KEY_KANA 21 +#define IRON_KEY_HANGUL 21 +#define IRON_KEY_EISU 22 +#define IRON_KEY_JUNJA 23 +#define IRON_KEY_FINAL 24 +#define IRON_KEY_HANJA 25 +#define IRON_KEY_KANJI 25 +#define IRON_KEY_ESCAPE 27 +#define IRON_KEY_CONVERT 28 +#define IRON_KEY_NON_CONVERT 29 +#define IRON_KEY_ACCEPT 30 +#define IRON_KEY_MODE_CHANGE 31 +#define IRON_KEY_SPACE 32 +#define IRON_KEY_PAGE_UP 33 +#define IRON_KEY_PAGE_DOWN 34 +#define IRON_KEY_END 35 +#define IRON_KEY_HOME 36 +#define IRON_KEY_LEFT 37 +#define IRON_KEY_UP 38 +#define IRON_KEY_RIGHT 39 +#define IRON_KEY_DOWN 40 +#define IRON_KEY_SELECT 41 +#define IRON_KEY_PRINT 42 +#define IRON_KEY_EXECUTE 43 +#define IRON_KEY_PRINT_SCREEN 44 +#define IRON_KEY_INSERT 45 +#define IRON_KEY_DELETE 46 +#define IRON_KEY_0 48 +#define IRON_KEY_1 49 +#define IRON_KEY_2 50 +#define IRON_KEY_3 51 +#define IRON_KEY_4 52 +#define IRON_KEY_5 53 +#define IRON_KEY_6 54 +#define IRON_KEY_7 55 +#define IRON_KEY_8 56 +#define IRON_KEY_9 57 +#define IRON_KEY_COLON 58 +#define IRON_KEY_SEMICOLON 59 +#define IRON_KEY_LESS_THAN 60 +#define IRON_KEY_EQUALS 61 +#define IRON_KEY_GREATER_THAN 62 +#define IRON_KEY_QUESTIONMARK 63 +#define IRON_KEY_AT 64 +#define IRON_KEY_A 65 +#define IRON_KEY_B 66 +#define IRON_KEY_C 67 +#define IRON_KEY_D 68 +#define IRON_KEY_E 69 +#define IRON_KEY_F 70 +#define IRON_KEY_G 71 +#define IRON_KEY_H 72 +#define IRON_KEY_I 73 +#define IRON_KEY_J 74 +#define IRON_KEY_K 75 +#define IRON_KEY_L 76 +#define IRON_KEY_M 77 +#define IRON_KEY_N 78 +#define IRON_KEY_O 79 +#define IRON_KEY_P 80 +#define IRON_KEY_Q 81 +#define IRON_KEY_R 82 +#define IRON_KEY_S 83 +#define IRON_KEY_T 84 +#define IRON_KEY_U 85 +#define IRON_KEY_V 86 +#define IRON_KEY_W 87 +#define IRON_KEY_X 88 +#define IRON_KEY_Y 89 +#define IRON_KEY_Z 90 +#define IRON_KEY_WIN 91 +#define IRON_KEY_CONTEXT_MENU 93 +#define IRON_KEY_SLEEP 95 +#define IRON_KEY_NUMPAD_0 96 +#define IRON_KEY_NUMPAD_1 97 +#define IRON_KEY_NUMPAD_2 98 +#define IRON_KEY_NUMPAD_3 99 +#define IRON_KEY_NUMPAD_4 100 +#define IRON_KEY_NUMPAD_5 101 +#define IRON_KEY_NUMPAD_6 102 +#define IRON_KEY_NUMPAD_7 103 +#define IRON_KEY_NUMPAD_8 104 +#define IRON_KEY_NUMPAD_9 105 +#define IRON_KEY_MULTIPLY 106 +#define IRON_KEY_ADD 107 +#define IRON_KEY_SEPARATOR 108 +#define IRON_KEY_SUBTRACT 109 +#define IRON_KEY_DECIMAL 110 +#define IRON_KEY_DIVIDE 111 +#define IRON_KEY_F1 112 +#define IRON_KEY_F2 113 +#define IRON_KEY_F3 114 +#define IRON_KEY_F4 115 +#define IRON_KEY_F5 116 +#define IRON_KEY_F6 117 +#define IRON_KEY_F7 118 +#define IRON_KEY_F8 119 +#define IRON_KEY_F9 120 +#define IRON_KEY_F10 121 +#define IRON_KEY_F11 122 +#define IRON_KEY_F12 123 +#define IRON_KEY_F13 124 +#define IRON_KEY_F14 125 +#define IRON_KEY_F15 126 +#define IRON_KEY_F16 127 +#define IRON_KEY_F17 128 +#define IRON_KEY_F18 129 +#define IRON_KEY_F19 130 +#define IRON_KEY_F20 131 +#define IRON_KEY_F21 132 +#define IRON_KEY_F22 133 +#define IRON_KEY_F23 134 +#define IRON_KEY_F24 135 +#define IRON_KEY_NUM_LOCK 144 +#define IRON_KEY_SCROLL_LOCK 145 +#define IRON_KEY_WIN_OEM_FJ_JISHO 146 +#define IRON_KEY_WIN_OEM_FJ_MASSHOU 147 +#define IRON_KEY_WIN_OEM_FJ_TOUROKU 148 +#define IRON_KEY_WIN_OEM_FJ_LOYA 149 +#define IRON_KEY_WIN_OEM_FJ_ROYA 150 +#define IRON_KEY_CIRCUMFLEX 160 +#define IRON_KEY_EXCLAMATION 161 +#define IRON_KEY_DOUBLE_QUOTE 162 +#define IRON_KEY_HASH 163 +#define IRON_KEY_DOLLAR 164 +#define IRON_KEY_PERCENT 165 +#define IRON_KEY_AMPERSAND 166 +#define IRON_KEY_UNDERSCORE 167 +#define IRON_KEY_OPEN_PAREN 168 +#define IRON_KEY_CLOSE_PAREN 169 +#define IRON_KEY_ASTERISK 170 +#define IRON_KEY_PLUS 171 +#define IRON_KEY_PIPE 172 +#define IRON_KEY_HYPHEN_MINUS 173 +#define IRON_KEY_OPEN_CURLY_BRACKET 174 +#define IRON_KEY_CLOSE_CURLY_BRACKET 175 +#define IRON_KEY_TILDE 176 +#define IRON_KEY_VOLUME_MUTE 181 +#define IRON_KEY_VOLUME_DOWN 182 +#define IRON_KEY_VOLUME_UP 183 +#define IRON_KEY_COMMA 188 +#define IRON_KEY_PERIOD 190 +#define IRON_KEY_SLASH 191 +#define IRON_KEY_BACK_QUOTE 192 +#define IRON_KEY_OPEN_BRACKET 219 +#define IRON_KEY_BACK_SLASH 220 +#define IRON_KEY_CLOSE_BRACKET 221 +#define IRON_KEY_QUOTE 222 +#define IRON_KEY_META 224 +#define IRON_KEY_ALT_GR 225 +#define IRON_KEY_WIN_ICO_HELP 227 +#define IRON_KEY_WIN_ICO_00 228 +#define IRON_KEY_WIN_ICO_CLEAR 230 +#define IRON_KEY_WIN_OEM_RESET 233 +#define IRON_KEY_WIN_OEM_JUMP 234 +#define IRON_KEY_WIN_OEM_PA1 235 +#define IRON_KEY_WIN_OEM_PA2 236 +#define IRON_KEY_WIN_OEM_PA3 237 +#define IRON_KEY_WIN_OEM_WSCTRL 238 +#define IRON_KEY_WIN_OEM_CUSEL 239 +#define IRON_KEY_WIN_OEM_ATTN 240 +#define IRON_KEY_WIN_OEM_FINISH 241 +#define IRON_KEY_WIN_OEM_COPY 242 +#define IRON_KEY_WIN_OEM_AUTO 243 +#define IRON_KEY_WIN_OEM_ENLW 244 +#define IRON_KEY_WIN_OEM_BACK_TAB 245 +#define IRON_KEY_ATTN 246 +#define IRON_KEY_CRSEL 247 +#define IRON_KEY_EXSEL 248 +#define IRON_KEY_EREOF 249 +#define IRON_KEY_PLAY 250 +#define IRON_KEY_ZOOM 251 +#define IRON_KEY_PA1 253 +#define IRON_KEY_WIN_OEM_CLEAR 254 -void kinc_keyboard_show(void); -void kinc_keyboard_hide(void); -bool kinc_keyboard_active(void); -void kinc_keyboard_set_key_down_callback(void (*value)(int /*key_code*/, void * /*data*/), void *data); -void kinc_keyboard_set_key_up_callback(void (*value)(int /*key_code*/, void * /*data*/), void *data); -void kinc_keyboard_set_key_press_callback(void (*value)(unsigned /*character*/, void * /*data*/), void *data); +void iron_keyboard_show(void); +void iron_keyboard_hide(void); +bool iron_keyboard_active(void); +void iron_keyboard_set_key_down_callback(void (*value)(int /*key_code*/, void * /*data*/), void *data); +void iron_keyboard_set_key_up_callback(void (*value)(int /*key_code*/, void * /*data*/), void *data); +void iron_keyboard_set_key_press_callback(void (*value)(unsigned /*character*/, void * /*data*/), void *data); -void kinc_internal_keyboard_trigger_key_down(int key_code); -void kinc_internal_keyboard_trigger_key_up(int key_code); -void kinc_internal_keyboard_trigger_key_press(unsigned character); +void iron_internal_keyboard_trigger_key_down(int key_code); +void iron_internal_keyboard_trigger_key_up(int key_code); +void iron_internal_keyboard_trigger_key_press(unsigned character); -#define KINC_MOUSE_LEFT 0 -#define KINC_MOUSE_RIGHT 1 -#define KINC_MOUSE_MIDDLE 2 +#define IRON_MOUSE_LEFT 0 +#define IRON_MOUSE_RIGHT 1 +#define IRON_MOUSE_MIDDLE 2 // eg backward sidebutton -#define KINC_MOUSE_EXTRA1 3 +#define IRON_MOUSE_EXTRA1 3 // eg forward sidebutton -#define KINC_MOUSE_EXTRA2 4 +#define IRON_MOUSE_EXTRA2 4 -void kinc_mouse_set_press_callback(void (*value)(int /*button*/, int /*x*/, int /*y*/, void * /*data*/), void *data); -void kinc_mouse_set_release_callback(void (*value)(int /*button*/, int /*x*/, int /*y*/, void * /*data*/), void *data); -void kinc_mouse_set_move_callback(void (*value)(int /*x*/, int /*y*/, int /*movement_x*/, int /*movement_y*/, void * /*data*/), +void iron_mouse_set_press_callback(void (*value)(int /*button*/, int /*x*/, int /*y*/, void * /*data*/), void *data); +void iron_mouse_set_release_callback(void (*value)(int /*button*/, int /*x*/, int /*y*/, void * /*data*/), void *data); +void iron_mouse_set_move_callback(void (*value)(int /*x*/, int /*y*/, int /*movement_x*/, int /*movement_y*/, void * /*data*/), void *data); -void kinc_mouse_set_scroll_callback(void (*value)(int /*delta*/, void * /*data*/), void *data); -bool kinc_mouse_can_lock(void); -bool kinc_mouse_is_locked(void); -void kinc_mouse_lock(); -void kinc_mouse_unlock(void); -void kinc_mouse_set_cursor(int cursor); -void kinc_mouse_show(void); -void kinc_mouse_hide(void); -void kinc_mouse_set_position(int x, int y); -void kinc_mouse_get_position(int *x, int *y); +void iron_mouse_set_scroll_callback(void (*value)(int /*delta*/, void * /*data*/), void *data); +bool iron_mouse_can_lock(void); +bool iron_mouse_is_locked(void); +void iron_mouse_lock(); +void iron_mouse_unlock(void); +void iron_mouse_set_cursor(int cursor); +void iron_mouse_show(void); +void iron_mouse_hide(void); +void iron_mouse_set_position(int x, int y); +void iron_mouse_get_position(int *x, int *y); -void kinc_internal_mouse_trigger_press(int button, int x, int y); -void kinc_internal_mouse_trigger_release(int button, int x, int y); -void kinc_internal_mouse_trigger_move(int x, int y); -void kinc_internal_mouse_trigger_scroll(int delta); -void kinc_internal_mouse_lock(); -void kinc_internal_mouse_unlock(void); -void kinc_internal_mouse_window_activated(); -void kinc_internal_mouse_window_deactivated(); +void iron_internal_mouse_trigger_press(int button, int x, int y); +void iron_internal_mouse_trigger_release(int button, int x, int y); +void iron_internal_mouse_trigger_move(int x, int y); +void iron_internal_mouse_trigger_scroll(int delta); +void iron_internal_mouse_lock(); +void iron_internal_mouse_unlock(void); +void iron_internal_mouse_window_activated(); +void iron_internal_mouse_window_deactivated(); -void kinc_pen_set_press_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)); -void kinc_pen_set_move_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)); -void kinc_pen_set_release_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)); -void kinc_eraser_set_press_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)); -void kinc_eraser_set_move_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)); -void kinc_eraser_set_release_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)); +void iron_pen_set_press_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)); +void iron_pen_set_move_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)); +void iron_pen_set_release_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)); +void iron_eraser_set_press_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)); +void iron_eraser_set_move_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)); +void iron_eraser_set_release_callback(void (*value)(int /*x*/, int /*y*/, float /*pressure*/)); -void kinc_internal_pen_trigger_move(int x, int y, float pressure); -void kinc_internal_pen_trigger_press(int x, int y, float pressure); -void kinc_internal_pen_trigger_release(int x, int y, float pressure); +void iron_internal_pen_trigger_move(int x, int y, float pressure); +void iron_internal_pen_trigger_press(int x, int y, float pressure); +void iron_internal_pen_trigger_release(int x, int y, float pressure); -void kinc_internal_eraser_trigger_move(int x, int y, float pressure); -void kinc_internal_eraser_trigger_press(int x, int y, float pressure); -void kinc_internal_eraser_trigger_release(int x, int y, float pressure); +void iron_internal_eraser_trigger_move(int x, int y, float pressure); +void iron_internal_eraser_trigger_press(int x, int y, float pressure); +void iron_internal_eraser_trigger_release(int x, int y, float pressure); -void kinc_surface_set_touch_start_callback(void (*value)(int /*index*/, int /*x*/, int /*y*/)); -void kinc_surface_set_move_callback(void (*value)(int /*index*/, int /*x*/, int /*y*/)); -void kinc_surface_set_touch_end_callback(void (*value)(int /*index*/, int /*x*/, int /*y*/)); +void iron_surface_set_touch_start_callback(void (*value)(int /*index*/, int /*x*/, int /*y*/)); +void iron_surface_set_move_callback(void (*value)(int /*index*/, int /*x*/, int /*y*/)); +void iron_surface_set_touch_end_callback(void (*value)(int /*index*/, int /*x*/, int /*y*/)); -void kinc_internal_surface_trigger_touch_start(int index, int x, int y); -void kinc_internal_surface_trigger_move(int index, int x, int y); -void kinc_internal_surface_trigger_touch_end(int index, int x, int y); +void iron_internal_surface_trigger_touch_start(int index, int x, int y); +void iron_internal_surface_trigger_move(int index, int x, int y); +void iron_internal_surface_trigger_touch_end(int index, int x, int y); -#define KINC_GAMEPAD_MAX_COUNT 12 +#define IRON_GAMEPAD_MAX_COUNT 12 -void kinc_gamepad_set_connect_callback(void (*value)(int /*gamepad*/, void * /*userdata*/), void *userdata); -void kinc_gamepad_set_disconnect_callback(void (*value)(int /*gamepad*/, void * /*userdata*/), void *userdata); -void kinc_gamepad_set_axis_callback(void (*value)(int /*gamepad*/, int /*axis*/, float /*value*/, void * /*userdata*/), void *userdata); -void kinc_gamepad_set_button_callback(void (*value)(int /*gamepad*/, int /*button*/, float /*value*/, void * /*userdata*/), void *userdata); -const char *kinc_gamepad_vendor(int gamepad); -const char *kinc_gamepad_product_name(int gamepad); -bool kinc_gamepad_connected(int gamepad); -void kinc_gamepad_rumble(int gamepad, float left, float right); +void iron_gamepad_set_connect_callback(void (*value)(int /*gamepad*/, void * /*userdata*/), void *userdata); +void iron_gamepad_set_disconnect_callback(void (*value)(int /*gamepad*/, void * /*userdata*/), void *userdata); +void iron_gamepad_set_axis_callback(void (*value)(int /*gamepad*/, int /*axis*/, float /*value*/, void * /*userdata*/), void *userdata); +void iron_gamepad_set_button_callback(void (*value)(int /*gamepad*/, int /*button*/, float /*value*/, void * /*userdata*/), void *userdata); +const char *iron_gamepad_vendor(int gamepad); +const char *iron_gamepad_product_name(int gamepad); +bool iron_gamepad_connected(int gamepad); +void iron_gamepad_rumble(int gamepad, float left, float right); -void kinc_internal_gamepad_trigger_connect(int gamepad); -void kinc_internal_gamepad_trigger_disconnect(int gamepad); -void kinc_internal_gamepad_trigger_axis(int gamepad, int axis, float value); -void kinc_internal_gamepad_trigger_button(int gamepad, int button, float value); +void iron_internal_gamepad_trigger_connect(int gamepad); +void iron_internal_gamepad_trigger_disconnect(int gamepad); +void iron_internal_gamepad_trigger_axis(int gamepad, int axis, float value); +void iron_internal_gamepad_trigger_button(int gamepad, int button, float value); diff --git a/base/sources/iron_thread.h b/base/sources/iron_thread.h index 5e68a615..f832df4f 100644 --- a/base/sources/iron_thread.h +++ b/base/sources/iron_thread.h @@ -4,24 +4,24 @@ #include #include BACKEND_THREAD_H -typedef struct kinc_thread { - kinc_thread_impl_t impl; -} kinc_thread_t; +typedef struct iron_thread { + iron_thread_impl_t impl; +} iron_thread_t; -void kinc_threads_init(void); -void kinc_threads_quit(void); -void kinc_thread_init(kinc_thread_t *thread, void (*func)(void *param), void *param); -void kinc_thread_wait_and_destroy(kinc_thread_t *thread); -bool kinc_thread_try_to_destroy(kinc_thread_t *thread); -void kinc_thread_set_name(const char *name); -void kinc_thread_sleep(int milliseconds); +void iron_threads_init(void); +void iron_threads_quit(void); +void iron_thread_init(iron_thread_t *thread, void (*func)(void *param), void *param); +void iron_thread_wait_and_destroy(iron_thread_t *thread); +bool iron_thread_try_to_destroy(iron_thread_t *thread); +void iron_thread_set_name(const char *name); +void iron_thread_sleep(int milliseconds); -typedef struct kinc_mutex { - kinc_mutex_impl_t impl; -} kinc_mutex_t; +typedef struct iron_mutex { + iron_mutex_impl_t impl; +} iron_mutex_t; -void kinc_mutex_init(kinc_mutex_t *mutex); -void kinc_mutex_destroy(kinc_mutex_t *mutex); -void kinc_mutex_lock(kinc_mutex_t *mutex); -bool kinc_mutex_try_to_lock(kinc_mutex_t *mutex); -void kinc_mutex_unlock(kinc_mutex_t *mutex); +void iron_mutex_init(iron_mutex_t *mutex); +void iron_mutex_destroy(iron_mutex_t *mutex); +void iron_mutex_lock(iron_mutex_t *mutex); +bool iron_mutex_try_to_lock(iron_mutex_t *mutex); +void iron_mutex_unlock(iron_mutex_t *mutex); diff --git a/base/sources/iron_ui.c b/base/sources/iron_ui.c index 1032490c..be2a9b0c 100644 --- a/base/sources/iron_ui.c +++ b/base/sources/iron_ui.c @@ -473,7 +473,7 @@ void ui_end_element() { void ui_resize(ui_handle_t *handle, int w, int h) { handle->redraws = 2; if (handle->texture.width != 0) { - kinc_g5_texture_destroy(&handle->texture); + iron_g5_texture_destroy(&handle->texture); } if (w < 1) { w = 1; @@ -481,7 +481,7 @@ void ui_resize(ui_handle_t *handle, int w, int h) { if (h < 1) { h = 1; } - kinc_g5_render_target_init(&handle->texture, w, h, KINC_IMAGE_FORMAT_RGBA32, 0); + iron_g5_render_target_init(&handle->texture, w, h, IRON_IMAGE_FORMAT_RGBA32, 0); } bool ui_input_in_rect(float x, float y, float w, float h) { @@ -497,10 +497,10 @@ bool ui_input_changed() { void ui_end_input() { if (ui_on_tab_drop != NULL && current->drag_tab_handle != NULL) { if (current->input_dx != 0 || current->input_dy != 0) { - kinc_mouse_set_cursor(1); // Hand + iron_mouse_set_cursor(1); // Hand } if (current->input_released) { - kinc_mouse_set_cursor(0); // Default + iron_mouse_set_cursor(0); // Default current->drag_tab_handle = NULL; } } @@ -514,13 +514,13 @@ void ui_end_input() { current->input_dy = 0; current->input_wheel_delta = 0; current->pen_in_use = false; - if (ui_key_repeat && current->is_key_down && kinc_time() - ui_key_repeat_time > 0.05) { - if (current->key_code == KINC_KEY_BACKSPACE || current->key_code == KINC_KEY_DELETE || current->key_code == KINC_KEY_LEFT || current->key_code == KINC_KEY_RIGHT || current->key_code == KINC_KEY_UP || current->key_code == KINC_KEY_DOWN) { - ui_key_repeat_time = kinc_time(); + if (ui_key_repeat && current->is_key_down && iron_time() - ui_key_repeat_time > 0.05) { + if (current->key_code == IRON_KEY_BACKSPACE || current->key_code == IRON_KEY_DELETE || current->key_code == IRON_KEY_LEFT || current->key_code == IRON_KEY_RIGHT || current->key_code == IRON_KEY_UP || current->key_code == IRON_KEY_DOWN) { + ui_key_repeat_time = iron_time(); current->is_key_pressed = true; } } - if (ui_touch_hold && current->input_down && current->input_x == current->input_started_x && current->input_y == current->input_started_y && current->input_started_time > 0 && kinc_time() - current->input_started_time > 0.7) { + if (ui_touch_hold && current->input_down && current->input_x == current->input_started_x && current->input_y == current->input_started_y && current->input_started_time > 0 && iron_time() - current->input_started_time > 0.7) { current->touch_hold_activated = true; current->input_released_r = true; current->input_started_time = 0; @@ -581,7 +581,7 @@ void ui_draw_tooltip_text(bool bind_global_g) { tooltip_w = line_tooltip_w; } } - current->tooltip_x = fmin(current->tooltip_x, kinc_window_width() - tooltip_w - 20); + current->tooltip_x = fmin(current->tooltip_x, iron_window_width() - tooltip_w - 20); if (bind_global_g) draw_restore_render_target(); float font_height = draw_font_height(current->ops->font, current->font_size); float off = 0; @@ -614,8 +614,8 @@ void ui_draw_tooltip_image(bool bind_global_g) { w = current->tooltip_img_max_width; } float h = current->tooltip_img->height * (w / current->tooltip_img->width); - current->tooltip_x = fmin(current->tooltip_x, kinc_window_width() - w - 20); - current->tooltip_y = fmin(current->tooltip_y, kinc_window_height() - h - 20); + current->tooltip_x = fmin(current->tooltip_x, iron_window_width() - w - 20); + current->tooltip_y = fmin(current->tooltip_y, iron_window_height() - h - 20); if (bind_global_g) { draw_restore_render_target(); } @@ -652,8 +652,8 @@ void ui_draw_tooltip(bool bind_global_g) { draw_set_font(current->ops->font, current->font_size * 2.0); float x_off = draw_string_width(current->ops->font, current->font_size * 2.0, current->text_selected) / 2.0; float y_off = draw_font_height(current->ops->font, current->font_size * 2.0) / 2.0; - float x = kinc_window_width() / 2.0; - float y = kinc_window_height() / 3.0; + float x = iron_window_width() / 2.0; + float y = iron_window_height() / 3.0; draw_set_color(theme->BUTTON_COL); draw_filled_rect(x - x_off, y - y_off, x_off * 2.0, y_off * 2.0); draw_set_color(theme->TEXT_COL); @@ -668,9 +668,9 @@ void ui_draw_tooltip(bool bind_global_g) { if (!current->tooltip_shown) { current->tooltip_shown = true; current->tooltip_x = current->input_x; - current->tooltip_time = kinc_time(); + current->tooltip_time = iron_time(); } - if (!current->tooltip_wait && kinc_time() - current->tooltip_time > UI_TOOLTIP_DELAY()) { + if (!current->tooltip_wait && iron_time() - current->tooltip_time > UI_TOOLTIP_DELAY()) { if (current->tooltip_img != NULL) { ui_draw_tooltip_image(bind_global_g); } @@ -693,7 +693,7 @@ void ui_draw_combo(bool begin /*= true*/) { float combo_h = (current->combo_selected_texts->length + (current->combo_selected_label != NULL ? 1 : 0) + (current->combo_search_bar ? 1 : 0)) * UI_ELEMENT_H(); float dist_top = current->combo_selected_y - combo_h - UI_ELEMENT_H() - current->window_border_top; - float dist_bottom = kinc_window_height() - current->window_border_bottom - (current->combo_selected_y + combo_h ); + float dist_bottom = iron_window_height() - current->window_border_bottom - (current->combo_selected_y + combo_h ); bool unroll_up = dist_bottom < 0 && dist_bottom < dist_top; ui_begin_region(current, current->combo_selected_x, current->combo_selected_y, current->combo_selected_w); @@ -707,8 +707,8 @@ void ui_draw_combo(bool begin /*= true*/) { } if (current->is_key_pressed || current->input_wheel_delta != 0) { - int arrow_up = current->is_key_pressed && current->key_code == (unroll_up ? KINC_KEY_DOWN : KINC_KEY_UP); - int arrow_down = current->is_key_pressed && current->key_code == (unroll_up ? KINC_KEY_UP : KINC_KEY_DOWN); + int arrow_up = current->is_key_pressed && current->key_code == (unroll_up ? IRON_KEY_DOWN : IRON_KEY_UP); + int arrow_down = current->is_key_pressed && current->key_code == (unroll_up ? IRON_KEY_UP : IRON_KEY_DOWN); int wheel_up = (unroll_up && current->input_wheel_delta > 0) || (!unroll_up && current->input_wheel_delta < 0); int wheel_down = (unroll_up && current->input_wheel_delta < 0) || (!unroll_up && current->input_wheel_delta > 0); if ((arrow_up || wheel_up) && current->combo_to_submit > 0) { @@ -771,7 +771,7 @@ void ui_draw_combo(bool begin /*= true*/) { int _BUTTON_COL = theme->BUTTON_COL; int _ELEMENT_OFFSET = theme->ELEMENT_OFFSET; theme->ELEMENT_OFFSET = 0; - float unroll_right = current->_x + current->combo_selected_w * 2.0 < kinc_window_width() - current->window_border_right ? 1 : -1; + float unroll_right = current->_x + current->combo_selected_w * 2.0 < iron_window_width() - current->window_border_right ? 1 : -1; bool reset_position = false; char search[512]; search[0] = '\0'; @@ -789,7 +789,7 @@ void ui_draw_combo(bool begin /*= true*/) { ui_combo_first = true; // Keep combo open } if (ui_combo_first) { - #if !defined(KINC_ANDROID) && !defined(KINC_IOS) + #if !defined(IRON_ANDROID) && !defined(IRON_IOS) ui_start_text_edit(ui_combo_search_handle, UI_ALIGN_LEFT); // Focus search bar #endif } @@ -823,7 +823,7 @@ void ui_draw_combo(bool begin /*= true*/) { } break; } - if (current->_y + UI_ELEMENT_H() > kinc_window_height() - current->window_border_bottom || current->_y - UI_ELEMENT_H() * 2 < current->window_border_top) { + if (current->_y + UI_ELEMENT_H() > iron_window_height() - current->window_border_bottom || current->_y - UI_ELEMENT_H() * 2 < current->window_border_top) { current->_x += current->combo_selected_w * unroll_right; // Next column current->_y = current->combo_selected_y; } @@ -863,24 +863,24 @@ void ui_draw_combo(bool begin /*= true*/) { void ui_bake_elements() { if (current->check_select_image.width != 0) { - kinc_g5_texture_destroy(¤t->check_select_image); + iron_g5_texture_destroy(¤t->check_select_image); } float r = UI_CHECK_SELECT_SIZE(); - kinc_g5_render_target_init(¤t->check_select_image, r, r, KINC_IMAGE_FORMAT_RGBA32, 0); + iron_g5_render_target_init(¤t->check_select_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); draw_set_render_target(¤t->check_select_image); - kinc_g5_clear(0x00000000, 0, KINC_G5_CLEAR_COLOR); + iron_g5_clear(0x00000000, 0, IRON_G5_CLEAR_COLOR); draw_set_color(0xffffffff); draw_line(0, r / 2.0, r / 2.0 - 2.0 * UI_SCALE(), r - 2.0 * UI_SCALE(), 2.0 * UI_SCALE()); draw_line(r / 2.0 - 3.0 * UI_SCALE(), r - 3.0 * UI_SCALE(), r / 2.0 + 5.0 * UI_SCALE(), r - 11.0 * UI_SCALE(), 2.0 * UI_SCALE()); draw_end(); if (current->radio_image.width != 0) { - kinc_g5_texture_destroy(¤t->radio_image); + iron_g5_texture_destroy(¤t->radio_image); } r = UI_CHECK_SIZE(); - kinc_g5_render_target_init(¤t->radio_image, r, r, KINC_IMAGE_FORMAT_RGBA32, 0); + iron_g5_render_target_init(¤t->radio_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); draw_set_render_target(¤t->radio_image); - kinc_g5_clear(0x00000000, 0, KINC_G5_CLEAR_COLOR); + iron_g5_clear(0x00000000, 0, IRON_G5_CLEAR_COLOR); draw_set_color(0xffaaaaaa); draw_filled_circle(r / 2.0, r / 2.0, r / 2.0, 0); draw_set_color(0xffffffff); @@ -888,12 +888,12 @@ void ui_bake_elements() { draw_end(); if (current->radio_select_image.width != 0) { - kinc_g5_texture_destroy(¤t->radio_select_image); + iron_g5_texture_destroy(¤t->radio_select_image); } r = UI_CHECK_SELECT_SIZE(); - kinc_g5_render_target_init(¤t->radio_select_image, r, r, KINC_IMAGE_FORMAT_RGBA32, 0); + iron_g5_render_target_init(¤t->radio_select_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); draw_set_render_target(¤t->radio_select_image); - kinc_g5_clear(0x00000000, 0, KINC_G5_CLEAR_COLOR); + iron_g5_clear(0x00000000, 0, IRON_G5_CLEAR_COLOR); draw_set_color(0xffaaaaaa); draw_filled_circle(r / 2.0, r / 2.0, 4.5 * UI_SCALE(), 0); draw_set_color(0xffffffff); @@ -902,22 +902,22 @@ void ui_bake_elements() { if (theme->ROUND_CORNERS) { if (current->filled_round_corner_image.width != 0) { - kinc_g5_texture_destroy(¤t->filled_round_corner_image); + iron_g5_texture_destroy(¤t->filled_round_corner_image); } r = 4.0 * UI_SCALE(); - kinc_g5_render_target_init(¤t->filled_round_corner_image, r, r, KINC_IMAGE_FORMAT_RGBA32, 0); + iron_g5_render_target_init(¤t->filled_round_corner_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); draw_set_render_target(¤t->filled_round_corner_image); - kinc_g5_clear(0x00000000, 0, KINC_G5_CLEAR_COLOR); + iron_g5_clear(0x00000000, 0, IRON_G5_CLEAR_COLOR); draw_set_color(0xffffffff); draw_filled_circle(r, r, r, 0); draw_end(); if (current->round_corner_image.width != 0) { - kinc_g5_texture_destroy(¤t->round_corner_image); + iron_g5_texture_destroy(¤t->round_corner_image); } - kinc_g5_render_target_init(¤t->round_corner_image, r, r, KINC_IMAGE_FORMAT_RGBA32, 0); + iron_g5_render_target_init(¤t->round_corner_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); draw_set_render_target(¤t->round_corner_image); - kinc_g5_clear(0x00000000, 0, KINC_G5_CLEAR_COLOR); + iron_g5_clear(0x00000000, 0, IRON_G5_CLEAR_COLOR); draw_set_color(0xffffffff); draw_circle(r, r, r, 0, 1); draw_end(); @@ -980,7 +980,7 @@ void ui_start_text_edit(ui_handle_t *handle, int align) { } current->tab_pressed_handle = handle; current->highlight_anchor = current->highlight_on_select ? 0 : current->cursor_x; - kinc_keyboard_show(); + iron_keyboard_show(); } void ui_submit_text_edit() { @@ -1003,7 +1003,7 @@ void ui_deselect_text(ui_t *ui) { if (ui->current_window != NULL) { ui->current_window->redraws = 2; } - kinc_keyboard_hide(); + iron_keyboard_hide(); ui->highlight_anchor = ui->cursor_x; if (ui_on_deselect_text != NULL) { ui_on_deselect_text(); @@ -1042,17 +1042,17 @@ void ui_update_text_edit(int align, bool editable, bool live_update) { char text[256]; strcpy(text, current->text_selected); if (current->is_key_pressed) { // Process input - if (current->key_code == KINC_KEY_LEFT) { // Move cursor + if (current->key_code == IRON_KEY_LEFT) { // Move cursor if (current->cursor_x > 0) { current->cursor_x--; } } - else if (current->key_code == KINC_KEY_RIGHT) { + else if (current->key_code == IRON_KEY_RIGHT) { if (current->cursor_x < strlen(text)) { current->cursor_x++; } } - else if (editable && current->key_code == KINC_KEY_BACKSPACE) { // Remove char + else if (editable && current->key_code == IRON_KEY_BACKSPACE) { // Remove char if (current->cursor_x > 0 && current->highlight_anchor == current->cursor_x) { ui_remove_char_at(text, current->cursor_x - 1); current->cursor_x--; @@ -1067,7 +1067,7 @@ void ui_update_text_edit(int align, bool editable, bool live_update) { ui_remove_chars_at(text, current->cursor_x, count); } } - else if (editable && current->key_code == KINC_KEY_DELETE) { + else if (editable && current->key_code == IRON_KEY_DELETE) { if (current->highlight_anchor == current->cursor_x) { ui_remove_char_at(text, current->cursor_x); } @@ -1081,22 +1081,22 @@ void ui_update_text_edit(int align, bool editable, bool live_update) { ui_remove_chars_at(text, current->cursor_x, count); } } - else if (current->key_code == KINC_KEY_RETURN) { // Deselect + else if (current->key_code == IRON_KEY_RETURN) { // Deselect ui_deselect_text(current); } - else if (current->key_code == KINC_KEY_ESCAPE) { // Cancel + else if (current->key_code == IRON_KEY_ESCAPE) { // Cancel strcpy(current->text_selected, current->text_selected_handle->text); ui_deselect_text(current); } - else if (current->key_code == KINC_KEY_TAB && current->tab_switch_enabled && !current->is_ctrl_down) { // Next field + else if (current->key_code == IRON_KEY_TAB && current->tab_switch_enabled && !current->is_ctrl_down) { // Next field current->tab_pressed = true; ui_deselect_text(current); current->key_code = 0; } - else if (current->key_code == KINC_KEY_HOME) { + else if (current->key_code == IRON_KEY_HOME) { current->cursor_x = 0; } - else if (current->key_code == KINC_KEY_END) { + else if (current->key_code == IRON_KEY_END) { current->cursor_x = strlen(text); } else if (current->is_ctrl_down && current->is_a_down) { // Select all @@ -1104,20 +1104,20 @@ void ui_update_text_edit(int align, bool editable, bool live_update) { current->highlight_anchor = 0; } else if (editable && // Write - current->key_code != KINC_KEY_SHIFT && - current->key_code != KINC_KEY_CAPS_LOCK && - current->key_code != KINC_KEY_CONTROL && - current->key_code != KINC_KEY_META && - current->key_code != KINC_KEY_ALT && - current->key_code != KINC_KEY_UP && - current->key_code != KINC_KEY_DOWN && + current->key_code != IRON_KEY_SHIFT && + current->key_code != IRON_KEY_CAPS_LOCK && + current->key_code != IRON_KEY_CONTROL && + current->key_code != IRON_KEY_META && + current->key_code != IRON_KEY_ALT && + current->key_code != IRON_KEY_UP && + current->key_code != IRON_KEY_DOWN && current->key_char >= 32) { ui_remove_chars_at(text, current->highlight_anchor, current->cursor_x - current->highlight_anchor); ui_insert_char_at(text, current->highlight_anchor, current->key_char); current->cursor_x = current->cursor_x + 1 > strlen(text) ? strlen(text) : current->cursor_x + 1; } - bool selecting = current->is_shift_down && (current->key_code == KINC_KEY_LEFT || current->key_code == KINC_KEY_RIGHT || current->key_code == KINC_KEY_SHIFT); + bool selecting = current->is_shift_down && (current->key_code == IRON_KEY_LEFT || current->key_code == IRON_KEY_RIGHT || current->key_code == IRON_KEY_SHIFT); // isCtrlDown && isAltDown is the condition for AltGr was pressed // AltGr is part of the German keyboard layout and part of key combinations like AltGr + e -> € if (!selecting && (!current->is_ctrl_down || (current->is_ctrl_down && current->is_alt_down))) { @@ -1502,7 +1502,7 @@ void ui_end_sticky() { draw_end(); current->sticky = false; current->scissor = true; - kinc_g4_scissor(0, current->_y, current->_window_w, current->_window_h - current->_y); + iron_g4_scissor(0, current->_y, current->_window_w, current->_window_h - current->_y); current->window_header_h += current->_y - current->window_header_h; current->_y += current->current_window->scroll_offset; current->is_hovered = false; @@ -1517,7 +1517,7 @@ void ui_end_window(bool bind_global_g) { if (handle->redraws > 0 || current->is_scrolling) { if (current->scissor) { current->scissor = false; - kinc_g4_disable_scissor(); + iron_g4_disable_scissor(); } if (current->tab_count > 0) { @@ -1681,10 +1681,10 @@ bool _ui_window(ui_handle_t *handle, int x, int y, int w, int h, bool drag) { current->tab_count = 0; if (theme->FILL_WINDOW_BG) { - kinc_g5_clear(theme->WINDOW_BG_COL, 0, KINC_G5_CLEAR_COLOR); + iron_g5_clear(theme->WINDOW_BG_COL, 0, IRON_G5_CLEAR_COLOR); } else { - kinc_g5_clear(0x00000000, 0, KINC_G5_CLEAR_COLOR); + iron_g5_clear(0x00000000, 0, IRON_G5_CLEAR_COLOR); draw_set_color(theme->WINDOW_BG_COL); draw_filled_rect(current->_x, current->_y - handle->scroll_offset, handle->last_max_x, handle->last_max_y); } @@ -1709,7 +1709,7 @@ bool _ui_window(ui_handle_t *handle, int x, int y, int w, int h, bool drag) { return true; } -bool ui_button(char *text, int align, char *label/*, kinc_g5_texture_t *icon, int sx, int sy, int sw, int sh*/) { +bool ui_button(char *text, int align, char *label/*, iron_g5_texture_t *icon, int sx, int sy, int sw, int sh*/) { if (!ui_is_visible(UI_ELEMENT_H())) { ui_end_element(); return false; @@ -1843,22 +1843,22 @@ bool ui_panel(ui_handle_t *handle, char *text, bool is_tree, bool filled) { } static int image_width(void *image) { - return ((kinc_g5_texture_t *)image)->width; + return ((iron_g5_texture_t *)image)->width; } static int image_height(void *image) { - return ((kinc_g5_texture_t *)image)->height; + return ((iron_g5_texture_t *)image)->height; } static void _draw_scaled_image(void *image, float dx, float dy, float dw, float dh) { - draw_scaled_texture((kinc_g5_texture_t *)image, dx, dy, dw, dh); + draw_scaled_texture((iron_g5_texture_t *)image, dx, dy, dw, dh); } static void _draw_scaled_sub_image(void *image, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { - draw_scaled_sub_texture((kinc_g5_texture_t *)image, sx, sy, sw, sh, dx, dy, dw, dh); + draw_scaled_sub_texture((iron_g5_texture_t *)image, sx, sy, sw, sh, dx, dy, dw, dh); } -int ui_sub_image(kinc_g5_texture_t *image, uint32_t tint, int h, int sx, int sy, int sw, int sh) { +int ui_sub_image(iron_g5_texture_t *image, uint32_t tint, int h, int sx, int sy, int sw, int sh) { float iw = (sw > 0 ? sw : image_width(image)) * UI_SCALE(); float ih = (sh > 0 ? sh : image_height(image)) * UI_SCALE(); float w = fmin(iw, current->_w); @@ -1929,7 +1929,7 @@ int ui_sub_image(kinc_g5_texture_t *image, uint32_t tint, int h, int sx, int sy, return started ? UI_STATE_STARTED : released ? UI_STATE_RELEASED : down ? UI_STATE_DOWN : hover ? UI_STATE_HOVERED : UI_STATE_IDLE; } -int ui_image(kinc_g5_texture_t *image, uint32_t tint, int h) { +int ui_image(iron_g5_texture_t *image, uint32_t tint, int h) { return ui_sub_image(image, tint, h, 0, 0, image_width(image), image_height(image)); } @@ -2156,7 +2156,7 @@ float ui_slider(ui_handle_t *handle, char *text, float from, float to, bool fill handle->changed = false; } - #if !defined(KINC_ANDROID) && !defined(KINC_IOS) + #if !defined(IRON_ANDROID) && !defined(IRON_IOS) if (handle == current->scroll_handle && current->input_dx != 0) { // Scroll #else if (handle == current->scroll_handle) { // Scroll @@ -2240,7 +2240,7 @@ void ui_tooltip(char *text) { current->tooltip_y = current->_y + current->_window_y; } -void ui_tooltip_image(kinc_g5_texture_t *image, int max_width) { +void ui_tooltip_image(iron_g5_texture_t *image, int max_width) { current->tooltip_img = image; current->tooltip_img_max_width = max_width; current->tooltip_invert_y = current->image_invert_y; @@ -2281,8 +2281,8 @@ void ui_mouse_down(ui_t *ui, int button, int x, int y) { else { ui->input_started_r = ui->input_down_r = true; } - ui->input_started_time = kinc_time(); - #if defined(KINC_ANDROID) || defined(KINC_IOS) + ui->input_started_time = iron_time(); + #if defined(IRON_ANDROID) || defined(IRON_IOS) ui_set_input_position(ui, x, y); #endif ui->input_started_x = x; @@ -2290,7 +2290,7 @@ void ui_mouse_down(ui_t *ui, int button, int x, int y) { } void ui_mouse_move(ui_t *ui, int x, int y, int movement_x, int movement_y) { - #if !defined(KINC_ANDROID) && !defined(KINC_IOS) + #if !defined(IRON_ANDROID) && !defined(IRON_IOS) ui_set_input_position(ui, x, y); #endif } @@ -2329,7 +2329,7 @@ void ui_mouse_up(ui_t *ui, int button, int x, int y) { else { ui->input_down_r = false; } - #if defined(KINC_ANDROID) || defined(KINC_IOS) + #if defined(IRON_ANDROID) || defined(IRON_IOS) ui_set_input_position(ui, x, y); #endif ui_deselect_text(ui); @@ -2340,7 +2340,7 @@ void ui_mouse_wheel(ui_t *ui, int delta) { } void ui_pen_down(ui_t *ui, int x, int y, float pressure) { - #if defined(KINC_ANDROID) || defined(KINC_IOS) + #if defined(IRON_ANDROID) || defined(IRON_IOS) return; #endif @@ -2348,7 +2348,7 @@ void ui_pen_down(ui_t *ui, int x, int y, float pressure) { } void ui_pen_up(ui_t *ui, int x, int y, float pressure) { - #if defined(KINC_ANDROID) || defined(KINC_IOS) + #if defined(IRON_ANDROID) || defined(IRON_IOS) return; #endif @@ -2362,7 +2362,7 @@ void ui_pen_up(ui_t *ui, int x, int y, float pressure) { } void ui_pen_move(ui_t *ui, int x, int y, float pressure) { - #if defined(KINC_IOS) + #if defined(IRON_IOS) // Listen to pen hover if no other input is active if (pressure == 0.0) { if (!ui->input_down && !ui->input_down_r) { @@ -2372,7 +2372,7 @@ void ui_pen_move(ui_t *ui, int x, int y, float pressure) { } #endif - #if defined(KINC_ANDROID) || defined(KINC_IOS) + #if defined(IRON_ANDROID) || defined(IRON_IOS) return; #endif @@ -2383,23 +2383,23 @@ void ui_key_down(ui_t *ui, int key_code) { ui->key_code = key_code; ui->is_key_pressed = true; ui->is_key_down = true; - ui_key_repeat_time = kinc_time() + 0.4; + ui_key_repeat_time = iron_time() + 0.4; switch (key_code) { - case KINC_KEY_SHIFT: ui->is_shift_down = true; break; - case KINC_KEY_CONTROL: ui->is_ctrl_down = true; break; - #ifdef KINC_DARWIN - case KINC_KEY_META: ui->is_ctrl_down = true; break; + case IRON_KEY_SHIFT: ui->is_shift_down = true; break; + case IRON_KEY_CONTROL: ui->is_ctrl_down = true; break; + #ifdef IRON_DARWIN + case IRON_KEY_META: ui->is_ctrl_down = true; break; #endif - case KINC_KEY_ALT: ui->is_alt_down = true; break; - case KINC_KEY_BACKSPACE: ui->is_backspace_down = true; break; - case KINC_KEY_DELETE: ui->is_delete_down = true; break; - case KINC_KEY_ESCAPE: ui->is_escape_down = true; break; - case KINC_KEY_RETURN: ui->is_return_down = true; break; - case KINC_KEY_TAB: ui->is_tab_down = true; break; - case KINC_KEY_A: ui->is_a_down = true; break; - case KINC_KEY_SPACE: ui->key_char = ' '; break; + case IRON_KEY_ALT: ui->is_alt_down = true; break; + case IRON_KEY_BACKSPACE: ui->is_backspace_down = true; break; + case IRON_KEY_DELETE: ui->is_delete_down = true; break; + case IRON_KEY_ESCAPE: ui->is_escape_down = true; break; + case IRON_KEY_RETURN: ui->is_return_down = true; break; + case IRON_KEY_TAB: ui->is_tab_down = true; break; + case IRON_KEY_A: ui->is_a_down = true; break; + case IRON_KEY_SPACE: ui->key_char = ' '; break; #ifdef UI_ANDROID_RMB // Detect right mouse button on Android.. - case KINC_KEY_BACK: if (!ui->input_down_r) ui_mouse_down(ui, 1, ui->input_x, ui->input_y); break; + case IRON_KEY_BACK: if (!ui->input_down_r) ui_mouse_down(ui, 1, ui->input_x, ui->input_y); break; #endif } } @@ -2407,20 +2407,20 @@ void ui_key_down(ui_t *ui, int key_code) { void ui_key_up(ui_t *ui, int key_code) { ui->is_key_down = false; switch (key_code) { - case KINC_KEY_SHIFT: ui->is_shift_down = false; break; - case KINC_KEY_CONTROL: ui->is_ctrl_down = false; break; - #ifdef KINC_DARWIN - case KINC_KEY_META: ui->is_ctrl_down = false; break; + case IRON_KEY_SHIFT: ui->is_shift_down = false; break; + case IRON_KEY_CONTROL: ui->is_ctrl_down = false; break; + #ifdef IRON_DARWIN + case IRON_KEY_META: ui->is_ctrl_down = false; break; #endif - case KINC_KEY_ALT: ui->is_alt_down = false; break; - case KINC_KEY_BACKSPACE: ui->is_backspace_down = false; break; - case KINC_KEY_DELETE: ui->is_delete_down = false; break; - case KINC_KEY_ESCAPE: ui->is_escape_down = false; break; - case KINC_KEY_RETURN: ui->is_return_down = false; break; - case KINC_KEY_TAB: ui->is_tab_down = false; break; - case KINC_KEY_A: ui->is_a_down = false; break; + case IRON_KEY_ALT: ui->is_alt_down = false; break; + case IRON_KEY_BACKSPACE: ui->is_backspace_down = false; break; + case IRON_KEY_DELETE: ui->is_delete_down = false; break; + case IRON_KEY_ESCAPE: ui->is_escape_down = false; break; + case IRON_KEY_RETURN: ui->is_return_down = false; break; + case IRON_KEY_TAB: ui->is_tab_down = false; break; + case IRON_KEY_A: ui->is_a_down = false; break; #ifdef UI_ANDROID_RMB - case KINC_KEY_BACK: ui_mouse_down(ui, 1, ui->input_x, ui->input_y); break; + case IRON_KEY_BACK: ui_mouse_down(ui, 1, ui->input_x, ui->input_y); break; #endif } } @@ -2430,7 +2430,7 @@ void ui_key_press(ui_t *ui, unsigned key_char) { ui->is_key_pressed = true; } -#if defined(KINC_ANDROID) || defined(KINC_IOS) +#if defined(IRON_ANDROID) || defined(IRON_IOS) static float ui_pinch_distance = 0.0; static float ui_pinch_total = 0.0; static bool ui_pinch_started = false; @@ -2622,7 +2622,7 @@ char *ui_file_browser(ui_handle_t *handle, bool folders_only) { char cmd[64]; strcpy(cmd, "ls "); - const char *system_id = kinc_system_id(); + const char *system_id = iron_system_id(); if (strcmp(system_id, "Windows") == 0) { strcpy(cmd, "dir /b "); if (folders_only) { @@ -2637,7 +2637,7 @@ char *ui_file_browser(ui_handle_t *handle, bool folders_only) { } char save[256]; - strcpy(save, kinc_internal_get_files_location()); + strcpy(save, iron_internal_get_files_location()); strcat(save, sep); strcat(save, data_path); strcat(save, "dir.txt"); @@ -2652,15 +2652,15 @@ char *ui_file_browser(ui_handle_t *handle, bool folders_only) { } strcpy(last_path, handle->text); - kinc_file_reader_t reader; - if (!kinc_file_reader_open(&reader, save, KINC_FILE_TYPE_ASSET)) { + iron_file_reader_t reader; + if (!iron_file_reader_open(&reader, save, IRON_FILE_TYPE_ASSET)) { return NULL; } - int reader_size = (int)kinc_file_reader_size(&reader); + int reader_size = (int)iron_file_reader_size(&reader); char str[2048]; // reader_size - kinc_file_reader_read(&reader, str, reader_size); - kinc_file_reader_close(&reader); + iron_file_reader_read(&reader, str, reader_size); + iron_file_reader_close(&reader); // Up directory int i1 = strstr(handle->text, "/") - handle->text; @@ -3163,7 +3163,7 @@ char *ui_text_area(ui_handle_t *handle, int align, bool editable, char *label, b strcpy(handle->text, line); current->submit_text_handle = NULL; ui_text_input(handle, show_label ? label : "", align, editable, false); - if (key_pressed && current->key_code != KINC_KEY_RETURN && current->key_code != KINC_KEY_ESCAPE) { // Edit text + if (key_pressed && current->key_code != IRON_KEY_RETURN && current->key_code != IRON_KEY_ESCAPE) { // Edit text int line_pos = ui_line_pos(lines, i); ui_remove_chars_at(lines, line_pos, strlen(line)); strcpy(line, current->text_selected); @@ -3203,18 +3203,18 @@ char *ui_text_area(ui_handle_t *handle, int align, bool editable, char *label, b if (key_pressed) { // Move cursor vertically - if (current->key_code == KINC_KEY_DOWN && handle->position < line_count - 1) { + if (current->key_code == IRON_KEY_DOWN && handle->position < line_count - 1) { handle_line_select(current, handle); handle->position++; scroll_align(current, handle); } - if (current->key_code == KINC_KEY_UP && handle->position > 0) { + if (current->key_code == IRON_KEY_UP && handle->position > 0) { handle_line_select(current, handle); handle->position--; scroll_align(current, handle); } // New line - if (editable && current->key_code == KINC_KEY_RETURN && !word_wrap) { + if (editable && current->key_code == IRON_KEY_RETURN && !word_wrap) { handle->position++; ui_insert_char_at(lines, ui_line_pos(lines, handle->position - 1) + current->cursor_x, '\n'); ui_start_text_edit(handle, UI_ALIGN_LEFT); @@ -3222,7 +3222,7 @@ char *ui_text_area(ui_handle_t *handle, int align, bool editable, char *label, b scroll_align(current, handle); } // Delete line - if (editable && current->key_code == KINC_KEY_BACKSPACE && cursor_start_x == 0 && handle->position > 0) { + if (editable && current->key_code == IRON_KEY_BACKSPACE && cursor_start_x == 0 && handle->position > 0) { handle->position--; current->cursor_x = current->highlight_anchor = strlen(ui_extract_line(lines, handle->position)); ui_remove_chars_at(lines, ui_line_pos(lines, handle->position + 1) - 1, 1); // Remove '\n' of the previous line diff --git a/base/sources/iron_ui.h b/base/sources/iron_ui.h index e6395422..f9cd0e1c 100644 --- a/base/sources/iron_ui.h +++ b/base/sources/iron_ui.h @@ -56,8 +56,8 @@ typedef struct ui_options { draw_font_t *font; ui_theme_t *theme; float scale_factor; - kinc_g5_texture_t *color_wheel; - kinc_g5_texture_t *black_white_gradient; + iron_g5_texture_t *color_wheel; + iron_g5_texture_t *black_white_gradient; } ui_options_t; typedef struct ui_handle_array { @@ -72,7 +72,7 @@ typedef struct ui_handle { uint32_t color; float value; char *text; - kinc_g5_texture_t texture; + iron_g5_texture_t texture; int redraws; float scroll_offset; bool scroll_enabled; @@ -232,7 +232,7 @@ typedef struct ui { int combo_to_submit; int combo_initial_value; char tooltip_text[512]; - kinc_g5_texture_t *tooltip_img; + iron_g5_texture_t *tooltip_img; int tooltip_img_max_width; bool tooltip_invert_y; float tooltip_x; @@ -251,11 +251,11 @@ typedef struct ui { bool scissor; bool elements_baked; - kinc_g5_texture_t check_select_image; - kinc_g5_texture_t radio_image; - kinc_g5_texture_t radio_select_image; - kinc_g5_texture_t round_corner_image; - kinc_g5_texture_t filled_round_corner_image; + iron_g5_texture_t check_select_image; + iron_g5_texture_t radio_image; + iron_g5_texture_t radio_select_image; + iron_g5_texture_t round_corner_image; + iron_g5_texture_t filled_round_corner_image; } ui_t; void ui_init(ui_t *ui, ui_options_t *ops); @@ -269,8 +269,8 @@ bool ui_button(char *text, int align, char *label); int ui_text(char *text, int align, int bg); bool ui_tab(ui_handle_t *handle, char *text, bool vertical, uint32_t color); bool ui_panel(ui_handle_t *handle, char *text, bool is_tree, bool filled); -int ui_sub_image(kinc_g5_texture_t *image, uint32_t tint, int h, int sx, int sy, int sw, int sh); -int ui_image(kinc_g5_texture_t *image, uint32_t tint, int h); +int ui_sub_image(iron_g5_texture_t *image, uint32_t tint, int h, int sx, int sy, int sw, int sh); +int ui_image(iron_g5_texture_t *image, uint32_t tint, int h); char *ui_text_input(ui_handle_t *handle, char *label, int align, bool editable, bool live_update); bool ui_check(ui_handle_t *handle, char *text, char *label); bool ui_radio(ui_handle_t *handle, int position, char *text, char *label); @@ -279,7 +279,7 @@ float ui_slider(ui_handle_t *handle, char *text, float from, float to, bool fill void ui_row(f32_array_t *ratios); void ui_separator(int h, bool fill); void ui_tooltip(char *text); -void ui_tooltip_image(kinc_g5_texture_t *image, int max_width); +void ui_tooltip_image(iron_g5_texture_t *image, int max_width); void _ui_end(bool last); void ui_end_window(bool bind_global_g); char *ui_hovered_tab_name(); @@ -294,7 +294,7 @@ void ui_pen_move(ui_t *ui, int x, int y, float pressure); void ui_key_down(ui_t *ui, int key_code); void ui_key_up(ui_t *ui, int key_code); void ui_key_press(ui_t *ui, unsigned character); -#if defined(KINC_ANDROID) || defined(KINC_IOS) +#if defined(IRON_ANDROID) || defined(IRON_IOS) void ui_touch_down(ui_t *ui, int index, int x, int y); void ui_touch_up(ui_t *ui, int index, int x, int y); void ui_touch_move(ui_t *ui, int index, int x, int y); diff --git a/base/sources/iron_ui_nodes.c b/base/sources/iron_ui_nodes.c index 260d8f6a..de81d179 100644 --- a/base/sources/iron_ui_nodes.c +++ b/base/sources/iron_ui_nodes.c @@ -14,7 +14,7 @@ static ui_nodes_t *current_nodes = NULL; static bool ui_nodes_elements_baked = false; -static kinc_g5_texture_t ui_socket_image; +static iron_g5_texture_t ui_socket_image; static bool ui_box_select = false; static int ui_box_select_x = 0; static int ui_box_select_y = 0; @@ -236,11 +236,11 @@ int ui_get_socket_id(ui_node_array_t *nodes) { void ui_nodes_bake_elements() { if (ui_socket_image.width != 0) { - kinc_g5_texture_destroy(&ui_socket_image); + iron_g5_texture_destroy(&ui_socket_image); } - kinc_g5_render_target_init(&ui_socket_image, 24, 24, KINC_IMAGE_FORMAT_RGBA32, 0); + iron_g5_render_target_init(&ui_socket_image, 24, 24, IRON_IMAGE_FORMAT_RGBA32, 0); draw_set_render_target(&ui_socket_image); - kinc_g5_clear(0x00000000, 0, KINC_G5_CLEAR_COLOR); + iron_g5_clear(0x00000000, 0, IRON_G5_CLEAR_COLOR); draw_set_color(0xff111111); draw_filled_circle(12, 12, 11, 0); @@ -1225,7 +1225,7 @@ void ui_node_canvas(ui_nodes_t *nodes, ui_node_canvas_t *canvas) { } // Select all nodes - if (current->is_ctrl_down && current->key_code == KINC_KEY_A && !current->is_typing) { + if (current->is_ctrl_down && current->key_code == IRON_KEY_A && !current->is_typing) { current_nodes->nodes_selected_id->length = 0; for (int i = 0; i < canvas->nodes->length; ++i) { add_to_selection(canvas->nodes->buffer[i]); diff --git a/base/sources/iron_vec4.h b/base/sources/iron_vec4.h index 0412d9fe..81b9760d 100644 --- a/base/sources/iron_vec4.h +++ b/base/sources/iron_vec4.h @@ -1,11 +1,11 @@ #pragma once -#define mat4_t kinc_matrix4x4_t -#define mat3_t kinc_matrix3x3_t -#define quat_t kinc_quaternion_t -#define vec4_t kinc_vector4_t -#define vec3_t kinc_vector3_t -#define vec2_t kinc_vector2_t +#define mat4_t iron_matrix4x4_t +#define mat3_t iron_matrix3x3_t +#define quat_t iron_quaternion_t +#define vec4_t iron_vector4_t +#define vec3_t iron_vector3_t +#define vec2_t iron_vector2_t #include #include "iron_mat4.h" diff --git a/base/sources/iron_video.h b/base/sources/iron_video.h index c6619118..f39a5742 100644 --- a/base/sources/iron_video.h +++ b/base/sources/iron_video.h @@ -4,22 +4,22 @@ // #include // #include BACKEND_VIDEO_H -// typedef struct kinc_video { -// kinc_video_impl_t impl; -// } kinc_video_t; +// typedef struct iron_video { +// iron_video_impl_t impl; +// } iron_video_t; -// const char **kinc_video_formats(void); +// const char **iron_video_formats(void); -// void kinc_video_init(kinc_video_t *video, const char *filename); -// void kinc_video_destroy(kinc_video_t *video); -// void kinc_video_play(kinc_video_t *video, bool loop); -// void kinc_video_pause(kinc_video_t *video); -// void kinc_video_stop(kinc_video_t *video); -// int kinc_video_width(kinc_video_t *video); -// int kinc_video_height(kinc_video_t *video); -// kinc_g5_texture_t *kinc_video_current_image(kinc_video_t *video); -// double kinc_video_duration(kinc_video_t *video); -// double kinc_video_position(kinc_video_t *video); -// bool kinc_video_finished(kinc_video_t *video); -// bool kinc_video_paused(kinc_video_t *video); -// void kinc_video_update(kinc_video_t *video, double time); +// void iron_video_init(iron_video_t *video, const char *filename); +// void iron_video_destroy(iron_video_t *video); +// void iron_video_play(iron_video_t *video, bool loop); +// void iron_video_pause(iron_video_t *video); +// void iron_video_stop(iron_video_t *video); +// int iron_video_width(iron_video_t *video); +// int iron_video_height(iron_video_t *video); +// iron_g5_texture_t *iron_video_current_image(iron_video_t *video); +// double iron_video_duration(iron_video_t *video); +// double iron_video_position(iron_video_t *video); +// bool iron_video_finished(iron_video_t *video); +// bool iron_video_paused(iron_video_t *video); +// void iron_video_update(iron_video_t *video, double time); diff --git a/base/sources/libs/gc.c b/base/sources/libs/gc.c index 19e0bdf2..680be637 100644 --- a/base/sources/libs/gc.c +++ b/base/sources/libs/gc.c @@ -494,9 +494,9 @@ size_t _gc_stop() { } size_t _gc_run() { - // double t = kinc_time(); + // double t = iron_time(); gc_mark(); size_t collected = gc_sweep(); - // kinc_log("gc took %fms, freed %db.\n", (kinc_time() - t) * 1000, collected); + // iron_log("gc took %fms, freed %db.\n", (iron_time() - t) * 1000, collected); return collected; } diff --git a/base/sources/libs/miniclib/license.txt b/base/sources/libs/miniclib/license.txt index 4d2ae2a5..a6d6a312 100644 --- a/base/sources/libs/miniclib/license.txt +++ b/base/sources/libs/miniclib/license.txt @@ -1,4 +1,4 @@ -Copyright (c) 2024 the Kinc Development Team +Copyright (c) 2024 the Kore Development Team This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/base/sources/libs/miniclib/math.c b/base/sources/libs/miniclib/math.c index 6efc3d05..04c0ab4e 100644 --- a/base/sources/libs/miniclib/math.c +++ b/base/sources/libs/miniclib/math.c @@ -1,6 +1,6 @@ #include "math.h" -#ifdef KINC_WASM +#ifdef IRON_WASM __attribute__((import_module("imports"), import_name("js_pow"))) float js_pow(float base, float exponent); __attribute__((import_module("imports"), import_name("js_floor"))) float js_floor(float x); __attribute__((import_module("imports"), import_name("js_sin"))) float js_sin(float x); @@ -16,84 +16,84 @@ double ldexp(double x, int exp) { } double pow(double base, double exponent) { -#ifdef KINC_WASM +#ifdef IRON_WASM return js_pow(base, exponent); #endif return 0.0; } double floor(double x) { -#ifdef KINC_WASM +#ifdef IRON_WASM return js_floor(x); #endif return 0.0; } float floorf(float x) { -#ifdef KINC_WASM +#ifdef IRON_WASM return js_floor(x); #endif return 0.0f; } double sin(double x) { -#ifdef KINC_WASM +#ifdef IRON_WASM return js_sin(x); #endif return 0.0; } float sinf(float x) { -#ifdef KINC_WASM +#ifdef IRON_WASM return js_sin(x); #endif return 0.0f; } double cos(double x) { -#ifdef KINC_WASM +#ifdef IRON_WASM return js_cos(x); #endif return 0.0; } float cosf(float x) { -#ifdef KINC_WASM +#ifdef IRON_WASM return js_cos(x); #endif return 0.0f; } double tan(double x) { -#ifdef KINC_WASM +#ifdef IRON_WASM return js_tan(x); #endif return 0.0; } float tanf(float x) { -#ifdef KINC_WASM +#ifdef IRON_WASM return js_tan(x); #endif return 0.0f; } double log(double x) { -#ifdef KINC_WASM +#ifdef IRON_WASM return js_log(x); #endif return 0.0; } double exp(double x) { -#ifdef KINC_WASM +#ifdef IRON_WASM return js_exp(x); #endif return 0.0; } double sqrt(double x) { -#ifdef KINC_WASM +#ifdef IRON_WASM return js_sqrt(x); #endif return 0.0; diff --git a/base/sources/libs/miniclib/memory.c b/base/sources/libs/miniclib/memory.c index ce4d68f6..6ff448d5 100644 --- a/base/sources/libs/miniclib/memory.c +++ b/base/sources/libs/miniclib/memory.c @@ -1,6 +1,6 @@ #include "stdlib.h" -#ifdef KINC_WASM +#ifdef IRON_WASM __attribute__((import_module("imports"), import_name("js_fprintf"))) void js_fprintf(const char *format); #define HEAP_SIZE 1024 * 1024 * 8 @@ -8,11 +8,11 @@ static unsigned char heap[HEAP_SIZE]; static size_t heap_top = 4; #endif -#ifdef KINC_WASM -__attribute__((export_name("malloc"))) +#ifdef IRON_WASM +__attribute__((export_name("malloc"))) #endif void *malloc(size_t size) { -#ifdef KINC_WASM +#ifdef IRON_WASM // Align to 4 bytes to make js typed arrays work if (size % 4 != 0) { size += 4 - size % 4; diff --git a/base/sources/libs/miniclib/stdio.c b/base/sources/libs/miniclib/stdio.c index 875b4b1a..caf67dda 100644 --- a/base/sources/libs/miniclib/stdio.c +++ b/base/sources/libs/miniclib/stdio.c @@ -1,6 +1,6 @@ #include "stdio.h" -#ifdef KINC_WASM +#ifdef IRON_WASM __attribute__((import_module("imports"), import_name("js_fprintf"))) void js_fprintf(const char *format); __attribute__((import_module("imports"), import_name("js_fopen"))) FILE *js_fopen(const char *filename); __attribute__((import_module("imports"), import_name("js_ftell"))) long int js_ftell(FILE *stream); @@ -11,7 +11,7 @@ __attribute__((import_module("imports"), import_name("js_fread"))) size_t js_fre FILE *stdout = NULL, *stderr = NULL; int fprintf(FILE *stream, const char *format, ...) { -#ifdef KINC_WASM +#ifdef IRON_WASM js_fprintf(format); #endif return 0; @@ -26,7 +26,7 @@ size_t fwrite(const void *ptr, size_t size, size_t count, FILE *stream) { } FILE *fopen(const char *filename, const char *mode) { -#ifdef KINC_WASM +#ifdef IRON_WASM return js_fopen(filename); #endif return NULL; @@ -37,21 +37,21 @@ int fclose(FILE *stream) { } long int ftell(FILE *stream) { -#ifdef KINC_WASM +#ifdef IRON_WASM return js_ftell(stream); #endif return 0; } int fseek(FILE *stream, long int offset, int origin) { -#ifdef KINC_WASM +#ifdef IRON_WASM return js_fseek(stream, offset, origin); #endif return 0; } size_t fread(void *ptr, size_t size, size_t count, FILE *stream) { -#ifdef KINC_WASM +#ifdef IRON_WASM return js_fread(ptr, size, count, stream); #endif return 0; diff --git a/base/sources/libs/stb_image.h b/base/sources/libs/stb_image.h index 2ec15349..1a357d30 100644 --- a/base/sources/libs/stb_image.h +++ b/base/sources/libs/stb_image.h @@ -589,7 +589,7 @@ typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; #endif #ifdef _MSC_VER -#ifndef KINC_NO_CLIB +#ifndef IRON_NO_CLIB #define STBI_HAS_LROTL #endif #endif diff --git a/base/sources/ts/args.ts b/base/sources/ts/args.ts index 2f6fba13..08df7196 100644 --- a/base/sources/ts/args.ts +++ b/base/sources/ts/args.ts @@ -126,11 +126,11 @@ function args_run() { }); } else { - kinc_log(tr("Invalid export directory")); + iron_log(tr("Invalid export directory")); } } else { - kinc_log(tr("Invalid texture type")); + iron_log(tr("Invalid texture type")); } } @@ -143,7 +143,7 @@ function args_run() { export_mesh_run(args_export_mesh_path + path_sep + f, null, false); } else { - kinc_log(tr("Invalid export directory")); + iron_log(tr("Invalid export directory")); } } @@ -153,7 +153,7 @@ function args_run() { } if (args_background) { - kinc_stop(); + iron_stop(); } }); } diff --git a/base/sources/ts/base.ts b/base/sources/ts/base.ts index c296fa33..202cee38 100644 --- a/base/sources/ts/base.ts +++ b/base/sources/ts/base.ts @@ -5,7 +5,7 @@ let base_is_resizing: bool = false; let base_drag_asset: asset_t = null; let base_drag_swatch: swatch_color_t = null; let base_drag_file: string = null; -let base_drag_file_icon: kinc_g5_texture_t = null; +let base_drag_file_icon: iron_g5_texture_t = null; let base_drag_tint: i32 = 0xffffffff; let base_drag_size: i32 = -1; let base_drag_rect: rect_t = null; @@ -16,8 +16,8 @@ let base_drop_x: f32 = 0.0; let base_drop_y: f32 = 0.0; let base_font: draw_font_t = null; let base_theme: ui_theme_t; -let base_color_wheel: kinc_g5_texture_t; -let base_color_wheel_gradient: kinc_g5_texture_t; +let base_color_wheel: iron_g5_texture_t; +let base_color_wheel_gradient: iron_g5_texture_t; let base_ui_box: ui_t; let base_ui_menu: ui_t; let base_default_element_w: i32 = 100; @@ -36,8 +36,8 @@ let base_default_fov: f32 = 0.69; let _base_material_count: i32; function base_init() { - base_last_window_width = kinc_window_width(); - base_last_window_height = kinc_window_height(); + base_last_window_width = iron_window_width(); + base_last_window_height = iron_window_height(); sys_notify_on_drop_files(function (drop_path: string) { ///if arm_linux @@ -70,8 +70,8 @@ function base_init() { iron_set_save_and_quit_callback(base_save_and_quit_callback); let font: draw_font_t = data_get_font("font.ttf"); - let image_color_wheel: kinc_g5_texture_t = data_get_image("color_wheel.k"); - let image_color_wheel_gradient: kinc_g5_texture_t = data_get_image("color_wheel_gradient.k"); + let image_color_wheel: iron_g5_texture_t = data_get_image("color_wheel.k"); + let image_color_wheel_gradient: iron_g5_texture_t = data_get_image("color_wheel_gradient.k"); base_font = font; config_load_theme(config_raw.theme, false); @@ -156,7 +156,7 @@ function base_save_and_quit_callback(save: bool) { project_save(true); } else { - kinc_stop(); + iron_stop(); } } @@ -174,16 +174,16 @@ function base_w(): i32 { let res: i32 = 0; if (config_raw.layout == null) { let sidebarw: i32 = ui_base_default_sidebar_w; - res = kinc_window_width() - sidebarw - ui_toolbar_default_w; + res = iron_window_width() - sidebarw - ui_toolbar_default_w; } else if (ui_nodes_show || ui_view2d_show) { - res = kinc_window_width() - config_raw.layout[layout_size_t.SIDEBAR_W] - config_raw.layout[layout_size_t.NODES_W] - ui_toolbar_w; + res = iron_window_width() - config_raw.layout[layout_size_t.SIDEBAR_W] - config_raw.layout[layout_size_t.NODES_W] - ui_toolbar_w; } else if (ui_base_show) { - res = kinc_window_width() - config_raw.layout[layout_size_t.SIDEBAR_W] - ui_toolbar_w; + res = iron_window_width() - config_raw.layout[layout_size_t.SIDEBAR_W] - ui_toolbar_w; } else { // Distract free - res = kinc_window_width(); + res = iron_window_width(); } if (context_raw.view_index > -1) { res = math_floor(res / 2); @@ -206,7 +206,7 @@ function base_h(): i32 { return util_render_decal_preview_size; } - let res: i32 = kinc_window_height(); + let res: i32 = iron_window_height(); if (config_raw.layout == null) { res -= ui_header_default_h * 2 + ui_status_default_status_h; @@ -235,33 +235,33 @@ function base_y(): i32 { } function base_on_resize() { - if (kinc_window_width() == 0 || kinc_window_height() == 0) { + if (iron_window_width() == 0 || iron_window_height() == 0) { return; } - let ratio_w: f32 = kinc_window_width() / base_last_window_width; - base_last_window_width = kinc_window_width(); - let ratio_h: f32 = kinc_window_height() / base_last_window_height; - base_last_window_height = kinc_window_height(); + let ratio_w: f32 = iron_window_width() / base_last_window_width; + base_last_window_width = iron_window_width(); + let ratio_h: f32 = iron_window_height() / base_last_window_height; + base_last_window_height = iron_window_height(); config_raw.layout[layout_size_t.NODES_W] = math_floor(config_raw.layout[layout_size_t.NODES_W] * ratio_w); config_raw.layout[layout_size_t.SIDEBAR_H0] = math_floor(config_raw.layout[layout_size_t.SIDEBAR_H0] * ratio_h); - config_raw.layout[layout_size_t.SIDEBAR_H1] = kinc_window_height() - config_raw.layout[layout_size_t.SIDEBAR_H0]; + config_raw.layout[layout_size_t.SIDEBAR_H1] = iron_window_height() - config_raw.layout[layout_size_t.SIDEBAR_H0]; base_resize(); base_save_window_rect(); } function base_save_window_rect() { - config_raw.window_w = kinc_window_width(); - config_raw.window_h = kinc_window_height(); - config_raw.window_x = kinc_window_x(); - config_raw.window_y = kinc_window_y(); + config_raw.window_w = iron_window_width(); + config_raw.window_h = iron_window_height(); + config_raw.window_x = iron_window_x(); + config_raw.window_y = iron_window_y(); config_save(); } function base_resize() { - if (kinc_window_width() == 0 || kinc_window_height() == 0) { + if (iron_window_width() == 0 || iron_window_height() == 0) { return; } @@ -367,7 +367,7 @@ function base_update() { } else if (context_in_viewport()) { if (ends_with(to_lower_case(base_drag_asset.file), ".hdr")) { - let image: kinc_g5_texture_t = project_get_image(base_drag_asset); + let image: iron_g5_texture_t = project_get_image(base_drag_asset); import_envmap_run(base_drag_asset.file, image); } } @@ -504,14 +504,14 @@ function base_handle_drop_paths() { } function base_get_drag_background(): rect_t { - let icons: kinc_g5_texture_t = resource_get("icons.k"); + let icons: iron_g5_texture_t = resource_get("icons.k"); if (base_drag_layer != null && !slot_layer_is_group(base_drag_layer) && base_drag_layer.fill_layer == null) { return resource_tile50(icons, 4, 1); } return null; } -function base_get_drag_image(): kinc_g5_texture_t { +function base_get_drag_image(): iron_g5_texture_t { base_drag_tint = 0xffffffff; base_drag_size = -1; base_drag_rect = null; @@ -527,7 +527,7 @@ function base_get_drag_image(): kinc_g5_texture_t { if (base_drag_file_icon != null) { return base_drag_file_icon; } - let icons: kinc_g5_texture_t = resource_get("icons.k"); + let icons: iron_g5_texture_t = resource_get("icons.k"); base_drag_rect = string_index_of(base_drag_file, ".") > 0 ? resource_tile50(icons, 3, 1) : resource_tile50(icons, 2, 1); base_drag_tint = ui_base_ui.ops.theme.HIGHLIGHT_COL; return icons; @@ -537,7 +537,7 @@ function base_get_drag_image(): kinc_g5_texture_t { return base_drag_material.image_icon; } if (base_drag_layer != null && slot_layer_is_group(base_drag_layer)) { - let icons: kinc_g5_texture_t = resource_get("icons.k"); + let icons: iron_g5_texture_t = resource_get("icons.k"); let folder_closed: rect_t = resource_tile50(icons, 2, 1); let folder_open: rect_t = resource_tile50(icons, 8, 1); base_drag_rect = base_drag_layer.show_panel ? folder_open : folder_closed; @@ -556,7 +556,7 @@ function base_get_drag_image(): kinc_g5_texture_t { } function base_render() { - if (kinc_window_width() == 0 || kinc_window_height() == 0) { + if (iron_window_width() == 0 || iron_window_height() == 0) { return; } @@ -585,7 +585,7 @@ function base_render() { if (base_is_dragging) { iron_set_mouse_cursor(1); // Hand - let img: kinc_g5_texture_t = base_get_drag_image(); + let img: iron_g5_texture_t = base_get_drag_image(); let scale_factor: f32 = ui_SCALE(ui_base_ui); let size: f32 = (base_drag_size == -1 ? 50 : base_drag_size) * scale_factor; let ratio: f32 = size / img.width; @@ -675,17 +675,17 @@ function base_get_asset_index(file_name: string): i32 { } function base_toggle_fullscreen() { - if (kinc_window_get_mode() == window_mode_t.WINDOWED) { - config_raw.window_w = kinc_window_width(); - config_raw.window_h = kinc_window_height(); - config_raw.window_x = kinc_window_x(); - config_raw.window_y = kinc_window_y(); + if (iron_window_get_mode() == window_mode_t.WINDOWED) { + config_raw.window_w = iron_window_width(); + config_raw.window_h = iron_window_height(); + config_raw.window_x = iron_window_x(); + config_raw.window_y = iron_window_y(); iron_set_window_mode(window_mode_t.FULLSCREEN); } else { iron_set_window_mode(window_mode_t.WINDOWED); - kinc_window_resize(config_raw.window_w, config_raw.window_h); - kinc_window_move(config_raw.window_x, config_raw.window_y); + iron_window_resize(config_raw.window_w, config_raw.window_h); + iron_window_move(config_raw.window_x, config_raw.window_y); } } @@ -752,8 +752,8 @@ function base_init_layout() { let new_layout: i32[] = []; array_push(new_layout, math_floor(ui_base_default_sidebar_w * raw.window_scale)); // LayoutSidebarW - array_push(new_layout, math_floor(kinc_window_height() / 2)); // LayoutSidebarH0 - array_push(new_layout, math_floor(kinc_window_height() / 2)); // LayoutSidebarH1 + array_push(new_layout, math_floor(iron_window_height() / 2)); // LayoutSidebarH0 + array_push(new_layout, math_floor(iron_window_height() / 2)); // LayoutSidebarH1 ///if arm_ios array_push(new_layout, show2d ? math_floor((app_w() + raw.layout[layout_size_t.NODES_W]) * 0.473) : math_floor(app_w() * 0.473)); // LayoutNodesW diff --git a/base/sources/ts/box_preferences.ts b/base/sources/ts/box_preferences.ts index 0a0ff648..1a0a35e7 100644 --- a/base/sources/ts/box_preferences.ts +++ b/base/sources/ts/box_preferences.ts @@ -325,7 +325,7 @@ function box_preferences_show() { config_raw.undo_steps = math_floor(context_raw.undo_handle.value = 1); } if (context_raw.undo_handle.changed) { - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; g2_end(); if (history_undo_layers != null) { diff --git a/base/sources/ts/box_projects.ts b/base/sources/ts/box_projects.ts index 9583c296..774a6ab0 100644 --- a/base/sources/ts/box_projects.ts +++ b/base/sources/ts/box_projects.ts @@ -1,7 +1,7 @@ let box_projects_htab: ui_handle_t = ui_handle_create(); let box_projects_hsearch: ui_handle_t = ui_handle_create(); -let box_projects_icon_map: map_t = null; +let box_projects_icon_map: map_t = null; let _box_projects_path: string; let _box_projects_icon_path: string; @@ -69,7 +69,7 @@ function box_projects_tab(ui: ui_t) { ui_separator(3, false); let slotw: i32 = math_floor(150 * ui_SCALE(ui)); - let num: i32 = math_floor(kinc_window_width() / slotw); + let num: i32 = math_floor(iron_window_width() / slotw); if (num == 0) { return; } @@ -113,9 +113,9 @@ function box_projects_tab(ui: ui_t) { if (box_projects_icon_map == null) { box_projects_icon_map = map_create(); } - let icon: kinc_g5_texture_t = map_get(box_projects_icon_map, icon_path); + let icon: iron_g5_texture_t = map_get(box_projects_icon_map, icon_path); if (icon == null) { - let image: kinc_g5_texture_t = data_get_image(icon_path); + let image: iron_g5_texture_t = data_get_image(icon_path); icon = image; map_set(box_projects_icon_map, icon_path, icon); } @@ -209,7 +209,7 @@ function box_projects_recent_tab(ui: ui_t) { } if (ui_button(file, ui_align_t.LEFT) && file_exists(path)) { - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); @@ -241,7 +241,7 @@ function box_projects_recent_tab(ui: ui_t) { } function box_projects_draw_badge(ui: ui_t) { - let img: kinc_g5_texture_t = data_get_image("badge.k"); + let img: iron_g5_texture_t = data_get_image("badge.k"); _ui_image(img); _ui_end_element(); } @@ -261,10 +261,10 @@ function box_projects_get_started_tab(ui: ui_t) { } function box_projects_align_to_fullscreen() { - ui_box_modalw = math_floor(kinc_window_width() / ui_SCALE(base_ui_box)); - ui_box_modalh = math_floor(kinc_window_height() / ui_SCALE(base_ui_box)); - let appw: i32 = kinc_window_width(); - let apph: i32 = kinc_window_height(); + ui_box_modalw = math_floor(iron_window_width() / ui_SCALE(base_ui_box)); + ui_box_modalh = math_floor(iron_window_height() / ui_SCALE(base_ui_box)); + let appw: i32 = iron_window_width(); + let apph: i32 = iron_window_height(); let mw: i32 = appw; let mh: i32 = apph; ui_box_hwnd.drag_x = math_floor(-appw / 2 + mw / 2); diff --git a/base/sources/ts/camera.ts b/base/sources/ts/camera.ts index e060cfc3..206fc283 100644 --- a/base/sources/ts/camera.ts +++ b/base/sources/ts/camera.ts @@ -21,19 +21,19 @@ function camera_update() { if (config_raw.wrap_mouse && camera_controls_down) { if (mouse_view_x() < 0) { mouse_x = mouse_last_x = app_x() + app_w(); - kinc_mouse_set_position(math_floor(mouse_x), math_floor(mouse_y)); + iron_mouse_set_position(math_floor(mouse_x), math_floor(mouse_y)); } else if (mouse_view_x() > app_w()) { mouse_x = mouse_last_x = app_x(); - kinc_mouse_set_position(math_floor(mouse_x), math_floor(mouse_y)); + iron_mouse_set_position(math_floor(mouse_x), math_floor(mouse_y)); } else if (mouse_view_y() < 0) { mouse_y = mouse_last_y = app_y() + app_h(); - kinc_mouse_set_position(math_floor(mouse_x), math_floor(mouse_y)); + iron_mouse_set_position(math_floor(mouse_x), math_floor(mouse_y)); } else if (mouse_view_y() > app_h()) { mouse_y = mouse_last_y = app_y(); - kinc_mouse_set_position(math_floor(mouse_x), math_floor(mouse_y)); + iron_mouse_set_position(math_floor(mouse_x), math_floor(mouse_y)); } } else { diff --git a/base/sources/ts/config.ts b/base/sources/ts/config.ts index 054c2daa..4a95e516 100644 --- a/base/sources/ts/config.ts +++ b/base/sources/ts/config.ts @@ -9,14 +9,14 @@ let config_button_spacing: string = config_default_button_spacing; function config_load() { let path: string = ""; if (path_is_protected()) { - path += kinc_internal_save_path(); + path += iron_internal_save_path(); } path += "config.json"; let blob: buffer_t = data_get_blob(path); ///if arm_linux if (blob == null) { // Protected directory - blob = data_get_blob(kinc_internal_save_path() + "config.json"); + blob = data_get_blob(iron_internal_save_path() + "config.json"); } ///end @@ -31,7 +31,7 @@ function config_save() { // when running from protected path like "Program Files" let path: string = ""; if (path_is_protected()) { - path += kinc_internal_save_path(); + path += iron_internal_save_path(); } else { path += path_data(); @@ -108,7 +108,7 @@ function config_save() { ///if arm_linux // Protected directory if (!file_exists(path)) { - iron_file_save_bytes(kinc_internal_save_path() + "config.json", buffer, 0); + iron_file_save_bytes(iron_internal_save_path() + "config.json", buffer, 0); } ///end } @@ -191,7 +191,7 @@ function config_get_date(): string { return v.date; } -function config_get_options(): kinc_window_options_t { +function config_get_options(): iron_window_options_t { let window_mode: window_mode_t = config_raw.window_mode == 0 ? window_mode_t.WINDOWED : window_mode_t.FULLSCREEN; let features: window_features_t = window_features_t.NONE; if (config_raw.window_resizable) { @@ -204,7 +204,7 @@ function config_get_options(): kinc_window_options_t { features |= window_features_t.MINIMIZABLE; } let title: string = "untitled - " + manifest_title; - let ops: kinc_window_options_t = { + let ops: iron_window_options_t = { title: title, width: config_raw.window_w, height: config_raw.window_h, @@ -253,7 +253,7 @@ function config_apply() { config_save(); context_raw.ddirty = 2; - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); render_path_base_apply_config(); diff --git a/base/sources/ts/console.ts b/base/sources/ts/console.ts index a3b8fc20..77b181f0 100644 --- a/base/sources/ts/console.ts +++ b/base/sources/ts/console.ts @@ -7,10 +7,10 @@ let console_progress_text: string = null; function console_draw_toast(s: string) { draw_set_color(0x55000000); - draw_filled_rect(0, 0, kinc_window_width(), kinc_window_height()); + draw_filled_rect(0, 0, iron_window_width(), iron_window_height()); let scale: f32 = ui_SCALE(base_get_uis()[0]); - let x: f32 = kinc_window_width() / 2; - let y: f32 = kinc_window_height() - 200 * scale; + let x: f32 = iron_window_width() / 2; + let y: f32 = iron_window_height() - 200 * scale; draw_filled_rect(x - 200 * scale, y, 400 * scale, 80 * scale); g2_set_font(base_font, math_floor(22 * scale)); draw_set_color(0xffffffff); @@ -78,7 +78,7 @@ function console_log(s: string) { } function console_trace(s: string) { - kinc_log(s); + iron_log(s); base_redraw_console(); array_insert(console_last_traces, 0, s); if (console_last_traces.length > 100) { diff --git a/base/sources/ts/context.ts b/base/sources/ts/context.ts index bb33e740..e93aa8b0 100644 --- a/base/sources/ts/context.ts +++ b/base/sources/ts/context.ts @@ -20,11 +20,11 @@ type context_t = { color_picker_callback?: (sc: swatch_color_t)=>void; default_irradiance?: f32_array_t; - default_radiance?: kinc_g5_texture_t; - default_radiance_mipmaps?: kinc_g5_texture_t[]; - saved_envmap?: kinc_g5_texture_t; - empty_envmap?: kinc_g5_texture_t; - preview_envmap?: kinc_g5_texture_t; + default_radiance?: iron_g5_texture_t; + default_radiance_mipmaps?: iron_g5_texture_t[]; + saved_envmap?: iron_g5_texture_t; + empty_envmap?: iron_g5_texture_t; + preview_envmap?: iron_g5_texture_t; envmap_loaded?: bool; show_envmap?: bool; show_envmap_handle?: ui_handle_t; @@ -105,11 +105,11 @@ type context_t = { layer_preview_dirty?: bool; layers_preview_dirty?: bool; node_preview_dirty?: bool; - node_preview?: kinc_g5_texture_t; - node_previews?: map_t; + node_preview?: iron_g5_texture_t; + node_previews?: map_t; node_previews_used?: string[]; node_preview_name?: string; - mask_preview_rgba32?: kinc_g5_texture_t; + mask_preview_rgba32?: iron_g5_texture_t; mask_preview_last?: slot_layer_t; colorid_picked?: bool; @@ -138,7 +138,7 @@ type context_t = { colorid_handle?: ui_handle_t; layers_export?: export_mode_t; - decal_image?: kinc_g5_texture_t; + decal_image?: iron_g5_texture_t; decal_preview?: bool; decal_x?: f32; decal_y?: f32; @@ -146,7 +146,7 @@ type context_t = { cache_draws?: bool; write_icon_on_export?: bool; - text_tool_image?: kinc_g5_texture_t; + text_tool_image?: iron_g5_texture_t; text_tool_text?: string; particle_material?: material_data_t; @@ -181,9 +181,9 @@ type context_t = { brush_nodes_radius?: f32; brush_nodes_opacity?: f32; - brush_mask_image?: kinc_g5_texture_t; + brush_mask_image?: iron_g5_texture_t; brush_mask_image_is_alpha?: bool; - brush_stencil_image?: kinc_g5_texture_t; + brush_stencil_image?: iron_g5_texture_t; brush_stencil_image_is_alpha?: bool; brush_stencil_x?: f32; brush_stencil_y?: f32; @@ -543,7 +543,7 @@ function context_set_layer(l: slot_layer_t) { context_raw.layer = l; ui_header_handle.redraws = 2; - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); diff --git a/base/sources/ts/export_arm.ts b/base/sources/ts/export_arm.ts index f23eb2cd..b0e0bafc 100644 --- a/base/sources/ts/export_arm.ts +++ b/base/sources/ts/export_arm.ts @@ -174,8 +174,8 @@ function export_arm_run_project() { ///if (arm_android || arm_ios) let rt: render_target_t = map_get(render_path_render_targets, context_raw.render_mode == render_mode_t.FORWARD ? "buf" : "tex"); - let tex: kinc_g5_texture_t = rt._image; - let mesh_icon: kinc_g5_texture_t = iron_g4_create_render_target(256, 256); + let tex: iron_g5_texture_t = rt._image; + let mesh_icon: iron_g5_texture_t = iron_g4_create_render_target(256, 256); let r: f32 = app_w() / app_h(); g2_begin(mesh_icon); draw_scaled_image(tex, -(256 * r - 256) / 2, 0, 256 * r, 256); @@ -196,7 +196,7 @@ function export_arm_run_project() { export_arm_bgra_swap(mesh_icon_pixels); ///end - app_notify_on_next_frame(function (mesh_icon: kinc_g5_texture_t) { + app_notify_on_next_frame(function (mesh_icon: iron_g5_texture_t) { iron_unload_image(mesh_icon); }); @@ -483,11 +483,11 @@ function export_arm_pack_assets(raw: project_format_t, assets: asset_t[]) { if (raw.packed_assets == null) { raw.packed_assets = []; } - let temp_images: kinc_g5_texture_t[] = []; + let temp_images: iron_g5_texture_t[] = []; for (let i: i32 = 0; i < assets.length; ++i) { if (!project_packed_asset_exists(raw.packed_assets, assets[i].file)) { - let image: kinc_g5_texture_t = project_get_image(assets[i]); - let temp: kinc_g5_texture_t = iron_g4_create_render_target(image.width, image.height); + let image: iron_g5_texture_t = project_get_image(assets[i]); + let temp: iron_g5_texture_t = iron_g4_create_render_target(image.width, image.height); g2_begin(temp); draw_image(image, 0, 0); g2_end(); @@ -501,9 +501,9 @@ function export_arm_pack_assets(raw: project_format_t, assets: asset_t[]) { array_push(raw.packed_assets, pa); } } - app_notify_on_next_frame(function (temp_images: kinc_g5_texture_t[]) { + app_notify_on_next_frame(function (temp_images: iron_g5_texture_t[]) { for (let i: i32 = 0; i < temp_images.length; ++i) { - let image: kinc_g5_texture_t = temp_images[i]; + let image: iron_g5_texture_t = temp_images[i]; iron_unload_image(image); } }, temp_images); diff --git a/base/sources/ts/export_texture.ts b/base/sources/ts/export_texture.ts index fed9f40c..9ad43e8d 100644 --- a/base/sources/ts/export_texture.ts +++ b/base/sources/ts/export_texture.ts @@ -178,7 +178,7 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ layers_make_temp_img(); layers_make_export_img(); let rt: render_target_t = map_get(render_path_render_targets, "empty_white"); - let empty: kinc_g5_texture_t = rt._image; + let empty: iron_g5_texture_t = rt._image; // Append object mask name let export_selected: bool = context_raw.layers_export == export_mode_t.SELECTED; @@ -190,15 +190,15 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ } // Clear export layer - iron_g4_begin(layers_expa); - kinc_g5_clear(color_from_floats(0.0, 0.0, 0.0, 0.0)); - iron_g4_end(); - iron_g4_begin(layers_expb); - kinc_g5_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); - iron_g4_end(); - iron_g4_begin(layers_expc); - kinc_g5_clear(color_from_floats(1.0, 0.0, 0.0, 0.0)); - iron_g4_end(); + _iron_g4_begin(layers_expa); + iron_g5_clear(color_from_floats(0.0, 0.0, 0.0, 0.0)); + _iron_g4_end(); + _iron_g4_begin(layers_expb); + iron_g5_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); + _iron_g4_end(); + _iron_g4_begin(layers_expc); + iron_g5_clear(color_from_floats(1.0, 0.0, 0.0, 0.0)); + _iron_g4_end(); // Flatten layers for (let i: i32 = 0; i < layers.length; ++i) { @@ -220,13 +220,13 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ } } - let mask: kinc_g5_texture_t = empty; + let mask: iron_g5_texture_t = empty; let l1masks: slot_layer_t[] = slot_layer_get_masks(l1); if (l1masks != null && !bake_material) { if (l1masks.length > 1) { layers_make_temp_mask_img(); g2_begin(pipes_temp_mask_image); - kinc_g5_clear(0x00000000); + iron_g5_clear(0x00000000); g2_end(); let l1: slot_layer_t = { texpaint: pipes_temp_mask_image @@ -248,18 +248,18 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ draw_set_pipeline(null); g2_end(); - iron_g4_begin(layers_expa); - kinc_g5_set_pipeline(pipes_merge); - iron_g4_set_texture(pipes_tex0, l1.texpaint); - iron_g4_set_texture(pipes_tex1, empty); - iron_g4_set_texture(pipes_texmask, mask); - iron_g4_set_texture(pipes_texa, layers_temp_image); - iron_g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); - iron_g4_set_int(pipes_blending, layers.length > 1 ? l1.blending : 0); - kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); - kinc_g4_set_index_buffer(const_data_screen_aligned_ib); + _iron_g4_begin(layers_expa); + iron_g5_set_pipeline(pipes_merge); + _iron_g4_set_texture(pipes_tex0, l1.texpaint); + _iron_g4_set_texture(pipes_tex1, empty); + _iron_g4_set_texture(pipes_texmask, mask); + _iron_g4_set_texture(pipes_texa, layers_temp_image); + _iron_g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); + _iron_g4_set_int(pipes_blending, layers.length > 1 ? l1.blending : 0); + iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); + iron_g4_set_index_buffer(const_data_screen_aligned_ib); iron_g4_draw_indexed_vertices(); - iron_g4_end(); + _iron_g4_end(); } if (l1.paint_nor) { @@ -269,18 +269,18 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ draw_set_pipeline(null); g2_end(); - iron_g4_begin(layers_expb); - kinc_g5_set_pipeline(pipes_merge); - iron_g4_set_texture(pipes_tex0, l1.texpaint); - iron_g4_set_texture(pipes_tex1, l1.texpaint_nor); - iron_g4_set_texture(pipes_texmask, mask); - iron_g4_set_texture(pipes_texa, layers_temp_image); - iron_g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); - iron_g4_set_int(pipes_blending, l1.paint_nor_blend ? -2 : -1); - kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); - kinc_g4_set_index_buffer(const_data_screen_aligned_ib); + _iron_g4_begin(layers_expb); + iron_g5_set_pipeline(pipes_merge); + _iron_g4_set_texture(pipes_tex0, l1.texpaint); + _iron_g4_set_texture(pipes_tex1, l1.texpaint_nor); + _iron_g4_set_texture(pipes_texmask, mask); + _iron_g4_set_texture(pipes_texa, layers_temp_image); + _iron_g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); + _iron_g4_set_int(pipes_blending, l1.paint_nor_blend ? -2 : -1); + iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); + iron_g4_set_index_buffer(const_data_screen_aligned_ib); iron_g4_draw_indexed_vertices(); - iron_g4_end(); + _iron_g4_end(); } if (l1.paint_occ || l1.paint_rough || l1.paint_met || l1.paint_height) { @@ -312,9 +312,9 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ ///end ///end - let texpaint: kinc_g5_texture_t = layers_expa; - let texpaint_nor: kinc_g5_texture_t = layers_expb; - let texpaint_pack: kinc_g5_texture_t = layers_expc; + let texpaint: iron_g5_texture_t = layers_expa; + let texpaint_nor: iron_g5_texture_t = layers_expb; + let texpaint_pack: iron_g5_texture_t = layers_expc; ///if is_lab texpaint = context_raw.brush_output_node_inst.texpaint; @@ -464,7 +464,7 @@ function export_texture_write_texture(file: string, pixels: buffer_t, type: i32 } if (context_raw.layers_destination == export_destination_t.PACKED) { - let image: kinc_g5_texture_t = iron_g4_create_texture_from_bytes(pixels, res_x, res_y); + let image: iron_g5_texture_t = iron_g4_create_texture_from_bytes(pixels, res_x, res_y); map_set(data_cached_images, file, image); let ar: string[] = string_split(file, path_sep); let name: string = ar[ar.length - 1]; diff --git a/base/sources/ts/file.ts b/base/sources/ts/file.ts index 3d14c372..3f8563bd 100644 --- a/base/sources/ts/file.ts +++ b/base/sources/ts/file.ts @@ -97,7 +97,7 @@ function file_start(path: string) { } function file_load_url(url: string) { - kinc_load_url(url); + iron_load_url(url); } function file_delete(path: string) { @@ -112,7 +112,7 @@ function file_download(url: string, dst_path: string, done: (url: string)=>void, ///if (arm_windows || arm_macos || arm_ios || arm_android) let fdd: file_download_data_t = { dst_path: dst_path, done: done }; map_set(_file_download_map, url, fdd); - iron_http_request(url, size, function (url: string, ab: buffer_t) { + _iron_http_request(url, size, function (url: string, ab: buffer_t) { let fdd: file_download_data_t = map_get(_file_download_map, url); if (ab != null) { iron_file_save_bytes(fdd.dst_path, ab, 0); @@ -131,7 +131,7 @@ function file_download(url: string, dst_path: string, done: (url: string)=>void, function file_download_bytes(url: string, done: (url: string, ab: buffer_t)=>void) { let save: string; if (path_is_protected()) { - save = kinc_internal_save_path(); + save = iron_internal_save_path(); } else { save = path_data() + path_sep; @@ -155,7 +155,7 @@ function file_cache_cloud(path: string, done: (s: string)=>void) { ///end let dest: string; if (path_is_protected()) { - dest = kinc_internal_save_path(); + dest = iron_internal_save_path(); } else { dest = iron_get_files_location() + path_sep; @@ -168,7 +168,7 @@ function file_cache_cloud(path: string, done: (s: string)=>void) { ///else let p: string; if (path_is_protected()) { - p = kinc_internal_save_path(); + p = iron_internal_save_path(); } else { p = path_working_dir() + path_sep; @@ -203,7 +203,7 @@ function file_cache_cloud(path: string, done: (s: string)=>void) { ///else let p: string; if (path_is_protected()) { - p = kinc_internal_save_path(); + p = iron_internal_save_path(); } else { p = path_working_dir() + path_sep; diff --git a/base/sources/ts/import_arm.ts b/base/sources/ts/import_arm.ts index de0a3a7c..8afc43bb 100644 --- a/base/sources/ts/import_arm.ts +++ b/base/sources/ts/import_arm.ts @@ -186,7 +186,7 @@ function import_arm_run_project(path: string) { context_raw.merged_object.base.visible = true; ///if (is_paint || is_sculpt) - let tex: kinc_g5_texture_t = project_layers[0].texpaint; + let tex: iron_g5_texture_t = project_layers[0].texpaint; if (tex.width != config_get_texture_res_x() || tex.height != config_get_texture_res_y()) { if (history_undo_layers != null) { for (let i: i32 = 0; i < history_undo_layers.length; ++i) { @@ -196,16 +196,16 @@ function import_arm_run_project(path: string) { } let rts: map_t = render_path_render_targets; let blend0: render_target_t = map_get(rts, "texpaint_blend0"); - let _texpaint_blend0: kinc_g5_texture_t = blend0._image; - app_notify_on_next_frame(function (_texpaint_blend0: kinc_g5_texture_t) { + let _texpaint_blend0: iron_g5_texture_t = blend0._image; + app_notify_on_next_frame(function (_texpaint_blend0: iron_g5_texture_t) { iron_unload_image(_texpaint_blend0); }, _texpaint_blend0); blend0.width = config_get_texture_res_x(); blend0.height = config_get_texture_res_y(); blend0._image = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8, 0); let blend1: render_target_t = map_get(rts, "texpaint_blend1"); - let _texpaint_blend1: kinc_g5_texture_t = blend1._image; - app_notify_on_next_frame(function (_texpaint_blend1: kinc_g5_texture_t) { + let _texpaint_blend1: iron_g5_texture_t = blend1._image; + app_notify_on_next_frame(function (_texpaint_blend1: iron_g5_texture_t) { iron_unload_image(_texpaint_blend1); }, _texpaint_blend1); blend1.width = config_get_texture_res_x(); @@ -238,9 +238,9 @@ function import_arm_run_project(path: string) { array_push(project_layers, l); if (!is_group) { - let _texpaint: kinc_g5_texture_t = null; - let _texpaint_nor: kinc_g5_texture_t = null; - let _texpaint_pack: kinc_g5_texture_t = null; + let _texpaint: iron_g5_texture_t = null; + let _texpaint_nor: iron_g5_texture_t = null; + let _texpaint_pack: iron_g5_texture_t = null; if (is_mask) { _texpaint = iron_g4_create_texture_from_bytes(lz4_decode(ld.texpaint, ld.res * ld.res * 4), ld.res, ld.res, tex_format_t.RGBA32); @@ -301,18 +301,18 @@ function import_arm_run_project(path: string) { l.paint_subs = ld.paint_subs; ///end - app_notify_on_next_frame(function (_texpaint: kinc_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint: iron_g5_texture_t) { iron_unload_image(_texpaint); }, _texpaint); ///if is_paint if (_texpaint_nor != null) { - app_notify_on_next_frame(function (_texpaint_nor: kinc_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint_nor: iron_g5_texture_t) { iron_unload_image(_texpaint_nor); }, _texpaint_nor); } if (_texpaint_pack != null) { - app_notify_on_next_frame(function (_texpaint_pack: kinc_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint_pack: iron_g5_texture_t) { iron_unload_image(_texpaint_pack); }, _texpaint_pack); } @@ -633,7 +633,7 @@ function import_arm_make_pink(abs: string) { b[1] = 0; b[2] = 255; b[3] = 255; - let pink: kinc_g5_texture_t = iron_g4_create_texture_from_bytes(b, 1, 1); + let pink: iron_g5_texture_t = iron_g4_create_texture_from_bytes(b, 1, 1); map_set(data_cached_images, abs, pink); } @@ -674,7 +674,7 @@ function import_arm_unpack_asset(project: project_format_t, abs: string, file: s if (!project_packed_asset_exists(project_raw.packed_assets, pa.name)) { array_push(project_raw.packed_assets, pa); } - let image: kinc_g5_texture_t = iron_g4_create_texture_from_encoded_bytes(pa.bytes, ends_with(pa.name, ".jpg") ? ".jpg" : ".png"); + let image: iron_g5_texture_t = iron_g4_create_texture_from_encoded_bytes(pa.bytes, ends_with(pa.name, ".jpg") ? ".jpg" : ".png"); map_set(data_cached_images, abs, image); break; } diff --git a/base/sources/ts/import_blend_material.ts b/base/sources/ts/import_blend_material.ts index 0e81c346..e76d8f87 100644 --- a/base/sources/ts/import_blend_material.ts +++ b/base/sources/ts/import_blend_material.ts @@ -30,7 +30,7 @@ function import_blend_material_run(path: string) { function _import_blend_material() { - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); @@ -42,7 +42,7 @@ function _import_blend_material() { let save: string; if (path_is_protected()) { - save = kinc_internal_save_path(); + save = iron_internal_save_path(); } else { save = path_data(); diff --git a/base/sources/ts/import_blend_mesh.ts b/base/sources/ts/import_blend_mesh.ts index 1d3dbe4d..9b1e0e56 100644 --- a/base/sources/ts/import_blend_mesh.ts +++ b/base/sources/ts/import_blend_mesh.ts @@ -33,7 +33,7 @@ function import_blend_mesh_run(path: string, replace_existing: bool = true) { let save: string; if (path_is_protected()) { - save = kinc_internal_save_path(); + save = iron_internal_save_path(); } else { save = path_data(); diff --git a/base/sources/ts/import_envmap.ts b/base/sources/ts/import_envmap.ts index 2ab9689b..21f0364f 100644 --- a/base/sources/ts/import_envmap.ts +++ b/base/sources/ts/import_envmap.ts @@ -1,21 +1,21 @@ -let import_envmap_pipeline: kinc_g5_pipeline_t = null; -let import_envmap_params_loc: kinc_g5_constant_location_t; +let import_envmap_pipeline: iron_g5_pipeline_t = null; +let import_envmap_params_loc: iron_g5_constant_location_t; let import_envmap_params: vec4_t = vec4_create(); let import_envmap_n: vec4_t = vec4_create(); -let import_envmap_radiance_loc: kinc_g5_texture_unit_t; -let import_envmap_radiance: kinc_g5_texture_t = null; -let import_envmap_radiance_cpu: kinc_g5_texture_t = null; -let import_envmap_mips: kinc_g5_texture_t[] = null; -let import_envmap_mips_cpu: kinc_g5_texture_t[] = null; +let import_envmap_radiance_loc: iron_g5_texture_unit_t; +let import_envmap_radiance: iron_g5_texture_t = null; +let import_envmap_radiance_cpu: iron_g5_texture_t = null; +let import_envmap_mips: iron_g5_texture_t[] = null; +let import_envmap_mips_cpu: iron_g5_texture_t[] = null; -function import_envmap_run(path: string, image: kinc_g5_texture_t) { +function import_envmap_run(path: string, image: iron_g5_texture_t) { // Init if (import_envmap_pipeline == null) { import_envmap_pipeline = iron_g4_create_pipeline(); import_envmap_pipeline.vertex_shader = sys_get_shader("pass.vert"); import_envmap_pipeline.fragment_shader = sys_get_shader("prefilter_envmap.frag"); - let vs: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); import_envmap_pipeline.input_layout = vs; import_envmap_pipeline.color_attachment_count = 1; @@ -43,8 +43,8 @@ function import_envmap_run(path: string, image: kinc_g5_texture_t) { let radiance_pixels: buffer_t = iron_g4_get_texture_pixels(import_envmap_radiance); if (import_envmap_radiance_cpu != null) { - let _radiance_cpu: kinc_g5_texture_t = import_envmap_radiance_cpu; - app_notify_on_next_frame(function (_radiance_cpu: kinc_g5_texture_t) { + let _radiance_cpu: iron_g5_texture_t = import_envmap_radiance_cpu; + app_notify_on_next_frame(function (_radiance_cpu: iron_g5_texture_t) { iron_unload_image(_radiance_cpu); }, _radiance_cpu); } @@ -53,8 +53,8 @@ function import_envmap_run(path: string, image: kinc_g5_texture_t) { // Radiance if (import_envmap_mips_cpu != null) { for (let i: i32 = 0; i < import_envmap_mips_cpu.length; ++i) { - let mip: kinc_g5_texture_t = import_envmap_mips_cpu[i]; - app_notify_on_next_frame(function (mip: kinc_g5_texture_t) { + let mip: iron_g5_texture_t = import_envmap_mips_cpu[i]; + app_notify_on_next_frame(function (mip: iron_g5_texture_t) { ///if (!arm_direct3d12) // TODO: crashes after 50+ imports iron_unload_image(mip); ///end @@ -86,16 +86,16 @@ function import_envmap_run(path: string, image: kinc_g5_texture_t) { project_raw.envmap = path; } -function import_envmap_get_radiance_mip(mip: kinc_g5_texture_t, level: i32, radiance: kinc_g5_texture_t) { - iron_g4_begin(mip); - kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); - kinc_g4_set_index_buffer(const_data_screen_aligned_ib); - kinc_g5_set_pipeline(import_envmap_pipeline); +function import_envmap_get_radiance_mip(mip: iron_g5_texture_t, level: i32, radiance: iron_g5_texture_t) { + _iron_g4_begin(mip); + iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); + iron_g4_set_index_buffer(const_data_screen_aligned_ib); + iron_g5_set_pipeline(import_envmap_pipeline); import_envmap_params.x = 0.1 + level / 8; - iron_g4_set_float4(import_envmap_params_loc, import_envmap_params.x, import_envmap_params.y, import_envmap_params.z, import_envmap_params.w); - iron_g4_set_texture(import_envmap_radiance_loc, radiance); + _iron_g4_set_float4(import_envmap_params_loc, import_envmap_params.x, import_envmap_params.y, import_envmap_params.z, import_envmap_params.w); + _iron_g4_set_texture(import_envmap_radiance_loc, radiance); iron_g4_draw_indexed_vertices(); - iron_g4_end(); + _iron_g4_end(); } function import_envmap_reverse_equirect(x: f32, y: f32): vec4_t { diff --git a/base/sources/ts/import_texture.ts b/base/sources/ts/import_texture.ts index 76da6f69..72bc08a8 100644 --- a/base/sources/ts/import_texture.ts +++ b/base/sources/ts/import_texture.ts @@ -1,7 +1,7 @@ type import_texture_data_t = { path: string; - image: kinc_g5_texture_t; + image: iron_g5_texture_t; }; function import_texture_run(path: string, hdr_as_envmap: bool = true) { @@ -18,7 +18,7 @@ function import_texture_run(path: string, hdr_as_envmap: bool = true) { if (a.file == path) { // Set as envmap if (hdr_as_envmap && ends_with(to_lower_case(path), ".hdr")) { - let image: kinc_g5_texture_t = data_get_image(path); + let image: iron_g5_texture_t = data_get_image(path); let itd: import_texture_data_t = { path: path, image: image }; app_notify_on_next_frame(function (itd: import_texture_data_t) { // Make sure file browser process did finish import_envmap_run(itd.path, itd.image); @@ -30,9 +30,9 @@ function import_texture_run(path: string, hdr_as_envmap: bool = true) { } let ext: string = substring(path, string_last_index_of(path, ".") + 1, path.length); - let importer: any = map_get(path_texture_importers, ext); // JSValue -> (s: string)=>kinc_g5_texture_t + let importer: any = map_get(path_texture_importers, ext); // JSValue -> (s: string)=>iron_g5_texture_t let cached: bool = map_get(data_cached_images, path) != null; // Already loaded or pink texture for missing file - let image: kinc_g5_texture_t; + let image: iron_g5_texture_t; if (importer == null || cached) { image = import_texture_default_importer(path); } @@ -62,6 +62,6 @@ function import_texture_run(path: string, hdr_as_envmap: bool = true) { } } -function import_texture_default_importer(path: string): kinc_g5_texture_t { +function import_texture_default_importer(path: string): iron_g5_texture_t { return data_get_image(path); } diff --git a/base/sources/ts/iron/app.ts b/base/sources/ts/iron/app.ts index 01b36289..c9ab9c3d 100644 --- a/base/sources/ts/iron/app.ts +++ b/base/sources/ts/iron/app.ts @@ -24,14 +24,14 @@ function app_w(): i32 { if (app_on_w != null) { return app_on_w(); } - return kinc_window_width(); + return iron_window_width(); } function app_h(): i32 { if (app_on_h != null) { return app_on_h(); } - return kinc_window_height(); + return iron_window_height(); } function app_x(): i32 { diff --git a/base/sources/ts/iron/audio.ts b/base/sources/ts/iron/audio.ts index 40fa0c81..9ab649f3 100644 --- a/base/sources/ts/iron/audio.ts +++ b/base/sources/ts/iron/audio.ts @@ -2,11 +2,11 @@ ///if arm_audio function audio_play(sound: sound_t, loop: bool = false, pitch: f32 = 1.0, unique: bool = false): audio_channel_t { - return kinc_a1_play_sound(sound.sound_, loop, pitch, unique); + return iron_a1_play_sound(sound.sound_, loop, pitch, unique); } function audio_stop(sound: sound_t) { - kinc_a1_stop_sound(sound.sound_); + iron_a1_stop_sound(sound.sound_); } ///end diff --git a/base/sources/ts/iron/camera_data.ts b/base/sources/ts/iron/camera_data.ts index fa1d3571..9be0e032 100644 --- a/base/sources/ts/iron/camera_data.ts +++ b/base/sources/ts/iron/camera_data.ts @@ -3,7 +3,7 @@ function camera_data_parse(name: string, id: string): camera_data_t { let format: scene_t = data_get_scene_raw(name); let raw: camera_data_t = camera_data_get_raw_by_name(format.camera_datas, id); if (raw == null) { - kinc_log("Camera data '" + id + "' not found!"); + iron_log("Camera data '" + id + "' not found!"); } return raw; } diff --git a/base/sources/ts/iron/const_data.ts b/base/sources/ts/iron/const_data.ts index 666a1661..1b3cab34 100644 --- a/base/sources/ts/iron/const_data.ts +++ b/base/sources/ts/iron/const_data.ts @@ -1,8 +1,8 @@ -let const_data_screen_aligned_vb: kinc_g5_vertex_buffer_t = null; -let const_data_screen_aligned_ib: kinc_g5_index_buffer_t = null; -let const_data_skydome_vb: kinc_g5_vertex_buffer_t = null; -let const_data_skydome_ib: kinc_g5_index_buffer_t = null; +let const_data_screen_aligned_vb: iron_g5_vertex_buffer_t = null; +let const_data_screen_aligned_ib: iron_g5_index_buffer_t = null; +let const_data_skydome_vb: iron_g5_vertex_buffer_t = null; +let const_data_skydome_ib: iron_g5_index_buffer_t = null; function const_data_create_screen_aligned_data() { // Over-sized triangle @@ -10,21 +10,21 @@ function const_data_create_screen_aligned_data() { let indices: i32[] = [0, 1, 2]; // Mandatory vertex data names and sizes - let structure: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let structure: iron_g5_vertex_structure_t = g4_vertex_struct_create(); g4_vertex_struct_add(structure, "pos", vertex_data_t.F32_2X); - const_data_screen_aligned_vb = iron_g4_create_vertex_buffer(math_floor(data.length / math_floor(kinc_g5_vertex_struct_size(structure) / 4)), structure, usage_t.STATIC); + const_data_screen_aligned_vb = iron_g4_create_vertex_buffer(math_floor(data.length / math_floor(iron_g5_vertex_struct_size(structure) / 4)), structure, usage_t.STATIC); let vertices: buffer_t = iron_g4_lock_vertex_buffer(const_data_screen_aligned_vb); for (let i: i32 = 0; i < math_floor((vertices.length) / 4); ++i) { buffer_set_f32(vertices, i * 4, data[i]); } - kinc_g4_vertex_buffer_unlock_all(const_data_screen_aligned_vb); + iron_g4_vertex_buffer_unlock_all(const_data_screen_aligned_vb); const_data_screen_aligned_ib = iron_g4_create_index_buffer(indices.length); let id: u32_array_t = iron_g4_lock_index_buffer(const_data_screen_aligned_ib); for (let i: i32 = 0; i < id.length; ++i) { id[i] = indices[i]; } - kinc_g4_index_buffer_unlock_all(const_data_screen_aligned_ib); + iron_g4_index_buffer_unlock_all(const_data_screen_aligned_ib); } ///include "const_data.h" @@ -36,10 +36,10 @@ declare let _const_data_skydome_nor: f32_ptr; declare let _const_data_skydome_nor_count: i32; function const_data_create_skydome_data() { - let structure: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let structure: iron_g5_vertex_structure_t = g4_vertex_struct_create(); g4_vertex_struct_add(structure, "pos", vertex_data_t.F32_3X); g4_vertex_struct_add(structure, "nor", vertex_data_t.F32_3X); - let struct_length: i32 = math_floor(kinc_g5_vertex_struct_size(structure) / 4); + let struct_length: i32 = math_floor(iron_g5_vertex_struct_size(structure) / 4); const_data_skydome_vb = iron_g4_create_vertex_buffer(math_floor(_const_data_skydome_pos_count / 3), structure, usage_t.STATIC); let vertices: buffer_t = iron_g4_lock_vertex_buffer(const_data_skydome_vb); for (let i: i32 = 0; i < math_floor((vertices.length) / 4 / struct_length); ++i) { @@ -50,12 +50,12 @@ function const_data_create_skydome_data() { buffer_set_f32(vertices, (i * struct_length + 4) * 4, ARRAY_ACCESS(_const_data_skydome_nor, i * 3 + 1)); buffer_set_f32(vertices, (i * struct_length + 5) * 4, ARRAY_ACCESS(_const_data_skydome_nor, i * 3 + 2)); } - kinc_g4_vertex_buffer_unlock_all(const_data_skydome_vb); + iron_g4_vertex_buffer_unlock_all(const_data_skydome_vb); const_data_skydome_ib = iron_g4_create_index_buffer(_const_data_skydome_indices_count); let id: u32_array_t = iron_g4_lock_index_buffer(const_data_skydome_ib); for (let i: i32 = 0; i < id.length; ++i) { id[i] = ARRAY_ACCESS(_const_data_skydome_indices, i); } - kinc_g4_index_buffer_unlock_all(const_data_skydome_ib); + iron_g4_index_buffer_unlock_all(const_data_skydome_ib); } diff --git a/base/sources/ts/iron/data.ts b/base/sources/ts/iron/data.ts index 12ec052d..077a1766 100644 --- a/base/sources/ts/iron/data.ts +++ b/base/sources/ts/iron/data.ts @@ -8,7 +8,7 @@ let data_cached_worlds: map_t = map_create(); let data_cached_shaders: map_t = map_create(); let data_cached_blobs: map_t = map_create(); -let data_cached_images: map_t = map_create(); +let data_cached_images: map_t = map_create(); let data_cached_videos: map_t = map_create(); let data_cached_fonts: map_t = map_create(); ///if arm_audio @@ -109,8 +109,8 @@ function data_get_blob(file: string): buffer_t { return b; } -function data_get_image(file: string, readable: bool = false): kinc_g5_texture_t { - let cached: kinc_g5_texture_t = map_get(data_cached_images, file); +function data_get_image(file: string, readable: bool = false): iron_g5_texture_t { + let cached: iron_g5_texture_t = map_get(data_cached_images, file); if (cached != null) { return cached; } @@ -120,7 +120,7 @@ function data_get_image(file: string, readable: bool = false): kinc_g5_texture_t return null; } - let b: kinc_g5_texture_t = image_; + let b: iron_g5_texture_t = image_; map_set(data_cached_images, file, b); data_assets_loaded++; return b; @@ -185,7 +185,7 @@ function data_delete_blob(handle: string) { } function data_delete_image(handle: string) { - let image: kinc_g5_texture_t = map_get(data_cached_images, handle); + let image: iron_g5_texture_t = map_get(data_cached_images, handle); if (image == null) { return; } @@ -246,7 +246,7 @@ function data_delete_all() { let cached_images_keys: string[] = map_keys(data_cached_images); for (let i: i32 = 0; i < cached_images_keys.length; ++i) { - let c: kinc_g5_texture_t = map_get(data_cached_images, cached_images_keys[i]); + let c: iron_g5_texture_t = map_get(data_cached_images, cached_images_keys[i]); iron_unload_image(c); } data_cached_images = map_create(); diff --git a/base/sources/ts/iron/g2.ts b/base/sources/ts/iron/g2.ts index 4a005702..12047557 100644 --- a/base/sources/ts/iron/g2.ts +++ b/base/sources/ts/iron/g2.ts @@ -11,7 +11,7 @@ declare type draw_font_t = { index?: i32; }; -let _g2_current: kinc_g5_texture_t = null; +let _g2_current: iron_g5_texture_t = null; let _g2_in_use: bool = false; let _g2_font_glyphs: i32[] = _g2_make_glyphs(32, 127); let _g2_font_glyphs_last: i32[] = _g2_font_glyphs; @@ -50,10 +50,10 @@ function _g2_make_glyphs(start: i32, end: i32): i32[] { return ar; } -function g2_begin(render_target: kinc_g5_texture_t = null) { +function g2_begin(render_target: iron_g5_texture_t = null) { if (_g2_in_use && !_g2_thrown) { _g2_thrown = true; - kinc_log("End before you begin"); + iron_log("End before you begin"); } _g2_in_use = true; _g2_current = render_target; @@ -71,7 +71,7 @@ function g2_begin(render_target: kinc_g5_texture_t = null) { function g2_end() { if (!_g2_in_use && !_g2_thrown) { _g2_thrown = true; - kinc_log("Begin before you end"); + iron_log("Begin before you end"); } _g2_in_use = false; _g2_current = null; diff --git a/base/sources/ts/iron/input.ts b/base/sources/ts/iron/input.ts index 45837eae..8d8eefa1 100644 --- a/base/sources/ts/iron/input.ts +++ b/base/sources/ts/iron/input.ts @@ -94,16 +94,16 @@ function mouse_released(button: string = "left"): bool { } function mouse_lock() { - if (kinc_mouse_can_lock()) { - kinc_mouse_lock(); + if (iron_mouse_can_lock()) { + iron_mouse_lock(); mouse_locked = true; mouse_hidden = true; } } function mouse_unlock() { - if (kinc_mouse_can_lock()) { - kinc_mouse_unlock(); + if (iron_mouse_can_lock()) { + iron_mouse_unlock(); mouse_locked = false; mouse_hidden = false; } diff --git a/base/sources/ts/iron/iron.ts b/base/sources/ts/iron/iron.ts index ffa494c7..995aae30 100644 --- a/base/sources/ts/iron/iron.ts +++ b/base/sources/ts/iron/iron.ts @@ -180,12 +180,12 @@ declare function color_set_gb(c: i32, i: u8): i32; declare function color_set_bb(c: i32, i: u8): i32; declare function color_set_ab(c: i32, i: u8): i32; -declare function iron_init(ops: kinc_window_options_t): void; -declare function kinc_set_app_name(name: string): void; -declare function kinc_log(v: any): void; -declare function kinc_g5_clear(color: i32, depth: f32 = 0.0, flags: i32 = clear_flag_t.COLOR): void; -declare function iron_set_update_callback(callback: ()=>void): void; -declare function iron_set_drop_files_callback(callback: (file: string)=>void): void; +declare function _iron_init(ops: iron_window_options_t): void; +declare function iron_set_app_name(name: string): void; +declare function iron_log(v: any): void; +declare function iron_g5_clear(color: i32, depth: f32 = 0.0, flags: i32 = clear_flag_t.COLOR): void; +declare function _iron_set_update_callback(callback: ()=>void): void; +declare function _iron_set_drop_files_callback(callback: (file: string)=>void): void; declare function iron_set_cut_copy_paste_callback(on_cut: ()=>string, on_copy: ()=>string, on_paste: (text: string)=>void): void; declare function iron_set_application_state_callback(on_foreground: ()=>void, on_resume: ()=>void, on_pause: ()=>void, on_background: ()=>void, on_shutdown: ()=>void): void; declare function iron_set_keyboard_down_callback(callback: (code: i32)=>void): void; @@ -203,70 +203,70 @@ declare function iron_set_pen_up_callback(callback: (x: i32, y: i32, pressure: f declare function iron_set_pen_move_callback(callback: (x: i32, y: i32, pressure: f32)=>void): void; declare function iron_set_gamepad_axis_callback(callback: (gamepad: i32, axis: i32, value: f32)=>void): void; declare function iron_set_gamepad_button_callback(callback: (gamepad: i32, button: i32, value: f32)=>void): void; -declare function kinc_mouse_lock(): void; -declare function kinc_mouse_unlock(): void; -declare function kinc_mouse_can_lock(): bool; -declare function kinc_mouse_is_locked(): bool; -declare function kinc_mouse_set_position(x: i32, y: i32): void; +declare function iron_mouse_lock(): void; +declare function iron_mouse_unlock(): void; +declare function iron_mouse_can_lock(): bool; +declare function iron_mouse_is_locked(): bool; +declare function iron_mouse_set_position(x: i32, y: i32): void; declare function iron_show_mouse(show: bool): void; declare function iron_show_keyboard(show: bool): void; declare function iron_g4_create_index_buffer(count: i32): any; declare function iron_g4_delete_index_buffer(buffer: any): void; declare function iron_g4_lock_index_buffer(buffer: any): u32_array_t; -declare function kinc_g4_index_buffer_unlock_all(buffer: any): void; -declare function kinc_g4_set_index_buffer(buffer: any): void; -declare function iron_g4_create_vertex_buffer(count: i32, structure: kinc_g5_vertex_structure_t, usage: i32): any; +declare function iron_g4_index_buffer_unlock_all(buffer: any): void; +declare function iron_g4_set_index_buffer(buffer: any): void; +declare function iron_g4_create_vertex_buffer(count: i32, structure: iron_g5_vertex_structure_t, usage: i32): any; declare function iron_g4_delete_vertex_buffer(buffer: any): void; declare function iron_g4_lock_vertex_buffer(buffer: any): buffer_t; -declare function kinc_g4_vertex_buffer_unlock_all(buffer: any): void; -declare function kinc_g4_set_vertex_buffer(buffer: any): void; +declare function iron_g4_vertex_buffer_unlock_all(buffer: any): void; +declare function iron_g4_set_vertex_buffer(buffer: any): void; declare function iron_g4_draw_indexed_vertices(start: i32 = 0, count: i32 = -1): void; -declare function iron_g4_create_shader(data: buffer_t, type: i32): kinc_g5_shader_t; -declare function iron_g4_create_shader_from_source(source: string, shader_type: shader_type_t): kinc_g5_shader_t; -declare function kinc_g5_shader_destroy(shader: kinc_g5_shader_t): void; +declare function iron_g4_create_shader(data: buffer_t, type: i32): iron_g5_shader_t; +declare function iron_g4_create_shader_from_source(source: string, shader_type: shader_type_t): iron_g5_shader_t; +declare function iron_g5_shader_destroy(shader: iron_g5_shader_t): void; declare function iron_g4_create_pipeline(): any; declare function iron_g4_delete_pipeline(pipeline: any): void; declare function iron_g4_compile_pipeline(pipeline: any): void; -declare function kinc_g5_set_pipeline(pipeline: any): void; +declare function iron_g5_set_pipeline(pipeline: any): void; declare function iron_load_image(file: string, readable: bool): any; -declare function iron_unload_image(image: kinc_g5_texture_t): void; +declare function iron_unload_image(image: iron_g5_texture_t): void; declare function iron_load_sound(file: string): any; -declare function kinc_a1_sound_destroy(sound: any): void; -declare function kinc_a1_play_sound(sound: any, loop: bool, pitch: f32, unique: bool): audio_channel_t; -declare function kinc_a1_stop_sound(sound: any): void; -declare function kinc_a1_channel_set_pitch(channel: audio_channel_t, pitch: f32): void; +declare function iron_a1_sound_destroy(sound: any): void; +declare function iron_a1_play_sound(sound: any, loop: bool, pitch: f32, unique: bool): audio_channel_t; +declare function iron_a1_stop_sound(sound: any): void; +declare function iron_a1_channel_set_pitch(channel: audio_channel_t, pitch: f32): void; declare function iron_load_blob(file: string): buffer_t; -declare function kinc_load_url(url: string): void; -declare function kinc_copy_to_clipboard(text: string): void; +declare function iron_load_url(url: string): void; +declare function iron_copy_to_clipboard(text: string): void; declare function iron_g4_get_constant_location(pipeline: any, name: string): any; declare function iron_g4_get_texture_unit(pipeline: any, name: string): any; -declare function iron_g4_set_texture(stage: any, texture: any): void; +declare function _iron_g4_set_texture(stage: any, texture: any): void; declare function iron_g4_set_texture_depth(unit: any, texture: any): void; declare function iron_g4_set_texture_parameters(tex_unit: any, u_addr: i32, v_addr: i32, min_filter: i32, mag_filter: i32, mip_filter: i32): void; -declare function iron_g4_set_bool(location: any, value: bool): void; -declare function iron_g4_set_int(location: any, value: i32): void; -declare function iron_g4_set_float(location: any, value: f32): void; -declare function iron_g4_set_float2(location: any, value1: f32, value2: f32): void; -declare function iron_g4_set_float3(location: any, value1: f32, value2: f32, value3: f32): void; -declare function iron_g4_set_float4(location: any, value1: f32, value2: f32, value3: f32, value4: f32): void; -declare function iron_g4_set_floats(location: any, values: f32_array_t): void; -declare function iron_g4_set_matrix4(location: any, matrix: mat4_t): void; -declare function iron_g4_set_matrix3(location: any, matrix: mat3_t): void; +declare function _iron_g4_set_bool(location: any, value: bool): void; +declare function _iron_g4_set_int(location: any, value: i32): void; +declare function _iron_g4_set_float(location: any, value: f32): void; +declare function _iron_g4_set_float2(location: any, value1: f32, value2: f32): void; +declare function _iron_g4_set_float3(location: any, value1: f32, value2: f32, value3: f32): void; +declare function _iron_g4_set_float4(location: any, value1: f32, value2: f32, value3: f32, value4: f32): void; +declare function _iron_g4_set_floats(location: any, values: f32_array_t): void; +declare function _iron_g4_set_matrix4(location: any, matrix: mat4_t): void; +declare function _iron_g4_set_matrix3(location: any, matrix: mat3_t): void; -declare function kinc_time(): f32; -declare function kinc_window_width(): i32; -declare function kinc_window_height(): i32; +declare function iron_time(): f32; +declare function iron_window_width(): i32; +declare function iron_window_height(): i32; declare function iron_set_window_title(title: string): void; -declare function kinc_window_get_mode(): i32; +declare function iron_window_get_mode(): i32; declare function iron_set_window_mode(mode: i32): void; -declare function kinc_window_resize(width: i32, height: i32): void; -declare function kinc_window_move(x: i32, y: i32): void; +declare function iron_window_resize(width: i32, height: i32): void; +declare function iron_window_move(x: i32, y: i32): void; declare function iron_screen_dpi(): i32; -declare function kinc_system_id(): string; -declare function kinc_stop(): void; -declare function kinc_count_displays(): i32; +declare function iron_system_id(): string; +declare function iron_stop(): void; +declare function iron_count_displays(): i32; declare function iron_display_width(index: i32): i32; declare function iron_display_height(index: i32): i32; declare function iron_display_x(index: i32): i32; @@ -278,30 +278,30 @@ declare function iron_g4_create_render_target(width: i32, height: i32, format: i declare function iron_g4_create_texture_from_bytes(data: buffer_t, width: i32, height: i32, format: i32 = tex_format_t.RGBA32, readable: bool = true): any; declare function iron_g4_create_texture_from_encoded_bytes(data: buffer_t, format: string, readable: bool = false): any; declare function iron_g4_get_texture_pixels(texture: any): buffer_t; -declare function kinc_g5_texture_generate_mipmaps(texture: any, levels: i32): void; -declare function iron_g4_set_mipmaps(texture: any, mipmaps: kinc_g5_texture_t[]): void; -declare function kinc_g5_render_target_set_depth_from(target: any, source: any): void; -declare function kinc_g4_viewport(x: i32, y: i32, width: i32, height: i32): void; -declare function kinc_g4_scissor(x: i32, y: i32, width: i32, height: i32): void; -declare function kinc_g4_disable_scissor(): void; -declare function iron_g4_begin(render_target: kinc_g5_texture_t, additional: kinc_g5_texture_t[] = null): void; -declare function iron_g4_end(): void; +declare function iron_g5_texture_generate_mipmaps(texture: any, levels: i32): void; +declare function iron_g4_set_mipmaps(texture: any, mipmaps: iron_g5_texture_t[]): void; +declare function iron_g5_render_target_set_depth_from(target: any, source: any): void; +declare function iron_g4_viewport(x: i32, y: i32, width: i32, height: i32): void; +declare function iron_g4_scissor(x: i32, y: i32, width: i32, height: i32): void; +declare function iron_g4_disable_scissor(): void; +declare function _iron_g4_begin(render_target: iron_g5_texture_t, additional: iron_g5_texture_t[] = null): void; +declare function _iron_g4_end(): void; declare function iron_g4_swap_buffers(): void; declare function iron_file_save_bytes(path: string, bytes: buffer_t, length?: i32): void; declare function iron_sys_command(cmd: string): i32; -declare function kinc_internal_save_path(): string; +declare function iron_internal_save_path(): string; declare function iron_get_arg_count(): i32; declare function iron_get_arg(index: i32): string; declare function iron_get_files_location(): string; -declare function iron_http_request(url: string, size: i32, callback: (url: string, _: buffer_t)=>void): void; +declare function _iron_http_request(url: string, size: i32, callback: (url: string, _: buffer_t)=>void): void; declare function draw_init(image_vert: buffer_t, image_frag: buffer_t, colored_vert: buffer_t, colored_frag: buffer_t, text_vert: buffer_t, text_frag: buffer_t): void; declare function draw_begin(): void; declare function draw_end(): void; -declare function draw_scaled_sub_image(image: kinc_g5_texture_t, sx: f32, sy: f32, sw: f32, sh: f32, dx: f32, dy: f32, dw: f32, dh: f32): void; -declare function draw_sub_image(image: kinc_g5_texture_t, x: f32, y: f32, sx: f32, sy: f32, sw: f32, sh: f32): void; -declare function draw_scaled_image(image: kinc_g5_texture_t, dx: f32, dy: f32, dw: f32, dh: f32): void; -declare function draw_image(image: kinc_g5_texture_t, x: f32, y: f32): void; +declare function draw_scaled_sub_image(image: iron_g5_texture_t, sx: f32, sy: f32, sw: f32, sh: f32, dx: f32, dy: f32, dw: f32, dh: f32): void; +declare function draw_sub_image(image: iron_g5_texture_t, x: f32, y: f32, sx: f32, sy: f32, sw: f32, sh: f32): void; +declare function draw_scaled_image(image: iron_g5_texture_t, dx: f32, dy: f32, dw: f32, dh: f32): void; +declare function draw_image(image: iron_g5_texture_t, x: f32, y: f32): void; declare function draw_filled_triangle(x0: f32, y0: f32, x1: f32, y1: f32, x2: f32, y2: f32): void; declare function draw_filled_rect(x: f32, y: f32, width: f32, height: f32): void; declare function draw_rect(x: f32, y: f32, width: f32, height: f32, strength: f32 = 1.0): void; @@ -347,18 +347,18 @@ declare function iron_mp4_encode(pixels: buffer_t): void; declare function iron_ml_inference(model: buffer_t, tensors: buffer_t[], input_shape?: i32[][], output_shape?: i32[], use_gpu?: bool): buffer_t; declare function iron_ml_unload(): void; -declare function kinc_g5_raytrace_supported(): bool; +declare function iron_g5_raytrace_supported(): bool; declare function iron_raytrace_init(shader: buffer_t): void; declare function iron_raytrace_as_init(): void; declare function iron_raytrace_as_add(vb: any, ib: any, transform: mat4_t): void; declare function iron_raytrace_as_build(vb_full: any, ib_full: any): void; -declare function iron_raytrace_set_textures(tex0: kinc_g5_texture_t, tex1: kinc_g5_texture_t, tex2: kinc_g5_texture_t, texenv: any, tex_sobol: any, tex_scramble: any, tex_rank: any): void; +declare function iron_raytrace_set_textures(tex0: iron_g5_texture_t, tex1: iron_g5_texture_t, tex2: iron_g5_texture_t, texenv: any, tex_sobol: any, tex_scramble: any, tex_rank: any): void; declare function iron_raytrace_dispatch_rays(target: any, cb: buffer_t): void; -declare function kinc_window_x(): i32; -declare function kinc_window_y(): i32; -declare function kinc_language(): string; +declare function iron_window_x(): i32; +declare function iron_window_y(): i32; +declare function iron_language(): string; declare function obj_parse(file_bytes: buffer_t, split_code: i32, start_pos: i32, udim: bool): any; declare function armpack_decode(b: buffer_t): any; @@ -389,7 +389,7 @@ declare function armpack_map_get_f32(map: map_t, key: string): f32; declare function armpack_map_get_i32(map: map_t, key: string): i32; declare type audio_channel_t = { - sound: any; // kinc_a1_sound_t + sound: any; // iron_a1_sound_t position: f32; loop: bool; volume: f32; @@ -568,22 +568,22 @@ declare function f32_nan(): f32; declare function f32_isnan(f: f32): bool; -function g4_vertex_struct_create(): kinc_g5_vertex_structure_t { - let raw: kinc_g5_vertex_structure_t = {}; +function g4_vertex_struct_create(): iron_g5_vertex_structure_t { + let raw: iron_g5_vertex_structure_t = {}; return raw; } -function g4_vertex_struct_add(raw: kinc_g5_vertex_structure_t, name: string, data: vertex_data_t) { - let e: kinc_g5_vertex_element_t = ADDRESS(ARRAY_ACCESS(raw.elements, raw.size)); +function g4_vertex_struct_add(raw: iron_g5_vertex_structure_t, name: string, data: vertex_data_t) { + let e: iron_g5_vertex_element_t = ADDRESS(ARRAY_ACCESS(raw.elements, raw.size)); e.name = name; e.data = data; raw.size++; } -declare function kinc_g5_vertex_struct_size(s: kinc_g5_vertex_structure_t): i32; -declare function kinc_g5_vertex_data_size(data: vertex_data_t); +declare function iron_g5_vertex_struct_size(s: iron_g5_vertex_structure_t): i32; +declare function iron_g5_vertex_data_size(data: vertex_data_t); -declare type kinc_g5_pipeline_t = { +declare type iron_g5_pipeline_t = { input_layout?: any; vertex_shader?: any; fragment_shader?: any; @@ -609,30 +609,30 @@ declare type kinc_g5_pipeline_t = { impl?: any; }; -declare type kinc_g5_shader_t = { +declare type iron_g5_shader_t = { impl?: any; }; -declare type kinc_g5_vertex_element_t = { +declare type iron_g5_vertex_element_t = { name?: string; data?: vertex_data_t; }; -declare type kinc_g5_vertex_structure_t = { - elements?: any; // kinc_g5_vertex_element_t[KINC_G5_MAX_VERTEX_ELEMENTS]; +declare type iron_g5_vertex_structure_t = { + elements?: any; // iron_g5_vertex_element_t[IRON_G5_MAX_VERTEX_ELEMENTS]; size?: i32; }; -declare type kinc_g5_index_buffer_t = { +declare type iron_g5_index_buffer_t = { impl?: any; }; -declare type kinc_g5_vertex_buffer_t = { +declare type iron_g5_vertex_buffer_t = { impl?: any; }; -declare type kinc_g5_constant_location_t = any; -declare type kinc_g5_texture_unit_t = any; +declare type iron_g5_constant_location_t = any; +declare type iron_g5_texture_unit_t = any; enum clear_flag_t { COLOR = 1, diff --git a/base/sources/ts/iron/lz4.ts b/base/sources/ts/iron/lz4.ts index eb8dc9b3..c133a354 100644 --- a/base/sources/ts/iron/lz4.ts +++ b/base/sources/ts/iron/lz4.ts @@ -31,7 +31,7 @@ function lz4_encode(b: buffer_t): buffer_t { let ibuf: u8_array_t = b; let ilen: u32 = ibuf.length; if (ilen >= 0x7e000000) { - kinc_log("LZ4 range error"); + iron_log("LZ4 range error"); return null; } diff --git a/base/sources/ts/iron/material_data.ts b/base/sources/ts/iron/material_data.ts index 76cc8dcf..49aa2808 100644 --- a/base/sources/ts/iron/material_data.ts +++ b/base/sources/ts/iron/material_data.ts @@ -38,7 +38,7 @@ function material_data_parse(file: string, name: string): material_data_t { let format: scene_t = data_get_scene_raw(file); let raw: material_data_t = material_data_get_raw_by_name(format.material_datas, name); if (raw == null) { - kinc_log("Material data '" + name + "' not found!"); + iron_log("Material data '" + name + "' not found!"); return null; } return material_data_create(raw, file); @@ -79,19 +79,19 @@ function material_context_create(raw: material_context_t): material_context_t { continue; } - let image: kinc_g5_texture_t = data_get_image(tex.file, false); + let image: iron_g5_texture_t = data_get_image(tex.file, false); array_push(raw._.textures, image); // Set mipmaps if (tex.mipmaps != null) { - let mipmaps: kinc_g5_texture_t[] = []; + let mipmaps: iron_g5_texture_t[] = []; while (mipmaps.length < tex.mipmaps.length) { array_push(mipmaps, null); } for (let j: i32 = 0; j < tex.mipmaps.length; ++j) { let name: string = tex.mipmaps[j]; - let mipimg: kinc_g5_texture_t = data_get_image(name); + let mipimg: iron_g5_texture_t = data_get_image(name); mipmaps[j] = mipimg; } @@ -100,7 +100,7 @@ function material_context_create(raw: material_context_t): material_context_t { tex.generate_mipmaps = false; } else if (tex.generate_mipmaps == true && image != null) { - kinc_g5_texture_generate_mipmaps(image, 1000); + iron_g5_texture_generate_mipmaps(image, 1000); tex.mipmaps = null; tex.generate_mipmaps = false; } diff --git a/base/sources/ts/iron/mesh_data.ts b/base/sources/ts/iron/mesh_data.ts index 4075ed17..9853cb41 100644 --- a/base/sources/ts/iron/mesh_data.ts +++ b/base/sources/ts/iron/mesh_data.ts @@ -3,7 +3,7 @@ function mesh_data_parse(name: string, id: string): mesh_data_t { let format: scene_t = data_get_scene_raw(name); let raw: mesh_data_t = mesh_data_get_raw_by_name(format.mesh_datas, id); if (raw == null) { - kinc_log("Mesh data '" + id + "' not found!"); + iron_log("Mesh data '" + id + "' not found!"); return null; } @@ -104,8 +104,8 @@ function mesh_data_create(raw: mesh_data_t): mesh_data_t { return raw; } -function mesh_data_get_vertex_struct(vertex_arrays: vertex_array_t[]): kinc_g5_vertex_structure_t { - let structure: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); +function mesh_data_get_vertex_struct(vertex_arrays: vertex_array_t[]): iron_g5_vertex_structure_t { + let structure: iron_g5_vertex_structure_t = g4_vertex_struct_create(); for (let i: i32 = 0; i < vertex_arrays.length; ++i) { g4_vertex_struct_add(structure, vertex_arrays[i].attrib, mesh_data_get_vertex_data(vertex_arrays[i].data)); } @@ -165,13 +165,13 @@ function mesh_data_get_vertex_array(raw: mesh_data_t, name: string): vertex_arra return null; } -function mesh_data_get(raw: mesh_data_t, vs: vertex_element_t[]): kinc_g5_vertex_buffer_t { +function mesh_data_get(raw: mesh_data_t, vs: vertex_element_t[]): iron_g5_vertex_buffer_t { let key: string = ""; for (let i: i32 = 0; i < vs.length; ++i) { let e: vertex_element_t = vs[i]; key += e.name; } - let vb: kinc_g5_vertex_buffer_t = map_get(raw._.vertex_buffer_map, key); + let vb: iron_g5_vertex_buffer_t = map_get(raw._.vertex_buffer_map, key); if (vb == null) { let vertex_arrays: vertex_array_t[] = []; let has_tex: bool = false; @@ -196,18 +196,18 @@ function mesh_data_get(raw: mesh_data_t, vs: vertex_element_t[]): kinc_g5_vertex let positions: vertex_array_t = mesh_data_get_vertex_array(raw, "pos"); let uvs: vertex_array_t = mesh_data_get_vertex_array(raw, "tex"); let cols: vertex_array_t = mesh_data_get_vertex_array(raw, "col"); - let vstruct: kinc_g5_vertex_structure_t = mesh_data_get_vertex_struct(vertex_arrays); + let vstruct: iron_g5_vertex_structure_t = mesh_data_get_vertex_struct(vertex_arrays); let size: i32 = mesh_data_get_vertex_size(positions.data); vb = iron_g4_create_vertex_buffer(math_floor(positions.values.length / size), vstruct, usage_t.STATIC); raw._.vertices = iron_g4_lock_vertex_buffer(vb); mesh_data_build_vertices(raw._.vertices, vertex_arrays, 0, has_tex && uvs == null, tex_offset); - kinc_g4_vertex_buffer_unlock_all(vb); + iron_g4_vertex_buffer_unlock_all(vb); map_set(raw._.vertex_buffer_map, key, vb); if (has_tex && uvs == null) { - kinc_log("Geometry " + raw.name + " is missing UV map"); + iron_log("Geometry " + raw.name + " is missing UV map"); } if (has_col && cols == null) { - kinc_log("Geometry " + raw.name + " is missing vertex colors"); + iron_log("Geometry " + raw.name + " is missing vertex colors"); } } return vb; @@ -223,11 +223,11 @@ function mesh_data_build(raw: mesh_data_t) { raw._.vertex_buffer = iron_g4_create_vertex_buffer(math_floor(positions.values.length / size), raw._.structure, usage_t.STATIC); raw._.vertices = iron_g4_lock_vertex_buffer(raw._.vertex_buffer); mesh_data_build_vertices(raw._.vertices, raw.vertex_arrays); - kinc_g4_vertex_buffer_unlock_all(raw._.vertex_buffer); + iron_g4_vertex_buffer_unlock_all(raw._.vertex_buffer); let struct_str: string = ""; for (let i: i32 = 0; i < raw._.structure.size; ++i) { - let e: kinc_g5_vertex_element_t = ADDRESS(ARRAY_ACCESS(raw._.structure.elements, i)); + let e: iron_g5_vertex_element_t = ADDRESS(ARRAY_ACCESS(raw._.structure.elements, i)); struct_str += e.name; } map_set(raw._.vertex_buffer_map, struct_str, raw._.vertex_buffer); @@ -239,14 +239,14 @@ function mesh_data_build(raw: mesh_data_t) { if (id.length == 0) { continue; } - let index_buffer: kinc_g5_index_buffer_t = iron_g4_create_index_buffer(id.length); + let index_buffer: iron_g5_index_buffer_t = iron_g4_create_index_buffer(id.length); let indices_array: u32_array_t = iron_g4_lock_index_buffer(index_buffer); for (let i: i32 = 0; i < indices_array.length; ++i) { indices_array[i] = id[i]; } - kinc_g4_index_buffer_unlock_all(index_buffer); + iron_g4_index_buffer_unlock_all(index_buffer); array_push(raw._.index_buffers, index_buffer); } @@ -340,13 +340,13 @@ function mesh_data_calculate_aabb(raw: mesh_data_t): vec4_t { function mesh_data_delete(raw: mesh_data_t) { let vertex_buffer_keys: string[] = map_keys(raw._.vertex_buffer_map); for (let i: i32 = 0; i < vertex_buffer_keys.length; ++i) { - let buf: kinc_g5_vertex_buffer_t = map_get(raw._.vertex_buffer_map, vertex_buffer_keys[i]); + let buf: iron_g5_vertex_buffer_t = map_get(raw._.vertex_buffer_map, vertex_buffer_keys[i]); if (buf != null) { iron_g4_delete_vertex_buffer(buf); } } for (let i: i32 = 0; i < raw._.index_buffers.length; ++i) { - let buf: kinc_g5_index_buffer_t = raw._.index_buffers[i]; + let buf: iron_g5_index_buffer_t = raw._.index_buffers[i]; iron_g4_delete_index_buffer(buf); } } diff --git a/base/sources/ts/iron/mesh_object.ts b/base/sources/ts/iron/mesh_object.ts index 2bc047a3..79d947a5 100644 --- a/base/sources/ts/iron/mesh_object.ts +++ b/base/sources/ts/iron/mesh_object.ts @@ -12,7 +12,7 @@ type mesh_object_t = { prev_matrix?: mat4_t; }; -let _mesh_object_last_pipeline: kinc_g5_pipeline_t = null; +let _mesh_object_last_pipeline: iron_g5_pipeline_t = null; let _mesh_object_material_contexts: material_context_t[] = []; let _mesh_object_shader_contexts: shader_context_t[] = []; @@ -172,7 +172,7 @@ function mesh_object_render(raw: mesh_object_t, context: string, bind_params: st // Uniforms if (scontext._.pipe_state != _mesh_object_last_pipeline) { - kinc_g5_set_pipeline(scontext._.pipe_state); + iron_g5_set_pipeline(scontext._.pipe_state); _mesh_object_last_pipeline = scontext._.pipe_state; } uniforms_set_context_consts(scontext, bind_params); @@ -181,8 +181,8 @@ function mesh_object_render(raw: mesh_object_t, context: string, bind_params: st uniforms_set_material_consts(scontext, material_contexts[mi]); } - kinc_g4_set_vertex_buffer(mesh_data_get(raw.data, elems)); - kinc_g4_set_index_buffer(raw.data._.index_buffers[i]); + iron_g4_set_vertex_buffer(mesh_data_get(raw.data, elems)); + iron_g4_set_index_buffer(raw.data._.index_buffers[i]); iron_g4_draw_indexed_vertices(); } diff --git a/base/sources/ts/iron/render_path.ts b/base/sources/ts/iron/render_path.ts index 57531a39..fc8b2d7b 100644 --- a/base/sources/ts/iron/render_path.ts +++ b/base/sources/ts/iron/render_path.ts @@ -11,7 +11,7 @@ type render_target_t = { // Runtime _depth_buffer_bits?: i32; _depth_from?: string; - _image?: kinc_g5_texture_t; // RT or image + _image?: iron_g5_texture_t; // RT or image _has_depth?: bool; }; @@ -36,7 +36,7 @@ let render_path_current_h: i32; let _render_path_frame_time: f32 = 0.0; let _render_path_frame: i32 = 0; let _render_path_current_target: render_target_t = null; -let _render_path_current_image: kinc_g5_texture_t = null; +let _render_path_current_image: iron_g5_texture_t = null; let _render_path_draw_order: draw_order_t = draw_order_t.DIST; let _render_path_paused: bool = false; let _render_path_depth_to_render_target: map_t = map_create(); @@ -89,7 +89,7 @@ function render_path_set_target(target: string, additional: string[] = null) { else { // Render target let rt: render_target_t = map_get(render_path_render_targets, target); _render_path_current_target = rt; - let additional_images: kinc_g5_texture_t[] = null; + let additional_images: iron_g5_texture_t[] = null; if (additional != null) { additional_images = []; for (let i: i32 = 0; i < additional.length; ++i) { @@ -108,33 +108,33 @@ function render_path_set_target(target: string, additional: string[] = null) { function render_path_set_depth_from(target: string, from: string) { let rt: render_target_t = map_get(render_path_render_targets, target); let rt_from: render_target_t = map_get(render_path_render_targets, from); - kinc_g5_render_target_set_depth_from(rt._image, rt_from._image); + iron_g5_render_target_set_depth_from(rt._image, rt_from._image); } -function render_path_begin(render_target: kinc_g5_texture_t = null, additional_targets: kinc_g5_texture_t[] = null) { +function render_path_begin(render_target: iron_g5_texture_t = null, additional_targets: iron_g5_texture_t[] = null) { if (_render_path_current_image != null) { render_path_end(); } _render_path_current_image = render_target; - iron_g4_begin(render_target, additional_targets); + _iron_g4_begin(render_target, additional_targets); } function render_path_end() { if (_render_path_scissor_set) { - kinc_g4_disable_scissor(); + iron_g4_disable_scissor(); _render_path_scissor_set = false; } - iron_g4_end(); + _iron_g4_end(); _render_path_current_image = null; _render_path_bind_params = null; } function render_path_set_current_viewport(view_w: i32, view_h: i32) { - kinc_g4_viewport(app_x(),render_path_current_h - (view_h - app_y()), view_w, view_h); + iron_g4_viewport(app_x(),render_path_current_h - (view_h - app_y()), view_w, view_h); } function render_path_set_current_scissor(view_w: i32, view_h: i32) { - kinc_g4_scissor(app_x(),render_path_current_h - (view_h - app_y()), view_w, view_h); + iron_g4_scissor(app_x(),render_path_current_h - (view_h - app_y()), view_w, view_h); _render_path_scissor_set = true; } @@ -144,12 +144,12 @@ function render_path_set_viewport(view_w: i32, view_h: i32) { } function render_path_clear_target(color: color_t = 0x00000000, depth: f32 = 0.0, flags: i32 = clear_flag_t.COLOR) { - kinc_g5_clear(color, depth, flags); + iron_g5_clear(color, depth, flags); } function render_path_gen_mipmaps(target: string) { let rt: render_target_t = map_get(render_path_render_targets, target); - kinc_g5_texture_generate_mipmaps(rt._image, 1000); + iron_g5_texture_generate_mipmaps(rt._image, 1000); } function _render_path_sort_dist(a: any_ptr, b: any_ptr): i32 { @@ -213,11 +213,11 @@ function render_path_draw_skydome(handle: string) { if (cc.context == null) { return; // World data not specified } - kinc_g5_set_pipeline(cc.context._.pipe_state); + iron_g5_set_pipeline(cc.context._.pipe_state); uniforms_set_context_consts(cc.context, _render_path_bind_params); uniforms_set_obj_consts(cc.context, null); // External hosek - kinc_g4_set_vertex_buffer(const_data_skydome_vb); - kinc_g4_set_index_buffer(const_data_skydome_ib); + iron_g4_set_vertex_buffer(const_data_skydome_vb); + iron_g4_set_index_buffer(const_data_skydome_ib); iron_g4_draw_indexed_vertices(); render_path_end(); } @@ -239,11 +239,11 @@ function render_path_draw_shader(handle: string) { if (const_data_screen_aligned_vb == null) { const_data_create_screen_aligned_data(); } - kinc_g5_set_pipeline(cc.context._.pipe_state); + iron_g5_set_pipeline(cc.context._.pipe_state); uniforms_set_context_consts(cc.context, _render_path_bind_params); uniforms_set_obj_consts(cc.context, null); - kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); - kinc_g4_set_index_buffer(const_data_screen_aligned_ib); + iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); + iron_g4_set_index_buffer(const_data_screen_aligned_ib); iron_g4_draw_indexed_vertices(); render_path_end(); @@ -285,12 +285,12 @@ function render_path_unload() { } } -function _render_path_resize_on_init(_image: kinc_g5_texture_t) { +function _render_path_resize_on_init(_image: iron_g5_texture_t) { iron_unload_image(_image); } function render_path_resize() { - if (kinc_window_width() == 0 || kinc_window_height() == 0) { + if (iron_window_width() == 0 || iron_window_height() == 0) { return; } @@ -314,7 +314,7 @@ function render_path_resize() { } if (nodepth != null) { - kinc_g5_render_target_set_depth_from(rt._image, nodepth._image); + iron_g5_render_target_set_depth_from(rt._image, nodepth._image); } } @@ -322,7 +322,7 @@ function render_path_resize() { for (let i: i32 = 0; i < render_targets_keys.length; ++i) { let rt: render_target_t = map_get(render_path_render_targets, render_targets_keys[i]); if (rt != null && rt.width == 0) { - let _image: kinc_g5_texture_t = rt._image; + let _image: iron_g5_texture_t = rt._image; app_notify_on_init(_render_path_resize_on_init, _image); rt._image = render_path_create_image(rt, rt._depth_buffer_bits); } @@ -333,7 +333,7 @@ function render_path_resize() { let rt: render_target_t = map_get(render_path_render_targets, render_targets_keys[i]); if (rt != null && rt._depth_from != "") { let depth_from: render_target_t = map_get(_render_path_depth_to_render_target, rt._depth_from); - kinc_g5_render_target_set_depth_from(rt._image, depth_from._image); + iron_g5_render_target_set_depth_from(rt._image, depth_from._image); } } } @@ -372,7 +372,7 @@ function render_path_create_target(t: render_target_t): render_target_t { t._depth_buffer_bits = 0; t._depth_from = t.depth_buffer; t._image = render_path_create_image(t, t._depth_buffer_bits); - kinc_g5_render_target_set_depth_from(t._image, depth_target._image); + iron_g5_render_target_set_depth_from(t._image, depth_target._image); } } else { // No depth buffer @@ -383,7 +383,7 @@ function render_path_create_target(t: render_target_t): render_target_t { return t; } -function render_path_create_image(t: render_target_t, depth_buffer_bits: i32): kinc_g5_texture_t { +function render_path_create_image(t: render_target_t, depth_buffer_bits: i32): iron_g5_texture_t { let width: i32 = t.width == 0 ? app_w() : t.width; let height: i32 = t.height == 0 ? app_h() : t.height; width = math_floor(width * t.scale); diff --git a/base/sources/ts/iron/scene.ts b/base/sources/ts/iron/scene.ts index f67859bd..1d85a436 100644 --- a/base/sources/ts/iron/scene.ts +++ b/base/sources/ts/iron/scene.ts @@ -13,7 +13,7 @@ let scene_animations: anim_raw_t[]; ///if arm_skin let scene_armatures: armature_t[]; ///end -let scene_embedded: map_t; +let scene_embedded: map_t; let _scene_ready: bool; let _scene_uid_counter: i32 = 0; @@ -50,7 +50,7 @@ function scene_create(format: scene_t): object_t { // Startup scene let scene_object: object_t = scene_add_scene(format.name, null); if (scene_cameras.length == 0) { - kinc_log("No camera found for scene '" + format.name + "'"); + iron_log("No camera found for scene '" + format.name + "'"); } scene_camera = scene_get_camera(format.camera_ref); @@ -444,7 +444,7 @@ function scene_load_embedded_data(datas: string[]) { } function scene_embed_data(file: string) { - let image: kinc_g5_texture_t = data_get_image(file); + let image: iron_g5_texture_t = data_get_image(file); map_set(scene_embedded, file, image); } @@ -475,14 +475,14 @@ type mesh_data_t = { type mesh_data_runtime_t = { refcount?: i32; // Number of users handle?: string; // Handle used to retrieve this object in Data - vertex_buffer?: kinc_g5_vertex_buffer_t; - vertex_buffer_map?: map_t; - index_buffers?: kinc_g5_index_buffer_t[]; + vertex_buffer?: iron_g5_vertex_buffer_t; + vertex_buffer_map?: map_t; + index_buffers?: iron_g5_index_buffer_t[]; ready?: bool; vertices?: buffer_t; indices?: u32_array_t[]; material_indices?: i32[]; - structure?: kinc_g5_vertex_structure_t; + structure?: iron_g5_vertex_structure_t; ///if arm_skin skeleton_transforms_inv?: mat4_t[]; actions?: map_t; @@ -542,7 +542,7 @@ type material_context_t = { }; type material_context_runtime_t = { - textures?: kinc_g5_texture_t[]; + textures?: iron_g5_texture_t[]; }; type bind_const_t = { @@ -599,11 +599,11 @@ type shader_context_t = { }; type shader_context_runtime_t = { - pipe_state?: kinc_g5_pipeline_t; - constants?: kinc_g5_constant_location_t[]; - tex_units?: kinc_g5_texture_unit_t[]; + pipe_state?: iron_g5_pipeline_t; + constants?: iron_g5_constant_location_t[]; + tex_units?: iron_g5_texture_unit_t[]; override_context?: _shader_override_t; - structure?: kinc_g5_vertex_structure_t; + structure?: iron_g5_vertex_structure_t; }; type _shader_override_t = { @@ -651,9 +651,9 @@ type world_data_t = { }; type world_data_runtime_t = { - envmap?: kinc_g5_texture_t; - radiance?: kinc_g5_texture_t; - radiance_mipmaps?: kinc_g5_texture_t[]; + envmap?: iron_g5_texture_t; + radiance?: iron_g5_texture_t; + radiance_mipmaps?: iron_g5_texture_t[]; irradiance?: f32_array_t; }; diff --git a/base/sources/ts/iron/shader_data.ts b/base/sources/ts/iron/shader_data.ts index 1a903adb..ad4e3b14 100644 --- a/base/sources/ts/iron/shader_data.ts +++ b/base/sources/ts/iron/shader_data.ts @@ -24,7 +24,7 @@ function shader_data_parse(file: string, name: string): shader_data_t { let format: scene_t = data_get_scene_raw(file); let raw: shader_data_t = shader_data_get_raw_by_name(format.shader_datas, name); if (raw == null) { - kinc_log("Shader data '" + name + "' not found!"); + iron_log("Shader data '" + name + "' not found!"); return null; } return shader_data_create(raw); @@ -211,10 +211,10 @@ function shader_context_parse_vertex_struct(raw: shader_context_t) { function shader_context_delete(raw: shader_context_t) { if (raw._.pipe_state.fragment_shader != null) { - kinc_g5_shader_destroy(raw._.pipe_state.fragment_shader); + iron_g5_shader_destroy(raw._.pipe_state.fragment_shader); } if (raw._.pipe_state.vertex_shader != null) { - kinc_g5_shader_destroy(raw._.pipe_state.vertex_shader); + iron_g5_shader_destroy(raw._.pipe_state.vertex_shader); } iron_g4_delete_pipeline(raw._.pipe_state); } diff --git a/base/sources/ts/iron/sys.ts b/base/sources/ts/iron/sys.ts index 72c615d7..cec5eaaa 100644 --- a/base/sources/ts/iron/sys.ts +++ b/base/sources/ts/iron/sys.ts @@ -17,9 +17,9 @@ let _sys_drop_files_listeners: sys_string_callback_t[] = []; let _sys_start_time: f32; let _sys_window_title: string; -let _sys_shaders: map_t = map_create(); +let _sys_shaders: map_t = map_create(); -declare type kinc_window_options_t = { +declare type iron_window_options_t = { title?: string; x?: i32; y?: i32; @@ -38,10 +38,10 @@ declare type kinc_window_options_t = { depth_bits?: i32; }; -function sys_start(ops: kinc_window_options_t) { - iron_init(ops); +function sys_start(ops: iron_window_options_t) { + _iron_init(ops); - _sys_start_time = kinc_time(); + _sys_start_time = iron_time(); draw_init( iron_load_blob(data_path() + "draw_image.vert" + sys_shader_ext()), iron_load_blob(data_path() + "draw_image.frag" + sys_shader_ext()), @@ -50,8 +50,8 @@ function sys_start(ops: kinc_window_options_t) { iron_load_blob(data_path() + "draw_text.vert" + sys_shader_ext()), iron_load_blob(data_path() + "draw_text.frag" + sys_shader_ext()) ); - iron_set_update_callback(sys_render_callback); - iron_set_drop_files_callback(sys_drop_files_callback); + _iron_set_update_callback(sys_render_callback); + _iron_set_drop_files_callback(sys_drop_files_callback); iron_set_application_state_callback(sys_foreground_callback, sys_resume_callback, sys_pause_callback, sys_background_callback, sys_shutdown_callback); iron_set_keyboard_down_callback(sys_keyboard_down_callback); iron_set_keyboard_up_callback(sys_keyboard_up_callback); @@ -142,7 +142,7 @@ function sys_drop_files(file_path: string) { } function sys_time(): f32 { - return kinc_time() - _sys_start_time; + return iron_time() - _sys_start_time; } function sys_render_callback() { @@ -251,7 +251,7 @@ function sys_title_set(value: string) { } function sys_display_primary_id(): i32 { - for (let i: i32 = 0; i < kinc_count_displays(); ++i) { + for (let i: i32 = 0; i < iron_count_displays(); ++i) { if (iron_display_is_primary(i)) { return i; } @@ -293,8 +293,8 @@ function sys_shader_ext(): string { ///end } -function sys_get_shader(name: string): kinc_g5_shader_t { - let shader: kinc_g5_shader_t = map_get(_sys_shaders, name); +function sys_get_shader(name: string): iron_g5_shader_t { + let shader: iron_g5_shader_t = map_get(_sys_shaders, name); if (shader == null) { shader = iron_g4_create_shader( iron_load_blob(data_path() + name + sys_shader_ext()), @@ -315,7 +315,7 @@ function sound_create(sound_: any): sound_t { } function sound_unload(raw: sound_t) { - kinc_a1_sound_destroy(raw.sound_); + iron_a1_sound_destroy(raw.sound_); } ///end diff --git a/base/sources/ts/iron/ui.ts b/base/sources/ts/iron/ui.ts index ccf9b6c3..4465a42e 100644 --- a/base/sources/ts/iron/ui.ts +++ b/base/sources/ts/iron/ui.ts @@ -122,11 +122,11 @@ function ui_nodes_PAN_Y(): f32 { return UI_NODES_PAN_Y(); } -function _ui_image(image: kinc_g5_texture_t, tint: i32 = 0xffffffff, h: f32 = -1.0, sx: i32 = 0, sy: i32 = 0, sw: i32 = 0, sh: i32 = 0): ui_state_t { +function _ui_image(image: iron_g5_texture_t, tint: i32 = 0xffffffff, h: f32 = -1.0, sx: i32 = 0, sy: i32 = 0, sw: i32 = 0, sh: i32 = 0): ui_state_t { return ui_sub_image(image, tint, h, sx, sy, sw, sh); } -function _ui_tooltip_image(image: kinc_g5_texture_t, max_width: i32 = 0) { +function _ui_tooltip_image(image: iron_g5_texture_t, max_width: i32 = 0) { return ui_tooltip_image(image, max_width); } @@ -309,7 +309,7 @@ declare function ui_draw_string(text: string, x_offset: f32, y_offset: f32, alig declare function ui_next_node_id(nodes: ui_node_t[]): i32; declare function ui_node_canvas(nodes: ui_nodes_t, canvas: ui_node_canvas_t): void; -declare type kinc_g5_texture_t = { +declare type iron_g5_texture_t = { width: i32; height: i32; }; @@ -372,7 +372,7 @@ declare type ui_handle_t = { color: u32; value: f32; text: string; - // kinc_g5_texture_t texture; + // iron_g5_texture_t texture; redraws: i32; scroll_offset: f32; scroll_enabled: bool; @@ -391,8 +391,8 @@ declare type ui_options_t = { font?: draw_font_t; theme?: ui_theme_t; scale_factor?: f32; - color_wheel?: kinc_g5_texture_t; - black_white_gradient?: kinc_g5_texture_t; + color_wheel?: iron_g5_texture_t; + black_white_gradient?: iron_g5_texture_t; }; declare type ui_coloring_t = { diff --git a/base/sources/ts/iron/uniforms.ts b/base/sources/ts/iron/uniforms.ts index 96f18db2..19a35497 100644 --- a/base/sources/ts/iron/uniforms.ts +++ b/base/sources/ts/iron/uniforms.ts @@ -6,7 +6,7 @@ let _uniforms_vec: vec4_t = vec4_create(); let _uniforms_vec2: vec4_t = vec4_create(); let _uniforms_quat: quat_t = quat_create(); -let uniforms_tex_links: (o: object_t, md: material_data_t, s: string)=>kinc_g5_texture_t = null; +let uniforms_tex_links: (o: object_t, md: material_data_t, s: string)=>iron_g5_texture_t = null; let uniforms_mat4_links: (o: object_t, md: material_data_t, s: string)=>mat4_t = null; let uniforms_vec4_links: (o: object_t, md: material_data_t, s: string)=>vec4_t = null; let uniforms_vec3_links: (o: object_t, md: material_data_t, s: string)=>vec4_t = null; @@ -57,20 +57,20 @@ function uniforms_set_context_consts(context: shader_context_t, bind_params: str } if (char_at(tulink, 0) == "$") { // Link to embedded data - iron_g4_set_texture(context._.tex_units[j], map_get(scene_embedded, substring(tulink, 1, tulink.length))); + _iron_g4_set_texture(context._.tex_units[j], map_get(scene_embedded, substring(tulink, 1, tulink.length))); iron_g4_set_texture_parameters(context._.tex_units[j], tex_addressing_t.REPEAT, tex_addressing_t.REPEAT, tex_filter_t.LINEAR, tex_filter_t.LINEAR, mip_map_filter_t.NONE); } else if (tulink == "_envmap_radiance") { let w: world_data_t = scene_world; if (w != null) { - iron_g4_set_texture(context._.tex_units[j], w._.radiance); + _iron_g4_set_texture(context._.tex_units[j], w._.radiance); iron_g4_set_texture_parameters(context._.tex_units[j], tex_addressing_t.REPEAT, tex_addressing_t.REPEAT, tex_filter_t.LINEAR, tex_filter_t.LINEAR, mip_map_filter_t.LINEAR); } } else if (tulink == "_envmap") { let w: world_data_t = scene_world; if (w != null) { - iron_g4_set_texture(context._.tex_units[j], w._.envmap); + _iron_g4_set_texture(context._.tex_units[j], w._.envmap); iron_g4_set_texture_parameters(context._.tex_units[j], tex_addressing_t.REPEAT, tex_addressing_t.REPEAT, tex_filter_t.LINEAR, tex_filter_t.LINEAR, mip_map_filter_t.NONE); } } @@ -96,11 +96,11 @@ function uniforms_set_obj_consts(context: shader_context_t, object: object_t) { continue; } - let image: kinc_g5_texture_t = uniforms_tex_links(object, current_material(object), tu.link); + let image: iron_g5_texture_t = uniforms_tex_links(object, current_material(object), tu.link); if (image != null) { ends_with(tu.link, "_depth") ? iron_g4_set_texture_depth(context._.tex_units[j], image) : - iron_g4_set_texture(context._.tex_units[j], image); + _iron_g4_set_texture(context._.tex_units[j], image); iron_g4_set_texture_parameters(context._.tex_units[j], tex_addressing_t.REPEAT, tex_addressing_t.REPEAT, tex_filter_t.LINEAR, tex_filter_t.LINEAR, mip_map_filter_t.NONE); } } @@ -122,7 +122,7 @@ function uniforms_bind_render_target(rt: render_target_t, context: shader_contex iron_g4_set_texture_depth(context._.tex_units[j], rt._image); // sampler2D } else { - iron_g4_set_texture(context._.tex_units[j], rt._image); // sampler2D + _iron_g4_set_texture(context._.tex_units[j], rt._image); // sampler2D } if (rt.mipmaps) { @@ -153,7 +153,7 @@ function uniforms_bind_render_target(rt: render_target_t, context: shader_contex } } -function uniforms_set_context_const(location: kinc_g5_constant_location_t, c: shader_const_t): bool { +function uniforms_set_context_const(location: iron_g5_constant_location_t, c: shader_const_t): bool { if (c.link == null) { return true; } @@ -191,7 +191,7 @@ function uniforms_set_context_const(location: kinc_g5_constant_location_t, c: sh return false; } - iron_g4_set_matrix4(location, m); + _iron_g4_set_matrix4(location, m); return true; } else if (c.type == "vec4") { @@ -202,10 +202,10 @@ function uniforms_set_context_const(location: kinc_g5_constant_location_t, c: sh // } if (!vec4_isnan(v)) { - iron_g4_set_float4(location, v.x, v.y, v.z, v.w); + _iron_g4_set_float4(location, v.x, v.y, v.z, v.w); } else { - iron_g4_set_float4(location, 0, 0, 0, 0); + _iron_g4_set_float4(location, 0, 0, 0, 0); } return true; } @@ -223,10 +223,10 @@ function uniforms_set_context_const(location: kinc_g5_constant_location_t, c: sh } if (!vec4_isnan(v)) { - iron_g4_set_float3(location, v.x, v.y, v.z); + _iron_g4_set_float3(location, v.x, v.y, v.z); } else { - iron_g4_set_float3(location, 0.0, 0.0, 0.0); + _iron_g4_set_float3(location, 0.0, 0.0, 0.0); } return true; } @@ -292,10 +292,10 @@ function uniforms_set_context_const(location: kinc_g5_constant_location_t, c: sh } if (!vec4_isnan(v)) { - iron_g4_set_float2(location, v.x, v.y); + _iron_g4_set_float2(location, v.x, v.y); } else { - iron_g4_set_float2(location, 0.0, 0.0); + _iron_g4_set_float2(location, 0.0, 0.0); } return true; } @@ -312,7 +312,7 @@ function uniforms_set_context_const(location: kinc_g5_constant_location_t, c: sh return false; } - iron_g4_set_float(location, f); + _iron_g4_set_float(location, f); return true; } else if (c.type == "floats") { @@ -323,7 +323,7 @@ function uniforms_set_context_const(location: kinc_g5_constant_location_t, c: sh } if (fa != null) { - iron_g4_set_floats(location, fa); + _iron_g4_set_floats(location, fa); return true; } } @@ -338,13 +338,13 @@ function uniforms_set_context_const(location: kinc_g5_constant_location_t, c: sh return false; } - iron_g4_set_int(location, i); + _iron_g4_set_int(location, i); return true; } return false; } -function uniforms_set_obj_const(obj: object_t, loc: kinc_g5_constant_location_t, c: shader_const_t) { +function uniforms_set_obj_const(obj: object_t, loc: iron_g5_constant_location_t, c: shader_const_t) { if (c.link == null) { return; } @@ -379,7 +379,7 @@ function uniforms_set_obj_const(obj: object_t, loc: kinc_g5_constant_location_t, if (mat4_isnan(m)) { return; } - iron_g4_set_matrix4(loc, m); + _iron_g4_set_matrix4(loc, m); } else if (c.type == "mat3") { let m: mat3_t = mat3_nan(); @@ -396,7 +396,7 @@ function uniforms_set_obj_const(obj: object_t, loc: kinc_g5_constant_location_t, if (mat3_isnan(m)) { return; } - iron_g4_set_matrix3(loc, m); + _iron_g4_set_matrix3(loc, m); } else if (c.type == "vec4") { let v: vec4_t = vec4_nan(); @@ -408,7 +408,7 @@ function uniforms_set_obj_const(obj: object_t, loc: kinc_g5_constant_location_t, if (vec4_isnan(v)) { return; } - iron_g4_set_float4(loc, v.x, v.y, v.z, v.w); + _iron_g4_set_float4(loc, v.x, v.y, v.z, v.w); } else if (c.type == "vec3") { let v: vec4_t = vec4_nan(); @@ -430,7 +430,7 @@ function uniforms_set_obj_const(obj: object_t, loc: kinc_g5_constant_location_t, if (vec4_isnan(v)) { return; } - iron_g4_set_float3(loc, v.x, v.y, v.z); + _iron_g4_set_float3(loc, v.x, v.y, v.z); } else if (c.type == "vec2") { let v: vec2_t = vec2_nan(); @@ -442,7 +442,7 @@ function uniforms_set_obj_const(obj: object_t, loc: kinc_g5_constant_location_t, if (vec2_isnan(v)) { return; } - iron_g4_set_float2(loc, v.x, v.y); + _iron_g4_set_float2(loc, v.x, v.y); } else if (c.type == "float") { let f: f32 = f32_nan(); @@ -469,7 +469,7 @@ function uniforms_set_obj_const(obj: object_t, loc: kinc_g5_constant_location_t, if (f32_isnan(f)) { return; } - iron_g4_set_float(loc, f); + _iron_g4_set_float(loc, f); } else if (c.type == "floats") { let fa: f32_array_t = null; @@ -488,7 +488,7 @@ function uniforms_set_obj_const(obj: object_t, loc: kinc_g5_constant_location_t, if (fa == null) { return; } - iron_g4_set_floats(loc, fa); + _iron_g4_set_floats(loc, fa); } else if (c.type == "int") { let i: i32 = INT_MAX; @@ -504,7 +504,7 @@ function uniforms_set_obj_const(obj: object_t, loc: kinc_g5_constant_location_t, return; } - iron_g4_set_int(loc, i); + _iron_g4_set_int(loc, i); } } @@ -536,7 +536,7 @@ function uniforms_set_material_consts(context: shader_context_t, material_contex for (let j: i32 = 0; j < context._.tex_units.length; ++j) { let sname: string = context.texture_units[j].name; if (mname == sname) { - iron_g4_set_texture(context._.tex_units[j], material_context._.textures[i]); + _iron_g4_set_texture(context._.tex_units[j], material_context._.textures[i]); // After texture sampler have been assigned, set texture parameters material_context_set_tex_params(material_context, i, context, j); break; @@ -556,23 +556,23 @@ function current_material(object: object_t): material_data_t { return null; } -function uniforms_set_material_const(location: kinc_g5_constant_location_t, shader_const: shader_const_t, material_const: bind_const_t) { +function uniforms_set_material_const(location: iron_g5_constant_location_t, shader_const: shader_const_t, material_const: bind_const_t) { if (shader_const.type == "vec4") { - iron_g4_set_float4(location, material_const.vec[0], material_const.vec[1], material_const.vec[2], material_const.vec[3]); + _iron_g4_set_float4(location, material_const.vec[0], material_const.vec[1], material_const.vec[2], material_const.vec[3]); } else if (shader_const.type == "vec3") { - iron_g4_set_float3(location, material_const.vec[0], material_const.vec[1], material_const.vec[2]); + _iron_g4_set_float3(location, material_const.vec[0], material_const.vec[1], material_const.vec[2]); } else if (shader_const.type == "vec2") { - iron_g4_set_float2(location, material_const.vec[0], material_const.vec[1]); + _iron_g4_set_float2(location, material_const.vec[0], material_const.vec[1]); } else if (shader_const.type == "float") { - iron_g4_set_float(location, material_const.vec[0]); + _iron_g4_set_float(location, material_const.vec[0]); } else if (shader_const.type == "bool") { - iron_g4_set_bool(location, material_const.vec[0] > 0.0); + _iron_g4_set_bool(location, material_const.vec[0] > 0.0); } else if (shader_const.type == "int") { - iron_g4_set_int(location, math_floor(material_const.vec[0])); + _iron_g4_set_int(location, math_floor(material_const.vec[0])); } } diff --git a/base/sources/ts/iron/world_data.ts b/base/sources/ts/iron/world_data.ts index e4b96b05..a4055145 100644 --- a/base/sources/ts/iron/world_data.ts +++ b/base/sources/ts/iron/world_data.ts @@ -5,7 +5,7 @@ function world_data_parse(name: string, id: string): world_data_t { let format: scene_t = data_get_scene_raw(name); let raw: world_data_t = world_data_get_raw_by_name(format.world_datas, id); if (raw == null) { - kinc_log("World data '" + id + "' not found!"); + iron_log("World data '" + id + "' not found!"); return null; } @@ -15,7 +15,7 @@ function world_data_parse(name: string, id: string): world_data_t { let irr: f32_array_t = world_data_set_irradiance(raw); raw._.irradiance = irr; if (raw.radiance != null) { - let rad: kinc_g5_texture_t = data_get_image(raw.radiance); + let rad: iron_g5_texture_t = data_get_image(raw.radiance); raw._.radiance = rad; while (raw._.radiance_mipmaps.length < raw.radiance_mipmaps) { array_push(raw._.radiance_mipmaps, null); @@ -25,7 +25,7 @@ function world_data_parse(name: string, id: string): world_data_t { let base: string = substring(raw.radiance, 0, dot); for (let i: i32 = 0; i < raw.radiance_mipmaps; ++i) { - let mipimg: kinc_g5_texture_t = data_get_image(base + "_" + i + ext, true); + let mipimg: iron_g5_texture_t = data_get_image(base + "_" + i + ext, true); raw._.radiance_mipmaps[i] = mipimg; } iron_g4_set_mipmaps(raw._.radiance, raw._.radiance_mipmaps); @@ -73,7 +73,7 @@ function world_data_set_irradiance(raw: world_data_t): f32_array_t { function world_data_load_envmap(raw: world_data_t) { if (raw.envmap != null) { - let image: kinc_g5_texture_t = data_get_image(raw.envmap); + let image: iron_g5_texture_t = data_get_image(raw.envmap); raw._.envmap = image; } } diff --git a/base/sources/ts/layers.ts b/base/sources/ts/layers.ts index e058c4db..7c0a5c83 100644 --- a/base/sources/ts/layers.ts +++ b/base/sources/ts/layers.ts @@ -1,8 +1,8 @@ -let layers_temp_image: kinc_g5_texture_t = null; -let layers_expa: kinc_g5_texture_t = null; -let layers_expb: kinc_g5_texture_t = null; -let layers_expc: kinc_g5_texture_t = null; +let layers_temp_image: iron_g5_texture_t = null; +let layers_expa: iron_g5_texture_t = null; +let layers_expb: iron_g5_texture_t = null; +let layers_expc: iron_g5_texture_t = null; let layers_default_base: f32 = 0.5; let layers_default_rough: f32 = 0.4; let layers_max_layers: i32 = @@ -32,20 +32,20 @@ function layers_init() { g2_begin(texpaint._image); draw_scaled_image(resource_get("placeholder.k"), 0, 0, config_get_texture_res_x(), config_get_texture_res_y()); // Base g2_end(); - iron_g4_begin(texpaint_nor._image); - kinc_g5_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); // Nor - iron_g4_end(); - iron_g4_begin(texpaint_pack._image); - kinc_g5_clear(color_from_floats(1.0, 0.4, 0.0, 0.0)); // Occ, rough, met - iron_g4_end(); + _iron_g4_begin(texpaint_nor._image); + iron_g5_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); // Nor + _iron_g4_end(); + _iron_g4_begin(texpaint_pack._image); + iron_g5_clear(color_from_floats(1.0, 0.4, 0.0, 0.0)); // Occ, rough, met + _iron_g4_end(); let texpaint_nor_empty: render_target_t = map_get(render_path_render_targets, "texpaint_nor_empty"); let texpaint_pack_empty: render_target_t = map_get(render_path_render_targets, "texpaint_pack_empty"); - iron_g4_begin(texpaint_nor_empty._image); - kinc_g5_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); // Nor - iron_g4_end(); - iron_g4_begin(texpaint_pack_empty._image); - kinc_g5_clear(color_from_floats(1.0, 0.4, 0.0, 0.0)); // Occ, rough, met - iron_g4_end(); + _iron_g4_begin(texpaint_nor_empty._image); + iron_g5_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); // Nor + _iron_g4_end(); + _iron_g4_begin(texpaint_pack_empty._image); + iron_g5_clear(color_from_floats(1.0, 0.4, 0.0, 0.0)); // Occ, rough, met + _iron_g4_end(); ///end } @@ -75,8 +75,8 @@ function layers_resize() { let rts: map_t = render_path_render_targets; let blend0: render_target_t = map_get(rts, "texpaint_blend0"); - let _texpaint_blend0: kinc_g5_texture_t = blend0._image; - app_notify_on_next_frame(function (_texpaint_blend0: kinc_g5_texture_t) { + let _texpaint_blend0: iron_g5_texture_t = blend0._image; + app_notify_on_next_frame(function (_texpaint_blend0: iron_g5_texture_t) { iron_unload_image(_texpaint_blend0); }, _texpaint_blend0); blend0.width = config_get_texture_res_x(); @@ -84,8 +84,8 @@ function layers_resize() { blend0._image = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); let blend1: render_target_t = map_get(rts, "texpaint_blend1"); - let _texpaint_blend1: kinc_g5_texture_t = blend1._image; - app_notify_on_next_frame(function (_texpaint_blend1: kinc_g5_texture_t) { + let _texpaint_blend1: iron_g5_texture_t = blend1._image; + app_notify_on_next_frame(function (_texpaint_blend1: iron_g5_texture_t) { iron_unload_image(_texpaint_blend1); }, _texpaint_blend1); blend1.width = config_get_texture_res_x(); @@ -96,8 +96,8 @@ function layers_resize() { let blur: render_target_t = map_get(rts, "texpaint_blur"); if (blur != null) { - let _texpaint_blur: kinc_g5_texture_t = blur._image; - app_notify_on_next_frame(function (_texpaint_blur: kinc_g5_texture_t) { + let _texpaint_blur: iron_g5_texture_t = blur._image; + app_notify_on_next_frame(function (_texpaint_blur: iron_g5_texture_t) { iron_unload_image(_texpaint_blur); }, _texpaint_blur); let size_x: f32 = math_floor(config_get_texture_res_x() * 0.95); @@ -160,8 +160,8 @@ function layers_make_temp_img() { function layers_make_temp_mask_img() { if (pipes_temp_mask_image != null && (pipes_temp_mask_image.width != config_get_texture_res_x() || pipes_temp_mask_image.height != config_get_texture_res_y())) { - let _temp_mask_image: kinc_g5_texture_t = pipes_temp_mask_image; - app_notify_on_next_frame(function (_temp_mask_image: kinc_g5_texture_t) { + let _temp_mask_image: iron_g5_texture_t = pipes_temp_mask_image; + app_notify_on_next_frame(function (_temp_mask_image: iron_g5_texture_t) { iron_unload_image(_temp_mask_image); }, _temp_mask_image); pipes_temp_mask_image = null; @@ -180,16 +180,16 @@ function layers_make_export_img() { ///end if (layers_expa != null && (layers_expa.width != l.texpaint.width || layers_expa.height != l.texpaint.height || layers_expa.format != l.texpaint.format)) { - let _expa: kinc_g5_texture_t = layers_expa; - let _expb: kinc_g5_texture_t = layers_expb; - let _expc: kinc_g5_texture_t = layers_expc; - app_notify_on_next_frame(function (_expa: kinc_g5_texture_t) { + let _expa: iron_g5_texture_t = layers_expa; + let _expb: iron_g5_texture_t = layers_expb; + let _expc: iron_g5_texture_t = layers_expc; + app_notify_on_next_frame(function (_expa: iron_g5_texture_t) { iron_unload_image(_expa); }, _expa); - app_notify_on_next_frame(function (_expb: kinc_g5_texture_t) { + app_notify_on_next_frame(function (_expb: iron_g5_texture_t) { iron_unload_image(_expb); }, _expb); - app_notify_on_next_frame(function (_expc: kinc_g5_texture_t) { + app_notify_on_next_frame(function (_expc: iron_g5_texture_t) { iron_unload_image(_expc); }, _expc); layers_expa = null; @@ -255,29 +255,29 @@ function layers_apply_mask(l: slot_layer_t, m: slot_layer_t) { g2_end(); // Apply mask - iron_g4_begin(l.texpaint); - kinc_g5_set_pipeline(pipes_apply_mask); - iron_g4_set_texture(pipes_tex0_mask, layers_temp_image); - iron_g4_set_texture(pipes_texa_mask, m.texpaint); - kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); - kinc_g4_set_index_buffer(const_data_screen_aligned_ib); + _iron_g4_begin(l.texpaint); + iron_g5_set_pipeline(pipes_apply_mask); + _iron_g4_set_texture(pipes_tex0_mask, layers_temp_image); + _iron_g4_set_texture(pipes_texa_mask, m.texpaint); + iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); + iron_g4_set_index_buffer(const_data_screen_aligned_ib); iron_g4_draw_indexed_vertices(); - iron_g4_end(); + _iron_g4_end(); } -function layers_commands_merge_pack(pipe: kinc_g5_pipeline_t, i0: kinc_g5_texture_t, i1: kinc_g5_texture_t, i1pack: kinc_g5_texture_t, i1mask_opacity: f32, i1texmask: kinc_g5_texture_t, i1blending: i32 = -1) { - iron_g4_begin(i0); - kinc_g5_set_pipeline(pipe); - iron_g4_set_texture(pipes_tex0, i1); - iron_g4_set_texture(pipes_tex1, i1pack); - iron_g4_set_texture(pipes_texmask, i1texmask); - iron_g4_set_texture(pipes_texa, layers_temp_image); - iron_g4_set_float(pipes_opac, i1mask_opacity); - iron_g4_set_int(pipes_blending, i1blending); - kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); - kinc_g4_set_index_buffer(const_data_screen_aligned_ib); +function layers_commands_merge_pack(pipe: iron_g5_pipeline_t, i0: iron_g5_texture_t, i1: iron_g5_texture_t, i1pack: iron_g5_texture_t, i1mask_opacity: f32, i1texmask: iron_g5_texture_t, i1blending: i32 = -1) { + _iron_g4_begin(i0); + iron_g5_set_pipeline(pipe); + _iron_g4_set_texture(pipes_tex0, i1); + _iron_g4_set_texture(pipes_tex1, i1pack); + _iron_g4_set_texture(pipes_texmask, i1texmask); + _iron_g4_set_texture(pipes_texa, layers_temp_image); + _iron_g4_set_float(pipes_opac, i1mask_opacity); + _iron_g4_set_int(pipes_blending, i1blending); + iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); + iron_g4_set_index_buffer(const_data_screen_aligned_ib); iron_g4_draw_indexed_vertices(); - iron_g4_end(); + _iron_g4_end(); } function layers_is_fill_material(): bool { @@ -299,7 +299,7 @@ function layers_update_fill_layers() { let _layer: slot_layer_t = context_raw.layer; let _tool: workspace_tool_t = context_raw.tool; let _fill_type: i32 = context_raw.fill_type_handle.position; - let current: kinc_g5_texture_t = null; + let current: iron_g5_texture_t = null; if (context_raw.tool == workspace_tool_t.MATERIAL) { if (render_path_paint_live_layer == null) { @@ -399,7 +399,7 @@ function layers_update_fill_layers() { } function layers_update_fill_layer(parse_paint: bool = true) { - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); @@ -718,8 +718,8 @@ function layers_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool g2_end(); let empty_rt: render_target_t = map_get(render_path_render_targets, "empty_white"); - let empty: kinc_g5_texture_t = empty_rt._image; - let mask: kinc_g5_texture_t = empty; + let empty: iron_g5_texture_t = empty_rt._image; + let mask: iron_g5_texture_t = empty; let l1masks: slot_layer_t[] = use_mask ? slot_layer_get_masks(l1) : null; if (l1masks != null) { // for (let i: i32 = 1; i < l1masks.length - 1; ++i) { @@ -729,32 +729,32 @@ function layers_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool } if (slot_layer_is_mask(l1)) { - iron_g4_begin(l0.texpaint); - kinc_g5_set_pipeline(pipes_merge_mask); - iron_g4_set_texture(pipes_tex0_merge_mask, l1.texpaint); - iron_g4_set_texture(pipes_texa_merge_mask, layers_temp_image); - iron_g4_set_float(pipes_opac_merge_mask, slot_layer_get_opacity(l1)); - iron_g4_set_int(pipes_blending_merge_mask, l1.blending); - kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); - kinc_g4_set_index_buffer(const_data_screen_aligned_ib); + _iron_g4_begin(l0.texpaint); + iron_g5_set_pipeline(pipes_merge_mask); + _iron_g4_set_texture(pipes_tex0_merge_mask, l1.texpaint); + _iron_g4_set_texture(pipes_texa_merge_mask, layers_temp_image); + _iron_g4_set_float(pipes_opac_merge_mask, slot_layer_get_opacity(l1)); + _iron_g4_set_int(pipes_blending_merge_mask, l1.blending); + iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); + iron_g4_set_index_buffer(const_data_screen_aligned_ib); iron_g4_draw_indexed_vertices(); - iron_g4_end(); + _iron_g4_end(); } if (slot_layer_is_layer(l1)) { if (l1.paint_base) { - iron_g4_begin(l0.texpaint); - kinc_g5_set_pipeline(pipes_merge); - iron_g4_set_texture(pipes_tex0, l1.texpaint); - iron_g4_set_texture(pipes_tex1, empty); - iron_g4_set_texture(pipes_texmask, mask); - iron_g4_set_texture(pipes_texa, layers_temp_image); - iron_g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); - iron_g4_set_int(pipes_blending, l1.blending); - kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); - kinc_g4_set_index_buffer(const_data_screen_aligned_ib); + _iron_g4_begin(l0.texpaint); + iron_g5_set_pipeline(pipes_merge); + _iron_g4_set_texture(pipes_tex0, l1.texpaint); + _iron_g4_set_texture(pipes_tex1, empty); + _iron_g4_set_texture(pipes_texmask, mask); + _iron_g4_set_texture(pipes_texa, layers_temp_image); + _iron_g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); + _iron_g4_set_int(pipes_blending, l1.blending); + iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); + iron_g4_set_index_buffer(const_data_screen_aligned_ib); iron_g4_draw_indexed_vertices(); - iron_g4_end(); + _iron_g4_end(); } if (l0.texpaint_nor != null) { @@ -765,18 +765,18 @@ function layers_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool g2_end(); if (l1.paint_nor) { - iron_g4_begin(l0.texpaint_nor); - kinc_g5_set_pipeline(pipes_merge); - iron_g4_set_texture(pipes_tex0, l1.texpaint); - iron_g4_set_texture(pipes_tex1, l1.texpaint_nor); - iron_g4_set_texture(pipes_texmask, mask); - iron_g4_set_texture(pipes_texa, layers_temp_image); - iron_g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); - iron_g4_set_int(pipes_blending, l1.paint_nor_blend ? -2 : -1); - kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); - kinc_g4_set_index_buffer(const_data_screen_aligned_ib); + _iron_g4_begin(l0.texpaint_nor); + iron_g5_set_pipeline(pipes_merge); + _iron_g4_set_texture(pipes_tex0, l1.texpaint); + _iron_g4_set_texture(pipes_tex1, l1.texpaint_nor); + _iron_g4_set_texture(pipes_texmask, mask); + _iron_g4_set_texture(pipes_texa, layers_temp_image); + _iron_g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); + _iron_g4_set_int(pipes_blending, l1.paint_nor_blend ? -2 : -1); + iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); + iron_g4_set_index_buffer(const_data_screen_aligned_ib); iron_g4_draw_indexed_vertices(); - iron_g4_end(); + _iron_g4_end(); } } diff --git a/base/sources/ts/line_draw.ts b/base/sources/ts/line_draw.ts index bd204973..a5c19831 100644 --- a/base/sources/ts/line_draw.ts +++ b/base/sources/ts/line_draw.ts @@ -4,14 +4,14 @@ let line_draw_strength: f32 = 0.005; let line_draw_mat: mat4_t = mat4_nan(); let line_draw_dim: vec4_t = vec4_nan(); -let line_draw_vertex_buffer: kinc_g5_vertex_buffer_t; -let line_draw_index_buffer: kinc_g5_index_buffer_t; -let line_draw_pipeline: kinc_g5_pipeline_t = null; -let line_draw_overlay_pipeline: kinc_g5_pipeline_t = null; +let line_draw_vertex_buffer: iron_g5_vertex_buffer_t; +let line_draw_index_buffer: iron_g5_index_buffer_t; +let line_draw_pipeline: iron_g5_pipeline_t = null; +let line_draw_overlay_pipeline: iron_g5_pipeline_t = null; let line_draw_vp: mat4_t; -let line_draw_vp_loc: kinc_g5_constant_location_t; -let line_draw_color_loc: kinc_g5_constant_location_t; +let line_draw_vp_loc: iron_g5_constant_location_t; +let line_draw_color_loc: iron_g5_constant_location_t; let line_draw_vb_data: buffer_t; let line_draw_ib_data: u32_array_t; @@ -40,7 +40,7 @@ let line_draw_camera_look: vec4_t = vec4_create(); function line_draw_init() { if (line_draw_pipeline == null) { - let structure: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let structure: iron_g5_vertex_structure_t = g4_vertex_struct_create(); g4_vertex_struct_add(structure, "pos", vertex_data_t.F32_3X); line_draw_pipeline = iron_g4_create_pipeline(); line_draw_pipeline.input_layout = structure; @@ -62,7 +62,7 @@ function line_draw_init() { line_draw_index_buffer = iron_g4_create_index_buffer(line_draw_max_indices); } if (line_draw_overlay_pipeline == null) { - let structure: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let structure: iron_g5_vertex_structure_t = g4_vertex_struct_create(); g4_vertex_struct_add(structure, "pos", vertex_data_t.F32_3X); line_draw_overlay_pipeline = iron_g4_create_pipeline(); line_draw_overlay_pipeline.input_layout = structure; @@ -227,17 +227,17 @@ function line_draw_begin() { } function line_draw_end(overlay: bool = false) { - kinc_g4_vertex_buffer_unlock_all(line_draw_vertex_buffer); - kinc_g4_index_buffer_unlock_all(line_draw_index_buffer); + iron_g4_vertex_buffer_unlock_all(line_draw_vertex_buffer); + iron_g4_index_buffer_unlock_all(line_draw_index_buffer); - kinc_g4_set_vertex_buffer(line_draw_vertex_buffer); - kinc_g4_set_index_buffer(line_draw_index_buffer); - kinc_g5_set_pipeline(overlay ? line_draw_overlay_pipeline : line_draw_pipeline); + iron_g4_set_vertex_buffer(line_draw_vertex_buffer); + iron_g4_set_index_buffer(line_draw_index_buffer); + iron_g5_set_pipeline(overlay ? line_draw_overlay_pipeline : line_draw_pipeline); let camera: camera_object_t = scene_camera; line_draw_vp = mat4_clone(camera.v); line_draw_vp = mat4_mult_mat(line_draw_vp, camera.p); - iron_g4_set_matrix4(line_draw_vp_loc, line_draw_vp); - iron_g4_set_float3(line_draw_color_loc, + _iron_g4_set_matrix4(line_draw_vp_loc, line_draw_vp); + _iron_g4_set_float3(line_draw_color_loc, color_get_rb(line_draw_color) / 255, color_get_gb(line_draw_color) / 255, color_get_bb(line_draw_color) / 255 @@ -245,8 +245,8 @@ function line_draw_end(overlay: bool = false) { iron_g4_draw_indexed_vertices(0, line_draw_lines * 6); } -let _shape_draw_sphere_vb: kinc_g5_vertex_buffer_t = null; -let _shape_draw_sphere_ib: kinc_g5_index_buffer_t = null; +let _shape_draw_sphere_vb: iron_g5_vertex_buffer_t = null; +let _shape_draw_sphere_ib: iron_g5_index_buffer_t = null; function shape_draw_sphere(mat: mat4_t) { line_draw_init(); @@ -256,7 +256,7 @@ function shape_draw_sphere(mat: mat4_t) { let md: mesh_data_t = sphere.data; let posa: i16_array_t = md.vertex_arrays[0].values; - let structure: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let structure: iron_g5_vertex_structure_t = g4_vertex_struct_create(); g4_vertex_struct_add(structure, "pos", vertex_data_t.F32_3X); _shape_draw_sphere_vb = iron_g4_create_vertex_buffer(posa.length, structure, usage_t.STATIC); let data: buffer_t = iron_g4_lock_vertex_buffer(_shape_draw_sphere_vb); @@ -265,21 +265,21 @@ function shape_draw_sphere(mat: mat4_t) { buffer_set_f32(data, (i * 3 + 1) * 4, posa[i * 4 + 1] / 32767); buffer_set_f32(data, (i * 3 + 2) * 4, posa[i * 4 + 2] / 32767); } - kinc_g4_vertex_buffer_unlock_all(_shape_draw_sphere_vb); + iron_g4_vertex_buffer_unlock_all(_shape_draw_sphere_vb); _shape_draw_sphere_ib = md._.index_buffers[0]; } - kinc_g4_set_vertex_buffer(_shape_draw_sphere_vb); - kinc_g4_set_index_buffer(_shape_draw_sphere_ib); - kinc_g5_set_pipeline(line_draw_overlay_pipeline); + iron_g4_set_vertex_buffer(_shape_draw_sphere_vb); + iron_g4_set_index_buffer(_shape_draw_sphere_ib); + iron_g5_set_pipeline(line_draw_overlay_pipeline); let camera: camera_object_t = scene_camera; line_draw_vp = mat4_clone(mat); let f: f32 = line_draw_strength * 50; line_draw_vp = mat4_scale(line_draw_vp, vec4_create(f, f, f)); line_draw_vp = mat4_mult_mat(line_draw_vp, camera.v); line_draw_vp = mat4_mult_mat(line_draw_vp, camera.p); - iron_g4_set_matrix4(line_draw_vp_loc, line_draw_vp); - iron_g4_set_float3(line_draw_color_loc, + _iron_g4_set_matrix4(line_draw_vp_loc, line_draw_vp); + _iron_g4_set_float3(line_draw_color_loc, color_get_rb(line_draw_color) / 255, color_get_gb(line_draw_color) / 255, color_get_bb(line_draw_color) / 255 diff --git a/base/sources/ts/logic_node.ts b/base/sources/ts/logic_node.ts index c027058c..5d017960 100644 --- a/base/sources/ts/logic_node.ts +++ b/base/sources/ts/logic_node.ts @@ -3,8 +3,8 @@ type logic_node_t = { inputs?: logic_node_input_t[]; outputs?: logic_node_t[][]; get?: (self: any, from: i32)=>logic_node_value_t; - get_as_image?: (self: any, from: i32)=>kinc_g5_texture_t; - get_cached_image?: (self: any)=>kinc_g5_texture_t; + get_as_image?: (self: any, from: i32)=>iron_g5_texture_t; + get_cached_image?: (self: any)=>iron_g5_texture_t; set?: (self: any, value: f32_array_t)=>void; ext?: logic_node_ext_t; }; @@ -47,14 +47,14 @@ function logic_node_get(self: logic_node_t, from: i32): any { return null; } -function logic_node_get_as_image(self: logic_node_t, from: i32): kinc_g5_texture_t { +function logic_node_get_as_image(self: logic_node_t, from: i32): iron_g5_texture_t { if (self.get_as_image != null) { return self.get_as_image(self.ext, from); } return null; } -function logic_node_get_cached_image(self: logic_node_t): kinc_g5_texture_t { +function logic_node_get_cached_image(self: logic_node_t): iron_g5_texture_t { if (self.get_cached_image != null) { return self.get_cached_image(self.ext); } @@ -78,7 +78,7 @@ function logic_node_input_get(self: logic_node_input_t): logic_node_value_t { return logic_node_get(self.node.base, self.from); } -function logic_node_input_get_as_image(self: logic_node_input_t): kinc_g5_texture_t { +function logic_node_input_get_as_image(self: logic_node_input_t): iron_g5_texture_t { return logic_node_get_as_image(self.node.base, self.from); } diff --git a/base/sources/ts/main.ts b/base/sources/ts/main.ts index ec3344c0..870b6650 100644 --- a/base/sources/ts/main.ts +++ b/base/sources/ts/main.ts @@ -2,7 +2,7 @@ function main() { // Used to locate external application data folder - kinc_set_app_name(manifest_title); + iron_set_app_name(manifest_title); config_load(); app_on_resize = base_on_resize; @@ -17,7 +17,7 @@ function main() { if (config_raw.layout == null) { base_init_layout(); } - kinc_set_app_name(manifest_title); + iron_set_app_name(manifest_title); app_init(); scene_set_active("Scene"); uniforms_ext_init(); diff --git a/base/sources/ts/nodes/color_node.ts b/base/sources/ts/nodes/color_node.ts index e133b467..51b4b8c3 100644 --- a/base/sources/ts/nodes/color_node.ts +++ b/base/sources/ts/nodes/color_node.ts @@ -2,7 +2,7 @@ type color_node_t = { base?: logic_node_t; value?: vec4_t; - image?: kinc_g5_texture_t; + image?: iron_g5_texture_t; }; function color_node_create(raw: ui_node_t, args: f32_array_t): color_node_t { @@ -29,7 +29,7 @@ function color_node_get(self: color_node_t, from: i32): logic_node_value_t { } } -function color_node_get_as_image(self: color_node_t, from: i32): kinc_g5_texture_t { +function color_node_get_as_image(self: color_node_t, from: i32): iron_g5_texture_t { if (self.base.inputs.length > 0) { return logic_node_input_get_as_image(self.base.inputs[0]); } diff --git a/base/sources/ts/nodes/float_node.ts b/base/sources/ts/nodes/float_node.ts index 13622b18..9fa86902 100644 --- a/base/sources/ts/nodes/float_node.ts +++ b/base/sources/ts/nodes/float_node.ts @@ -2,7 +2,7 @@ type float_node_t = { base?: logic_node_t; value?: f32; - image?: kinc_g5_texture_t; + image?: iron_g5_texture_t; }; function float_node_create(raw: ui_node_t, args: f32_array_t): float_node_t { @@ -25,7 +25,7 @@ function float_node_get(self: float_node_t, from: i32): logic_node_value_t { } } -function float_node_get_as_image(self: float_node_t, from: i32): kinc_g5_texture_t { +function float_node_get_as_image(self: float_node_t, from: i32): iron_g5_texture_t { if (self.base.inputs.length > 0) { return logic_node_input_get_as_image(self.base.inputs[0]); } diff --git a/base/sources/ts/nodes/vector_node.ts b/base/sources/ts/nodes/vector_node.ts index 9248b917..773fc609 100644 --- a/base/sources/ts/nodes/vector_node.ts +++ b/base/sources/ts/nodes/vector_node.ts @@ -2,7 +2,7 @@ type vector_node_t = { base?: logic_node_t; value?: vec4_t; - image?: kinc_g5_texture_t; + image?: iron_g5_texture_t; }; function vector_node_create(raw: ui_node_t, args: f32_array_t): vector_node_t { @@ -33,7 +33,7 @@ function vector_node_get(self: vector_node_t, from: i32): logic_node_value_t { return v; } -function vector_node_get_as_image(self: vector_node_t, from: i32): kinc_g5_texture_t { +function vector_node_get_as_image(self: vector_node_t, from: i32): iron_g5_texture_t { // let x: f32 = logic_node_input_get(self.base.inputs[0]); // let y: f32 = logic_node_input_get(self.base.inputs[1]); // let z: f32 = logic_node_input_get(self.base.inputs[2]); diff --git a/base/sources/ts/parser_material.ts b/base/sources/ts/parser_material.ts index 8d77a167..25a024f2 100644 --- a/base/sources/ts/parser_material.ts +++ b/base/sources/ts/parser_material.ts @@ -466,7 +466,7 @@ function _parser_material_cache_tex_text_node(file: string, text: string) { if (map_get(data_cached_images, file) == null) { app_notify_on_init(function(text: string) { let _text_tool_text: string = context_raw.text_tool_text; - let _text_tool_image: kinc_g5_texture_t = context_raw.text_tool_image; + let _text_tool_image: iron_g5_texture_t = context_raw.text_tool_image; context_raw.text_tool_text = text; context_raw.text_tool_image = null; diff --git a/base/sources/ts/path.ts b/base/sources/ts/path.ts index 1ad9a0f3..df1dadda 100644 --- a/base/sources/ts/path.ts +++ b/base/sources/ts/path.ts @@ -15,7 +15,7 @@ let path_mesh_formats: string[] = ["obj", "blend"]; let path_texture_formats: string[] = ["jpg", "jpeg", "png", "tga", "bmp", "psd", "gif", "hdr", "k"]; let path_mesh_importers: map_t = map_create(); // JSValue -> (s: string)=>raw_mesh_t -let path_texture_importers: map_t = map_create(); // JSValue -> (s: string)=>kinc_g5_texture_t +let path_texture_importers: map_t = map_create(); // JSValue -> (s: string)=>iron_g5_texture_t let path_base_color_ext: string[] = ["albedo", "alb", "basecol", "basecolor", "diffuse", "diff", "base", "bc", "d", "color", "col"]; let path_opacity_ext: string[] = ["opac", "opacity", "alpha"]; @@ -80,7 +80,7 @@ function path_working_dir(): string { let cmd: string = path_pwd; let save: string; if (path_is_protected()) { - save = kinc_internal_save_path(); + save = iron_internal_save_path(); } else { save = path_data() + path_sep; diff --git a/base/sources/ts/pipes.ts b/base/sources/ts/pipes.ts index 0e622650..c5c66461 100644 --- a/base/sources/ts/pipes.ts +++ b/base/sources/ts/pipes.ts @@ -1,59 +1,59 @@ -let pipes_copy: kinc_g5_pipeline_t; -let pipes_copy8: kinc_g5_pipeline_t; -let pipes_copy128: kinc_g5_pipeline_t; -let pipes_copy_bgra: kinc_g5_pipeline_t; -let pipes_copy_rgb: kinc_g5_pipeline_t = null; -let pipes_copy_r: kinc_g5_pipeline_t; -let pipes_copy_g: kinc_g5_pipeline_t; -let pipes_copy_a: kinc_g5_pipeline_t; -let pipes_copy_a_tex: kinc_g5_texture_unit_t; +let pipes_copy: iron_g5_pipeline_t; +let pipes_copy8: iron_g5_pipeline_t; +let pipes_copy128: iron_g5_pipeline_t; +let pipes_copy_bgra: iron_g5_pipeline_t; +let pipes_copy_rgb: iron_g5_pipeline_t = null; +let pipes_copy_r: iron_g5_pipeline_t; +let pipes_copy_g: iron_g5_pipeline_t; +let pipes_copy_a: iron_g5_pipeline_t; +let pipes_copy_a_tex: iron_g5_texture_unit_t; -let pipes_merge: kinc_g5_pipeline_t = null; -let pipes_merge_r: kinc_g5_pipeline_t = null; -let pipes_merge_g: kinc_g5_pipeline_t = null; -let pipes_merge_b: kinc_g5_pipeline_t = null; -let pipes_merge_mask: kinc_g5_pipeline_t; +let pipes_merge: iron_g5_pipeline_t = null; +let pipes_merge_r: iron_g5_pipeline_t = null; +let pipes_merge_g: iron_g5_pipeline_t = null; +let pipes_merge_b: iron_g5_pipeline_t = null; +let pipes_merge_mask: iron_g5_pipeline_t; -let pipes_invert8: kinc_g5_pipeline_t; -let pipes_apply_mask: kinc_g5_pipeline_t; -let pipes_colorid_to_mask: kinc_g5_pipeline_t; +let pipes_invert8: iron_g5_pipeline_t; +let pipes_apply_mask: iron_g5_pipeline_t; +let pipes_colorid_to_mask: iron_g5_pipeline_t; -let pipes_tex0: kinc_g5_texture_unit_t; -let pipes_tex1: kinc_g5_texture_unit_t; -let pipes_texmask: kinc_g5_texture_unit_t; -let pipes_texa: kinc_g5_texture_unit_t; -let pipes_opac: kinc_g5_constant_location_t; -let pipes_blending: kinc_g5_constant_location_t; -let pipes_tex0_mask: kinc_g5_texture_unit_t; -let pipes_texa_mask: kinc_g5_texture_unit_t; -let pipes_tex0_merge_mask: kinc_g5_texture_unit_t; -let pipes_texa_merge_mask: kinc_g5_texture_unit_t; -let pipes_tex_colorid: kinc_g5_texture_unit_t; -let pipes_texpaint_colorid: kinc_g5_texture_unit_t; -let pipes_opac_merge_mask: kinc_g5_constant_location_t; -let pipes_blending_merge_mask: kinc_g5_constant_location_t; -let pipes_temp_mask_image: kinc_g5_texture_t = null; +let pipes_tex0: iron_g5_texture_unit_t; +let pipes_tex1: iron_g5_texture_unit_t; +let pipes_texmask: iron_g5_texture_unit_t; +let pipes_texa: iron_g5_texture_unit_t; +let pipes_opac: iron_g5_constant_location_t; +let pipes_blending: iron_g5_constant_location_t; +let pipes_tex0_mask: iron_g5_texture_unit_t; +let pipes_texa_mask: iron_g5_texture_unit_t; +let pipes_tex0_merge_mask: iron_g5_texture_unit_t; +let pipes_texa_merge_mask: iron_g5_texture_unit_t; +let pipes_tex_colorid: iron_g5_texture_unit_t; +let pipes_texpaint_colorid: iron_g5_texture_unit_t; +let pipes_opac_merge_mask: iron_g5_constant_location_t; +let pipes_blending_merge_mask: iron_g5_constant_location_t; +let pipes_temp_mask_image: iron_g5_texture_t = null; -let pipes_inpaint_preview: kinc_g5_pipeline_t; -let pipes_tex0_inpaint_preview: kinc_g5_texture_unit_t; -let pipes_texa_inpaint_preview: kinc_g5_texture_unit_t; +let pipes_inpaint_preview: iron_g5_pipeline_t; +let pipes_tex0_inpaint_preview: iron_g5_texture_unit_t; +let pipes_texa_inpaint_preview: iron_g5_texture_unit_t; -let pipes_cursor: kinc_g5_pipeline_t; -let pipes_cursor_vp: kinc_g5_constant_location_t; -let pipes_cursor_inv_vp: kinc_g5_constant_location_t; -let pipes_cursor_mouse: kinc_g5_constant_location_t; -let pipes_cursor_tex_step: kinc_g5_constant_location_t; -let pipes_cursor_radius: kinc_g5_constant_location_t; -let pipes_cursor_camera_right: kinc_g5_constant_location_t; -let pipes_cursor_tint: kinc_g5_constant_location_t; -let pipes_cursor_gbufferd: kinc_g5_texture_unit_t; +let pipes_cursor: iron_g5_pipeline_t; +let pipes_cursor_vp: iron_g5_constant_location_t; +let pipes_cursor_inv_vp: iron_g5_constant_location_t; +let pipes_cursor_mouse: iron_g5_constant_location_t; +let pipes_cursor_tex_step: iron_g5_constant_location_t; +let pipes_cursor_radius: iron_g5_constant_location_t; +let pipes_cursor_camera_right: iron_g5_constant_location_t; +let pipes_cursor_tint: iron_g5_constant_location_t; +let pipes_cursor_gbufferd: iron_g5_texture_unit_t; -function _pipes_make_merge(red: bool, green: bool, blue: bool, alpha: bool): kinc_g5_pipeline_t { - let pipe: kinc_g5_pipeline_t = iron_g4_create_pipeline(); +function _pipes_make_merge(red: bool, green: bool, blue: bool, alpha: bool): iron_g5_pipeline_t { + let pipe: iron_g5_pipeline_t = iron_g4_create_pipeline(); pipe.vertex_shader = sys_get_shader("pass.vert"); pipe.fragment_shader = sys_get_shader("layer_merge.frag"); - let vs: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipe.input_layout = vs; ARRAY_ACCESS(pipe.color_write_mask_red, 0) = red; @@ -82,7 +82,7 @@ function pipes_init() { pipes_copy = iron_g4_create_pipeline(); pipes_copy.vertex_shader = sys_get_shader("layer_view.vert"); pipes_copy.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_g5_vertex_structure_t = 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); @@ -94,7 +94,7 @@ function pipes_init() { pipes_copy_bgra = iron_g4_create_pipeline(); pipes_copy_bgra.vertex_shader = sys_get_shader("layer_view.vert"); pipes_copy_bgra.fragment_shader = sys_get_shader("layer_copy_bgra.frag"); - let vs: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_g5_vertex_structure_t = 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); @@ -106,7 +106,7 @@ function pipes_init() { pipes_copy8 = iron_g4_create_pipeline(); pipes_copy8.vertex_shader = sys_get_shader("layer_view.vert"); pipes_copy8.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_g5_vertex_structure_t = 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); @@ -120,7 +120,7 @@ function pipes_init() { pipes_copy128 = iron_g4_create_pipeline(); pipes_copy128.vertex_shader = sys_get_shader("layer_view.vert"); pipes_copy128.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_g5_vertex_structure_t = 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); @@ -135,7 +135,7 @@ function pipes_init() { pipes_invert8 = iron_g4_create_pipeline(); pipes_invert8.vertex_shader = sys_get_shader("layer_view.vert"); pipes_invert8.fragment_shader = sys_get_shader("layer_invert.frag"); - let vs: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_g5_vertex_structure_t = 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); @@ -149,7 +149,7 @@ function pipes_init() { pipes_apply_mask = iron_g4_create_pipeline(); pipes_apply_mask.vertex_shader = sys_get_shader("pass.vert"); pipes_apply_mask.fragment_shader = sys_get_shader("mask_apply.frag"); - let vs: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipes_apply_mask.input_layout = vs; iron_g4_compile_pipeline(pipes_apply_mask); @@ -161,7 +161,7 @@ function pipes_init() { pipes_merge_mask = iron_g4_create_pipeline(); pipes_merge_mask.vertex_shader = sys_get_shader("pass.vert"); pipes_merge_mask.fragment_shader = sys_get_shader("mask_merge.frag"); - let vs: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipes_merge_mask.input_layout = vs; iron_g4_compile_pipeline(pipes_merge_mask); @@ -175,7 +175,7 @@ function pipes_init() { pipes_colorid_to_mask = iron_g4_create_pipeline(); pipes_colorid_to_mask.vertex_shader = sys_get_shader("pass.vert"); pipes_colorid_to_mask.fragment_shader = sys_get_shader("mask_colorid.frag"); - let vs: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipes_colorid_to_mask.input_layout = vs; iron_g4_compile_pipeline(pipes_colorid_to_mask); @@ -189,7 +189,7 @@ function pipes_init() { pipes_copy_r = iron_g4_create_pipeline(); pipes_copy_r.vertex_shader = sys_get_shader("layer_view.vert"); pipes_copy_r.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_g5_vertex_structure_t = 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); @@ -204,7 +204,7 @@ function pipes_init() { pipes_copy_g = iron_g4_create_pipeline(); pipes_copy_g.vertex_shader = sys_get_shader("layer_view.vert"); pipes_copy_g.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_g5_vertex_structure_t = 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); @@ -219,7 +219,7 @@ function pipes_init() { pipes_inpaint_preview = iron_g4_create_pipeline(); pipes_inpaint_preview.vertex_shader = sys_get_shader("pass.vert"); pipes_inpaint_preview.fragment_shader = sys_get_shader("inpaint_preview.frag"); - let vs: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipes_inpaint_preview.input_layout = vs; iron_g4_compile_pipeline(pipes_inpaint_preview); @@ -231,7 +231,7 @@ function pipes_init() { pipes_copy_a = iron_g4_create_pipeline(); pipes_copy_a.vertex_shader = sys_get_shader("pass.vert"); pipes_copy_a.fragment_shader = sys_get_shader("layer_copy_rrrr.frag"); - let vs: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipes_copy_a.input_layout = vs; ARRAY_ACCESS(pipes_copy_a.color_write_mask_red, 0) = false; @@ -246,7 +246,7 @@ function pipes_init() { pipes_copy_rgb = iron_g4_create_pipeline(); pipes_copy_rgb.vertex_shader = sys_get_shader("layer_view.vert"); pipes_copy_rgb.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_g5_vertex_structure_t = 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); @@ -259,7 +259,7 @@ function pipes_init() { pipes_cursor = iron_g4_create_pipeline(); pipes_cursor.vertex_shader = sys_get_shader("cursor.vert"); pipes_cursor.fragment_shader = sys_get_shader("cursor.frag"); - let vs: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); ///if (arm_metal || arm_vulkan) g4_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); ///else diff --git a/base/sources/ts/project.ts b/base/sources/ts/project.ts index 5f7e48a1..fd280128 100644 --- a/base/sources/ts/project.ts +++ b/base/sources/ts/project.ts @@ -7,7 +7,7 @@ let project_asset_id: i32 = 0; let project_mesh_assets: string[] = []; let project_material_groups: node_group_t[] = []; let project_paint_objects: mesh_object_t[] = null; -let project_asset_map: map_t = map_create(); // kinc_g5_texture_t | font_t +let project_asset_map: map_t = map_create(); // iron_g5_texture_t | font_t let project_mesh_list: string[] = null; let project_materials: slot_material_t[] = null; @@ -45,7 +45,7 @@ function project_open() { return; } - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); @@ -62,7 +62,7 @@ function project_save(save_and_quit: bool = false) { document_directory = substring(document_directory, 0, document_directory.length - 8); // Strip /"untitled" project_filepath = document_directory + "/" + sys_title() + ".arm"; ///elseif arm_android - project_filepath = kinc_internal_save_path() + "/" + sys_title() + ".arm"; + project_filepath = iron_internal_save_path() + "/" + sys_title() + ".arm"; ///else project_save_as(save_and_quit); return; @@ -79,7 +79,7 @@ function project_save(save_and_quit: bool = false) { app_notify_on_init(function () { export_arm_run_project(); if (_project_save_and_quit) { - kinc_stop(); + iron_stop(); } }); } @@ -226,7 +226,7 @@ function project_new(reset_layers: bool = true) { let n: string = context_raw.project_type == project_model_t.ROUNDED_CUBE ? ".Cube" : "Tessellated"; let md: mesh_data_t = data_get_mesh("Scene", n); - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); @@ -640,7 +640,7 @@ function project_reimport_texture(asset: asset_t) { } } -function project_get_image(asset: asset_t): kinc_g5_texture_t { +function project_get_image(asset: asset_t): iron_g5_texture_t { return asset != null ? map_get(project_asset_map, asset.id) : null; } diff --git a/base/sources/ts/render_path_base.ts b/base/sources/ts/render_path_base.ts index 71b697d6..d307ccb9 100644 --- a/base/sources/ts/render_path_base.ts +++ b/base/sources/ts/render_path_base.ts @@ -95,7 +95,7 @@ function render_path_base_ssaa4(): bool { } function render_path_base_is_cached(): bool { - if (kinc_window_width() == 0 || kinc_window_height() == 0) { + if (iron_window_width() == 0 || iron_window_height() == 0) { return true; } diff --git a/base/sources/ts/render_path_raytrace.ts b/base/sources/ts/render_path_raytrace.ts index a0bf1714..3fd3dfbb 100644 --- a/base/sources/ts/render_path_raytrace.ts +++ b/base/sources/ts/render_path_raytrace.ts @@ -7,10 +7,10 @@ let render_path_raytrace_first: bool = true; let render_path_raytrace_f32a: f32_array_t = f32_array_create(24); let render_path_raytrace_help_mat: mat4_t = mat4_identity(); let render_path_raytrace_transform: mat4_t; -let render_path_raytrace_vb: kinc_g5_vertex_buffer_t; -let render_path_raytrace_ib: kinc_g5_index_buffer_t; +let render_path_raytrace_vb: iron_g5_vertex_buffer_t; +let render_path_raytrace_ib: iron_g5_index_buffer_t; -let render_path_raytrace_last_envmap: kinc_g5_texture_t = null; +let render_path_raytrace_last_envmap: iron_g5_texture_t = null; let render_path_raytrace_is_bake: bool = false; ///if arm_direct3d12 @@ -21,7 +21,7 @@ let render_path_raytrace_ext: string = ".metal"; let render_path_raytrace_ext: string = ".spirv"; ///end -let render_path_raytrace_last_texpaint: kinc_g5_texture_t = null; +let render_path_raytrace_last_texpaint: iron_g5_texture_t = null; function render_path_raytrace_init() { } @@ -45,14 +45,14 @@ function render_path_raytrace_commands(use_live_layer: bool) { } let probe: world_data_t = scene_world; - let saved_envmap: kinc_g5_texture_t = context_raw.show_envmap_blur ? probe._.radiance_mipmaps[0] : context_raw.saved_envmap; + let saved_envmap: iron_g5_texture_t = context_raw.show_envmap_blur ? probe._.radiance_mipmaps[0] : context_raw.saved_envmap; if (render_path_raytrace_last_envmap != saved_envmap) { render_path_raytrace_last_envmap = saved_envmap; - let bnoise_sobol: kinc_g5_texture_t = map_get(scene_embedded, "bnoise_sobol.k"); - let bnoise_scramble: kinc_g5_texture_t = map_get(scene_embedded, "bnoise_scramble.k"); - let bnoise_rank: kinc_g5_texture_t = map_get(scene_embedded, "bnoise_rank.k"); + let bnoise_sobol: iron_g5_texture_t = map_get(scene_embedded, "bnoise_sobol.k"); + let bnoise_scramble: iron_g5_texture_t = map_get(scene_embedded, "bnoise_scramble.k"); + let bnoise_rank: iron_g5_texture_t = map_get(scene_embedded, "bnoise_rank.k"); let l: slot_layer_t = layers_flatten(true); iron_raytrace_set_textures(l.texpaint, l.texpaint_nor, l.texpaint_pack, saved_envmap, bnoise_sobol, bnoise_scramble, bnoise_rank); @@ -63,9 +63,9 @@ function render_path_raytrace_commands(use_live_layer: bool) { if (l.texpaint != render_path_raytrace_last_texpaint) { render_path_raytrace_last_texpaint = l.texpaint; - let bnoise_sobol: kinc_g5_texture_t = map_get(scene_embedded, "bnoise_sobol.k"); - let bnoise_scramble: kinc_g5_texture_t = map_get(scene_embedded, "bnoise_scramble.k"); - let bnoise_rank: kinc_g5_texture_t = map_get(scene_embedded, "bnoise_rank.k"); + let bnoise_sobol: iron_g5_texture_t = map_get(scene_embedded, "bnoise_sobol.k"); + let bnoise_scramble: iron_g5_texture_t = map_get(scene_embedded, "bnoise_scramble.k"); + let bnoise_rank: iron_g5_texture_t = map_get(scene_embedded, "bnoise_rank.k"); iron_raytrace_set_textures(l.texpaint, l.texpaint_nor, l.texpaint_pack, saved_envmap, bnoise_sobol, bnoise_scramble, bnoise_rank); } @@ -168,8 +168,8 @@ function render_path_raytrace_raytrace_init(shader_name: string, build: bool = t iron_raytrace_as_add(render_path_raytrace_vb, render_path_raytrace_ib, render_path_raytrace_transform); ///end - let vb_full: kinc_g5_vertex_buffer_t = context_raw.merged_object.data._.vertex_buffer; - let ib_full: kinc_g5_index_buffer_t = context_raw.merged_object.data._.index_buffers[0]; + let vb_full: iron_g5_vertex_buffer_t = context_raw.merged_object.data._.vertex_buffer; + let ib_full: iron_g5_index_buffer_t = context_raw.merged_object.data._.index_buffers[0]; iron_raytrace_as_build(vb_full, ib_full); } diff --git a/base/sources/ts/render_path_raytrace_bake.ts b/base/sources/ts/render_path_raytrace_bake.ts index caac69f4..845c37da 100644 --- a/base/sources/ts/render_path_raytrace_bake.ts +++ b/base/sources/ts/render_path_raytrace_bake.ts @@ -4,7 +4,7 @@ let render_path_raytrace_bake_rays_sec: i32 = 0; let render_path_raytrace_bake_current_sample: i32 = 0; let render_path_raytrace_bake_rays_timer: f32 = 0.0; let render_path_raytrace_bake_rays_counter: i32 = 0; -let render_path_raytrace_bake_last_layer: kinc_g5_texture_t = null; +let render_path_raytrace_bake_last_layer: iron_g5_texture_t = null; let render_path_raytrace_bake_last_bake: i32 = 0; function render_path_raytrace_bake_commands(parse_paint_material: (b?: bool)=>void): bool { @@ -74,15 +74,15 @@ function render_path_raytrace_bake_commands(parse_paint_material: (b?: bool)=>vo } let probe: world_data_t = scene_world; - let saved_envmap: kinc_g5_texture_t = context_raw.show_envmap_blur ? probe._.radiance_mipmaps[0] : context_raw.saved_envmap; + let saved_envmap: iron_g5_texture_t = context_raw.show_envmap_blur ? probe._.radiance_mipmaps[0] : context_raw.saved_envmap; if (render_path_raytrace_last_envmap != saved_envmap || render_path_raytrace_bake_last_layer != context_raw.layer.texpaint) { render_path_raytrace_last_envmap = saved_envmap; render_path_raytrace_bake_last_layer = context_raw.layer.texpaint; - let bnoise_sobol: kinc_g5_texture_t = map_get(scene_embedded, "bnoise_sobol.k"); - let bnoise_scramble: kinc_g5_texture_t = map_get(scene_embedded, "bnoise_scramble.k"); - let bnoise_rank: kinc_g5_texture_t = map_get(scene_embedded, "bnoise_rank.k"); + let bnoise_sobol: iron_g5_texture_t = map_get(scene_embedded, "bnoise_sobol.k"); + let bnoise_scramble: iron_g5_texture_t = map_get(scene_embedded, "bnoise_scramble.k"); + let bnoise_rank: iron_g5_texture_t = map_get(scene_embedded, "bnoise_rank.k"); let baketex0: render_target_t = map_get(render_path_render_targets, "baketex0"); let baketex1: render_target_t = map_get(render_path_render_targets, "baketex1"); diff --git a/base/sources/ts/resource.ts b/base/sources/ts/resource.ts index fc5e4750..984a40de 100644 --- a/base/sources/ts/resource.ts +++ b/base/sources/ts/resource.ts @@ -1,31 +1,31 @@ -let resource_bundled: map_t = map_create(); +let resource_bundled: map_t = map_create(); function resource_load(names: string[]) { for (let i: i32 = 0; i < names.length; ++i) { let s: string = names[i]; - let image: kinc_g5_texture_t = data_get_image(s); + let image: iron_g5_texture_t = data_get_image(s); map_set(resource_bundled, s, image); } } -function resource_get(name: string): kinc_g5_texture_t { +function resource_get(name: string): iron_g5_texture_t { return map_get(resource_bundled, name); } -function resource_tile50(img: kinc_g5_texture_t, x: i32, y: i32): rect_t { +function resource_tile50(img: iron_g5_texture_t, x: i32, y: i32): rect_t { let size: i32 = config_raw.window_scale > 1 ? 100 : 50; let r: rect_t = { x: x * size, y: y * size, w: size, h: size }; return r; } -function resource_tile25(img: kinc_g5_texture_t, x: i32, y: i32): rect_t { +function resource_tile25(img: iron_g5_texture_t, x: i32, y: i32): rect_t { let size: i32 = config_raw.window_scale > 1 ? 50 : 25; let r: rect_t = { x: x * size, y: y * size, w: size, h: size }; return r; } -function resource_tile18(img: kinc_g5_texture_t, x: i32, y: i32): rect_t { +function resource_tile18(img: iron_g5_texture_t, x: i32, y: i32): rect_t { let size: i32 = config_raw.window_scale > 1 ? 36 : 18; let r: rect_t = { x: x * size, y: img.height - (y + 1) * size, w: size, h: size }; return r; diff --git a/base/sources/ts/slot_brush.ts b/base/sources/ts/slot_brush.ts index 75296691..20cdc90e 100644 --- a/base/sources/ts/slot_brush.ts +++ b/base/sources/ts/slot_brush.ts @@ -2,8 +2,8 @@ type slot_brush_t = { nodes?: ui_nodes_t; canvas?: ui_node_canvas_t; - image?: kinc_g5_texture_t; // 200px - image_icon?: kinc_g5_texture_t; // 50px + image?: iron_g5_texture_t; // 200px + image_icon?: iron_g5_texture_t; // 50px preview_ready?: bool; id?: i32; }; diff --git a/base/sources/ts/slot_font.ts b/base/sources/ts/slot_font.ts index 209d452e..d4a4e0c2 100644 --- a/base/sources/ts/slot_font.ts +++ b/base/sources/ts/slot_font.ts @@ -1,6 +1,6 @@ type slot_font_t = { - image?: kinc_g5_texture_t; // 200px + image?: iron_g5_texture_t; // 200px preview_ready?: bool; id?: i32; font?: draw_font_t; diff --git a/base/sources/ts/slot_layer.ts b/base/sources/ts/slot_layer.ts index 1e482065..771efb51 100644 --- a/base/sources/ts/slot_layer.ts +++ b/base/sources/ts/slot_layer.ts @@ -5,10 +5,10 @@ type slot_layer_t = { ext?: string; visible?: bool; parent?: slot_layer_t; // Group (for layers) or layer (for masks) - texpaint?: kinc_g5_texture_t; // Base or mask - texpaint_nor?: kinc_g5_texture_t; - texpaint_pack?: kinc_g5_texture_t; - texpaint_preview?: kinc_g5_texture_t; // Layer preview + texpaint?: iron_g5_texture_t; // Base or mask + texpaint_nor?: iron_g5_texture_t; + texpaint_pack?: iron_g5_texture_t; + texpaint_preview?: iron_g5_texture_t; // Layer preview mask_opacity?: f32; // Opacity mask fill_layer?: slot_material_t; show_panel?: bool; @@ -179,22 +179,22 @@ function slot_layer_unload(raw: slot_layer_t) { return; } - let _texpaint: kinc_g5_texture_t = raw.texpaint; - let _texpaint_nor: kinc_g5_texture_t = raw.texpaint_nor; - let _texpaint_pack: kinc_g5_texture_t = raw.texpaint_pack; - let _texpaint_preview: kinc_g5_texture_t = raw.texpaint_preview; + let _texpaint: iron_g5_texture_t = raw.texpaint; + let _texpaint_nor: iron_g5_texture_t = raw.texpaint_nor; + let _texpaint_pack: iron_g5_texture_t = raw.texpaint_pack; + let _texpaint_preview: iron_g5_texture_t = raw.texpaint_preview; - app_notify_on_next_frame(function (_texpaint: kinc_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint: iron_g5_texture_t) { iron_unload_image(_texpaint); }, _texpaint); if (_texpaint_nor != null) { - app_notify_on_next_frame(function (_texpaint_nor: kinc_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint_nor: iron_g5_texture_t) { iron_unload_image(_texpaint_nor); }, _texpaint_nor); } if (_texpaint_pack != null) { - app_notify_on_next_frame(function (_texpaint_pack: kinc_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint_pack: iron_g5_texture_t) { iron_unload_image(_texpaint_pack); }, _texpaint_pack); } @@ -216,11 +216,11 @@ function slot_layer_swap(raw: slot_layer_t, other: slot_layer_t) { let rt1: render_target_t = map_get(render_path_render_targets, "texpaint" + other.ext); rt0._image = other.texpaint; rt1._image = raw.texpaint; - let _texpaint: kinc_g5_texture_t = raw.texpaint; + let _texpaint: iron_g5_texture_t = raw.texpaint; raw.texpaint = other.texpaint; other.texpaint = _texpaint; - let _texpaint_preview: kinc_g5_texture_t = raw.texpaint_preview; + let _texpaint_preview: iron_g5_texture_t = raw.texpaint_preview; raw.texpaint_preview = other.texpaint_preview; other.texpaint_preview = _texpaint_preview; } @@ -234,8 +234,8 @@ function slot_layer_swap(raw: slot_layer_t, other: slot_layer_t) { nor1._image = raw.texpaint_nor; let pack1: render_target_t = map_get(render_path_render_targets, "texpaint_pack" + other.ext); pack1._image = raw.texpaint_pack; - let _texpaint_nor: kinc_g5_texture_t = raw.texpaint_nor; - let _texpaint_pack: kinc_g5_texture_t = raw.texpaint_pack; + let _texpaint_nor: iron_g5_texture_t = raw.texpaint_nor; + let _texpaint_pack: iron_g5_texture_t = raw.texpaint_pack; raw.texpaint_nor = other.texpaint_nor; raw.texpaint_pack = other.texpaint_pack; other.texpaint_nor = _texpaint_nor; @@ -243,10 +243,10 @@ function slot_layer_swap(raw: slot_layer_t, other: slot_layer_t) { } } -function slot_layer_clear(raw: slot_layer_t, base_color: i32 = 0x00000000, base_image: kinc_g5_texture_t = null, occlusion: f32 = 1.0, roughness: f32 = layers_default_rough, metallic: f32 = 0.0) { - iron_g4_begin(raw.texpaint); - kinc_g5_clear(base_color); // Base - iron_g4_end(); +function slot_layer_clear(raw: slot_layer_t, base_color: i32 = 0x00000000, base_image: iron_g5_texture_t = null, occlusion: f32 = 1.0, roughness: f32 = layers_default_rough, metallic: f32 = 0.0) { + _iron_g4_begin(raw.texpaint); + iron_g5_clear(base_color); // Base + _iron_g4_end(); if (base_image != null) { g2_begin(raw.texpaint); draw_scaled_image(base_image, 0, 0, raw.texpaint.width, raw.texpaint.height); @@ -254,12 +254,12 @@ function slot_layer_clear(raw: slot_layer_t, base_color: i32 = 0x00000000, base_ } if (slot_layer_is_layer(raw)) { - iron_g4_begin(raw.texpaint_nor); - kinc_g5_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); // Nor - iron_g4_end(); - iron_g4_begin(raw.texpaint_pack); - kinc_g5_clear(color_from_floats(occlusion, roughness, metallic, 0.0)); // Occ, rough, met - iron_g4_end(); + _iron_g4_begin(raw.texpaint_nor); + iron_g5_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); // Nor + _iron_g4_end(); + _iron_g4_begin(raw.texpaint_pack); + iron_g5_clear(color_from_floats(occlusion, roughness, metallic, 0.0)); // Occ, rough, met + _iron_g4_end(); } context_raw.layer_preview_dirty = true; @@ -267,14 +267,14 @@ function slot_layer_clear(raw: slot_layer_t, base_color: i32 = 0x00000000, base_ } function slot_layer_invert_mask(raw: slot_layer_t) { - let inverted: kinc_g5_texture_t = iron_g4_create_render_target(raw.texpaint.width, raw.texpaint.height, tex_format_t.RGBA32); + let inverted: iron_g5_texture_t = iron_g4_create_render_target(raw.texpaint.width, raw.texpaint.height, tex_format_t.RGBA32); g2_begin(inverted); draw_set_pipeline(pipes_invert8); draw_image(raw.texpaint, 0, 0); draw_set_pipeline(null); g2_end(); - let _texpaint: kinc_g5_texture_t = raw.texpaint; - app_notify_on_next_frame(function (_texpaint: kinc_g5_texture_t) { + let _texpaint: iron_g5_texture_t = raw.texpaint; + app_notify_on_next_frame(function (_texpaint: iron_g5_texture_t) { iron_unload_image(_texpaint); }, _texpaint); let rt: render_target_t = map_get(render_path_render_targets, "texpaint" + raw.id); @@ -338,7 +338,7 @@ function slot_layer_duplicate(raw: slot_layer_t): slot_layer_t { if (l.texpaint_preview != null) { g2_begin(l.texpaint_preview); - kinc_g5_clear(0x00000000); + iron_g5_clear(0x00000000); draw_set_pipeline(pipes_copy); draw_scaled_image(raw.texpaint_preview, 0, 0, raw.texpaint_preview.width, raw.texpaint_preview.height); draw_set_pipeline(null); @@ -383,7 +383,7 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { format = tex_format_t.RGBA128; ///end - let _texpaint: kinc_g5_texture_t = raw.texpaint; + let _texpaint: iron_g5_texture_t = raw.texpaint; raw.texpaint = iron_g4_create_render_target(res_x, res_y, format); g2_begin(raw.texpaint); draw_set_pipeline(pipes_copy); @@ -391,7 +391,7 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { draw_set_pipeline(null); g2_end(); - let _texpaint_nor: kinc_g5_texture_t = raw.texpaint_nor; + let _texpaint_nor: iron_g5_texture_t = raw.texpaint_nor; if (raw.texpaint_nor != null) { raw.texpaint_nor = iron_g4_create_render_target(res_x, res_y, format); @@ -402,7 +402,7 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { g2_end(); } - let _texpaint_pack: kinc_g5_texture_t = raw.texpaint_pack; + let _texpaint_pack: iron_g5_texture_t = raw.texpaint_pack; if (raw.texpaint_pack != null) { raw.texpaint_pack = iron_g4_create_render_target(res_x, res_y, format); @@ -413,18 +413,18 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { g2_end(); } - app_notify_on_next_frame(function (_texpaint: kinc_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint: iron_g5_texture_t) { iron_unload_image(_texpaint); }, _texpaint); if (_texpaint_nor != null) { - app_notify_on_next_frame(function (_texpaint_nor: kinc_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint_nor: iron_g5_texture_t) { iron_unload_image(_texpaint_nor); }, _texpaint_nor); } if (_texpaint_pack != null) { - app_notify_on_next_frame(function (_texpaint_pack: kinc_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint_pack: iron_g5_texture_t) { iron_unload_image(_texpaint_pack); }, _texpaint_pack); } @@ -443,7 +443,7 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { } } else if (slot_layer_is_mask(raw)) { - let _texpaint: kinc_g5_texture_t = raw.texpaint; + let _texpaint: iron_g5_texture_t = raw.texpaint; raw.texpaint = iron_g4_create_render_target(res_x, res_y, tex_format_t.RGBA32); g2_begin(raw.texpaint); @@ -452,7 +452,7 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { draw_set_pipeline(null); g2_end(); - app_notify_on_next_frame(function (_texpaint: kinc_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint: iron_g5_texture_t) { iron_unload_image(_texpaint); }, _texpaint); diff --git a/base/sources/ts/slot_material.ts b/base/sources/ts/slot_material.ts index cb81347c..da04e083 100644 --- a/base/sources/ts/slot_material.ts +++ b/base/sources/ts/slot_material.ts @@ -2,8 +2,8 @@ type slot_material_t = { nodes?: ui_nodes_t; canvas?: ui_node_canvas_t; - image?: kinc_g5_texture_t; - image_icon?: kinc_g5_texture_t; + image?: iron_g5_texture_t; + image_icon?: iron_g5_texture_t; preview_ready?: bool; data?: material_data_t; id?: i32; diff --git a/base/sources/ts/tab_browser.ts b/base/sources/ts/tab_browser.ts index 1032c3c5..2f9b1966 100644 --- a/base/sources/ts/tab_browser.ts +++ b/base/sources/ts/tab_browser.ts @@ -246,7 +246,7 @@ function tab_browser_draw(htab: ui_handle_t) { tab_browser_hpath.text = "/storage/emulated/0/DCIM/Camera"; } if (ui_menu_button(tr("Projects"))) { - tab_browser_hpath.text = kinc_internal_save_path(); + tab_browser_hpath.text = iron_internal_save_path(); } }); ///else diff --git a/base/sources/ts/tab_brushes.ts b/base/sources/ts/tab_brushes.ts index 9bfe7a12..56479885 100644 --- a/base/sources/ts/tab_brushes.ts +++ b/base/sources/ts/tab_brushes.ts @@ -52,8 +52,8 @@ function tab_brushes_draw(htab: ui_handle_t) { } continue; } - let img: kinc_g5_texture_t = ui_SCALE(ui) > 1 ? project_brushes[i].image : project_brushes[i].image_icon; - let img_full: kinc_g5_texture_t = project_brushes[i].image; + let img: iron_g5_texture_t = ui_SCALE(ui) > 1 ? project_brushes[i].image : project_brushes[i].image_icon; + let img_full: iron_g5_texture_t = project_brushes[i].image; if (context_raw.brush == project_brushes[i]) { // ui_fill(1, -2, img.width + 3, img.height + 3, ui.ops.theme.HIGHLIGHT_COL); // TODO diff --git a/base/sources/ts/tab_console.ts b/base/sources/ts/tab_console.ts index 88237cb8..187481da 100644 --- a/base/sources/ts/tab_console.ts +++ b/base/sources/ts/tab_console.ts @@ -49,7 +49,7 @@ function tab_console_draw(htab: ui_handle_t) { ///if (arm_windows || arm_linux || arm_macos) if (ui_button(tr("Copy"))) { let str: string = string_array_join(console_last_traces, "\n"); - kinc_copy_to_clipboard(str); + iron_copy_to_clipboard(str); } ///end diff --git a/base/sources/ts/tab_fonts.ts b/base/sources/ts/tab_fonts.ts index c6255138..6f48a748 100644 --- a/base/sources/ts/tab_fonts.ts +++ b/base/sources/ts/tab_fonts.ts @@ -29,7 +29,7 @@ function tab_fonts_draw(htab: ui_handle_t) { ui_end_sticky(); ui_separator(3, false); - let statusw: i32 = kinc_window_width() - ui_toolbar_w - config_raw.layout[layout_size_t.SIDEBAR_W]; + let statusw: i32 = iron_window_width() - ui_toolbar_w - config_raw.layout[layout_size_t.SIDEBAR_W]; let slotw: i32 = math_floor(51 * ui_SCALE(ui)); let num: i32 = math_floor(statusw / slotw); if (num == 0) { @@ -60,7 +60,7 @@ function tab_fonts_draw(htab: ui_handle_t) { } continue; } - let img: kinc_g5_texture_t = project_fonts[i].image; + let img: iron_g5_texture_t = project_fonts[i].image; if (context_raw.font == project_fonts[i]) { // ui_fill(1, -2, img.width + 3, img.height + 3, ui.ops.theme.HIGHLIGHT_COL); // TODO @@ -80,7 +80,7 @@ function tab_fonts_draw(htab: ui_handle_t) { let state: ui_state_t = ui_state_t.IDLE; if (project_fonts[i].preview_ready) { // draw_set_pipeline(pipe); // L8 - // iron_g4_set_int(channel_location, 1); + // _iron_g4_set_int(channel_location, 1); state = _ui_image(img); // draw_set_pipeline(null); } diff --git a/base/sources/ts/tab_layers.ts b/base/sources/ts/tab_layers.ts index 441c3442..5f8083a8 100644 --- a/base/sources/ts/tab_layers.ts +++ b/base/sources/ts/tab_layers.ts @@ -345,7 +345,7 @@ function tab_layers_draw_layer_slot_full(l: slot_layer_t, i: i32) { } // Draw eye icon - let icons: kinc_g5_texture_t = resource_get("icons.k"); + let icons: iron_g5_texture_t = resource_get("icons.k"); let r: rect_t = resource_tile18(icons, l.visible ? 0 : 1, 0); let center: f32 = (step / 2) * ui_SCALE(ui); ui._x += 2; @@ -573,7 +573,7 @@ function tab_layers_draw_layer_highlight(l: slot_layer_t, mini: bool) { function tab_layers_handle_layer_icon_state(l: slot_layer_t, i: i32, state: ui_state_t, uix: f32, uiy: f32) { let ui: ui_t = ui_base_ui; - let texpaint_preview: kinc_g5_texture_t = l.texpaint_preview; + let texpaint_preview: iron_g5_texture_t = l.texpaint_preview; tab_layers_show_context_menu = false; @@ -620,7 +620,7 @@ function tab_layers_handle_layer_icon_state(l: slot_layer_t, i: i32, state: ui_s function tab_layers_draw_layer_icon(l: slot_layer_t, i: i32, uix: f32, uiy: f32, mini: bool): ui_state_t { let ui: ui_t = ui_base_ui; - let icons: kinc_g5_texture_t = resource_get("icons.k"); + let icons: iron_g5_texture_t = resource_get("icons.k"); let icon_h: i32 = (ui_ELEMENT_H(ui) - (mini ? 2 : 3)) * 2; if (mini && ui_SCALE(ui) > 1) { @@ -637,9 +637,9 @@ function tab_layers_draw_layer_icon(l: slot_layer_t, i: i32, uix: f32, uiy: f32, } if (!slot_layer_is_group(l)) { - let texpaint_preview: kinc_g5_texture_t = l.texpaint_preview; + let texpaint_preview: iron_g5_texture_t = l.texpaint_preview; - let icon: kinc_g5_texture_t = l.fill_layer == null ? texpaint_preview : l.fill_layer.image_icon; + let icon: iron_g5_texture_t = l.fill_layer == null ? texpaint_preview : l.fill_layer.image_icon; if (l.fill_layer == null) { // Checker let r: rect_t = resource_tile50(icons, 4, 1); @@ -654,7 +654,7 @@ function tab_layers_draw_layer_icon(l: slot_layer_t, i: i32, uix: f32, uiy: f32, } if (l.fill_layer == null && slot_layer_is_mask(l)) { draw_set_pipeline(ui_view2d_pipe); - iron_g4_set_int(ui_view2d_channel_loc, 1); + _iron_g4_set_int(ui_view2d_channel_loc, 1); } let state: ui_state_t = _ui_image(icon, 0xffffffff, icon_h); @@ -1008,7 +1008,7 @@ function tab_layers_make_mask_preview_rgba32(l: slot_layer_t) { let l: slot_layer_t = tab_layers_l; g2_begin(context_raw.mask_preview_rgba32); draw_set_pipeline(ui_view2d_pipe); - iron_g4_set_int(ui_view2d_channel_loc, 1); + _iron_g4_set_int(ui_view2d_channel_loc, 1); draw_image(l.texpaint_preview, 0, 0); g2_end(); draw_set_pipeline(null); diff --git a/base/sources/ts/tab_materials.ts b/base/sources/ts/tab_materials.ts index c600ac2c..9a0f1ef7 100644 --- a/base/sources/ts/tab_materials.ts +++ b/base/sources/ts/tab_materials.ts @@ -80,8 +80,8 @@ function tab_materials_draw_slots(mini: bool) { } continue; } - let img: kinc_g5_texture_t = ui_SCALE(ui) > 1 ? project_materials[i].image : project_materials[i].image_icon; - let img_full: kinc_g5_texture_t = project_materials[i].image; + let img: iron_g5_texture_t = ui_SCALE(ui) > 1 ? project_materials[i].image : project_materials[i].image_icon; + let img_full: iron_g5_texture_t = project_materials[i].image; // Highligh selected if (context_raw.material == project_materials[i]) { diff --git a/base/sources/ts/tab_swatches.ts b/base/sources/ts/tab_swatches.ts index cbce67b7..0035d42b 100644 --- a/base/sources/ts/tab_swatches.ts +++ b/base/sources/ts/tab_swatches.ts @@ -1,13 +1,13 @@ -let _tab_swatches_empty: kinc_g5_texture_t; +let _tab_swatches_empty: iron_g5_texture_t; let tab_swatches_drag_pos: i32 = -1; let _tab_swatches_draw_i: i32; -function tab_swatches_empty_set(image: kinc_g5_texture_t) { +function tab_swatches_empty_set(image: iron_g5_texture_t) { _tab_swatches_empty = image; } -function tab_swatches_empty_get(): kinc_g5_texture_t { +function tab_swatches_empty_get(): iron_g5_texture_t { if (_tab_swatches_empty == null) { let b: u8_array_t = u8_array_create(4); b[0] = 255; @@ -199,7 +199,7 @@ function tab_swatches_draw(htab: ui_handle_t) { let color: i32 = context_raw.swatch.base; color = color_set_ab(color, context_raw.swatch.opacity * 255); let val: u32 = color; - kinc_copy_to_clipboard(i32_to_string(val)); + iron_copy_to_clipboard(i32_to_string(val)); } ///end else if (project_raw.swatches.length > 1 && ui_menu_button(tr("Delete"), "delete")) { diff --git a/base/sources/ts/tab_textures.ts b/base/sources/ts/tab_textures.ts index 309f6f42..1a7f551f 100644 --- a/base/sources/ts/tab_textures.ts +++ b/base/sources/ts/tab_textures.ts @@ -1,5 +1,5 @@ -let _tab_textures_draw_img: kinc_g5_texture_t; +let _tab_textures_draw_img: iron_g5_texture_t; let _tab_textures_draw_path: string; let _tab_textures_draw_asset: asset_t; let _tab_textures_draw_i: i32; @@ -40,10 +40,10 @@ function tab_textures_draw(htab: ui_handle_t) { if (project_assets.length > 0) { ///if (is_paint || is_sculpt) - let statusw: i32 = kinc_window_width() - ui_toolbar_w - config_raw.layout[layout_size_t.SIDEBAR_W]; + let statusw: i32 = iron_window_width() - ui_toolbar_w - config_raw.layout[layout_size_t.SIDEBAR_W]; ///end ///if is_lab - let statusw: i32 = kinc_window_width(); + let statusw: i32 = iron_window_width(); ///end let slotw: i32 = math_floor(52 * ui_SCALE(ui)); @@ -78,7 +78,7 @@ function tab_textures_draw(htab: ui_handle_t) { } let asset: asset_t = project_assets[i]; - let img: kinc_g5_texture_t = project_get_image(asset); + let img: iron_g5_texture_t = project_get_image(asset); if (img == null) { let empty_rt: render_target_t = map_get(render_path_render_targets, "empty_black"); img = empty_rt._image; @@ -140,14 +140,14 @@ function tab_textures_draw(htab: ui_handle_t) { _tab_textures_draw_path = path; app_notify_on_next_frame(function () { - let img: kinc_g5_texture_t = _tab_textures_draw_img; - let target: kinc_g5_texture_t = iron_g4_create_render_target(tab_textures_to_pow2(img.width), tab_textures_to_pow2(img.height)); + let img: iron_g5_texture_t = _tab_textures_draw_img; + let target: iron_g5_texture_t = iron_g4_create_render_target(tab_textures_to_pow2(img.width), tab_textures_to_pow2(img.height)); g2_begin(target); draw_set_pipeline(pipes_copy); draw_scaled_image(img, 0, 0, target.width, target.height); draw_set_pipeline(null); g2_end(); - app_notify_on_next_frame(function (target: kinc_g5_texture_t) { + app_notify_on_next_frame(function (target: iron_g5_texture_t) { let path: string = _tab_textures_draw_path; let f: string = ui_files_filename; if (f == "") { @@ -220,7 +220,7 @@ function tab_textures_draw(htab: ui_handle_t) { } } else { - let img: kinc_g5_texture_t = resource_get("icons.k"); + let img: iron_g5_texture_t = resource_get("icons.k"); let r: rect_t = resource_tile50(img, 0, 1); _ui_image(img, ui.ops.theme.BUTTON_COL, r.h, r.x, r.y, r.w, r.h); if (ui.is_hovered) { diff --git a/base/sources/ts/translator.ts b/base/sources/ts/translator.ts index 95ab8b22..7c04f087 100644 --- a/base/sources/ts/translator.ts +++ b/base/sources/ts/translator.ts @@ -59,7 +59,7 @@ function translator_load_translations(new_locale: string) { } if (new_locale == "system") { - config_raw.locale = kinc_language(); + config_raw.locale = iron_language(); } // Check whether the requested or detected locale is available @@ -111,8 +111,8 @@ function translator_load_translations(new_locale: string) { if (cjk) { if (path_is_protected()) { - _translator_load_translations_cjk_font_path = kinc_internal_save_path(); - _translator_load_translations_cjk_font_disk_path = kinc_internal_save_path(); + _translator_load_translations_cjk_font_path = iron_internal_save_path(); + _translator_load_translations_cjk_font_disk_path = iron_internal_save_path(); } else { _translator_load_translations_cjk_font_path = ""; diff --git a/base/sources/ts/ui_base.ts b/base/sources/ts/ui_base.ts index e85282c9..a7a6d53f 100644 --- a/base/sources/ts/ui_base.ts +++ b/base/sources/ts/ui_base.ts @@ -591,7 +591,7 @@ function ui_base_update() { let shortcuts: string[] = ["l", "b", "n", "o", "r", "m", "a", "h", "e", "s", "t", "1", "2", "3", "4"]; - if (kinc_g5_raytrace_supported()) { + if (iron_g5_raytrace_supported()) { array_push(modes, tr("Path Traced")); array_push(shortcuts, "p"); } @@ -659,8 +659,8 @@ function ui_base_update() { if (config_raw.layout[layout_size_t.NODES_W] < 32) { config_raw.layout[layout_size_t.NODES_W] = 32; } - else if (config_raw.layout[layout_size_t.NODES_W] > kinc_window_width() * 0.7) { - config_raw.layout[layout_size_t.NODES_W] = math_floor(kinc_window_width() * 0.7); + else if (config_raw.layout[layout_size_t.NODES_W] > iron_window_width() * 0.7) { + config_raw.layout[layout_size_t.NODES_W] = math_floor(iron_window_width() * 0.7); } } else { // UINodes / UIView2D ratio @@ -675,7 +675,7 @@ function ui_base_update() { } else if (ui_base_border_handle == ui_base_hwnds[tab_area_t.STATUS]) { let my: i32 = math_floor(mouse_movement_y); - if (config_raw.layout[layout_size_t.STATUS_H] - my >= ui_status_default_status_h * config_raw.window_scale && config_raw.layout[layout_size_t.STATUS_H] - my < kinc_window_height() * 0.7) { + if (config_raw.layout[layout_size_t.STATUS_H] - my >= ui_status_default_status_h * config_raw.window_scale && config_raw.layout[layout_size_t.STATUS_H] - my < iron_window_height() * 0.7) { config_raw.layout[layout_size_t.STATUS_H] -= my; } } @@ -685,8 +685,8 @@ function ui_base_update() { if (config_raw.layout[layout_size_t.SIDEBAR_W] < ui_base_sidebar_mini_w) { config_raw.layout[layout_size_t.SIDEBAR_W] = ui_base_sidebar_mini_w; } - else if (config_raw.layout[layout_size_t.SIDEBAR_W] > kinc_window_width() - ui_base_sidebar_mini_w) { - config_raw.layout[layout_size_t.SIDEBAR_W] = kinc_window_width() - ui_base_sidebar_mini_w; + else if (config_raw.layout[layout_size_t.SIDEBAR_W] > iron_window_width() - ui_base_sidebar_mini_w) { + config_raw.layout[layout_size_t.SIDEBAR_W] = iron_window_width() - ui_base_sidebar_mini_w; } } else { @@ -1082,14 +1082,14 @@ function ui_base_update_ui() { continue; } - let target: kinc_g5_texture_t = l.texpaint_preview; + let target: iron_g5_texture_t = l.texpaint_preview; if (target == null) { continue; } - let source: kinc_g5_texture_t = l.texpaint; + let source: iron_g5_texture_t = l.texpaint; g2_begin(target); - kinc_g5_clear(0x00000000); + iron_g5_clear(0x00000000); // draw_set_pipeline(l.is_mask() ? pipes_copy8 : pipes_copy); draw_set_pipeline(pipes_copy); // texpaint_preview is always RGBA32 for now draw_scaled_image(source, 0, 0, target.width, target.height); @@ -1104,12 +1104,12 @@ function ui_base_update_ui() { // Update layer preview let l: slot_layer_t = context_raw.layer; - let target: kinc_g5_texture_t = l.texpaint_preview; + let target: iron_g5_texture_t = l.texpaint_preview; if (target != null) { - let source: kinc_g5_texture_t = l.texpaint; + let source: iron_g5_texture_t = l.texpaint; g2_begin(target); - kinc_g5_clear(0x00000000); + iron_g5_clear(0x00000000); // draw_set_pipeline(raw.layer.is_mask() ? pipes_copy8 : pipes_copy); draw_set_pipeline(pipes_copy); // texpaint_preview is always RGBA32 for now draw_scaled_image(source, 0, 0, target.width, target.height); @@ -1167,7 +1167,7 @@ function ui_base_render() { g2_begin(null); } - if (!ui_base_show || kinc_window_width() == 0 || kinc_window_height() == 0) { + if (!ui_base_show || iron_window_width() == 0 || iron_window_height() == 0) { return; } @@ -1208,7 +1208,7 @@ function ui_base_draw_sidebar() { // Tabs let mini: bool = config_raw.layout[layout_size_t.SIDEBAR_W] <= ui_base_sidebar_mini_w; let expand_button_offset: i32 = config_raw.touch_ui ? math_floor(ui_ELEMENT_H(ui_base_ui) + ui_ELEMENT_OFFSET(ui_base_ui)) : 0; - ui_base_tabx = kinc_window_width() - config_raw.layout[layout_size_t.SIDEBAR_W]; + ui_base_tabx = iron_window_width() - config_raw.layout[layout_size_t.SIDEBAR_W]; let _SCROLL_W: i32 = ui_base_ui.ops.theme.SCROLL_W; if (mini) { @@ -1235,7 +1235,7 @@ function ui_base_draw_sidebar() { if (config_raw.touch_ui) { let width: i32 = config_raw.layout[layout_size_t.SIDEBAR_W]; let height: i32 = math_floor(ui_ELEMENT_H(ui_base_ui) + ui_ELEMENT_OFFSET(ui_base_ui)); - if (ui_window(ui_handle(__ID__), kinc_window_width() - width, kinc_window_height() - height, width, height + 1)) { + if (ui_window(ui_handle(__ID__), iron_window_width() - width, iron_window_height() - height, width, height + 1)) { ui_base_ui._w = width; let _BUTTON_H: i32 = ui_base_ui.ops.theme.BUTTON_H; let _BUTTON_COL: i32 = ui_base_ui.ops.theme.BUTTON_COL; @@ -1253,7 +1253,7 @@ function ui_base_draw_sidebar() { // Expand button if (config_raw.layout[layout_size_t.SIDEBAR_W] == 0) { let width: i32 = math_floor(g2_font_width(ui_base_ui.ops.font, ui_base_ui.font_size, "<<") + 25 * ui_SCALE(ui_base_ui)); - if (ui_window(ui_base_hminimized, kinc_window_width() - width, 0, width, math_floor(ui_ELEMENT_H(ui_base_ui) + ui_ELEMENT_OFFSET(ui_base_ui) + 1))) { + if (ui_window(ui_base_hminimized, iron_window_width() - width, 0, width, math_floor(ui_ELEMENT_H(ui_base_ui) + ui_ELEMENT_OFFSET(ui_base_ui) + 1))) { ui_base_ui._w = width; let _BUTTON_H: i32 = ui_base_ui.ops.theme.BUTTON_H; let _BUTTON_COL: i32 = ui_base_ui.ops.theme.BUTTON_COL; @@ -1295,8 +1295,8 @@ function ui_base_render_cursor() { // Radius being scaled if (context_raw.brush_locked) { - mx += context_raw.lock_started_x - kinc_window_width() / 2; - my += context_raw.lock_started_y - kinc_window_height() / 2; + mx += context_raw.lock_started_x - iron_window_width() / 2; + my += context_raw.lock_started_y - iron_window_height() / 2; } if (context_raw.brush_stencil_image != null && @@ -1338,16 +1338,16 @@ function ui_base_render_cursor() { // Show picked material next to cursor if (context_raw.tool == workspace_tool_t.PICKER && context_raw.picker_select_material && context_raw.color_picker_callback == null) { - let img: kinc_g5_texture_t = context_raw.material.image_icon; + let img: iron_g5_texture_t = context_raw.material.image_icon; draw_image(img, mx + 10, my + 10); } if (context_raw.tool == workspace_tool_t.PICKER && context_raw.color_picker_callback != null) { - let img: kinc_g5_texture_t = resource_get("icons.k"); + let img: iron_g5_texture_t = resource_get("icons.k"); let rect: rect_t = resource_tile50(img, workspace_tool_t.PICKER, 0); draw_sub_image(img, mx + 10, my + 10, rect.x, rect.y, rect.w, rect.h); } - let cursor_img: kinc_g5_texture_t = resource_get("cursor.k"); + let cursor_img: iron_g5_texture_t = resource_get("cursor.k"); let psize: i32 = math_floor(182 * (context_raw.brush_radius * context_raw.brush_nodes_radius) * ui_SCALE(ui_base_ui)); // Clone source cursor @@ -1370,8 +1370,8 @@ function ui_base_render_cursor() { // Radius being scaled if (context_raw.brush_locked) { - context_raw.decal_x += (context_raw.lock_started_x - kinc_window_width() / 2) / base_w(); - context_raw.decal_y += (context_raw.lock_started_y - kinc_window_height() / 2) / base_h(); + context_raw.decal_x += (context_raw.lock_started_x - iron_window_width() / 2) / base_w(); + context_raw.decal_y += (context_raw.lock_started_y - iron_window_height() / 2) / base_h(); } } diff --git a/base/sources/ts/ui_box.ts b/base/sources/ts/ui_box.ts index 774e2b13..94d745de 100644 --- a/base/sources/ts/ui_box.ts +++ b/base/sources/ts/ui_box.ts @@ -28,8 +28,8 @@ function ui_box_render() { let in_use: bool = ui.combo_selected_handle != null; let is_escape: bool = keyboard_started("escape"); if (ui_box_draws > 2 && (ui.input_released || is_escape) && !in_use && !ui.is_typing) { - let appw: i32 = kinc_window_width(); - let apph: i32 = kinc_window_height(); + let appw: i32 = iron_window_width(); + let apph: i32 = iron_window_height(); let mw: i32 = math_floor(ui_box_modalw * ui_SCALE(ui)); let mh: i32 = math_floor(ui_box_modalh * ui_SCALE(ui)); let left: f32 = (appw / 2 - mw / 2) + ui_box_hwnd.drag_x; @@ -50,14 +50,14 @@ function ui_box_render() { ///else draw_set_color(color_from_floats(0, 0, 0, 0.5)); ///end - draw_filled_rect(0, 0, kinc_window_width(), kinc_window_height()); + draw_filled_rect(0, 0, iron_window_width(), iron_window_height()); } g2_end(); let ui: ui_t = base_ui_box; - let appw: i32 = kinc_window_width(); - let apph: i32 = kinc_window_height(); + let appw: i32 = iron_window_width(); + let apph: i32 = iron_window_height(); let mw: i32 = math_floor(ui_box_modalw * ui_SCALE(ui)); let mh: i32 = math_floor(ui_box_modalh * ui_SCALE(ui)); if (mw > appw) { @@ -102,7 +102,7 @@ function ui_box_render() { ///if (arm_windows || arm_linux || arm_macos) if (ui_box_copyable && ui_button(tr("Copy"))) { - kinc_copy_to_clipboard(ui_box_text); + iron_copy_to_clipboard(ui_box_text); } ///end if (ui_button(tr("OK"))) { @@ -176,7 +176,7 @@ function ui_box_tween_in() { let a: tween_anim_t = { target: ADDRESS(ui_box_tween_alpha), to: 0.5, duration: 0.2, ease: ease_t.EXPO_OUT }; tween_to(a); - ui_box_hwnd.drag_y = math_floor(kinc_window_height() / 2); + ui_box_hwnd.drag_y = math_floor(iron_window_height() / 2); a = { target: ADDRESS(ui_box_hwnd.drag_y), to: 0.0, duration: 0.2, ease: ease_t.EXPO_OUT, tick: ui_box_tween_tick }; tween_to(a); } @@ -185,7 +185,7 @@ function ui_box_tween_out() { let a: tween_anim_t = { target: ADDRESS(ui_box_tween_alpha), to: 0.0, duration: 0.2, ease: ease_t.EXPO_IN, done: ui_box_hide_internal }; tween_to(a); - a = { target: ADDRESS(ui_box_hwnd.drag_y), to: kinc_window_height() / 2, duration: 0.2, ease: ease_t.EXPO_IN }; + a = { target: ADDRESS(ui_box_hwnd.drag_y), to: iron_window_height() / 2, duration: 0.2, ease: ease_t.EXPO_IN }; tween_to(a); } @@ -196,7 +196,7 @@ function ui_box_tween_tick() { function ui_box_window_border(ui: ui_t) { if (ui.scissor) { ui.scissor = false; - kinc_g4_disable_scissor(); + iron_g4_disable_scissor(); } // Border draw_set_color(ui.ops.theme.SEPARATOR_COL); diff --git a/base/sources/ts/ui_files.ts b/base/sources/ts/ui_files.ts index f6b6d5f6..0ca5f892 100644 --- a/base/sources/ts/ui_files.ts +++ b/base/sources/ts/ui_files.ts @@ -1,7 +1,7 @@ type draw_cloud_icon_data_t = { f: string; - image: kinc_g5_texture_t; + image: iron_g5_texture_t; }; let ui_files_default_path: string = @@ -21,7 +21,7 @@ let ui_files_path: string = ui_files_default_path; let ui_files_last_path: string = ""; let ui_files_last_search: string = ""; let ui_files_files: string[] = null; -let ui_files_icon_map: map_t = null; +let ui_files_icon_map: map_t = null; let ui_files_icon_file_map: map_t = null; let ui_files_selected: i32 = -1; let ui_files_show_extensions: bool = false; @@ -71,14 +71,14 @@ function ui_files_release_keys() { ///end } -function make_draw_cloud_icon_data(f: string, image: kinc_g5_texture_t): draw_cloud_icon_data_t { +function make_draw_cloud_icon_data(f: string, image: iron_g5_texture_t): draw_cloud_icon_data_t { let data: draw_cloud_icon_data_t = { f: f, image: image }; return data; } function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = false, search: string = "", refresh: bool = false, context_menu: (s: string)=>void = null): string { - let icons: kinc_g5_texture_t = resource_get("icons.k"); + let icons: iron_g5_texture_t = resource_get("icons.k"); let folder: rect_t = resource_tile50(icons, 2, 1); let file: rect_t = resource_tile50(icons, 3, 1); let is_cloud: bool = starts_with(handle.text, "cloud"); @@ -173,7 +173,7 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = let uiy: f32 = ui._y; let state: ui_state_t = ui_state_t.IDLE; let generic: bool = true; - let icon: kinc_g5_texture_t = null; + let icon: iron_g5_texture_t = null; if (is_cloud && f != ".." && !ui_files_offline) { if (ui_files_icon_map == null) { @@ -188,7 +188,7 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = let icon_file: string = substring(f, 0, dot) + "_icon.jpg"; if (array_index_of(files_all, icon_file) >= 0) { let rt: render_target_t = map_get(render_path_render_targets, "empty_black"); - let empty: kinc_g5_texture_t = rt._image; + let empty: iron_g5_texture_t = rt._image; map_set(ui_files_icon_map, handle.text + path_sep + f, empty); _ui_files_file_browser_handle = handle; @@ -196,7 +196,7 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = file_cache_cloud(handle.text + path_sep + icon_file, function (abs: string) { if (abs != null) { - let image: kinc_g5_texture_t = data_get_image(abs); + let image: iron_g5_texture_t = data_get_image(abs); ///if arm_windows abs = string_replace_all(abs, "\\", "/"); ///end @@ -205,7 +205,7 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = let data: draw_cloud_icon_data_t = make_draw_cloud_icon_data(f, image); app_notify_on_init(function (data: draw_cloud_icon_data_t) { - let icon: kinc_g5_texture_t = iron_g4_create_render_target(data.image.width, data.image.height); + let icon: iron_g5_texture_t = iron_g4_create_render_target(data.image.width, data.image.height); if (ends_with(data.f, ".arm")) { // Used for material sphere alpha cutout g2_begin(icon); @@ -215,7 +215,7 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = } else { g2_begin(icon); - kinc_g5_clear(0xffffffff); + iron_g5_clear(0xffffffff); } draw_set_pipeline(pipes_copy_rgb); draw_image(data.image, 0, 0); @@ -312,9 +312,9 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = icon = map_get(ui_files_icon_map, shandle); if (icon == null) { let rt: render_target_t = map_get(render_path_render_targets, "empty_black"); - let empty: kinc_g5_texture_t = rt._image; + let empty: iron_g5_texture_t = rt._image; map_set(ui_files_icon_map, shandle, empty); - let image: kinc_g5_texture_t = data_get_image(shandle); + let image: iron_g5_texture_t = data_get_image(shandle); let args: ui_files_make_icon_t = { image: image, @@ -428,12 +428,12 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = function ui_files_make_icon (args: ui_files_make_icon_t) { let w: i32 = args.w; - let image: kinc_g5_texture_t = args.image; + let image: iron_g5_texture_t = args.image; let sw: i32 = image.width > image.height ? w : math_floor(1.0 * image.width / image.height * w); let sh: i32 = image.width > image.height ? math_floor(1.0 * image.height / image.width * w) : w; - let icon: kinc_g5_texture_t = iron_g4_create_render_target(sw, sh); + let icon: iron_g5_texture_t = iron_g4_create_render_target(sw, sh); g2_begin(icon); - kinc_g5_clear(0xffffffff); + iron_g5_clear(0xffffffff); draw_set_pipeline(pipes_copy_rgb); draw_scaled_image(image, 0, 0, sw, sh); draw_set_pipeline(null); @@ -452,7 +452,7 @@ function ui_files_go_up(handle: ui_handle_t) { } type ui_files_make_icon_t = { - image: kinc_g5_texture_t; + image: iron_g5_texture_t; shandle: string; w: i32; }; diff --git a/base/sources/ts/ui_header.ts b/base/sources/ts/ui_header.ts index 2c316af4..70b2274d 100644 --- a/base/sources/ts/ui_header.ts +++ b/base/sources/ts/ui_header.ts @@ -24,9 +24,9 @@ function ui_header_render_ui() { let nodesw: i32 = (ui_nodes_show || ui_view2d_show) ? config_raw.layout[layout_size_t.NODES_W] : 0; ///if is_lab - let ww: i32 = kinc_window_width() - nodesw; + let ww: i32 = iron_window_width() - nodesw; ///else - let ww: i32 = kinc_window_width() - ui_toolbar_w - config_raw.layout[layout_size_t.SIDEBAR_W] - nodesw; + let ww: i32 = iron_window_width() - ui_toolbar_w - config_raw.layout[layout_size_t.SIDEBAR_W] - nodesw; ///end if (ui_window(ui_header_handle, app_x(), ui_header_h, ww, ui_header_h)) { diff --git a/base/sources/ts/ui_menu.ts b/base/sources/ts/ui_menu.ts index dfa5f205..f6a43af9 100644 --- a/base/sources/ts/ui_menu.ts +++ b/base/sources/ts/ui_menu.ts @@ -32,8 +32,8 @@ function ui_menu_render() { // First draw out of screen, then align the menu based on menu height if (ui_menu_show_first) { - ui_menu_x -= kinc_window_width() * 2; - ui_menu_y -= kinc_window_height() * 2; + ui_menu_x -= iron_window_width() * 2; + ui_menu_y -= iron_window_height() * 2; } ui_begin_region(ui, ui_menu_x, ui_menu_y, menu_w); @@ -122,7 +122,7 @@ function ui_menu_render() { ui_menu_separator(ui); if (ui_menu_button(tr("Exit"))) { - kinc_stop(); + iron_stop(); } } else if (ui_menu_category == menu_category_t.EDIT) { @@ -243,7 +243,7 @@ function ui_menu_render() { ///if (is_paint || is_sculpt) context_raw.draw_wireframe = ui_check(context_raw.wireframe_handle, " " + tr("Wireframe")); if (context_raw.wireframe_handle.changed) { - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; g2_end(); util_uv_cache_uv_map(); g2_begin(current); @@ -312,7 +312,7 @@ function ui_menu_render() { ]; let shortcuts: string[] = ["l", "b", "n", "o", "r", "m", "a", "h", "e", "s", "t", "1", "2", "3", "4"]; - if (kinc_g5_raytrace_supported()) { + if (iron_g5_raytrace_supported()) { array_push(modes, tr("Path Traced")); array_push(shortcuts, "p"); } @@ -437,16 +437,16 @@ function ui_menu_render() { } if (ui_menu_button(tr("Report Bug"))) { ///if (arm_macos || arm_ios) // Limited url length - file_load_url("https://github.com/armory3d/armortools/issues/new?labels=bug&template=bug_report.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + kinc_system_id()); + file_load_url("https://github.com/armory3d/armortools/issues/new?labels=bug&template=bug_report.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + iron_system_id()); ///else - file_load_url("https://github.com/armory3d/armortools/issues/new?labels=bug&template=bug_report.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + kinc_system_id() + "*%0A%0A**Issue description:**%0A%0A**Steps to reproduce:**%0A%0A"); + file_load_url("https://github.com/armory3d/armortools/issues/new?labels=bug&template=bug_report.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + iron_system_id() + "*%0A%0A**Issue description:**%0A%0A**Steps to reproduce:**%0A%0A"); ///end } if (ui_menu_button(tr("Request Feature"))) { ///if (arm_macos || arm_ios) // Limited url length - file_load_url("https://github.com/armory3d/armortools/issues/new?labels=feature%20request&template=feature_request.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + kinc_system_id()); + file_load_url("https://github.com/armory3d/armortools/issues/new?labels=feature%20request&template=feature_request.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + iron_system_id()); ///else - file_load_url("https://github.com/armory3d/armortools/issues/new?labels=feature%20request&template=feature_request.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + kinc_system_id() + "*%0A%0A**Feature description:**%0A%0A"); + file_load_url("https://github.com/armory3d/armortools/issues/new?labels=feature%20request&template=feature_request.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + iron_system_id() + "*%0A%0A**Feature description:**%0A%0A"); ///end } ui_menu_separator(ui); @@ -489,12 +489,12 @@ function ui_menu_render() { if (ui_menu_button(tr("About..."))) { let msg: string = manifest_title + ".org - v" + manifest_version + " (" + config_get_date() + ") - " + config_get_sha() + "\n"; - msg += kinc_system_id() + " - " + strings_graphics_api(); + msg += iron_system_id() + " - " + strings_graphics_api(); ///if arm_windows let save: string; if (path_is_protected()) { - save = kinc_internal_save_path(); + save = iron_internal_save_path(); } else { save = path_data(); @@ -528,7 +528,7 @@ function ui_menu_render() { let tab_vertical: bool = config_raw.touch_ui; if (ui_tab(ui_handle(__ID__), tr("About"), tab_vertical)) { - let img: kinc_g5_texture_t = data_get_image("badge.k"); + let img: iron_g5_texture_t = data_get_image("badge.k"); _ui_image(img); _ui_end_element(); @@ -542,7 +542,7 @@ function ui_menu_render() { ///if (arm_windows || arm_linux || arm_macos) if (ui_button(tr("Copy"))) { - kinc_copy_to_clipboard(_ui_menu_render_msg); + iron_copy_to_clipboard(_ui_menu_render_msg); } ///else _ui_end_element(); @@ -572,8 +572,8 @@ function ui_menu_render() { if (ui_menu_show_first) { ui_menu_show_first = false; ui_menu_h = ui._y - ui_menu_y; - ui_menu_x += kinc_window_width() * 2; - ui_menu_y += kinc_window_height() * 2; + ui_menu_x += iron_window_width() * 2; + ui_menu_y += iron_window_height() * 2; ui_menu_fit_to_screen(); ui_menu_render(); // Render at correct position now } @@ -602,20 +602,20 @@ function ui_menu_draw(commands: (ui: ui_t)=>void = null, x: i32 = -1, y: i32 = - function ui_menu_fit_to_screen() { // Prevent the menu going out of screen let menu_w: f32 = base_default_element_w * ui_SCALE(base_ui_menu) * 2.3; - if (ui_menu_x + menu_w > kinc_window_width()) { + if (ui_menu_x + menu_w > iron_window_width()) { if (ui_menu_x - menu_w > 0) { ui_menu_x = math_floor(ui_menu_x - menu_w); } else { - ui_menu_x = math_floor(kinc_window_width() - menu_w); + ui_menu_x = math_floor(iron_window_width() - menu_w); } } - if (ui_menu_y + ui_menu_h > kinc_window_height()) { + if (ui_menu_y + ui_menu_h > iron_window_height()) { if (ui_menu_y - ui_menu_h > 0) { ui_menu_y = math_floor(ui_menu_y - ui_menu_h); } else { - ui_menu_y = kinc_window_height() - ui_menu_h; + ui_menu_y = iron_window_height() - ui_menu_h; } ui_menu_x += 1; // Move out of mouse focus } diff --git a/base/sources/ts/ui_menubar.ts b/base/sources/ts/ui_menubar.ts index b0b5ccb0..0652bef7 100644 --- a/base/sources/ts/ui_menubar.ts +++ b/base/sources/ts/ui_menubar.ts @@ -125,10 +125,10 @@ function ui_menubar_draw_tab_header() { let nodesw: i32 = (ui_nodes_show || ui_view2d_show) ? config_raw.layout[layout_size_t.NODES_W] : 0; ///if (is_paint || is_sculpt) - let ww: i32 = kinc_window_width() - config_raw.layout[layout_size_t.SIDEBAR_W] - ui_menubar_w - nodesw; + let ww: i32 = iron_window_width() - config_raw.layout[layout_size_t.SIDEBAR_W] - ui_menubar_w - nodesw; panel_x = (app_x() - item_w) + ui_menubar_w; ///else - let ww: i32 = kinc_window_width() - ui_menubar_w - nodesw; + let ww: i32 = iron_window_width() - ui_menubar_w - nodesw; panel_x = (app_x()) + ui_menubar_w; ///end @@ -231,7 +231,7 @@ function ui_menubar_icon_button(ui: ui_t, i: i32, j: i32): bool { let col: u32 = ui.ops.theme.WINDOW_BG_COL; let light: bool = col > 0xff666666 ; let icon_accent: i32 = light ? 0xff666666 : 0xffaaaaaa; - let img: kinc_g5_texture_t = resource_get("icons.k"); + let img: iron_g5_texture_t = resource_get("icons.k"); let rect: rect_t = resource_tile50(img, i, j); return _ui_image(img, icon_accent, -1.0, rect.x, rect.y, rect.w, rect.h) == ui_state_t.RELEASED; } diff --git a/base/sources/ts/ui_nodes.ts b/base/sources/ts/ui_nodes.ts index c0009613..d51ca4c4 100644 --- a/base/sources/ts/ui_nodes.ts +++ b/base/sources/ts/ui_nodes.ts @@ -32,7 +32,7 @@ let ui_nodes_last_node_selected_id: i32 = -1; let ui_nodes_release_link: bool = false; let ui_nodes_is_node_menu_op: bool = false; -let ui_nodes_grid: kinc_g5_texture_t = null; +let ui_nodes_grid: iron_g5_texture_t = null; let ui_nodes_grid_redraw: bool = true; let ui_nodes_grid_cell_w: i32 = 200; let ui_nodes_grid_small_cell_w: i32 = 40; @@ -403,19 +403,19 @@ function ui_nodes_get_canvas_control(ui: ui_t, controls_down: bool): ui_canvas_c if (config_raw.wrap_mouse && controls_down) { if (ui.input_x < ui._window_x) { ui.input_x = ui._window_x + ui._window_w; - kinc_mouse_set_position(math_floor(ui.input_x), math_floor(ui.input_y)); + iron_mouse_set_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; - kinc_mouse_set_position(math_floor(ui.input_x), math_floor(ui.input_y)); + iron_mouse_set_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; - kinc_mouse_set_position(math_floor(ui.input_x), math_floor(ui.input_y)); + iron_mouse_set_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; - kinc_mouse_set_position(math_floor(ui.input_x), math_floor(ui.input_y)); + iron_mouse_set_position(math_floor(ui.input_x), math_floor(ui.input_y)); } } @@ -715,7 +715,7 @@ function ui_nodes_get_node_y(): i32 { return math_floor((mouse_y - ui_nodes_wy - ui_nodes_PAN_Y()) / ui_nodes_SCALE()); } -function ui_nodes_draw_grid(zoom: f32): kinc_g5_texture_t { +function ui_nodes_draw_grid(zoom: f32): iron_g5_texture_t { let ww: i32 = config_raw.layout[layout_size_t.NODES_W]; ///if (is_paint || is_sculpt) @@ -736,9 +736,9 @@ function ui_nodes_draw_grid(zoom: f32): kinc_g5_texture_t { h = 1; } - let grid: kinc_g5_texture_t = iron_g4_create_render_target(w, h); + let grid: iron_g5_texture_t = iron_g4_create_render_target(w, h); g2_begin(grid); - kinc_g5_clear(ui_nodes_ui.ops.theme.SEPARATOR_COL); + iron_g5_clear(ui_nodes_ui.ops.theme.SEPARATOR_COL); let sep_col: i32 = ui_nodes_ui.ops.theme.SEPARATOR_COL; let line_primary: i32 = sep_col - 0x00050505; @@ -858,7 +858,7 @@ function ui_nodes_render() { } ui_nodes_release_link = ui_nodes_ui.input_released; - if (!ui_nodes_show || kinc_window_width() == 0 || kinc_window_height() == 0) { + if (!ui_nodes_show || iron_window_width() == 0 || iron_window_height() == 0) { return; } @@ -1056,7 +1056,7 @@ function ui_nodes_render() { // Node previews if (config_raw.node_preview && nodes.nodes_selected_id.length > 0) { - let img: kinc_g5_texture_t = null; + let img: iron_g5_texture_t = null; let sel: ui_node_t = ui_get_node(c.nodes, nodes.nodes_selected_id[0]); ///if (is_paint || is_sculpt) @@ -1106,7 +1106,7 @@ function ui_nodes_render() { ///if (is_paint || is_sculpt) if (single_channel) { draw_set_pipeline(ui_view2d_pipe); - iron_g4_set_int(ui_view2d_channel_loc, 1); + _iron_g4_set_int(ui_view2d_channel_loc, 1); } ///end diff --git a/base/sources/ts/ui_status.ts b/base/sources/ts/ui_status.ts index fda4f767..f759a528 100644 --- a/base/sources/ts/ui_status.ts +++ b/base/sources/ts/ui_status.ts @@ -6,10 +6,10 @@ function ui_status_init() { function ui_status_width(): i32 { ///if (is_paint || is_sculpt) - return kinc_window_width() - ui_toolbar_w - config_raw.layout[layout_size_t.SIDEBAR_W]; + return iron_window_width() - ui_toolbar_w - config_raw.layout[layout_size_t.SIDEBAR_W]; ///end ///if is_lab - return kinc_window_width(); + return iron_window_width(); ///end } @@ -18,7 +18,7 @@ function ui_status_render_ui() { let statush: i32 = config_raw.layout[layout_size_t.STATUS_H]; - if (ui_window(ui_base_hwnds[tab_area_t.STATUS], app_x(), kinc_window_height() - statush, ui_status_width(), statush)) { + if (ui_window(ui_base_hwnds[tab_area_t.STATUS], app_x(), iron_window_height() - statush, ui_status_width(), statush)) { ui._y += 2; // Border diff --git a/base/sources/ts/ui_toolbar.ts b/base/sources/ts/ui_toolbar.ts index 1d6dedfc..b6c1e45d 100644 --- a/base/sources/ts/ui_toolbar.ts +++ b/base/sources/ts/ui_toolbar.ts @@ -30,7 +30,7 @@ let _ui_toolbar_i: i32; function ui_toolbar_init() { } -function ui_toolbar_draw_tool(i: i32, ui: ui_t, img: kinc_g5_texture_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_draw_tool(i: i32, ui: ui_t, img: iron_g5_texture_t, icon_accent: i32, keys: string[]) { ui._x += 2; if (context_raw.tool == i) { ui_toolbar_draw_highlight(); @@ -94,7 +94,7 @@ function ui_toolbar_render_ui() { let x: i32 = 0; let y: i32 = ui_header_h; - let h: i32 = kinc_window_height() - ui_header_h; + let h: i32 = iron_window_height() - ui_header_h; let _WINDOW_BG_COL: i32 = ui.ops.theme.WINDOW_BG_COL; if (context_is_floating_toolbar()) { @@ -108,7 +108,7 @@ function ui_toolbar_render_ui() { ui._y -= 4 * ui_SCALE(ui); ui.image_scroll_align = false; - let img: kinc_g5_texture_t = resource_get("icons.k"); + let img: iron_g5_texture_t = resource_get("icons.k"); let col: u32 = ui.ops.theme.WINDOW_BG_COL; let light: bool = col > 0xff666666; diff --git a/base/sources/ts/ui_view2d.ts b/base/sources/ts/ui_view2d.ts index b5d55c4f..70c528c8 100644 --- a/base/sources/ts/ui_view2d.ts +++ b/base/sources/ts/ui_view2d.ts @@ -1,6 +1,6 @@ -let ui_view2d_pipe: kinc_g5_pipeline_t; -let ui_view2d_channel_loc: kinc_g5_constant_location_t; +let ui_view2d_pipe: iron_g5_pipeline_t; +let ui_view2d_channel_loc: iron_g5_constant_location_t; let ui_view2d_text_input_hover: bool = false; let ui_view2d_uvmap_show: bool = false; let ui_view2d_tex_type: paint_tex_t = paint_tex_t.BASE; @@ -22,12 +22,12 @@ let ui_view2d_pan_y: f32 = 0.0; let ui_view2d_pan_scale: f32 = 1.0; let ui_view2d_tiled_show: bool = false; let ui_view2d_controls_down: bool = false; -let _ui_view2d_render_tex: kinc_g5_texture_t; +let _ui_view2d_render_tex: iron_g5_texture_t; let _ui_view2d_render_x: f32; let _ui_view2d_render_y: f32; let _ui_view2d_render_tw: f32; let _ui_view2d_render_th: f32; -let ui_view2d_grid: kinc_g5_texture_t = null; +let ui_view2d_grid: iron_g5_texture_t = null; let ui_view2d_grid_redraw: bool = true; function ui_view2d_init() { @@ -35,7 +35,7 @@ function ui_view2d_init() { ui_view2d_pipe = iron_g4_create_pipeline(); ui_view2d_pipe.vertex_shader = sys_get_shader("layer_view.vert"); ui_view2d_pipe.fragment_shader = sys_get_shader("layer_view.frag"); - let vs: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_g5_vertex_structure_t = 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); @@ -81,7 +81,7 @@ function ui_view2d_render() { if (!ui_view2d_show) { return; } - if (kinc_window_width() == 0 || kinc_window_height() == 0) { + if (iron_window_width() == 0 || iron_window_height() == 0) { return; } @@ -117,8 +117,8 @@ function ui_view2d_render() { ui_begin(ui_view2d_ui); let headerh: i32 = config_raw.layout[layout_size_t.HEADER] == 1 ? ui_header_h * 2 : ui_header_h; - let apph: i32 = kinc_window_height() - config_raw.layout[layout_size_t.STATUS_H] + headerh; - ui_view2d_wh = kinc_window_height() - config_raw.layout[layout_size_t.STATUS_H]; + let apph: i32 = iron_window_height() - config_raw.layout[layout_size_t.STATUS_H] + headerh; + ui_view2d_wh = iron_window_height() - config_raw.layout[layout_size_t.STATUS_H]; if (ui_nodes_show) { ui_view2d_wh -= config_raw.layout[layout_size_t.NODES_H]; @@ -139,7 +139,7 @@ function ui_view2d_render() { draw_image(ui_view2d_grid, x, y); // Texture - let tex: kinc_g5_texture_t = null; + let tex: iron_g5_texture_t = null; let l: slot_layer_t = context_raw.layer; let channel: i32 = 0; @@ -177,14 +177,14 @@ function ui_view2d_render() { } if (ui_view2d_layer_mode == view_2d_layer_mode_t.VISIBLE) { - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); layer = layers_flatten(); if (g2_in_use) g2_begin(current); } else if (slot_layer_is_group(layer)) { - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); layer = layers_flatten(false, slot_layer_get_children(layer)); @@ -223,7 +223,7 @@ function ui_view2d_render() { if (!context_raw.texture_filter) { draw_set_bilinear_filter(false); } - iron_g4_set_int(ui_view2d_channel_loc, channel); + _iron_g4_set_int(ui_view2d_channel_loc, channel); } ///end @@ -258,7 +258,7 @@ function ui_view2d_render() { app_notify_on_next_frame(function () { let rt: render_target_t = map_get(render_path_render_targets, "texpaint_picker"); - let texpaint_picker: kinc_g5_texture_t = rt._image; + let texpaint_picker: iron_g5_texture_t = rt._image; g2_begin(texpaint_picker); draw_scaled_image(_ui_view2d_render_tex, -_ui_view2d_render_x, -_ui_view2d_render_y, _ui_view2d_render_tw, _ui_view2d_render_th); g2_end(); @@ -410,7 +410,7 @@ function ui_view2d_render() { // Picked position ///if (is_paint || is_sculpt) if (context_raw.tool == workspace_tool_t.PICKER && (ui_view2d_type == view_2d_type_t.LAYER || ui_view2d_type == view_2d_type_t.ASSET)) { - let cursor_img: kinc_g5_texture_t = resource_get("cursor.k"); + let cursor_img: iron_g5_texture_t = resource_get("cursor.k"); let hsize: f32 = 16 * ui_SCALE(ui_view2d_ui); let size: f32 = hsize * 2; draw_scaled_image(cursor_img, tx + tw * context_raw.uvx_picked - hsize, ty + th * context_raw.uvy_picked - hsize, size, size); diff --git a/base/sources/ts/uniforms_ext.ts b/base/sources/ts/uniforms_ext.ts index d3842864..16f470a4 100644 --- a/base/sources/ts/uniforms_ext.ts +++ b/base/sources/ts/uniforms_ext.ts @@ -301,7 +301,7 @@ function uniforms_ext_mat4_link(object: object_t, mat: material_data_t, link: st return mat4_nan(); } -function uniforms_ext_tex_link(object: object_t, mat: material_data_t, link: string): kinc_g5_texture_t { +function uniforms_ext_tex_link(object: object_t, mat: material_data_t, link: string): iron_g5_texture_t { if (link == "_texpaint_undo") { ///if is_lab return null; diff --git a/base/sources/ts/util_mesh.ts b/base/sources/ts/util_mesh.ts index 51ad97f7..50f3e573 100644 --- a/base/sources/ts/util_mesh.ts +++ b/base/sources/ts/util_mesh.ts @@ -159,7 +159,7 @@ function util_mesh_swap_axis(a: i32, b: i32) { } let g: mesh_data_t = o.data; - let l: i32 = kinc_g5_vertex_struct_size(g._.structure) / 2; + let l: i32 = iron_g5_vertex_struct_size(g._.structure) / 2; let vertices: buffer_t = iron_g4_lock_vertex_buffer(g._.vertex_buffer); // posnortex for (let i: i32 = 0; i < math_floor((vertices.length) / 2 / l); ++i) { buffer_set_i16(vertices, (i * l ) * 2, vas[0].values[i * 4 ]); @@ -169,7 +169,7 @@ function util_mesh_swap_axis(a: i32, b: i32) { buffer_set_i16(vertices, (i * l + 4) * 2, vas[1].values[i * 2 ]); buffer_set_i16(vertices, (i * l + 5) * 2, vas[1].values[i * 2 + 1]); } - kinc_g4_vertex_buffer_unlock_all(g._.vertex_buffer); + iron_g4_vertex_buffer_unlock_all(g._.vertex_buffer); } util_mesh_remove_merged(); @@ -184,7 +184,7 @@ function util_mesh_flip_normals() { let va0: i16_array_t = vas[0].values; let va1: i16_array_t = vas[1].values; let g: mesh_data_t = o.data; - let l: i32 = kinc_g5_vertex_struct_size(g._.structure) / 2; + let l: i32 = iron_g5_vertex_struct_size(g._.structure) / 2; let vertices: buffer_t = iron_g4_lock_vertex_buffer(g._.vertex_buffer); // posnortex for (let i: i32 = 0; i < math_floor((vertices.length) / 2 / l); ++i) { va0[i * 4 + 3] = -va0[i * 4 + 3]; @@ -194,7 +194,7 @@ function util_mesh_flip_normals() { buffer_set_i16(vertices, (i * l + 4) * 2, -buffer_get_i16(vertices, (i * l + 4) * 2)); buffer_set_i16(vertices, (i * l + 5) * 2, -buffer_get_i16(vertices, (i * l + 5) * 2)); } - kinc_g4_vertex_buffer_unlock_all(g._.vertex_buffer); + iron_g4_vertex_buffer_unlock_all(g._.vertex_buffer); } render_path_raytrace_ready = false; @@ -210,7 +210,7 @@ function util_mesh_calc_normals(smooth: bool = false) { for (let i: i32 = 0; i < objects.length; ++i) { let o: mesh_object_t = objects[i]; let g: mesh_data_t = o.data; - let l: i32 = kinc_g5_vertex_struct_size(g._.structure) / 2; + let l: i32 = iron_g5_vertex_struct_size(g._.structure) / 2; let inda: u32_array_t = g._.indices[0]; let vertices: buffer_t = iron_g4_lock_vertex_buffer(g._.vertex_buffer); // posnortex for (let i: i32 = 0; i < math_floor(inda.length / 3); ++i) { @@ -286,7 +286,7 @@ function util_mesh_calc_normals(smooth: bool = false) { } } } - kinc_g4_vertex_buffer_unlock_all(g._.vertex_buffer); + iron_g4_vertex_buffer_unlock_all(g._.vertex_buffer); let va0: i16_array_t = o.data.vertex_arrays[0].values; let va1: i16_array_t = o.data.vertex_arrays[1].values; @@ -370,25 +370,25 @@ function util_mesh_to_origin() { va[i * 4 + 2] = math_floor((va[i * 4 + 2] * sc - dz) / max_scale * 32767); } - let l: i32 = kinc_g5_vertex_struct_size(g._.structure) / 2; + let l: i32 = iron_g5_vertex_struct_size(g._.structure) / 2; let vertices: buffer_t = iron_g4_lock_vertex_buffer(g._.vertex_buffer); // posnortex for (let i: i32 = 0; i < math_floor((vertices.length) / 2 / l); ++i) { buffer_set_i16(vertices, (i * l ) * 2, va[i * 4 ]); buffer_set_i16(vertices, (i * l + 1) * 2, va[i * 4 + 1]); buffer_set_i16(vertices, (i * l + 2) * 2, va[i * 4 + 2]); } - kinc_g4_vertex_buffer_unlock_all(g._.vertex_buffer); + iron_g4_vertex_buffer_unlock_all(g._.vertex_buffer); } util_mesh_merge(); } -function util_mesh_apply_displacement(texpaint_pack: kinc_g5_texture_t, strength: f32 = 0.1, uv_scale: f32 = 1.0) { +function util_mesh_apply_displacement(texpaint_pack: iron_g5_texture_t, strength: f32 = 0.1, uv_scale: f32 = 1.0) { let height: buffer_t = iron_g4_get_texture_pixels(texpaint_pack); let res: i32 = texpaint_pack.width; let o: mesh_object_t = project_paint_objects[0]; let g: mesh_data_t = o.data; - let l: i32 = kinc_g5_vertex_struct_size(g._.structure) / 2; + let l: i32 = iron_g5_vertex_struct_size(g._.structure) / 2; let vertices: buffer_t = iron_g4_lock_vertex_buffer(g._.vertex_buffer); // posnortex for (let i: i32 = 0; i < math_floor((vertices.length) / 2 / l); ++i) { let x: i32 = math_floor(buffer_get_i16(vertices, (i * l + 6) * 2) / 32767 * res); @@ -402,7 +402,7 @@ function util_mesh_apply_displacement(texpaint_pack: kinc_g5_texture_t, strength buffer_set_i16(vertices, (i * l + 1) * 2, buffer_get_i16(vertices, (i * l + 1) * 2) - math_floor(buffer_get_i16(vertices, (i * l + 5) * 2) * h)); buffer_set_i16(vertices, (i * l + 2) * 2, buffer_get_i16(vertices, (i * l + 2) * 2) - math_floor(buffer_get_i16(vertices, (i * l + 3) * 2) * h)); } - kinc_g4_vertex_buffer_unlock_all(g._.vertex_buffer); + iron_g4_vertex_buffer_unlock_all(g._.vertex_buffer); let va0: i16_array_t = o.data.vertex_arrays[0].values; for (let i: i32 = 0; i < math_floor((vertices.length) / 4 / l); ++i) { diff --git a/base/sources/ts/util_render.ts b/base/sources/ts/util_render.ts index 852c80da..80b5be47 100644 --- a/base/sources/ts/util_render.ts +++ b/base/sources/ts/util_render.ts @@ -3,8 +3,8 @@ let util_render_material_preview_size: i32 = 256; let util_render_decal_preview_size: i32 = 512; let util_render_layer_preview_size: i32 = 200; let util_render_font_preview_size: i32 = 200; -let util_render_screen_aligned_full_vb: kinc_g5_vertex_buffer_t = null; -let util_render_screen_aligned_full_ib: kinc_g5_index_buffer_t = null; +let util_render_screen_aligned_full_vb: iron_g5_vertex_buffer_t = null; +let util_render_screen_aligned_full_ib: iron_g5_index_buffer_t = null; function util_render_make_material_preview() { context_raw.material_preview = true; @@ -79,7 +79,7 @@ function util_render_make_material_preview() { } function util_render_make_decal_preview() { - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); @@ -143,7 +143,7 @@ function util_render_make_decal_preview() { } function util_render_make_text_preview() { - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); @@ -168,7 +168,7 @@ function util_render_make_text_preview() { ///end } g2_begin(context_raw.text_tool_image); - kinc_g5_clear(0xff000000); + iron_g5_clear(0xff000000); g2_set_font(font, font_size); draw_set_color(0xffffffff); draw_string(text, tex_w / 2 - text_w / 2, tex_w / 2 - text_h / 2); @@ -178,7 +178,7 @@ function util_render_make_text_preview() { } function util_render_make_font_preview() { - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); @@ -192,7 +192,7 @@ function util_render_make_font_preview() { context_raw.font.image = iron_g4_create_render_target(tex_w, tex_w, tex_format_t.RGBA32); } g2_begin(context_raw.font.image); - kinc_g5_clear(0x00000000); + iron_g5_clear(0x00000000); g2_set_font(font, font_size); draw_set_color(0xffffffff); draw_string(text, tex_w / 2 - text_w / 2, tex_w / 2 - text_h / 2); @@ -207,7 +207,7 @@ function util_render_make_brush_preview() { return; } - let current: kinc_g5_texture_t = _g2_current; + let current: iron_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); @@ -365,9 +365,9 @@ function util_render_make_brush_preview() { // Scale layer down to to image preview l = render_path_paint_live_layer; - let target: kinc_g5_texture_t = context_raw.brush.image; + let target: iron_g5_texture_t = context_raw.brush.image; g2_begin(target); - kinc_g5_clear(0x00000000); + iron_g5_clear(0x00000000); draw_set_pipeline(pipes_copy); draw_scaled_image(l.texpaint, 0, 0, target.width, target.height); draw_set_pipeline(null); @@ -388,7 +388,7 @@ function util_render_make_brush_preview() { if (g2_in_use) g2_begin(current); } -function util_render_make_node_preview(canvas: ui_node_canvas_t, node: ui_node_t, image: kinc_g5_texture_t, group: ui_node_canvas_t = null, parents: ui_node_t[] = null) { +function util_render_make_node_preview(canvas: ui_node_canvas_t, node: ui_node_t, image: iron_g5_texture_t, group: ui_node_canvas_t = null, parents: ui_node_t[] = null) { let res: parse_node_preview_result_t = make_material_parse_node_preview_material(node, group, parents); if (res == null || res.scon == null) { return; @@ -402,16 +402,16 @@ function util_render_make_node_preview(canvas: ui_node_canvas_t, node: ui_node_t context_raw.paint_object.base.transform.scale_world = 3.0; transform_build_matrix(context_raw.paint_object.base.transform); - iron_g4_begin(image); - kinc_g5_set_pipeline(res.scon._.pipe_state); + _iron_g4_begin(image); + iron_g5_set_pipeline(res.scon._.pipe_state); let empty: string[] = [""]; uniforms_set_context_consts(res.scon, empty); uniforms_set_obj_consts(res.scon, context_raw.paint_object.base); uniforms_set_material_consts(res.scon, res.mcon); - kinc_g4_set_vertex_buffer(util_render_screen_aligned_full_vb); - kinc_g4_set_index_buffer(util_render_screen_aligned_full_ib); + iron_g4_set_vertex_buffer(util_render_screen_aligned_full_vb); + iron_g4_set_index_buffer(util_render_screen_aligned_full_ib); iron_g4_draw_indexed_vertices(); - iron_g4_end(); + _iron_g4_end(); context_raw.paint_object.base.transform.scale_world = _scale_world; transform_build_matrix(context_raw.paint_object.base.transform); @@ -458,22 +458,22 @@ function util_render_create_screen_aligned_full_data() { let indices: u32[] = [0, 1, 2]; // Mandatory vertex data names and sizes - let structure: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let structure: iron_g5_vertex_structure_t = 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); - util_render_screen_aligned_full_vb = iron_g4_create_vertex_buffer(math_floor(data.length / math_floor(kinc_g5_vertex_struct_size(structure) / 2)), structure, usage_t.STATIC); + util_render_screen_aligned_full_vb = iron_g4_create_vertex_buffer(math_floor(data.length / math_floor(iron_g5_vertex_struct_size(structure) / 2)), structure, usage_t.STATIC); let vertices: buffer_t = iron_g4_lock_vertex_buffer(util_render_screen_aligned_full_vb); for (let i: i32 = 0; i < math_floor((vertices.length) / 2); ++i) { buffer_set_i16(vertices, i * 2, data[i]); } - kinc_g4_vertex_buffer_unlock_all(util_render_screen_aligned_full_vb); + iron_g4_vertex_buffer_unlock_all(util_render_screen_aligned_full_vb); util_render_screen_aligned_full_ib = iron_g4_create_index_buffer(indices.length); let id: u32_array_t = iron_g4_lock_index_buffer(util_render_screen_aligned_full_ib); for (let i: i32 = 0; i < id.length; ++i) { id[i] = indices[i]; } - kinc_g4_index_buffer_unlock_all(util_render_screen_aligned_full_ib); + iron_g4_index_buffer_unlock_all(util_render_screen_aligned_full_ib); } diff --git a/base/sources/ts/util_uv.ts b/base/sources/ts/util_uv.ts index 27a31cff..8d2e388d 100644 --- a/base/sources/ts/util_uv.ts +++ b/base/sources/ts/util_uv.ts @@ -1,14 +1,14 @@ -let util_uv_uvmap: kinc_g5_texture_t = null; +let util_uv_uvmap: iron_g5_texture_t = null; let util_uv_uvmap_cached: bool = false; -let util_uv_trianglemap: kinc_g5_texture_t = null; +let util_uv_trianglemap: iron_g5_texture_t = null; let util_uv_trianglemap_cached: bool = false; -let util_uv_dilatemap: kinc_g5_texture_t = null; +let util_uv_dilatemap: iron_g5_texture_t = null; let util_uv_dilatemap_cached: bool = false; -let util_uv_uvislandmap: kinc_g5_texture_t = null; +let util_uv_uvislandmap: iron_g5_texture_t = null; let util_uv_uvislandmap_cached: bool = false; let util_uv_dilate_bytes: buffer_t = null; -let util_uv_pipe_dilate: kinc_g5_pipeline_t = null; +let util_uv_pipe_dilate: iron_g5_pipeline_t = null; function util_uv_cache_uv_map() { if (util_uv_uvmap != null && (util_uv_uvmap.width != config_get_texture_res_x() || util_uv_uvmap.height != config_get_texture_res_y())) { @@ -35,7 +35,7 @@ function util_uv_cache_uv_map() { let texa: i16_array_t = mesh.vertex_arrays[2].values; let inda: u32_array_t = mesh.index_arrays[0].values; g2_begin(util_uv_uvmap); - kinc_g5_clear(0x00000000); + iron_g5_clear(0x00000000); draw_set_color(0xffffffff); let strength: f32 = res_x > 2048 ? 2.0 : 1.0; let f: f32 = (1 / 32767) * util_uv_uvmap.width; @@ -74,7 +74,7 @@ function util_uv_cache_triangle_map() { let texa: i16_array_t = mesh.vertex_arrays[2].values; let inda: u32_array_t = mesh.index_arrays[0].values; g2_begin(util_uv_trianglemap); - kinc_g5_clear(0xff000000); + iron_g5_clear(0xff000000); let f: f32 = (1 / 32767) * util_uv_trianglemap.width; let color: i32 = 0xff000001; for (let i: i32 = 0; i < math_floor(inda.length / 3); ++i) { @@ -109,7 +109,7 @@ function util_uv_cache_dilate_map() { util_uv_pipe_dilate = iron_g4_create_pipeline(); util_uv_pipe_dilate.vertex_shader = sys_get_shader("dilate_map.vert"); util_uv_pipe_dilate.fragment_shader = sys_get_shader("dilate_map.frag"); - let vs: kinc_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); ///if (arm_metal || arm_vulkan) g4_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); ///else @@ -130,9 +130,9 @@ function util_uv_cache_dilate_map() { mask = context_raw.layer_filter; } let geom: mesh_data_t = mask == 0 && context_raw.merged_object != null ? context_raw.merged_object.data : context_raw.paint_object.data; - iron_g4_begin(util_uv_dilatemap); - kinc_g5_clear(0x00000000); - kinc_g5_set_pipeline(util_uv_pipe_dilate); + _iron_g4_begin(util_uv_dilatemap); + iron_g5_clear(0x00000000); + iron_g5_set_pipeline(util_uv_pipe_dilate); ///if (arm_metal || arm_vulkan) let vs: vertex_element_t[] = [ { @@ -140,13 +140,13 @@ function util_uv_cache_dilate_map() { data: "short2norm" } ]; - kinc_g4_set_vertex_buffer(mesh_data_get(geom, vs)); + iron_g4_set_vertex_buffer(mesh_data_get(geom, vs)); ///else - kinc_g4_set_vertex_buffer(geom._.vertex_buffer); + iron_g4_set_vertex_buffer(geom._.vertex_buffer); ///end - kinc_g4_set_index_buffer(geom._.index_buffers[0]); + iron_g4_set_index_buffer(geom._.index_buffers[0]); iron_g4_draw_indexed_vertices(); - iron_g4_end(); + _iron_g4_end(); util_uv_dilatemap_cached = true; util_uv_dilate_bytes = null; } diff --git a/base/tests/cube/sources/main.ts b/base/tests/cube/sources/main.ts index cc1e397d..10a52937 100644 --- a/base/tests/cube/sources/main.ts +++ b/base/tests/cube/sources/main.ts @@ -1,7 +1,7 @@ // ../../../make --graphics vulkan --run function main() { - let ops: kinc_window_options_t = { + let ops: iron_window_options_t = { title: "Empty", width: 1280, height: 720, diff --git a/base/tests/fall/sources/main.ts b/base/tests/fall/sources/main.ts index 5711dcad..a1749811 100644 --- a/base/tests/fall/sources/main.ts +++ b/base/tests/fall/sources/main.ts @@ -3,7 +3,7 @@ ///include "../../sources/libs/asim/asim.h" function main() { - let ops: kinc_window_options_t = { + let ops: iron_window_options_t = { title: "Empty", width: 1280, height: 720, diff --git a/base/tests/triangle/main.ts b/base/tests/triangle/main.ts index 537a18d6..ca837c98 100644 --- a/base/tests/triangle/main.ts +++ b/base/tests/triangle/main.ts @@ -2,38 +2,38 @@ // Red triangle test // ../../../make --graphics vulkan --run -let pipeline: kinc_g5_pipeline_t; +let pipeline: iron_g5_pipeline_t; let vb: any; let ib: any; function render() { - iron_g4_begin(null, null); + _iron_g4_begin(null, null); let flags: i32 = 0; flags |= 1; // Color flags |= 2; // Depth - kinc_g5_clear(0xff000000, 1.0, flags); + iron_g5_clear(0xff000000, 1.0, flags); - kinc_g5_set_pipeline(pipeline); - kinc_g4_set_vertex_buffer(vb); - kinc_g4_set_index_buffer(ib); + iron_g5_set_pipeline(pipeline); + iron_g4_set_vertex_buffer(vb); + iron_g4_set_index_buffer(ib); iron_g4_draw_indexed_vertices(0, -1); - iron_g4_end(); + _iron_g4_end(); } function main() { let resizable: i32 = 1; let minimizable: i32 = 2; let maximizable: i32 = 4; - iron_init("Iron", 640, 480, true, 0, resizable | minimizable | maximizable, -1, -1, 60); + _iron_init("Iron", 640, 480, true, 0, resizable | minimizable | maximizable, -1, -1, 60); pipeline = iron_g4_create_pipeline(); let f32_3x: vertex_data_t = vertex_data_t.F32_3X; - let elem: kinc_g5_vertex_element_t = { name: "pos", data: f32_3x }; - let elems: kinc_g5_vertex_element_t[] = [elem]; + let elem: iron_g5_vertex_element_t = { name: "pos", data: f32_3x }; + let elems: iron_g5_vertex_element_t[] = [elem]; - let structure0: kinc_g5_vertex_structure_t = { elements: elems }; + let structure0: iron_g5_vertex_structure_t = { elements: elems }; let vs_buffer: buffer_t = iron_load_blob("./data/test.vert.spirv"); let fs_buffer: buffer_t = iron_load_blob("./data/test.frag.spirv"); @@ -76,14 +76,14 @@ function main() { for (let i: i32 = 0; i < vertices.length; i++) { buffer_set_f32(vb_data, i * 4, vertices[i]); } - kinc_g4_vertex_buffer_unlock_all(vb); + iron_g4_vertex_buffer_unlock_all(vb); ib = iron_g4_create_index_buffer(indices.length); let ib_data: u32_array_t = iron_g4_lock_index_buffer(ib); for (let i: i32 = 0; i < indices.length; i++) { ib_data[i] = indices[i]; } - kinc_g4_index_buffer_unlock_all(ib); + iron_g4_index_buffer_unlock_all(ib); - iron_set_update_callback(render); + _iron_set_update_callback(render); } diff --git a/base/tools/amake/aimage.c b/base/tools/amake/aimage.c index 24e0ac34..82396698 100644 --- a/base/tools/amake/aimage.c +++ b/base/tools/amake/aimage.c @@ -18,7 +18,7 @@ typedef struct image { int width; int height; bool is_hdr; -} kinc_g5_texture_t; +} iron_g5_texture_t; static bool ends_with(const char *s, const char *end) { size_t len_s = strlen(s); @@ -26,21 +26,21 @@ static bool ends_with(const char *s, const char *end) { return strncmp(s + len_s - len_end, end, len_end) == 0; } -static kinc_g5_texture_t read_png_jpg(const char *filename) { +static iron_g5_texture_t read_png_jpg(const char *filename) { int width, height, n; char *data = stbi_load(filename, &width, &height, &n, 4); - kinc_g5_texture_t img = { .data = data, .width = width, .height = height, .is_hdr = false }; + iron_g5_texture_t img = { .data = data, .width = width, .height = height, .is_hdr = false }; return img; } -static kinc_g5_texture_t read_hdr(const char *filename) { +static iron_g5_texture_t read_hdr(const char *filename) { int width, height, n; float *data = stbi_loadf(filename, &width, &height, &n, 4); - kinc_g5_texture_t img = { .data = data, .width = width, .height = height, .is_hdr = true }; + iron_g5_texture_t img = { .data = data, .width = width, .height = height, .is_hdr = true }; return img; } -static void *scale_image(kinc_g5_texture_t img, int width, int height) { +static void *scale_image(iron_g5_texture_t img, int width, int height) { unsigned char *scaled = malloc(width * height * 4); stbir_resize_uint8_generic(img.data, img.width, img.height, img.width * 4, scaled, width, height, width * 4, 4, 3, 0, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_COLORSPACE_SRGB, 0); @@ -72,7 +72,7 @@ static void write_ico_entry(FILE *file, int width, int height, int size, int off } void export_ico(const char *from, const char *to) { - kinc_g5_texture_t img = read_png_jpg(from); + iron_g5_texture_t img = read_png_jpg(from); FILE *file = fopen(to, "wb"); unsigned char *data256 = scale_image(img, 256, 256); @@ -115,7 +115,7 @@ void export_ico(const char *from, const char *to) { } void export_png(const char *from, const char *to, int width, int height) { - kinc_g5_texture_t img = read_png_jpg(from); + iron_g5_texture_t img = read_png_jpg(from); if (width > 0 && height > 0) { unsigned char *scaled = scale_image(img, width, height); @@ -151,7 +151,7 @@ static void write_k(int width, int height, const char *format, char *data, int s } void export_k(const char *from, const char *to) { - kinc_g5_texture_t img; + iron_g5_texture_t img; if (ends_with(from, ".hdr")) { img = read_hdr(from); } diff --git a/base/tools/amake/alang.js b/base/tools/amake/alang.js index 5e989872..ccf8b3b4 100644 --- a/base/tools/amake/alang.js +++ b/base/tools/amake/alang.js @@ -1473,8 +1473,8 @@ function write_kickstart() { out("\n"); } out("\t_main();\n"); - out("\t#ifndef NO_KINC_START\n"); - out("\tkinc_start();\n"); + out("\t#ifndef NO_IRON_START\n"); + out("\tiron_start();\n"); out("\t#endif\n"); out("}\n\n"); } diff --git a/base/tools/amake/alang.ts b/base/tools/amake/alang.ts index 3dc3ff35..0db8aad7 100644 --- a/base/tools/amake/alang.ts +++ b/base/tools/amake/alang.ts @@ -1509,8 +1509,8 @@ function write_kickstart() { out("\n"); } out("\t_main();\n"); - out("\t#ifndef NO_KINC_START\n"); - out("\tkinc_start();\n"); + out("\t#ifndef NO_IRON_START\n"); + out("\tiron_start();\n"); out("\t#endif\n"); out("}\n\n"); } diff --git a/base/tools/amake/project.js b/base/tools/amake/project.js index 16788860..ceae197b 100644 --- a/base/tools/amake/project.js +++ b/base/tools/amake/project.js @@ -5,7 +5,7 @@ let project = new Project("amake"); // alang project.add_define("NO_GC"); project.add_define("NO_IRON_API"); - project.add_define("NO_KINC_START"); + project.add_define("NO_IRON_START"); project.add_tsfiles("./"); // alang.ts project.add_include_dir("./"); // iron.h project.add_cfiles("build/iron.c"); diff --git a/base/tools/make.js b/base/tools/make.js index 551eca69..0641cb03 100644 --- a/base/tools/make.js +++ b/base/tools/make.js @@ -3150,7 +3150,7 @@ class Project { } } -function export_koremake_project() { +function export_amake_project() { console.log('Creating ' + goptions.target + ' project files.'); let project = Project.create("."); @@ -3217,7 +3217,7 @@ function compile_project(make, project) { function main() { console.log('Using Iron from ' + irondir); goptions.build_path = goptions.debug ? 'Debug' : 'Release'; - let project = export_koremake_project(); + let project = export_amake_project(); let project_name = project.get_safe_name(); if (goptions.compile && project_name !== '') { diff --git a/base/tools/pad/sources/main.ts b/base/tools/pad/sources/main.ts index 1fe954d9..af69ee59 100644 --- a/base/tools/pad/sources/main.ts +++ b/base/tools/pad/sources/main.ts @@ -23,7 +23,7 @@ let minimap_w: i32 = 150; let minimap_h: i32 = 0; let minimap_box_h: i32 = 0; let minimap_scrolling: bool = false; -let minimap: kinc_g5_texture_t = null; +let minimap: iron_g5_texture_t = null; let window_header_h: i32 = 0; function drop_files(path: string) { @@ -50,13 +50,13 @@ function encode_storage(): string { function shutdown() { let storage_string: string = sys_string_to_buffer(encode_storage()); - iron_file_save_bytes(kinc_internal_save_path() + "/config.json", storage_string, 0); + iron_file_save_bytes(iron_internal_save_path() + "/config.json", storage_string, 0); } function main() { - kinc_set_app_name("ArmorPad"); + iron_set_app_name("ArmorPad"); - let blob_storage: buffer_t = iron_load_blob(kinc_internal_save_path() + "/config.json"); + let blob_storage: buffer_t = iron_load_blob(iron_internal_save_path() + "/config.json"); if (blob_storage == null) { storage = {}; storage.project = ""; @@ -76,7 +76,7 @@ function main() { text_handle.text = storage.text; - let ops: kinc_window_options_t = { + let ops: iron_window_options_t = { title: "ArmorPad", x: storage.window_x, y: storage.window_y, @@ -117,7 +117,7 @@ function main() { ui_text_area_scroll_past_end = true; sys_notify_on_frames(render); - iron_set_drop_files_callback(drop_files); + _iron_set_drop_files_callback(drop_files); iron_set_application_state_callback(null, null, null, null, shutdown); } @@ -180,17 +180,17 @@ function list_folder(path: string) { } function render() { - storage.window_w = kinc_window_width(); - storage.window_h = kinc_window_height(); - storage.window_x = kinc_window_x(); - storage.window_y = kinc_window_y(); + storage.window_w = iron_window_width(); + storage.window_h = iron_window_height(); + storage.window_x = iron_window_x(); + storage.window_y = iron_window_y(); if (ui.input_dx != 0 || ui.input_dy != 0) { iron_set_mouse_cursor(0); // Arrow } ui_begin(ui); - if (ui_window(sidebar_handle, 0, 0, storage.sidebar_w, kinc_window_height(), false)) { + if (ui_window(sidebar_handle, 0, 0, storage.sidebar_w, iron_window_height(), false)) { if (storage.project != "") { list_folder(storage.project); } @@ -199,12 +199,12 @@ function render() { } } - ui_fill(kinc_window_width() - minimap_w, 0, minimap_w, UI_ELEMENT_H() + UI_ELEMENT_OFFSET() + 1, theme.SEPARATOR_COL); - ui_fill(storage.sidebar_w, 0, 1, kinc_window_height(), theme.SEPARATOR_COL); + ui_fill(iron_window_width() - minimap_w, 0, minimap_w, UI_ELEMENT_H() + UI_ELEMENT_OFFSET() + 1, theme.SEPARATOR_COL); + ui_fill(storage.sidebar_w, 0, 1, iron_window_height(), theme.SEPARATOR_COL); let editor_updated: bool = false; - if (ui_window(editor_handle, storage.sidebar_w + 1, 0, kinc_window_width() - storage.sidebar_w - minimap_w, kinc_window_height(), false)) { + if (ui_window(editor_handle, storage.sidebar_w + 1, 0, iron_window_width() - storage.sidebar_w - minimap_w, iron_window_height(), false)) { editor_updated = true; let htab: ui_handle_t = ui_handle(__ID__); let file_name: string = substring(storage.file, string_last_index_of(storage.file, "/") + 1, storage.file.length); @@ -241,7 +241,7 @@ function render() { } // Minimap controls - let minimap_x: i32 = kinc_window_width() - minimap_w; + let minimap_x: i32 = iron_window_width() - minimap_w; let minimap_y: i32 = window_header_h + 1; let redraw: bool = false; if (ui.input_started && hit_test(ui.input_x, ui.input_y, minimap_x + 5, minimap_y, minimap_w, minimap_h)) { @@ -312,8 +312,8 @@ function build_project() { } function draw_minimap() { - if (minimap_h != kinc_window_height()) { - minimap_h = kinc_window_height(); + if (minimap_h != iron_window_height()) { + minimap_h = iron_window_height(); if (minimap != null) { iron_unload_image(minimap); } @@ -321,7 +321,7 @@ function draw_minimap() { } g2_begin(minimap); - kinc_g5_clear(theme.SEPARATOR_COL); + iron_g5_clear(theme.SEPARATOR_COL); draw_set_color(0xff333333); let lines: string[] = string_split(storage.text, "\n"); let minimap_full_h: i32 = lines.length * 2; @@ -349,7 +349,7 @@ function draw_minimap() { // Current position let visible_area: i32 = out_of_screen > 0 ? minimap_h : minimap_full_h; draw_set_color(0x11ffffff); - minimap_box_h = math_floor((kinc_window_height() - window_header_h) / UI_ELEMENT_H() * 2); + minimap_box_h = math_floor((iron_window_height() - window_header_h) / UI_ELEMENT_H() * 2); draw_filled_rect(0, scroll_progress * visible_area, minimap_w, minimap_box_h); g2_end(); } diff --git a/base/tools/platform.sh b/base/tools/platform.sh index 0a71d510..940ee7c7 100644 --- a/base/tools/platform.sh +++ b/base/tools/platform.sh @@ -1,10 +1,10 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then MACHINE_TYPE=`uname -m` if [[ "$MACHINE_TYPE" == "aarch64"* ]]; then - KINC_PLATFORM=linux_arm64 + IRON_PLATFORM=linux_arm64 elif [[ "$MACHINE_TYPE" == "x86_64"* ]]; then - KINC_PLATFORM=linux_x64 + IRON_PLATFORM=linux_x64 fi elif [[ "$OSTYPE" == "darwin"* ]]; then - KINC_PLATFORM=macos + IRON_PLATFORM=macos fi