-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: resource sharing now fully working. with example
- Loading branch information
1 parent
e4c58d7
commit be915ed
Showing
6 changed files
with
300 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
use blue_engine::{primitive_shapes::square, Engine, ObjectSettings, TextureData}; | ||
|
||
fn main() { | ||
// Start the engine | ||
let mut engine = Engine::new().expect("window not initialized"); | ||
|
||
// build a texture as an example of resource to be shared | ||
let texture = engine | ||
.renderer | ||
.build_texture( | ||
"background", | ||
TextureData::Path("resources/BlueLogoDiscord.png"), | ||
blue_engine::TextureMode::Clamp, | ||
) | ||
.unwrap(); | ||
|
||
// build your main object with the texture | ||
square( | ||
"main", | ||
ObjectSettings::default(), | ||
&mut engine.renderer, | ||
&mut engine.objects, | ||
) | ||
.expect("Error during creation of main square"); | ||
|
||
// add the texture to the main object as normally would | ||
engine | ||
.objects | ||
.get_mut("main") | ||
.unwrap() | ||
.set_texture(texture) | ||
.expect("Error during inserting texture to the main square"); | ||
// set position to make it visible | ||
engine | ||
.objects | ||
.get_mut("main") | ||
.expect("Error during setting the position of the main square") | ||
.set_position(-1.5f32, 0f32, 0f32); | ||
|
||
// create another object where you want to get resources shared with | ||
square( | ||
"alt", | ||
ObjectSettings::default(), | ||
&mut engine.renderer, | ||
&mut engine.objects, | ||
) | ||
.expect("Error during creation of alt square"); | ||
|
||
// here you can use `reference_texture` to reference the texture from the main object | ||
engine | ||
.objects | ||
.get_mut("alt") | ||
.expect("Error during copying texture of the main square") | ||
.reference_texture("main"); | ||
// setting position again to make it visible | ||
engine | ||
.objects | ||
.get_mut("alt") | ||
.expect("Error during setting the position of the alt square") | ||
.set_position(1.5f32, 0f32, 0f32); | ||
|
||
engine | ||
.update_loop(move |_, _, _, _, _, _| {}) | ||
.expect("Error during update loop"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.