Skip to content

Commit 6d7419b

Browse files
authored
Merge pull request #49 from lambda-sh/vmarcella/update-examples
Demos as examples
2 parents 3d142dd + 198eb06 commit 6d7419b

File tree

15 files changed

+70
-147
lines changed

15 files changed

+70
-147
lines changed

Cargo.lock

Lines changed: 0 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@ members = [
55
"lambda",
66
"crates/lambda-platform",
77
"crates/lambda-args",
8-
"tools/lambda_rs_demo",
9-
"tools/minimal",
10-
"tools/triangles_demo",
118
"tools/obj_loader"
129
]
1310

1411
default-members = [
1512
"lambda",
1613
"crates/lambda-platform",
17-
"tools/lambda_rs_demo",
1814
"tools/obj_loader"
1915
]

README.md

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
<img src="https://media.githubusercontent.com/media/lambda-sh/lambda/main/lambda/assets/logos/lambda_header.png" />
33
</p>
44

5+
[![Cross Platform builds & tests](https://github.com/lambda-sh/lambda/actions/workflows/compile_lambda_rs.yml/badge.svg)](https://github.com/lambda-sh/lambda/actions/workflows/compile_lambda_rs.yml)
6+
7+
8+
59
## Table of contents
610
1. [Description](#description)
711
2. [API Documentation](#documentation)
@@ -11,9 +15,10 @@
1115
2. [Optional depedencies](#opt_deps)
1216
3. [Linux, Macos, Windows](#bash)
1317
5. [Getting started](#get_started)
14-
6. [Planned additions](#plans)
15-
7. [How to contribute](#contribute)
16-
8. [Resources](#resources)
18+
6. [Examples](#examples)
19+
7. [Planned additions](#plans)
20+
8. [How to contribute](#contribute)
21+
9. [Resources](#resources)
1722
## Description <a name="description"></a>
1823
Lambda is a framework for developing cross platform applications and workloads using Rust.
1924

@@ -88,37 +93,69 @@ If this works successfully, then lambda is ready to work on your system!
8893
## Getting started <a name="get_started"></a>
8994
Coming soon.
9095

96+
## Examples <a name="examples"></a>
97+
### Minimal
98+
A minimal example of an application with a working window using lambda.
99+
```rust
100+
cargo run --example minimal
101+
```
102+
103+
### Push Constants
104+
An example of using shaders with push constants to render a 3D image.
105+
```rust
106+
cargo run --example push_constants
107+
```
108+
109+
### Triangle
110+
An example using shaders to render a single triangle.
111+
```rust
112+
cargo run --example triangle
113+
```
114+
115+
### Triangles
116+
An example using shaders to render multiple triangles and keyboard input to move one of the triangles on screen.
117+
```rust
118+
cargo run --example triangles
119+
```
91120

92121
## Plans <a name="plans"></a>
93-
- [x] Architecture support
122+
- ### Architecture support
94123
- [x] x86
95124
- [x] arm64
96-
- [ ] Operating system support
125+
- ### Operating system support
97126
- [x] MacOS
98127
- [x] Linux
99128
- [x] Windows 10/11
100129
- [ ] Xbox Series S|X (Long term goal)
101130
- [ ] iOS (Long term goal)
102131
- [ ] Android (Long term goal)
103-
- [x] Rendering API support
132+
- ### Rendering API support
104133
- [x] OpenGL
105134
- [x] Vulkan
106135
- [x] Metal
107136
- [x] DirectX11
108137
- [x] DirectX12
109-
- [ ] Crates
110-
- [ ] lambda-arch -- Architecture support
111-
- [x] (WIP) lambda-platform -- Platform support
112-
- [ ] (WIP) lambda-core -- Core library implementations
113-
- [ ] lambda-cloud -- Cloud integrations
114-
- [ ] (WIP) lambda -- The public Lambda API
115-
- [ ] Tools
116-
- [x] lambda-rs-demo -- 2D rendering demo
117-
- [ ] lambda-rs-cube -- 3D rendering demo
118-
- [ ] lambda-checker -- Checks system specifications against lambda requirements
119-
- [ ] CI/CD
120-
- [ ] Github action pipelines for creating downloadable builds from releases.
121-
- [ ] Tests & benchmarking.
138+
- ### Crates
139+
- [x] (WIP) lambda-args -- Command line argument parsing.
140+
- [x] (WIP) lambda-platform -- Dependency wrappers & platform support.
141+
- [ ] lambda-cloud -- Cloud integrations.
142+
- [x] (WIP) lambda -- The public Lambda API.
143+
- ### Examples
144+
- [x] Minimal -- A minimal example of an application with a working window
145+
using lambda.
146+
- [x] Push Constants -- An example of using shaders with push constants to
147+
render a 3D image.
148+
- [x] Triangle -- An example using shaders to render a single triangle.
149+
- [x] Triangles -- An example using shaders to render multiple triangles and keyboard input to move one of the triangles on screen.
150+
- ### Tools
151+
- [x] obj-loader -- (WIP) Loads .obj files into lambda. Meshes need to be triangulated in order for it to render at the moment.
152+
- [ ] platform-info -- Utility for viewing information about the current platform.
153+
- ### CI/CD
154+
- [x] Github action pipelines for building lambda on all platforms.
155+
- [ ] Github action pipelines for creating downloadable builds from releases.
156+
- [ ] Tests & benchmarking.
157+
- [ ] Unit tests.
158+
- [ ] Nightly builds.
122159

123160
## How to contribute <a name="contribute"></a>
124161
Fork the current repository and then make the changes that you'd like to

lambda/assets/shaders/triangles.frag

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#extension GL_ARB_separate_shader_objects : enable
33

44
layout(location = 0) in vec4 vertex_color;
5+
56
layout(location = 0) out vec4 fragment_color;
67

78
void main() {

lambda/assets/shaders/triangles.vert

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
#version 450
22
#extension GL_ARB_separate_shader_objects : enable
33

4-
layout(push_constant) uniform PushConstants {
4+
layout(push_constant) uniform PushConstant {
55
vec4 color;
66
vec2 pos;
77
vec2 scale;
8-
} push_constants;
8+
} pcs;
99

1010
layout(location = 0) out vec4 vertex_color;
1111

1212
vec2 positions[3] = vec2[](
13-
vec2(0.0, -0.5),
14-
vec2(-0.5, 0.5),
15-
vec2(0.5, 0.5)
16-
);
13+
vec2(0.0, -0.5),
14+
vec2(-0.5, 0.5),
15+
vec2(0.5, 0.5)
16+
);
1717

1818
void main() {
19-
vec2 pos = positions[gl_VertexIndex] * push_constants.scale;
20-
vertex_color = push_constants.color;
21-
gl_Position = vec4((post + push_constants.pos), 0.0, 1.0);
19+
vec2 position = positions[gl_VertexIndex] * pcs.scale;
20+
vertex_color = pcs.color;
21+
gl_Position = vec4((position + pcs.pos), 0.0, 1.0);
2222
}
File renamed without changes.

tools/lambda_rs_demo/src/main.rs renamed to lambda/examples/triangle.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ impl Default for DemoComponent {
156156
fn default() -> Self {
157157
// Specify virtual shaders to use for rendering
158158
let triangle_vertex = VirtualShader::Source {
159-
source: include_str!("../assets/triangle.vert").to_string(),
159+
source: include_str!("../assets/shaders/triangle.vert").to_string(),
160160
kind: ShaderKind::Vertex,
161161
name: String::from("triangle"),
162162
entry_point: String::from("main"),
163163
};
164164

165165
let triangle_fragment = VirtualShader::Source {
166-
source: include_str!("../assets/triangle.frag").to_string(),
166+
source: include_str!("../assets/shaders/triangle.frag").to_string(),
167167
kind: ShaderKind::Fragment,
168168
name: String::from("triangle"),
169169
entry_point: String::from("main"),

tools/triangles_demo/src/main.rs renamed to lambda/examples/triangles.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,14 @@ impl Default for TrianglesComponent {
220220
fn default() -> Self {
221221
// Specify virtual shaders to use for rendering
222222
let triangle_vertex = VirtualShader::Source {
223-
source: include_str!("../assets/triangles.vert").to_string(),
223+
source: include_str!("../assets/shaders/triangles.vert").to_string(),
224224
kind: ShaderKind::Vertex,
225225
name: String::from("triangles"),
226226
entry_point: String::from("main"),
227227
};
228228

229229
let triangle_fragment = VirtualShader::Source {
230-
source: include_str!("../assets/triangles.frag").to_string(),
230+
source: include_str!("../assets/shaders/triangles.frag").to_string(),
231231
kind: ShaderKind::Fragment,
232232
name: String::from("triangles"),
233233
entry_point: String::from("main"),

tools/lambda_rs_demo/Cargo.toml

Lines changed: 0 additions & 14 deletions
This file was deleted.

tools/lambda_rs_demo/assets/triangle.frag

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)