diff --git a/src/bin/platformer/graphics.rs b/src/bin/platformer/graphics.rs index 4361276..b7e460b 100644 --- a/src/bin/platformer/graphics.rs +++ b/src/bin/platformer/graphics.rs @@ -4,7 +4,7 @@ use std::{ use glam::{ Quat, - Vec4, + // Vec4, }; use opengl_rust::{ @@ -15,18 +15,13 @@ use opengl_rust::{ Pass, }, renderable_model::{ - attributes, RenderableModel, + attributes, }, shader_closure::ShaderLookup, texture::Texture, }; -use crate::{ - GameState, - TriangleStream, -}; - mod uniforms { use iota::iota; iota! { @@ -47,12 +42,12 @@ pub struct Graphics { shaders: Vec , shader_lookup: HashMap , - mesh_cube: RenderableModel, + // mesh_cube: RenderableModel, mesh_protag_kun: RenderableModel, mesh_sky: RenderableModel, mesh_sphere: RenderableModel, - text_stream: TriangleStream, + // text_stream: TriangleStream, texture_crate: Texture, texture_earth: Texture, @@ -100,7 +95,7 @@ impl Graphics { }) .collect (); - let mesh_cube = renderable_from_iqm_file ("cube.iqm"); + // let mesh_cube = renderable_from_iqm_file ("cube.iqm"); let mesh_protag_kun = renderable_from_iqm_file ("protag-kun.iqm"); let mesh_sky = renderable_from_iqm_file ("sky-sphere.iqm"); let mesh_sphere = renderable_from_iqm_file ("sphere.iqm"); @@ -125,7 +120,7 @@ impl Graphics { .depth_mask (1) .clone (), ]; - + /* let text_stream = TriangleStream { verts: gpu_buffers::VertexBuffer::streaming (4 * 5 * 6 * 1024), indices: { @@ -140,7 +135,7 @@ impl Graphics { gpu_buffers::IndexBuffer::from_slice_u32 (&v) } }; - + */ let shader_lookup = HashMap::from_iter (shaders.iter ().enumerate () .map (|(i, s)| { (s.get_id (), i) @@ -154,14 +149,14 @@ impl Graphics { }); Graphics { - mesh_cube, + // mesh_cube, mesh_protag_kun, mesh_sky, mesh_sphere, passes, shader_lookup, shaders, - text_stream, + // text_stream, texture_crate: Texture::from_file ("crate.png"), texture_earth: Texture::from_file ("earth.png"), texture_sky: Texture::from_file ("sky.png"), @@ -178,9 +173,9 @@ impl Graphics { level: &crate::LoadedLevel, camera: &crate::Camera, ) { - use serde::Deserialize; + // use serde::Deserialize; use uniforms as u; - + /* #[derive (Default, Deserialize)] struct Config { camera: CameraCfg, @@ -193,7 +188,7 @@ impl Graphics { #[serde(default)] translate_mix: f32, } - /* + let cfg: Option = std::fs::read_to_string ("config.json").ok () .map (|s| serde_json::from_str (s.as_str ()).ok ()) .flatten (); @@ -227,8 +222,6 @@ impl Graphics { let view_mat = proj_mat * view_mat; - let world_model_mat = Mat4::IDENTITY; - self.passes [0].with (gl_state, || { glezz::clear_color (109f32 / 255.0, 194f32 / 255.0, 202f32 / 255.0, 1.0f32); glezz::clear (gl::COLOR_BUFFER_BIT | gl::DEPTH_BUFFER_BIT | gl::STENCIL_BUFFER_BIT); diff --git a/src/bin/platformer/level_loader.rs b/src/bin/platformer/level_loader.rs index 798f3c8..0934139 100644 --- a/src/bin/platformer/level_loader.rs +++ b/src/bin/platformer/level_loader.rs @@ -14,7 +14,6 @@ impl LoadedLevel { pub fn from_path (path: &str) -> Result { use gltf::{ Semantic, - scene::Transform, }; let (level, buffers, _) = gltf::import (path)?; @@ -35,11 +34,11 @@ impl LoadedLevel { let (translation, _, _) = node.transform ().decomposed (); player_spawn = Some (Vec3::from (translation)); } - else if let Some (camera) = node.camera () { + else if let Some (_camera) = node.camera () { } else if let Some (mesh) = node.mesh () { - for (i, prim) in mesh.primitives ().enumerate () { + for (_i, prim) in mesh.primitives ().enumerate () { let positions = match prim.get (&Semantic::Positions) { None => continue, Some (x) => x, @@ -52,15 +51,15 @@ impl LoadedLevel { None => continue, Some (x) => x, }; - let pos_view = match positions.view () { + let _pos_view = match positions.view () { None => continue, Some (x) => x, }; - let norm_view = match normals.view () { + let _norm_view = match normals.view () { None => continue, Some (x) => x, }; - let indices_view = match indices.view () { + let _indices_view = match indices.view () { None => continue, Some (x) => x, }; diff --git a/src/bin/platformer/main.rs b/src/bin/platformer/main.rs index 3a08d31..a67937b 100644 --- a/src/bin/platformer/main.rs +++ b/src/bin/platformer/main.rs @@ -1,21 +1,12 @@ use std::{ - collections::HashMap, time::Instant, }; use anyhow::Result; -use maplit::hashmap; use opengl_rust::{ prelude::*, - gl_state::*, physics::PhysicsBody, - renderable_model::{ - attributes, - RenderableModel, - }, - shader_closure::ShaderLookup, - texture::Texture, }; mod graphics; @@ -31,12 +22,12 @@ pub struct GameState { static_level: StaticLevel, } -struct StaticLevel { +pub struct StaticLevel { tris: Vec , } #[derive (Clone, Default)] -struct LogicState { +pub struct LogicState { player: PhysicsBody, player_jump_vec: Option , } @@ -199,7 +190,7 @@ async fn main () -> Result <()> { let mut phys_tris: Vec = Vec::new (); for node in scene.nodes () { - if let Some (c) = node.camera () { + if node.camera ().is_some () { camera = Some (Camera { transform: node.transform ().clone (), }); @@ -409,34 +400,13 @@ async fn main () -> Result <()> { Ok (()) } -struct ShaderLocations { - attr_pos: u32, - attr_normal: u32, - attr_color: u32, - uni_mvp: i32, -} - -impl ShaderLocations { - pub fn new (shader_program: &opengl_rust::shader::ShaderProgram) -> anyhow::Result - { - let attr = |name: &str| shader_program.get_attribute_location (&CString::new (name.as_bytes ())?).try_into ().context ("Attribute location negative"); - let uni = |name: &str| shader_program.get_uniform_location (&CString::new (name.as_bytes ())?).try_into ().context ("Uniform location bad"); - - Ok (Self { - attr_pos: attr ("attr_pos")?, - attr_normal: attr ("attr_normal")?, - attr_color: attr ("attr_color")?, - uni_mvp: uni ("uni_mvp")?, - }) - } -} - +/* struct TriangleStream { pub verts: gpu_buffers::VertexBuffer, pub indices: gpu_buffers::IndexBuffer, } - -struct Camera { +*/ +pub struct Camera { transform: gltf::scene::Transform, } diff --git a/src/physics.rs b/src/physics.rs index 3accd8c..949fc07 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -155,6 +155,8 @@ pub fn step ( } } + let _ = t_remaining; + PhysicsResult { body: PhysicsBody { pos: old_pos, @@ -178,7 +180,7 @@ pub fn get_candidate ( radius, radius )); - let v = p1 - p0; + let _v = p1 - p0; let mut candidate = Collision { t: 2.0, @@ -358,12 +360,12 @@ pub fn get_candidate ( fn get_candidate_face (verts: &[Vec3], normal: Vec3, p0: Vec3, p1: Vec3, radius: f32) -> Option { - let radius3 = Vec3::from (( + let _radius3 = Vec3::from (( radius, radius, radius )); - let v = p1 - p0; + let _v = p1 - p0; let distance_to_face0 = Vec3::dot (normal, p0 - verts [0]) - radius; let distance_to_face1 = Vec3::dot (normal, p1 - verts [0]) - radius;