@bornengine/engine 0.4.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +231 -0
- package/native/android/Cargo.lock +1848 -0
- package/native/android/Cargo.toml +24 -0
- package/native/android/src/lib.rs +702 -0
- package/native/ios/Cargo.lock +1690 -0
- package/native/ios/Cargo.toml +32 -0
- package/native/ios/src/lib.rs +1267 -0
- package/native/linux/Cargo.lock +3279 -0
- package/native/linux/Cargo.toml +29 -0
- package/native/linux/src/lib.rs +1331 -0
- package/native/macos/Cargo.lock +3310 -0
- package/native/macos/Cargo.toml +46 -0
- package/native/macos/src/lib.rs +1302 -0
- package/native/shared/Cargo.lock +1899 -0
- package/native/shared/Cargo.toml +62 -0
- package/native/shared/assets/default_font.ttf +0 -0
- package/native/shared/build.rs +270 -0
- package/native/shared/shaders/common/clouds.wgsl +122 -0
- package/native/shared/shaders/common/fog.wgsl +16 -0
- package/native/shared/shaders/common/foliage_wind.wgsl +98 -0
- package/native/shared/shaders/common/imposter.wgsl +112 -0
- package/native/shared/shaders/common/pbr.wgsl +186 -0
- package/native/shared/shaders/common/shadows.wgsl +186 -0
- package/native/shared/shaders/common/sky.wgsl +8 -0
- package/native/shared/shaders/common/tonemap.wgsl +25 -0
- package/native/shared/shaders/impulse_field.wgsl +57 -0
- package/native/shared/shaders/material_abi.wgsl +383 -0
- package/native/shared/shaders/materials/test_minimal.wgsl +42 -0
- package/native/shared/src/anim_mixer.rs +61 -0
- package/native/shared/src/attach.rs +263 -0
- package/native/shared/src/audio/decode.rs +123 -0
- package/native/shared/src/audio/mod.rs +863 -0
- package/native/shared/src/audio/render.rs +892 -0
- package/native/shared/src/audio/spsc.rs +156 -0
- package/native/shared/src/audio/stream.rs +226 -0
- package/native/shared/src/custom_shaders.rs +104 -0
- package/native/shared/src/decals.rs +245 -0
- package/native/shared/src/drs.rs +211 -0
- package/native/shared/src/engine.rs +261 -0
- package/native/shared/src/ffi.rs +116 -0
- package/native/shared/src/ffi_core/assets.rs +388 -0
- package/native/shared/src/ffi_core/audio_ffi.rs +184 -0
- package/native/shared/src/ffi_core/draw.rs +334 -0
- package/native/shared/src/ffi_core/game_loop.rs +577 -0
- package/native/shared/src/ffi_core/input.rs +234 -0
- package/native/shared/src/ffi_core/mod.rs +127 -0
- package/native/shared/src/ffi_core/models.rs +1154 -0
- package/native/shared/src/ffi_core/ragdoll_ffi.rs +261 -0
- package/native/shared/src/ffi_core/scene.rs +626 -0
- package/native/shared/src/ffi_core/vfx.rs +212 -0
- package/native/shared/src/ffi_core/visual.rs +691 -0
- package/native/shared/src/frame_callbacks.rs +122 -0
- package/native/shared/src/geometry.rs +236 -0
- package/native/shared/src/handles.rs +182 -0
- package/native/shared/src/input.rs +448 -0
- package/native/shared/src/jolt_sys.rs +822 -0
- package/native/shared/src/lib.rs +55 -0
- package/native/shared/src/models.rs +1093 -0
- package/native/shared/src/models_gltf.rs +1280 -0
- package/native/shared/src/particles.rs +391 -0
- package/native/shared/src/physics_jolt.rs +1908 -0
- package/native/shared/src/picking.rs +298 -0
- package/native/shared/src/postfx.rs +345 -0
- package/native/shared/src/profiler.rs +492 -0
- package/native/shared/src/ragdoll.rs +474 -0
- package/native/shared/src/renderer/atmosphere_lut.rs +573 -0
- package/native/shared/src/renderer/brdf_lut.rs +154 -0
- package/native/shared/src/renderer/draw2d.rs +143 -0
- package/native/shared/src/renderer/formats.rs +822 -0
- package/native/shared/src/renderer/froxel.rs +421 -0
- package/native/shared/src/renderer/gi_bake.rs +653 -0
- package/native/shared/src/renderer/graph.rs +462 -0
- package/native/shared/src/renderer/hiz.rs +269 -0
- package/native/shared/src/renderer/hot_reload.rs +390 -0
- package/native/shared/src/renderer/impulse_field.rs +456 -0
- package/native/shared/src/renderer/lighting.rs +154 -0
- package/native/shared/src/renderer/material_instancing.rs +171 -0
- package/native/shared/src/renderer/material_pipeline.rs +700 -0
- package/native/shared/src/renderer/material_system.rs +1996 -0
- package/native/shared/src/renderer/material_system_tests.rs +601 -0
- package/native/shared/src/renderer/material_system_wasm.rs +41 -0
- package/native/shared/src/renderer/mod.rs +12556 -0
- package/native/shared/src/renderer/model_draw.rs +641 -0
- package/native/shared/src/renderer/occlusion.rs +429 -0
- package/native/shared/src/renderer/planar_pass.rs +593 -0
- package/native/shared/src/renderer/planar_reflection.rs +499 -0
- package/native/shared/src/renderer/post_pass.rs +249 -0
- package/native/shared/src/renderer/postfx_chain.rs +728 -0
- package/native/shared/src/renderer/pt_pass.rs +577 -0
- package/native/shared/src/renderer/scene_pass.rs +607 -0
- package/native/shared/src/renderer/shader_include.rs +205 -0
- package/native/shared/src/renderer/shader_library.rs +135 -0
- package/native/shared/src/renderer/shaders/ao.rs +570 -0
- package/native/shared/src/renderer/shaders/core.rs +1243 -0
- package/native/shared/src/renderer/shaders/env.rs +907 -0
- package/native/shared/src/renderer/shaders/gi.rs +810 -0
- package/native/shared/src/renderer/shaders/mod.rs +19 -0
- package/native/shared/src/renderer/shaders/post.rs +1558 -0
- package/native/shared/src/renderer/shaders/pt.rs +1859 -0
- package/native/shared/src/renderer/shaders/ssgi.rs +1586 -0
- package/native/shared/src/renderer/shadow_pass.rs +731 -0
- package/native/shared/src/renderer/ssgi_pass.rs +392 -0
- package/native/shared/src/renderer/ssr_pass.rs +188 -0
- package/native/shared/src/renderer/texture_store.rs +473 -0
- package/native/shared/src/renderer/transient.rs +591 -0
- package/native/shared/src/renderer/types.rs +941 -0
- package/native/shared/src/renderer/util.rs +152 -0
- package/native/shared/src/scene.rs +1362 -0
- package/native/shared/src/sdf_cache.rs +274 -0
- package/native/shared/src/shadows.rs +1036 -0
- package/native/shared/src/staging.rs +102 -0
- package/native/shared/src/string_header.rs +266 -0
- package/native/shared/src/text_renderer.rs +502 -0
- package/native/shared/src/textures.rs +197 -0
- package/native/tvos/Cargo.lock +1693 -0
- package/native/tvos/Cargo.toml +36 -0
- package/native/tvos/metal-patched/Cargo.toml +178 -0
- package/native/tvos/metal-patched/LICENSE-APACHE +201 -0
- package/native/tvos/metal-patched/LICENSE-MIT +25 -0
- package/native/tvos/metal-patched/src/acceleration_structure.rs +667 -0
- package/native/tvos/metal-patched/src/acceleration_structure_pass.rs +108 -0
- package/native/tvos/metal-patched/src/argument.rs +366 -0
- package/native/tvos/metal-patched/src/blitpass.rs +102 -0
- package/native/tvos/metal-patched/src/buffer.rs +71 -0
- package/native/tvos/metal-patched/src/capturedescriptor.rs +76 -0
- package/native/tvos/metal-patched/src/capturemanager.rs +113 -0
- package/native/tvos/metal-patched/src/commandbuffer.rs +192 -0
- package/native/tvos/metal-patched/src/commandqueue.rs +44 -0
- package/native/tvos/metal-patched/src/computepass.rs +107 -0
- package/native/tvos/metal-patched/src/constants.rs +152 -0
- package/native/tvos/metal-patched/src/counters.rs +119 -0
- package/native/tvos/metal-patched/src/depthstencil.rs +190 -0
- package/native/tvos/metal-patched/src/device.rs +2134 -0
- package/native/tvos/metal-patched/src/drawable.rs +39 -0
- package/native/tvos/metal-patched/src/encoder.rs +2041 -0
- package/native/tvos/metal-patched/src/heap.rs +281 -0
- package/native/tvos/metal-patched/src/indirect_encoder.rs +344 -0
- package/native/tvos/metal-patched/src/lib.rs +657 -0
- package/native/tvos/metal-patched/src/library.rs +902 -0
- package/native/tvos/metal-patched/src/mps.rs +575 -0
- package/native/tvos/metal-patched/src/pipeline/compute.rs +475 -0
- package/native/tvos/metal-patched/src/pipeline/mod.rs +71 -0
- package/native/tvos/metal-patched/src/pipeline/render.rs +762 -0
- package/native/tvos/metal-patched/src/renderpass.rs +443 -0
- package/native/tvos/metal-patched/src/resource.rs +182 -0
- package/native/tvos/metal-patched/src/sampler.rs +165 -0
- package/native/tvos/metal-patched/src/sync.rs +178 -0
- package/native/tvos/metal-patched/src/texture.rs +352 -0
- package/native/tvos/metal-patched/src/types.rs +90 -0
- package/native/tvos/metal-patched/src/vertexdescriptor.rs +250 -0
- package/native/tvos/src/audio_backend.rs +197 -0
- package/native/tvos/src/lib.rs +1891 -0
- package/native/visionos/Cargo.lock +1693 -0
- package/native/visionos/Cargo.toml +40 -0
- package/native/visionos/src/audio_backend.rs +197 -0
- package/native/visionos/src/lib.rs +1887 -0
- package/native/watchos/Cargo.lock +16 -0
- package/native/watchos/Cargo.toml +19 -0
- package/native/watchos/shaders/bloom_postfx.metal +99 -0
- package/native/watchos/src/BloomWatchApp.swift +1267 -0
- package/native/watchos/src/BloomWatchAudio.swift +179 -0
- package/native/watchos/src/audio.rs +55 -0
- package/native/watchos/src/draw_list.rs +229 -0
- package/native/watchos/src/ffi_stubs.rs +915 -0
- package/native/watchos/src/ffi_stubs_manual.rs +35 -0
- package/native/watchos/src/lib.rs +1124 -0
- package/native/watchos/src/models.rs +746 -0
- package/native/watchos/src/postfx.rs +95 -0
- package/native/watchos/src/scene.rs +534 -0
- package/native/watchos/src/textures.rs +184 -0
- package/native/web/Cargo.lock +1657 -0
- package/native/web/Cargo.toml +43 -0
- package/native/web/bloom_glue.js +695 -0
- package/native/web/build.sh +131 -0
- package/native/web/index.html +35 -0
- package/native/web/jolt_bridge.js +1519 -0
- package/native/web/src/input_ffi.rs +286 -0
- package/native/web/src/lib.rs +1796 -0
- package/native/web/src/material_ffi.rs +710 -0
- package/native/web/src/parity_ffi.rs +343 -0
- package/native/web/src/physics_ffi.rs +643 -0
- package/native/web/src/ragdoll_ffi.rs +250 -0
- package/native/web/src/render_settings.rs +98 -0
- package/native/windows/Cargo.lock +1815 -0
- package/native/windows/Cargo.toml +68 -0
- package/native/windows/src/lib.rs +1486 -0
- package/package.json +4279 -0
- package/src/audio/index.ts +315 -0
- package/src/core/colors.ts +63 -0
- package/src/core/index.ts +1206 -0
- package/src/core/keys.ts +63 -0
- package/src/core/types.ts +104 -0
- package/src/index.ts +171 -0
- package/src/math/index.ts +516 -0
- package/src/mobile/index.ts +294 -0
- package/src/models/index.ts +1258 -0
- package/src/physics/index.ts +1134 -0
- package/src/scene/index.ts +698 -0
- package/src/shapes/index.ts +120 -0
- package/src/text/index.ts +48 -0
- package/src/textures/index.ts +187 -0
- package/src/vfx/index.ts +191 -0
- package/src/world/index.ts +24 -0
- package/src/world/loader.ts +423 -0
- package/src/world/prefab.ts +217 -0
- package/src/world/render.ts +172 -0
- package/src/world/saver.ts +108 -0
- package/src/world/serialize.ts +301 -0
- package/src/world/terrain.ts +355 -0
- package/src/world/types.ts +160 -0
- package/src/world/validate.ts +319 -0
- package/src/world/version.ts +114 -0
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
//! 2D/3D immediate-mode drawing, render modes, text.
|
|
2
|
+
//!
|
|
3
|
+
//! Section of [`define_core_ffi!`](crate::define_core_ffi) — see
|
|
4
|
+
//! `ffi_core/mod.rs` for the architecture and the invoking-crate contract.
|
|
5
|
+
//! Internal: platform crates must invoke `define_core_ffi!()`, never the
|
|
6
|
+
//! section macros directly.
|
|
7
|
+
|
|
8
|
+
#[doc(hidden)]
|
|
9
|
+
#[macro_export]
|
|
10
|
+
macro_rules! __bloom_ffi_draw {
|
|
11
|
+
() => {
|
|
12
|
+
|
|
13
|
+
// bloom_clear_background [source: macos]
|
|
14
|
+
#[no_mangle]
|
|
15
|
+
pub extern "C" fn bloom_clear_background(r: f64, g: f64, b: f64, a: f64) {
|
|
16
|
+
$crate::ffi::guard("bloom_clear_background", move || {
|
|
17
|
+
engine().renderer.set_clear_color(r, g, b, a);
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// bloom_draw_line [source: macos]
|
|
22
|
+
#[no_mangle]
|
|
23
|
+
pub extern "C" fn bloom_draw_line(x1: f64, y1: f64, x2: f64, y2: f64, thickness: f64, r: f64, g: f64, b: f64, a: f64) {
|
|
24
|
+
$crate::ffi::guard("bloom_draw_line", move || {
|
|
25
|
+
engine().renderer.draw_line(x1, y1, x2, y2, thickness, r, g, b, a);
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// bloom_draw_rect [source: macos]
|
|
30
|
+
#[no_mangle]
|
|
31
|
+
pub extern "C" fn bloom_draw_rect(x: f64, y: f64, w: f64, h: f64, r: f64, g: f64, b: f64, a: f64) {
|
|
32
|
+
$crate::ffi::guard("bloom_draw_rect", move || {
|
|
33
|
+
engine().renderer.draw_rect(x, y, w, h, r, g, b, a);
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// bloom_draw_rect_lines [source: macos]
|
|
38
|
+
#[no_mangle]
|
|
39
|
+
pub extern "C" fn bloom_draw_rect_lines(x: f64, y: f64, w: f64, h: f64, thickness: f64, r: f64, g: f64, b: f64, a: f64) {
|
|
40
|
+
$crate::ffi::guard("bloom_draw_rect_lines", move || {
|
|
41
|
+
engine().renderer.draw_rect_lines(x, y, w, h, thickness, r, g, b, a);
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// bloom_draw_circle [source: macos]
|
|
46
|
+
#[no_mangle]
|
|
47
|
+
pub extern "C" fn bloom_draw_circle(cx: f64, cy: f64, radius: f64, r: f64, g: f64, b: f64, a: f64) {
|
|
48
|
+
$crate::ffi::guard("bloom_draw_circle", move || {
|
|
49
|
+
engine().renderer.draw_circle(cx, cy, radius, r, g, b, a);
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// bloom_draw_circle_lines [source: macos]
|
|
54
|
+
#[no_mangle]
|
|
55
|
+
pub extern "C" fn bloom_draw_circle_lines(cx: f64, cy: f64, radius: f64, r: f64, g: f64, b: f64, a: f64) {
|
|
56
|
+
$crate::ffi::guard("bloom_draw_circle_lines", move || {
|
|
57
|
+
engine().renderer.draw_circle_lines(cx, cy, radius, r, g, b, a);
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// bloom_draw_triangle [source: macos]
|
|
62
|
+
#[no_mangle]
|
|
63
|
+
pub extern "C" fn bloom_draw_triangle(x1: f64, y1: f64, x2: f64, y2: f64, x3: f64, y3: f64, r: f64, g: f64, b: f64, a: f64) {
|
|
64
|
+
$crate::ffi::guard("bloom_draw_triangle", move || {
|
|
65
|
+
engine().renderer.draw_triangle(x1, y1, x2, y2, x3, y3, r, g, b, a);
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// bloom_draw_poly [source: macos]
|
|
70
|
+
#[no_mangle]
|
|
71
|
+
pub extern "C" fn bloom_draw_poly(cx: f64, cy: f64, sides: f64, radius: f64, rotation: f64, r: f64, g: f64, b: f64, a: f64) {
|
|
72
|
+
$crate::ffi::guard("bloom_draw_poly", move || {
|
|
73
|
+
engine().renderer.draw_poly(cx, cy, sides, radius, rotation, r, g, b, a);
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// bloom_draw_text [source: macos]
|
|
78
|
+
#[no_mangle]
|
|
79
|
+
pub extern "C" fn bloom_draw_text(text_ptr: *const u8, x: f64, y: f64, size: f64, r: f64, g: f64, b: f64, a: f64) {
|
|
80
|
+
$crate::ffi::guard("bloom_draw_text", move || {
|
|
81
|
+
let text = $crate::string_header::str_from_header(text_ptr);
|
|
82
|
+
let mut eng = engine();
|
|
83
|
+
// Need to split borrow: take text out temporarily
|
|
84
|
+
let mut text_renderer = std::mem::replace(&mut eng.text, $crate::text_renderer::TextRenderer::empty());
|
|
85
|
+
text_renderer.draw_text(&mut eng.renderer, text, x, y, size as u32, r, g, b, a);
|
|
86
|
+
eng.text = text_renderer;
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// bloom_measure_text [source: macos]
|
|
91
|
+
#[no_mangle]
|
|
92
|
+
pub extern "C" fn bloom_measure_text(text_ptr: *const u8, size: f64) -> f64 {
|
|
93
|
+
$crate::ffi::guard("bloom_measure_text", move || {
|
|
94
|
+
let text = $crate::string_header::str_from_header(text_ptr);
|
|
95
|
+
engine().text.measure_text(text, size as u32)
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// bloom_draw_text_ex [source: macos]
|
|
100
|
+
#[no_mangle]
|
|
101
|
+
pub extern "C" fn bloom_draw_text_ex(font_handle: f64, text_ptr: *const u8, x: f64, y: f64, size: f64, spacing: f64, r: f64, g: f64, b: f64, a: f64) {
|
|
102
|
+
$crate::ffi::guard("bloom_draw_text_ex", move || {
|
|
103
|
+
let text = $crate::string_header::str_from_header(text_ptr);
|
|
104
|
+
let mut eng = engine();
|
|
105
|
+
let mut text_renderer = std::mem::replace(&mut eng.text, $crate::text_renderer::TextRenderer::empty());
|
|
106
|
+
text_renderer.draw_text_ex(&mut eng.renderer, font_handle as usize, text, x, y, size as u32, spacing as f32, r, g, b, a);
|
|
107
|
+
eng.text = text_renderer;
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// bloom_measure_text_ex [source: macos]
|
|
112
|
+
#[no_mangle]
|
|
113
|
+
pub extern "C" fn bloom_measure_text_ex(font_handle: f64, text_ptr: *const u8, size: f64, spacing: f64) -> f64 {
|
|
114
|
+
$crate::ffi::guard("bloom_measure_text_ex", move || {
|
|
115
|
+
let text = $crate::string_header::str_from_header(text_ptr);
|
|
116
|
+
engine().text.measure_text_ex(font_handle as usize, text, size as u32, spacing as f32)
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// bloom_draw_texture [source: macos]
|
|
121
|
+
#[no_mangle]
|
|
122
|
+
pub extern "C" fn bloom_draw_texture(handle: f64, x: f64, y: f64, tint_r: f64, tint_g: f64, tint_b: f64, tint_a: f64) {
|
|
123
|
+
$crate::ffi::guard("bloom_draw_texture", move || {
|
|
124
|
+
let mut eng = engine();
|
|
125
|
+
if let Some(tex) = eng.textures.get(handle) {
|
|
126
|
+
let bind_group_idx = tex.bind_group_idx;
|
|
127
|
+
eng.renderer.draw_texture(bind_group_idx, x, y, tint_r, tint_g, tint_b, tint_a);
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// bloom_draw_texture_rec [source: macos]
|
|
133
|
+
#[no_mangle]
|
|
134
|
+
pub extern "C" fn bloom_draw_texture_rec(
|
|
135
|
+
handle: f64,
|
|
136
|
+
src_x: f64, src_y: f64, src_w: f64, src_h: f64,
|
|
137
|
+
dst_x: f64, dst_y: f64,
|
|
138
|
+
tint_r: f64, tint_g: f64, tint_b: f64, tint_a: f64,
|
|
139
|
+
) {
|
|
140
|
+
$crate::ffi::guard("bloom_draw_texture_rec", move || {
|
|
141
|
+
let mut eng = engine();
|
|
142
|
+
if let Some(tex) = eng.textures.get(handle) {
|
|
143
|
+
let bind_group_idx = tex.bind_group_idx;
|
|
144
|
+
eng.renderer.draw_texture_rec(
|
|
145
|
+
bind_group_idx,
|
|
146
|
+
src_x, src_y, src_w, src_h,
|
|
147
|
+
dst_x, dst_y,
|
|
148
|
+
tint_r, tint_g, tint_b, tint_a,
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// bloom_draw_texture_pro [source: macos]
|
|
155
|
+
#[no_mangle]
|
|
156
|
+
pub extern "C" fn bloom_draw_texture_pro(
|
|
157
|
+
handle: f64,
|
|
158
|
+
src_x: f64, src_y: f64, src_w: f64, src_h: f64,
|
|
159
|
+
dst_x: f64, dst_y: f64, dst_w: f64, dst_h: f64,
|
|
160
|
+
origin_x: f64, origin_y: f64, rotation: f64,
|
|
161
|
+
tint_r: f64, tint_g: f64, tint_b: f64, tint_a: f64,
|
|
162
|
+
) {
|
|
163
|
+
$crate::ffi::guard("bloom_draw_texture_pro", move || {
|
|
164
|
+
let mut eng = engine();
|
|
165
|
+
if let Some(tex) = eng.textures.get(handle) {
|
|
166
|
+
let bind_group_idx = tex.bind_group_idx;
|
|
167
|
+
eng.renderer.draw_texture_pro(
|
|
168
|
+
bind_group_idx,
|
|
169
|
+
src_x, src_y, src_w, src_h,
|
|
170
|
+
dst_x, dst_y, dst_w, dst_h,
|
|
171
|
+
origin_x, origin_y, rotation,
|
|
172
|
+
tint_r, tint_g, tint_b, tint_a,
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// bloom_begin_mode_2d [source: macos]
|
|
179
|
+
#[no_mangle]
|
|
180
|
+
pub extern "C" fn bloom_begin_mode_2d(offset_x: f64, offset_y: f64, target_x: f64, target_y: f64, rotation: f64, zoom: f64) {
|
|
181
|
+
$crate::ffi::guard("bloom_begin_mode_2d", move || {
|
|
182
|
+
engine().renderer.begin_mode_2d(
|
|
183
|
+
offset_x as f32, offset_y as f32,
|
|
184
|
+
target_x as f32, target_y as f32,
|
|
185
|
+
rotation as f32, zoom as f32,
|
|
186
|
+
);
|
|
187
|
+
})
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// bloom_end_mode_2d [source: macos]
|
|
191
|
+
#[no_mangle]
|
|
192
|
+
pub extern "C" fn bloom_end_mode_2d() {
|
|
193
|
+
$crate::ffi::guard("bloom_end_mode_2d", move || {
|
|
194
|
+
engine().renderer.end_mode_2d();
|
|
195
|
+
})
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// bloom_begin_mode_3d [source: macos]
|
|
199
|
+
#[no_mangle]
|
|
200
|
+
pub extern "C" fn bloom_begin_mode_3d(
|
|
201
|
+
pos_x: f64, pos_y: f64, pos_z: f64,
|
|
202
|
+
target_x: f64, target_y: f64, target_z: f64,
|
|
203
|
+
up_x: f64, up_y: f64, up_z: f64,
|
|
204
|
+
fovy: f64, projection: f64,
|
|
205
|
+
) {
|
|
206
|
+
$crate::ffi::guard("bloom_begin_mode_3d", move || {
|
|
207
|
+
engine().renderer.begin_mode_3d(
|
|
208
|
+
pos_x as f32, pos_y as f32, pos_z as f32,
|
|
209
|
+
target_x as f32, target_y as f32, target_z as f32,
|
|
210
|
+
up_x as f32, up_y as f32, up_z as f32,
|
|
211
|
+
fovy as f32, projection as f32,
|
|
212
|
+
);
|
|
213
|
+
})
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// bloom_end_mode_3d [source: macos]
|
|
217
|
+
#[no_mangle]
|
|
218
|
+
pub extern "C" fn bloom_end_mode_3d() {
|
|
219
|
+
$crate::ffi::guard("bloom_end_mode_3d", move || {
|
|
220
|
+
engine().renderer.end_mode_3d();
|
|
221
|
+
})
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// bloom_draw_cube [source: macos]
|
|
225
|
+
#[no_mangle]
|
|
226
|
+
pub extern "C" fn bloom_draw_cube(x: f64, y: f64, z: f64, w: f64, h: f64, d: f64, r: f64, g: f64, b: f64, a: f64) {
|
|
227
|
+
$crate::ffi::guard("bloom_draw_cube", move || {
|
|
228
|
+
engine().renderer.draw_cube(x, y, z, w, h, d, r, g, b, a);
|
|
229
|
+
})
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// bloom_draw_cube_wires [source: macos]
|
|
233
|
+
#[no_mangle]
|
|
234
|
+
pub extern "C" fn bloom_draw_cube_wires(x: f64, y: f64, z: f64, w: f64, h: f64, d: f64, r: f64, g: f64, b: f64, a: f64) {
|
|
235
|
+
$crate::ffi::guard("bloom_draw_cube_wires", move || {
|
|
236
|
+
engine().renderer.draw_cube_wires(x, y, z, w, h, d, r, g, b, a);
|
|
237
|
+
})
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// bloom_draw_sphere [source: macos]
|
|
241
|
+
#[no_mangle]
|
|
242
|
+
pub extern "C" fn bloom_draw_sphere(cx: f64, cy: f64, cz: f64, radius: f64, r: f64, g: f64, b: f64, a: f64) {
|
|
243
|
+
$crate::ffi::guard("bloom_draw_sphere", move || {
|
|
244
|
+
engine().renderer.draw_sphere(cx, cy, cz, radius, r, g, b, a);
|
|
245
|
+
})
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// bloom_draw_sphere_wires [source: macos]
|
|
249
|
+
#[no_mangle]
|
|
250
|
+
pub extern "C" fn bloom_draw_sphere_wires(cx: f64, cy: f64, cz: f64, radius: f64, r: f64, g: f64, b: f64, a: f64) {
|
|
251
|
+
$crate::ffi::guard("bloom_draw_sphere_wires", move || {
|
|
252
|
+
engine().renderer.draw_sphere_wires(cx, cy, cz, radius, r, g, b, a);
|
|
253
|
+
})
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// bloom_draw_cylinder [source: macos]
|
|
257
|
+
#[no_mangle]
|
|
258
|
+
pub extern "C" fn bloom_draw_cylinder(x: f64, y: f64, z: f64, radius_top: f64, radius_bottom: f64, height: f64, r: f64, g: f64, b: f64, a: f64) {
|
|
259
|
+
$crate::ffi::guard("bloom_draw_cylinder", move || {
|
|
260
|
+
engine().renderer.draw_cylinder(x, y, z, radius_top, radius_bottom, height, r, g, b, a);
|
|
261
|
+
})
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// bloom_draw_plane [source: macos]
|
|
265
|
+
#[no_mangle]
|
|
266
|
+
pub extern "C" fn bloom_draw_plane(cx: f64, cy: f64, cz: f64, w: f64, d: f64, r: f64, g: f64, b: f64, a: f64) {
|
|
267
|
+
$crate::ffi::guard("bloom_draw_plane", move || {
|
|
268
|
+
engine().renderer.draw_plane(cx, cy, cz, w, d, r, g, b, a);
|
|
269
|
+
})
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// bloom_draw_grid [source: macos]
|
|
273
|
+
#[no_mangle]
|
|
274
|
+
pub extern "C" fn bloom_draw_grid(slices: f64, spacing: f64) {
|
|
275
|
+
$crate::ffi::guard("bloom_draw_grid", move || {
|
|
276
|
+
engine().renderer.draw_grid(slices as i32, spacing);
|
|
277
|
+
})
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// bloom_draw_ray [source: macos]
|
|
281
|
+
#[no_mangle]
|
|
282
|
+
pub extern "C" fn bloom_draw_ray(origin_x: f64, origin_y: f64, origin_z: f64, dir_x: f64, dir_y: f64, dir_z: f64, r: f64, g: f64, b: f64, a: f64) {
|
|
283
|
+
$crate::ffi::guard("bloom_draw_ray", move || {
|
|
284
|
+
engine().renderer.draw_ray(origin_x, origin_y, origin_z, dir_x, dir_y, dir_z, r, g, b, a);
|
|
285
|
+
})
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// bloom_begin_texture_mode [source: macos]
|
|
289
|
+
#[no_mangle]
|
|
290
|
+
pub extern "C" fn bloom_begin_texture_mode(handle: f64) {
|
|
291
|
+
$crate::ffi::guard("bloom_begin_texture_mode", move || {
|
|
292
|
+
let mut eng = engine();
|
|
293
|
+
let (w, h, bg_idx) = match eng.textures.render_textures.get(handle) {
|
|
294
|
+
Some(rt) => {
|
|
295
|
+
let tex_handle = rt.texture_handle;
|
|
296
|
+
match eng.textures.textures.get(tex_handle) {
|
|
297
|
+
Some(td) => (rt.width, rt.height, td.bind_group_idx as usize),
|
|
298
|
+
None => return,
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
None => return,
|
|
302
|
+
};
|
|
303
|
+
if let Some(texture) = eng.renderer.get_texture_ref(bg_idx) {
|
|
304
|
+
// We need to call begin_texture_mode with a reference to the texture,
|
|
305
|
+
// but get_texture_ref borrows renderer immutably. Clone the texture view
|
|
306
|
+
// data we need first, then call the mutable method.
|
|
307
|
+
let color_view = texture.create_view(&wgpu::TextureViewDescriptor::default());
|
|
308
|
+
// Create depth texture for this RT.
|
|
309
|
+
let depth_tex = eng.renderer.device.create_texture(&wgpu::TextureDescriptor {
|
|
310
|
+
label: Some("rt_depth"), size: wgpu::Extent3d { width: w, height: h, depth_or_array_layers: 1 },
|
|
311
|
+
mip_level_count: 1, sample_count: 1, dimension: wgpu::TextureDimension::D2,
|
|
312
|
+
format: wgpu::TextureFormat::Depth32Float, usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
|
|
313
|
+
view_formats: &[],
|
|
314
|
+
});
|
|
315
|
+
let depth_view = depth_tex.create_view(&wgpu::TextureViewDescriptor::default());
|
|
316
|
+
eng.renderer.rt_color_view = Some(color_view);
|
|
317
|
+
eng.renderer.rt_depth_view = Some(depth_view);
|
|
318
|
+
eng.renderer.rt_depth_texture = Some(depth_tex);
|
|
319
|
+
eng.renderer.rt_width = w;
|
|
320
|
+
eng.renderer.rt_height = h;
|
|
321
|
+
}
|
|
322
|
+
})
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// bloom_end_texture_mode [source: macos]
|
|
326
|
+
#[no_mangle]
|
|
327
|
+
pub extern "C" fn bloom_end_texture_mode() {
|
|
328
|
+
$crate::ffi::guard("bloom_end_texture_mode", move || {
|
|
329
|
+
engine().renderer.end_texture_mode();
|
|
330
|
+
})
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
};
|
|
334
|
+
}
|