pub struct TextureAtlasBuilder { /* private fields */ }Implementations§
Source§impl TextureAtlasBuilder
impl TextureAtlasBuilder
Sourcepub fn add_texture_file(self, id: &str, file: &str) -> Self
pub fn add_texture_file(self, id: &str, file: &str) -> Self
Examples found in repository?
examples/texture_atlas.rs (lines 19-22)
5fn main() {
6 let mut runner = est_render::runner::new().expect("Failed to create runner");
7
8 let mut window = runner
9 .create_window("Clear Color Example", Point2::new(800, 600))
10 .build()
11 .expect("Failed to create window");
12
13 let mut gpu = est_render::gpu::new(Some(&mut window))
14 .build()
15 .expect("Failed to create GPU");
16
17 let texture_atlas = gpu
18 .create_texture_atlas()
19 .add_texture_file(
20 "example_texture",
21 "./examples/resources/test1.png",
22 )
23 .add_texture_file(
24 "example_texture2",
25 "./examples/resources/test2.png",
26 )
27 .build()
28 .expect("Failed to create texture atlas");
29
30 while runner.pump_events(None) {
31 for event in runner.get_events() {
32 match event {
33 Event::WindowClosed { .. } => {
34 return;
35 }
36 _ => {}
37 }
38 }
39
40 if let Ok(mut cmd) = gpu.begin_command() {
41 if let Ok(mut gp) = cmd.begin_renderpass() {
42 gp.set_clear_color(Color::BLUEVIOLET);
43 gp.set_blend(0, Some(&BlendState::NONE));
44
45 if let Some(mut drawing) = gp.begin_drawing() {
46 drawing.set_texture_atlas(Some((&texture_atlas, "example_texture")));
47 drawing.draw_rect_image(
48 Vector2::new(100.0, 100.0),
49 Vector2::new(200.0, 200.0),
50 Color::WHITE,
51 );
52 drawing.set_texture_atlas(Some((&texture_atlas, "example_texture2")));
53 drawing.draw_rect_image(
54 Vector2::new(350.0, 100.0),
55 Vector2::new(200.0, 200.0),
56 Color::WHITE,
57 );
58 drawing.draw_circle_image(Vector2::new(600.0, 200.0), 100.0, 20, Color::WHITE);
59 }
60 }
61 }
62 }
63}pub fn add_texture_file_buf(self, id: &str, data: &[u8]) -> Self
pub fn add_texture_raw( self, id: &str, data: Vec<u8>, width: u32, height: u32, ) -> Self
Sourcepub fn build(self) -> Result<TextureAtlas, TextureAtlasBuilderError>
pub fn build(self) -> Result<TextureAtlas, TextureAtlasBuilderError>
Examples found in repository?
examples/texture_atlas.rs (line 27)
5fn main() {
6 let mut runner = est_render::runner::new().expect("Failed to create runner");
7
8 let mut window = runner
9 .create_window("Clear Color Example", Point2::new(800, 600))
10 .build()
11 .expect("Failed to create window");
12
13 let mut gpu = est_render::gpu::new(Some(&mut window))
14 .build()
15 .expect("Failed to create GPU");
16
17 let texture_atlas = gpu
18 .create_texture_atlas()
19 .add_texture_file(
20 "example_texture",
21 "./examples/resources/test1.png",
22 )
23 .add_texture_file(
24 "example_texture2",
25 "./examples/resources/test2.png",
26 )
27 .build()
28 .expect("Failed to create texture atlas");
29
30 while runner.pump_events(None) {
31 for event in runner.get_events() {
32 match event {
33 Event::WindowClosed { .. } => {
34 return;
35 }
36 _ => {}
37 }
38 }
39
40 if let Ok(mut cmd) = gpu.begin_command() {
41 if let Ok(mut gp) = cmd.begin_renderpass() {
42 gp.set_clear_color(Color::BLUEVIOLET);
43 gp.set_blend(0, Some(&BlendState::NONE));
44
45 if let Some(mut drawing) = gp.begin_drawing() {
46 drawing.set_texture_atlas(Some((&texture_atlas, "example_texture")));
47 drawing.draw_rect_image(
48 Vector2::new(100.0, 100.0),
49 Vector2::new(200.0, 200.0),
50 Color::WHITE,
51 );
52 drawing.set_texture_atlas(Some((&texture_atlas, "example_texture2")));
53 drawing.draw_rect_image(
54 Vector2::new(350.0, 100.0),
55 Vector2::new(200.0, 200.0),
56 Color::WHITE,
57 );
58 drawing.draw_circle_image(Vector2::new(600.0, 200.0), 100.0, 20, Color::WHITE);
59 }
60 }
61 }
62 }
63}Trait Implementations§
Source§impl Clone for TextureAtlasBuilder
impl Clone for TextureAtlasBuilder
Source§fn clone(&self) -> TextureAtlasBuilder
fn clone(&self) -> TextureAtlasBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TextureAtlasBuilder
impl !RefUnwindSafe for TextureAtlasBuilder
impl !Send for TextureAtlasBuilder
impl !Sync for TextureAtlasBuilder
impl Unpin for TextureAtlasBuilder
impl !UnwindSafe for TextureAtlasBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more