pub struct UniformTexture { /* private fields */ }Expand description
A UniformTexture is a special type of texture that you can renderer to and also render itself to the screen. Uniform Textures is usefull for things like lightmaps or graphics techniques that reuqire multiple rendering passes.
Implementations§
Source§impl UniformTexture
impl UniformTexture
Sourcepub fn new(engine: &Engine, size: Vec2<u32>) -> Self
pub fn new(engine: &Engine, size: Vec2<u32>) -> Self
creates a UniformTexture of a specified size
this can be reszied at anytime with
Material::resize_uniform_texture
Examples found in repository?
examples/lightmap.rs (line 22)
15fn main() {
16 let mut engine = EngineBuilder::new()
17 .set_window_title("Lightmap")
18 .with_resolution((800, 800))
19 .build()
20 .unwrap();
21
22 let uniform_texture = UniformTexture::new(&engine, engine.get_window_size());
23
24 let light = Light {
25 colour: Colour::ORANGE,
26 pos_x: 0.0,
27 pos_y: 0.0,
28 brightness: 0.75,
29 aspect_ratio: 1.0,
30 };
31
32 let light_data = UniformData::new(&light);
33
34 let shader_options = ShaderOptions::with_all(&light_data, &uniform_texture);
35 let light_shader = Shader::new(
36 "examples/light.wgsl",
37 shader_options,
38 &mut engine,
39 LoadingOp::Blocking,
40 );
41
42 let material = MaterialBuilder::new()
43 .set_shader(light_shader)
44 .build(&mut engine);
45
46 let ocluder_material = MaterialBuilder::new().build(&mut engine);
47
48 let rectangles = vec![
49 Rectangle::new(Vec2 { x: 120.0, y: 20.0 }, Vec2 { x: 50.0, y: 50.0 }),
50 Rectangle::new(Vec2 { x: 270.0, y: 70.0 }, Vec2 { x: 50.0, y: 50.0 }),
51 Rectangle::new(Vec2 { x: 130.0, y: 280.0 }, Vec2 { x: 50.0, y: 50.0 }),
52 Rectangle::new(Vec2 { x: 220.0, y: 300.0 }, Vec2 { x: 50.0, y: 50.0 }),
53 Rectangle::new(Vec2 { x: 350.0, y: 350.0 }, Vec2 { x: 100.0, y: 100.0 }),
54 ];
55
56 let s = TextureExample {
57 material,
58 ocluder_material,
59 light,
60 uniform_texture,
61 rectangles,
62 mouse_pos: ZEROS,
63 };
64
65 engine.run(s);
66}Sourcepub fn new_with_sampler(
engine: &Engine,
size: Vec2<u32>,
mag_sampler: SamplerType,
min_sampler: SamplerType,
) -> Self
pub fn new_with_sampler( engine: &Engine, size: Vec2<u32>, mag_sampler: SamplerType, min_sampler: SamplerType, ) -> Self
This creates a UniformTexture with samplers which allows you to select what sampling type to use for both the mag_sampler,
when the texture is being drawn larger than the orignal resolution and min_sampler, when the texture is being drawn
smaller than the original resolution.
Auto Trait Implementations§
impl Freeze for UniformTexture
impl !RefUnwindSafe for UniformTexture
impl Send for UniformTexture
impl Sync for UniformTexture
impl Unpin for UniformTexture
impl !UnwindSafe for UniformTexture
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§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> 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> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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