MCPcopy Create free account
hub / github.com/AryanpurTech/BlueEngine / main

Function main

examples/utils/resource_sharing.rs:10–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8use blue_engine::{Engine, ObjectSettings, TextureData, Vector3, primitive_shapes::square};
9
10fn main() -> Result<(), blue_engine::error::Error> {
11 // Start the engine
12 let mut engine = Engine::new()?;
13
14 // build your main object with the texture
15 square(
16 "main",
17 ObjectSettings::default(),
18 &mut engine.renderer,
19 &mut engine.objects,
20 )?;
21
22 // add the texture to the main object as normally would
23 engine
24 .objects
25 .get_mut("main")
26 .unwrap()
27 // build a texture as an example of resource to be shared
28 .set_texture(
29 "background",
30 TextureData::Path("examples/resources/BlueLogoDiscord.png".to_string()),
31 blue_engine::TextureMode::Clamp,
32 &mut engine.renderer,
33 )?
34 .set_position(Vector3::new(-1.5f32, 0f32, 0f32)); // set position to make it visible
35
36 // create another object where you want to get resources shared with
37 square(
38 "alt",
39 ObjectSettings::default(),
40 &mut engine.renderer,
41 &mut engine.objects,
42 )?;
43
44 // here you can use `reference_texture` to reference the texture from the main object
45 engine
46 .objects
47 .get_mut("alt")
48 .expect("Error during copying texture of the main square")
49 // setting position again to make it visible
50 .set_position([1.5f32, 0f32, 0f32])
51 .reference_texture("main");
52
53 engine.update_loop(move |_| {})?;
54
55 Ok(())
56}

Callers

nothing calls this directly

Calls 5

set_textureMethod · 0.80
reference_textureMethod · 0.80
update_loopMethod · 0.80
squareFunction · 0.50
set_positionMethod · 0.45

Tested by

no test coverage detected