summaryrefslogtreecommitdiff
path: root/2026/framing/src/game.rs
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2026-05-28 20:16:38 -0400
committerLLLL Colonq <llll@colonq>2026-05-28 20:16:38 -0400
commitfa4d63110a3e12d0242b6e6ddcded74d04480f28 (patch)
tree330e6ccfe650f1fd9143f9db67b481d4c74a2e05 /2026/framing/src/game.rs
Initial commit
Diffstat (limited to '2026/framing/src/game.rs')
-rw-r--r--2026/framing/src/game.rs67
1 files changed, 67 insertions, 0 deletions
diff --git a/2026/framing/src/game.rs b/2026/framing/src/game.rs
new file mode 100644
index 0000000..59e9697
--- /dev/null
+++ b/2026/framing/src/game.rs
@@ -0,0 +1,67 @@
+#![allow(dead_code, unused_variables)]
+use std::collections::HashMap;
+use teleia::*;
+
+struct Assets {
+ font: font::Bitmap,
+ shader_flat: shader::Shader,
+ mesh_square: mesh::Mesh,
+ texture_test: texture::Texture,
+}
+
+impl Assets {
+ fn new(ctx: &context::Context) -> Self {
+ Self {
+ font: font::Bitmap::default(ctx),
+ shader_flat: shader::Shader::new(
+ ctx,
+ include_str!("assets/shaders/flat/vert.glsl"),
+ include_str!("assets/shaders/flat/frag.glsl"),
+ ),
+ mesh_square: mesh::Mesh::from_obj(ctx, include_bytes!("assets/meshes/square.obj")),
+ texture_test: texture::Texture::new(ctx, include_bytes!("assets/textures/test.png")),
+ }
+ }
+}
+
+pub struct Game {
+ assets: Assets,
+}
+
+impl Game {
+ pub fn new(ctx: &context::Context) -> Self {
+ Self {
+ assets: Assets::new(ctx),
+ }
+ }
+}
+
+impl teleia::state::Game for Game {
+ fn initialize_audio(&self, ctx: &context::Context, st: &state::State, actx: &audio::Context) -> HashMap<String, audio::Audio> {
+ HashMap::from_iter(vec![
+ ("test".to_owned(), audio::Audio::new(&actx, include_bytes!("assets/audio/test.wav"))),
+ ])
+ }
+ fn update(&mut self, _ctx: &context::Context, _st: &mut state::State) -> Erm<()> {
+ Ok(())
+ }
+ fn render(&mut self, ctx: &context::Context, st: &mut state::State) -> Erm<()> {
+ ctx.clear_color(glam::Vec4::new(0.0, 0.0, 0.0, 0.0));
+ ctx.clear();
+ self.assets.font.render_text_at(
+ ctx, st,
+ glam::Vec2::new(0.0, 0.0),
+ "hello computer",
+ font::BitmapParams::default(),
+ );
+ st.bind_2d(ctx, &self.assets.shader_flat);
+ self.assets.texture_test.bind(ctx);
+ self.assets.shader_flat.set_position_2d(
+ ctx, st,
+ &glam::Vec2::new(40.0, 40.0),
+ &glam::Vec2::new(16.0, 16.0),
+ );
+ self.assets.mesh_square.render(ctx);
+ Ok(())
+ }
+}