diff options
Diffstat (limited to 'engine/src/object.rs')
-rw-r--r-- | engine/src/object.rs | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/engine/src/object.rs b/engine/src/object.rs index 4e143a0..5391cf5 100644 --- a/engine/src/object.rs +++ b/engine/src/object.rs @@ -4,13 +4,13 @@ use std::io::Error as IoError; use std::path::{Path, PathBuf}; use crate::material::Material; +use crate::mesh::Mesh; use crate::opengl::shader::{ Error as ShaderError, Kind as ShaderKind, Program as ShaderProgram, Shader, }; -use crate::renderer::Renderable; use crate::shader_preprocessor::{Error as ShaderPreprocessorError, ShaderPreprocessor}; use crate::texture::{Id as TextureId, Texture}; use crate::transform::Transform; @@ -26,7 +26,8 @@ const FRAGMENT_SHADER_FILE: &str = "fragment.glsl"; pub struct Object { id: Id, - renderable: Renderable, + mesh: Mesh, + shader: ShaderProgram, transform: Transform, textures: HashMap<TextureId, Texture>, material: Material, @@ -69,9 +70,16 @@ impl Object &self.material } - pub(crate) fn renderable(&self) -> &Renderable + #[must_use] + pub fn mesh(&self) -> &Mesh + { + &self.mesh + } + + #[must_use] + pub fn shader(&self) -> &ShaderProgram { - &self.renderable + &self.shader } pub(crate) fn transform(&self) -> &Transform @@ -207,14 +215,14 @@ impl Builder .link() .map_err(Error::LinkShaderProgramFailed)?; - let renderable = - Renderable::new(shader_program, &self.vertices, self.indices.as_deref()); + let mesh = Mesh::new(self.vertices, self.indices); let transform = Transform::new(); Ok(Object { id, - renderable, + mesh, + shader: shader_program, transform, textures: self.textures, material: self.material.ok_or(Error::NoMaterial)?, |