summaryrefslogtreecommitdiff
path: root/engine/src/opengl/shader.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/opengl/shader.rs')
-rw-r--r--engine/src/opengl/shader.rs17
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);