diff options
Diffstat (limited to 'opengl-bindings/src/shader.rs')
| -rw-r--r-- | opengl-bindings/src/shader.rs | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/opengl-bindings/src/shader.rs b/opengl-bindings/src/shader.rs index 7eb1ac9..00fec58 100644 --- a/opengl-bindings/src/shader.rs +++ b/opengl-bindings/src/shader.rs @@ -4,7 +4,7 @@ use std::ptr::null_mut; use safer_ffi::layout::ReprC; use crate::data_types::{Matrix, Vec3}; -use crate::CurrentContextWithFns; +use crate::MaybeCurrentContextWithFns; #[derive(Debug)] pub struct Shader @@ -15,7 +15,7 @@ pub struct Shader impl Shader { #[must_use] - pub fn new(current_context: &CurrentContextWithFns<'_>, kind: Kind) -> Self + pub fn new(current_context: &MaybeCurrentContextWithFns, kind: Kind) -> Self { let shader = unsafe { current_context @@ -32,7 +32,7 @@ impl Shader /// Returns `Err` if `source` is not ASCII. pub fn set_source( &self, - current_context: &CurrentContextWithFns<'_>, + current_context: &MaybeCurrentContextWithFns, source: &str, ) -> Result<(), Error> { @@ -64,7 +64,7 @@ impl Shader /// Returns `Err` if compiling fails. pub fn compile( &self, - current_context: &CurrentContextWithFns<'_>, + current_context: &MaybeCurrentContextWithFns, ) -> Result<(), Error> { unsafe { @@ -90,14 +90,14 @@ impl Shader Ok(()) } - pub fn delete(self, current_context: &CurrentContextWithFns<'_>) + pub fn delete(self, current_context: &MaybeCurrentContextWithFns) { unsafe { current_context.fns().DeleteShader(self.shader); } } - fn get_info_log(&self, current_context: &CurrentContextWithFns<'_>) -> String + fn get_info_log(&self, current_context: &MaybeCurrentContextWithFns) -> String { const BUF_SIZE: crate::sys::types::GLsizei = 512; @@ -137,14 +137,18 @@ pub struct Program impl Program { #[must_use] - pub fn new(current_context: &CurrentContextWithFns<'_>) -> Self + pub fn new(current_context: &MaybeCurrentContextWithFns) -> Self { let program = unsafe { current_context.fns().CreateProgram() }; Self { program } } - pub fn attach(&self, current_context: &CurrentContextWithFns<'_>, shader: &Shader) + pub fn attach( + &self, + current_context: &MaybeCurrentContextWithFns, + shader: &Shader, + ) { unsafe { current_context @@ -157,7 +161,10 @@ impl Program /// /// # Errors /// Returns `Err` if linking fails. - pub fn link(&self, current_context: &CurrentContextWithFns<'_>) -> Result<(), Error> + pub fn link( + &self, + current_context: &MaybeCurrentContextWithFns, + ) -> Result<(), Error> { unsafe { current_context.fns().LinkProgram(self.program); @@ -182,7 +189,7 @@ impl Program Ok(()) } - pub fn activate(&self, current_context: &CurrentContextWithFns<'_>) + pub fn activate(&self, current_context: &MaybeCurrentContextWithFns) { unsafe { current_context.fns().UseProgram(self.program); @@ -191,7 +198,7 @@ impl Program pub fn set_uniform_at_location( &self, - current_context: &CurrentContextWithFns<'_>, + current_context: &MaybeCurrentContextWithFns, location: UniformLocation, var: &impl UniformVariable, ) @@ -201,7 +208,7 @@ impl Program pub fn set_uniform( &self, - current_context: &CurrentContextWithFns<'_>, + current_context: &MaybeCurrentContextWithFns, name: &CStr, var: &impl UniformVariable, ) @@ -225,14 +232,14 @@ impl Program self.program } - pub fn delete(self, current_context: &CurrentContextWithFns<'_>) + pub fn delete(self, current_context: &MaybeCurrentContextWithFns) { unsafe { current_context.fns().DeleteProgram(self.program); } } - fn get_info_log(&self, current_context: &CurrentContextWithFns<'_>) -> String + fn get_info_log(&self, current_context: &MaybeCurrentContextWithFns) -> String { const BUF_SIZE: crate::sys::types::GLsizei = 512; @@ -257,7 +264,7 @@ pub trait UniformVariable: ReprC + sealed::Sealed { fn set( &self, - current_context: &CurrentContextWithFns<'_>, + current_context: &MaybeCurrentContextWithFns, program: &Program, uniform_location: UniformLocation, ); @@ -267,7 +274,7 @@ impl UniformVariable for f32 { fn set( &self, - current_context: &CurrentContextWithFns<'_>, + current_context: &MaybeCurrentContextWithFns, program: &Program, uniform_location: UniformLocation, ) @@ -288,7 +295,7 @@ impl UniformVariable for i32 { fn set( &self, - current_context: &CurrentContextWithFns<'_>, + current_context: &MaybeCurrentContextWithFns, program: &Program, uniform_location: UniformLocation, ) @@ -309,7 +316,7 @@ impl UniformVariable for Vec3<f32> { fn set( &self, - current_context: &CurrentContextWithFns<'_>, + current_context: &MaybeCurrentContextWithFns, program: &Program, uniform_location: UniformLocation, ) @@ -332,7 +339,7 @@ impl UniformVariable for Matrix<f32, 4, 4> { fn set( &self, - current_context: &CurrentContextWithFns<'_>, + current_context: &MaybeCurrentContextWithFns, program: &Program, uniform_location: UniformLocation, ) |
