Struct bottomless_pit::shader::UniformData
source · pub struct UniformData { /* private fields */ }Expand description
UniformData contains the byte data of any struct that implements
ShaderType which
can be derived. This data needs to be added to a Material upon creation.
Implementations§
source§impl UniformData
impl UniformData
sourcepub fn new<T: ShaderType + WriteInto>(engine: &Engine, data: &T) -> Self
pub fn new<T: ShaderType + WriteInto>(engine: &Engine, data: &T) -> Self
Examples found in repository?
examples/ngon.rs (line 28)
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
fn main() {
let mut engine = EngineBuilder::new()
.with_resolution((500, 500))
.remove_vsync()
.set_clear_colour(Colour::BLACK)
.build()
.unwrap();
let data = Time {
time: 0.0,
_pading: 0.0,
_padding2: 0.0,
_padding4: 0.0,
};
let uniform_data = UniformData::new(&engine, &data);
let mouse_shader = Shader::new("examples/sinewaves.wgsl", true, &mut engine);
let regular_material = MaterialBuilder::new()
.set_uniform(&uniform_data)
.set_shader(mouse_shader)
.build(&mut engine);
let pos = Position {
regular_material,
time: 0.0,
};
engine.run(pos);
}More examples
examples/shader.rs (line 29)
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
fn main() {
let mut engine = EngineBuilder::new()
.set_clear_colour(Colour::WHITE)
.build()
.unwrap();
let mouse_shader = Shader::new("examples/mouse.wgsl", true, &mut engine);
let circle_shader = Shader::new("examples/movement.wgsl", true, &mut engine);
let data = MousePos {
x: 0.0,
y: 0.0,
_junk: 0.0,
_padding2: 0.0,
};
let mouse_uniform_data = UniformData::new(&engine, &data);
// On wasm we need this to be 16 bytes aligned so we have added this instead of
// a 0.0_f32
let circle_uniform_data = UniformData::new(&engine, &data);
let mouse_material = MaterialBuilder::new()
.set_shader(mouse_shader)
.set_uniform(&mouse_uniform_data)
.build(&mut engine);
let circle_material = MaterialBuilder::new()
.set_shader(circle_shader)
.set_uniform(&circle_uniform_data)
.build(&mut engine);
let defualt_material = MaterialBuilder::new().build(&mut engine);
let game = ShaderExample {
data,
mouse_material,
circle_material,
defualt_material,
theta: 0.0,
};
engine.run(game);
}Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for UniformData
impl Send for UniformData
impl Sync for UniformData
impl Unpin for UniformData
impl !UnwindSafe for UniformData
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