Skip to content

Commit b07a245

Browse files
committed
[add] minor fixes, documentation changes, and updated the runtime configurations for the render context and window system.
1 parent 2600d0d commit b07a245

3 files changed

Lines changed: 27 additions & 13 deletions

File tree

crates/lambda-platform/src/gfx/shader.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! Low level shader implementations used by the lambda-platform crate to load
2+
//! RISC-V compiled shaders into the GPU.
3+
14
use gfx_hal::{
25
device::Device,
36
pso::Specialization as ShaderSpecializations,
@@ -15,7 +18,7 @@ pub enum ShaderModuleType {
1518
Compute,
1619
}
1720

18-
/// Builder class for
21+
/// Builder class for creating a shader module.
1922
pub struct ShaderModuleBuilder {
2023
entry_name: String,
2124
specializations: ShaderSpecializations<'static>,

lambda/src/runtimes/mod.rs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ use crate::core::{
3333

3434
pub struct GenericRuntimeBuilder {
3535
app_name: String,
36-
render_api: RenderContextBuilder,
36+
render_context_builder: RenderContextBuilder,
37+
window_builder: WindowBuilder,
3738
window_size: (u32, u32),
3839
components: Vec<Box<dyn RenderableComponent<Events>>>,
3940
}
@@ -42,7 +43,8 @@ impl GenericRuntimeBuilder {
4243
pub fn new(app_name: &str) -> Self {
4344
return Self {
4445
app_name: app_name.to_string(),
45-
render_api: RenderContextBuilder::new(app_name),
46+
render_context_builder: RenderContextBuilder::new(app_name),
47+
window_builder: WindowBuilder::new(),
4648
window_size: (800, 600),
4749
components: Vec::new(),
4850
};
@@ -54,20 +56,29 @@ impl GenericRuntimeBuilder {
5456
return self;
5557
}
5658

57-
pub fn with_window_size(mut self, width: u32, height: u32) -> Self {
58-
self.window_size = (width, height);
59+
/// Configures the `RenderAPIBuilder` before the `RenderContext` is built
60+
/// using a callback provided by the user. The renderer in it's default
61+
/// state will be good enough for most applications, but if you need to
62+
/// customize the renderer you can do so here.
63+
pub fn with_renderer_configured_as(
64+
mut self,
65+
configuration: impl FnOnce(RenderContextBuilder) -> RenderContextBuilder,
66+
) -> Self {
67+
self.render_context_builder = configuration(self.render_context_builder);
5968
return self;
6069
}
6170

62-
/// Configures the RenderAPIBuilder before the RenderingAPI is built using a
63-
/// callback provided by the user.
64-
pub fn with_renderer(
71+
/// Configures the WindowBuilder before the Window is built using a callback
72+
/// provided by the user. If you need to customize the window you can do so
73+
/// here.
74+
pub fn with_window_configured_as(
6575
mut self,
66-
configure: impl FnOnce(RenderContextBuilder) -> RenderContextBuilder,
76+
configuration: impl FnOnce(WindowBuilder) -> WindowBuilder,
6777
) -> Self {
68-
self.render_api = configure(self.render_api);
78+
self.window_builder = configuration(self.window_builder);
6979
return self;
7080
}
81+
7182
/// Attach a component to the current runnable.
7283
pub fn with_component<T: Default + RenderableComponent<Events> + 'static>(
7384
self,
@@ -92,7 +103,7 @@ impl GenericRuntimeBuilder {
92103
.with_dimensions(width, height)
93104
.build(&mut event_loop);
94105
let component_stack = self.components;
95-
let render_api = self.render_api.build(&window);
106+
let render_api = self.render_context_builder.build(&window);
96107

97108
return GenericRuntime {
98109
name,
@@ -271,7 +282,7 @@ impl Runtime for GenericRuntime {
271282
WinitEvent::UserEvent(lambda_event) => match lambda_event {
272283
Events::Runtime { event, issued_at } => match event {
273284
RuntimeEvent::Initialized => {
274-
println!("Starting the kernel {}", name);
285+
println!("[INFO] Initializing all of the components for the runtime: {}", name);
275286
for component in &mut component_stack {
276287
component.on_attach();
277288
component

tools/lambda_rs_demo/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl Default for DemoComponent {
219219

220220
fn main() {
221221
let runtime = GenericRuntimeBuilder::new("2D Triangle Demo")
222-
.with_renderer(move |render_context_builder| {
222+
.with_renderer_configured_as(move |render_context_builder| {
223223
return render_context_builder.with_render_timeout(1_000_000_000);
224224
})
225225
.with_component(move |runtime, demo: DemoComponent| {

0 commit comments

Comments
 (0)