1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Tier-2: model loading + generated-mesh smoke tests.
//! Salvaged from raylib-test/src/models.rs.
#![cfg(feature = "software_renderer")]
// `Mesh` is only referenced inside the SUPPORT_MESH_GENERATION gate
// below; scoping the prelude import to that gate avoids an
// unused_imports warning when the feature is off.
#[cfg(feature = "SUPPORT_MESH_GENERATION")]
use raylib::prelude::*;
use raylib::test_harness::with_headless;
#[test]
fn models_load_and_generated_smoke() {
with_headless(64, 64, |_rl, _thread| {
// OBJ model loading: use vendored cube.obj from raylib examples.
// Gated on SUPPORT_FILEFORMAT_OBJ.
#[cfg(feature = "SUPPORT_FILEFORMAT_OBJ")]
{
let obj_path = "raylib-sys/raylib/examples/models/resources/models/obj/cube.obj";
if std::path::Path::new(obj_path).exists() {
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
let _ = _rl.load_model(_thread, obj_path);
}));
if result.is_err() {
eprintln!("SKIP: load_model not supported under software_renderer");
}
} else {
eprintln!("SKIP: {obj_path} not found");
}
}
#[cfg(not(feature = "SUPPORT_FILEFORMAT_OBJ"))]
eprintln!("SKIP: load_model (OBJ) requires SUPPORT_FILEFORMAT_OBJ");
// Model from generated mesh: gen_mesh_cube + load_model_from_mesh.
// May fail under software_renderer if GL VBO upload is required.
// Gated on SUPPORT_MESH_GENERATION.
#[cfg(feature = "SUPPORT_MESH_GENERATION")]
{
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
// SAFETY: the mesh is immediately handed to load_model_from_mesh
// which takes ownership; the WeakMesh wrapper exists only to
// bridge the type system across the call.
let mesh = unsafe { Mesh::gen_mesh_cube(_thread, 1.0, 1.0, 1.0).make_weak() };
let _model = _rl
.load_model_from_mesh(_thread, mesh)
.expect("load_model_from_mesh");
}));
if result.is_err() {
eprintln!(
"SKIP: gen_mesh_cube + load_model_from_mesh not supported under software_renderer"
);
}
}
#[cfg(not(feature = "SUPPORT_MESH_GENERATION"))]
eprintln!("SKIP: gen_mesh_cube requires SUPPORT_MESH_GENERATION");
});
}