-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64f3b87
commit dbcd854
Showing
16 changed files
with
965 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
max_width = 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# Contributors | ||
- [JeronAldaron](https://github.com/JeronAldaron) | ||
- [Aldarobot](https://github.com/Aldarobot) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "video" | ||
version = "0.1.0" | ||
authors = ["Jeron Aldaron Lau <[email protected]>"] | ||
edition = "2018" | ||
build = "build.rs" | ||
|
||
[dependencies.cala] | ||
features = ["graphics"] | ||
path = "../../" | ||
|
||
[build-dependencies] | ||
# yeet = { path = "../../../yeet" } | ||
res = "0.3" # { path = "../../../res" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fn main() { | ||
res::generate(&[res::shader("color") | ||
.transform() | ||
.gradient() | ||
.num_instances(2)]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
use cala::ShaderBuilder; | ||
|
||
#[allow(unused)] | ||
pub struct Context { | ||
colors: cala::Shader, | ||
triangle: cala::Shape, | ||
timed: cala::TimedLoop, | ||
} | ||
|
||
// Initialize & set loop to `init()`. | ||
cala::init!(run, { | ||
// Set the background color. | ||
cala::background(0.0, 1.0, 0.0); | ||
|
||
// Load a shader. | ||
let mut colors = cala::shader!("color"); | ||
|
||
// Define vertices. | ||
#[rustfmt::skip] | ||
let vertices = [ | ||
-0.5, -0.5, 1.0, 0.5, 0.0, | ||
0.5, -0.5, 0.0, 0.0, 1.0, | ||
0.0, 0.5, 1.0, 1.0, 1.0, | ||
]; | ||
|
||
// Build triangle Shape | ||
let mut triangle = | ||
cala::Shape::new(cala::shape(&mut colors).vert(&vertices).face([ | ||
[1.0, 0.0, 0.0, 0.0], | ||
[0.0, 1.0, 0.0, 0.0], | ||
[0.0, 0.0, 1.0, 0.0], | ||
[0.0, 0.0, 0.0, 1.0], | ||
])); | ||
|
||
triangle.instances(&[ | ||
cala::Transform::new() | ||
.scale(0.5, 0.5, 0.5) | ||
.translate(-0.5, 0.0, 0.0), | ||
cala::Transform::new() | ||
.scale(0.5, 0.5, 0.5) | ||
.translate(0.5, 0.0, 0.0), | ||
]); | ||
|
||
// Finish building shader. | ||
cala::build(&colors); | ||
|
||
let timed = cala::TimedLoop::new(1, 0); | ||
|
||
Context { | ||
colors, | ||
triangle, | ||
timed, | ||
} | ||
}); | ||
|
||
// Function that runs while your app runs. | ||
pub fn run(context: &mut Context) -> cala::Loop<Context> { | ||
context.timed.add(); | ||
let delta: f32 = context.timed.into(); | ||
|
||
context.triangle.transform(0, cala::Transform::new() | ||
.scale(0.5, 0.5, 0.5) | ||
.translate(-0.5, -0.5 + delta, 0.0) | ||
); | ||
|
||
// Draw triangle | ||
cala::draw(&context.colors, &context.triangle); | ||
|
||
// Request next frame. | ||
cala::Continue | ||
} |
Oops, something went wrong.