Struct bottomless_pit::engine_handle::EngineBuilder
source · pub struct EngineBuilder { /* private fields */ }Expand description
A builder class that helps create an application with specific details
Implementations§
source§impl EngineBuilder
impl EngineBuilder
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a builder with some defualt presets
Self {
resolution: (600, 600),
full_screen: false,
target_fps: 30,
close_key: None,
clear_colour: Colour::BLACK,
window_icon: None,
window_title: "Bottonless-Pit Game".into(),
resizable: true,
vysnc: false,
}Examples found in repository?
More examples
8 9 10 11 12 13 14 15 16 17 18 19 20
fn main() {
let mut engine = EngineBuilder::new()
.with_resolution((400, 400))
.set_clear_colour(Colour::BLACK)
.build()
.unwrap();
let material = MaterialBuilder::new().build(&mut engine);
let pos = DebugTriangle { material };
engine.run(pos);
}10 11 12 13 14 15 16 17 18 19 20 21 22
fn main() {
let mut engine = EngineBuilder::new()
.set_clear_colour(Colour::BLACK)
.build()
.unwrap();
let comic = Font::new("examples/Comic.ttf", &mut engine);
let text_mat = TextMaterial::new("AA", Colour::RED, 100.0, 100.0, &mut engine);
let text_example = TextExample { text_mat, comic };
engine.run(text_example);
}10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
fn main() {
let mut engine = EngineBuilder::new()
.set_clear_colour(Colour::BLACK)
.build()
.unwrap();
let texture = Texture::new(&mut engine, "examples/bplogo.png");
let texture_material = MaterialBuilder::new()
.add_texture(texture)
.build(&mut engine);
let regular_material = MaterialBuilder::new().build(&mut engine);
let pos = Position {
pos: Vec2 { x: 0.0, y: 0.0 },
regular_material,
texture_material,
};
engine.run(pos);
}9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
fn main() {
let mut engine = EngineBuilder::new()
.set_window_title("Testing Triangle")
.with_resolution((400, 400))
.build()
.unwrap();
let texture = Texture::new(&mut engine, "examples/bplogo.png");
let texture = MaterialBuilder::new()
.add_texture(texture)
.build(&mut engine);
let defualt = MaterialBuilder::new().build(&mut engine);
let s = TextureExample {
current: texture,
other: defualt,
pos: Vec2 { x: 0.0, y: 0.0 },
};
engine.run(s);
}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);
}sourcepub fn with_resolution(self, resolution: (u32, u32)) -> Self
pub fn with_resolution(self, resolution: (u32, u32)) -> Self
Overides the defualt resolution
Examples found in repository?
8 9 10 11 12 13 14 15 16 17 18 19 20
fn main() {
let mut engine = EngineBuilder::new()
.with_resolution((400, 400))
.set_clear_colour(Colour::BLACK)
.build()
.unwrap();
let material = MaterialBuilder::new().build(&mut engine);
let pos = DebugTriangle { material };
engine.run(pos);
}More examples
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
fn main() {
let mut engine = EngineBuilder::new()
.set_window_title("Testing Triangle")
.with_resolution((400, 400))
.build()
.unwrap();
let texture = Texture::new(&mut engine, "examples/bplogo.png");
let texture = MaterialBuilder::new()
.add_texture(texture)
.build(&mut engine);
let defualt = MaterialBuilder::new().build(&mut engine);
let s = TextureExample {
current: texture,
other: defualt,
pos: Vec2 { x: 0.0, y: 0.0 },
};
engine.run(s);
}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);
}sourcepub fn fullscreen(self) -> Self
pub fn fullscreen(self) -> Self
Will cause the window to be fullscreen upon launch
sourcepub fn set_target_fps(self, fps: u16) -> Self
pub fn set_target_fps(self, fps: u16) -> Self
Sets a target fps cap. The thread will spin sleep using the spin_sleep crate untill the desired frame time is reached. If the frames are slower than the target no action is taken to “speed” up the rendering and updating
sourcepub fn remove_vsync(self) -> Self
pub fn remove_vsync(self) -> Self
Will cause the framerate to be uncapped if the platform supports it using wgpu’s PresentMode::AutoNoVsync by defualt the engine uses PresentMode::AutoVsync
Examples found in repository?
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);
}sourcepub fn set_close_key(self, key: Key) -> Self
pub fn set_close_key(self, key: Key) -> Self
Sets a key that will instantly close the window
sourcepub fn set_clear_colour(self, colour: Colour) -> Self
pub fn set_clear_colour(self, colour: Colour) -> Self
Sets the colour that the background will be
Examples found in repository?
8 9 10 11 12 13 14 15 16 17 18 19 20
fn main() {
let mut engine = EngineBuilder::new()
.with_resolution((400, 400))
.set_clear_colour(Colour::BLACK)
.build()
.unwrap();
let material = MaterialBuilder::new().build(&mut engine);
let pos = DebugTriangle { material };
engine.run(pos);
}More examples
10 11 12 13 14 15 16 17 18 19 20 21 22
fn main() {
let mut engine = EngineBuilder::new()
.set_clear_colour(Colour::BLACK)
.build()
.unwrap();
let comic = Font::new("examples/Comic.ttf", &mut engine);
let text_mat = TextMaterial::new("AA", Colour::RED, 100.0, 100.0, &mut engine);
let text_example = TextExample { text_mat, comic };
engine.run(text_example);
}10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
fn main() {
let mut engine = EngineBuilder::new()
.set_clear_colour(Colour::BLACK)
.build()
.unwrap();
let texture = Texture::new(&mut engine, "examples/bplogo.png");
let texture_material = MaterialBuilder::new()
.add_texture(texture)
.build(&mut engine);
let regular_material = MaterialBuilder::new().build(&mut engine);
let pos = Position {
pos: Vec2 { x: 0.0, y: 0.0 },
regular_material,
texture_material,
};
engine.run(pos);
}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);
}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);
}sourcepub fn set_window_title(self, title: &str) -> Self
pub fn set_window_title(self, title: &str) -> Self
Sets the title of the window
Examples found in repository?
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
fn main() {
let mut engine = EngineBuilder::new()
.set_window_title("Testing Triangle")
.with_resolution((400, 400))
.build()
.unwrap();
let texture = Texture::new(&mut engine, "examples/bplogo.png");
let texture = MaterialBuilder::new()
.add_texture(texture)
.build(&mut engine);
let defualt = MaterialBuilder::new().build(&mut engine);
let s = TextureExample {
current: texture,
other: defualt,
pos: Vec2 { x: 0.0, y: 0.0 },
};
engine.run(s);
}sourcepub fn set_window_icon(self, icon: Icon) -> Self
pub fn set_window_icon(self, icon: Icon) -> Self
Sets the window icon
sourcepub fn unresizable(self) -> Self
pub fn unresizable(self) -> Self
Prevents the window from being resized during runtime
sourcepub fn build(self) -> Result<Engine, BuildError>
pub fn build(self) -> Result<Engine, BuildError>
Attempts to buld the Engine
Examples found in repository?
More examples
8 9 10 11 12 13 14 15 16 17 18 19 20
fn main() {
let mut engine = EngineBuilder::new()
.with_resolution((400, 400))
.set_clear_colour(Colour::BLACK)
.build()
.unwrap();
let material = MaterialBuilder::new().build(&mut engine);
let pos = DebugTriangle { material };
engine.run(pos);
}10 11 12 13 14 15 16 17 18 19 20 21 22
fn main() {
let mut engine = EngineBuilder::new()
.set_clear_colour(Colour::BLACK)
.build()
.unwrap();
let comic = Font::new("examples/Comic.ttf", &mut engine);
let text_mat = TextMaterial::new("AA", Colour::RED, 100.0, 100.0, &mut engine);
let text_example = TextExample { text_mat, comic };
engine.run(text_example);
}10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
fn main() {
let mut engine = EngineBuilder::new()
.set_clear_colour(Colour::BLACK)
.build()
.unwrap();
let texture = Texture::new(&mut engine, "examples/bplogo.png");
let texture_material = MaterialBuilder::new()
.add_texture(texture)
.build(&mut engine);
let regular_material = MaterialBuilder::new().build(&mut engine);
let pos = Position {
pos: Vec2 { x: 0.0, y: 0.0 },
regular_material,
texture_material,
};
engine.run(pos);
}9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
fn main() {
let mut engine = EngineBuilder::new()
.set_window_title("Testing Triangle")
.with_resolution((400, 400))
.build()
.unwrap();
let texture = Texture::new(&mut engine, "examples/bplogo.png");
let texture = MaterialBuilder::new()
.add_texture(texture)
.build(&mut engine);
let defualt = MaterialBuilder::new().build(&mut engine);
let s = TextureExample {
current: texture,
other: defualt,
pos: Vec2 { x: 0.0, y: 0.0 },
};
engine.run(s);
}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);
}