diff options
author | HampusM <hampus@hampusmat.com> | 2024-11-23 21:32:03 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-11-23 21:32:03 +0100 |
commit | daf280048d82eed42d44423ce50ae9e809ba91a9 (patch) | |
tree | fdd1580b3c50f2f7cebc5175b38777a7117c904f /engine/src/opengl | |
parent | 999264a46f9a545771c6710b0893ca32cf6e7ee3 (diff) |
refactor(engine): make shaders a renderer detail
Diffstat (limited to 'engine/src/opengl')
-rw-r--r-- | engine/src/opengl/shader.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/engine/src/opengl/shader.rs b/engine/src/opengl/shader.rs index 070897e..36dc1a4 100644 --- a/engine/src/opengl/shader.rs +++ b/engine/src/opengl/shader.rs @@ -2,7 +2,6 @@ use std::ffi::CStr; use std::ptr::null_mut; use crate::matrix::Matrix; -use crate::shader::Kind; use crate::vector::Vec3; #[derive(Debug)] @@ -20,7 +19,7 @@ impl Shader Self { shader } } - pub fn set_source(&self, source: &str) -> Result<(), Error> + pub fn set_source(&mut self, source: &str) -> Result<(), Error> { if !source.is_ascii() { return Err(Error::SourceNotAscii); @@ -39,7 +38,7 @@ impl Shader Ok(()) } - pub fn compile(&self) -> Result<(), Error> + pub fn compile(&mut self) -> Result<(), Error> { unsafe { gl::CompileShader(self.shader); @@ -90,6 +89,14 @@ impl Drop for Shader } } +/// Shader kind. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub enum Kind +{ + Vertex, + Fragment, +} + impl Kind { fn into_gl(self) -> gl::types::GLenum @@ -117,14 +124,14 @@ impl Program Self { program } } - pub fn attach(&self, shader: &Shader) + pub fn attach(&mut self, shader: &Shader) { unsafe { gl::AttachShader(self.program, shader.shader); } } - pub fn link(&self) -> Result<(), Error> + pub fn link(&mut self) -> Result<(), Error> { unsafe { gl::LinkProgram(self.program); |