Skip to content

Commit

Permalink
render_states: Use Option<&'texture> instead of *const Texture
Browse files Browse the repository at this point in the history
  • Loading branch information
crumblingstatue committed Oct 9, 2024
1 parent 37fef9f commit 15b668b
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/graphics/render_states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ pub struct RenderStates<'texture, 'shader, 'shader_texture: 'shader> {
pub blend_mode: BlendMode,
/// The transform
pub transform: Transform,
texture: *const Texture,
texture: Option<&'texture Texture>,
shader: *const ffi::sfShader,
_texture: PhantomData<&'texture Texture>,
_shader: PhantomData<&'shader Shader<'shader_texture>>,
}

Expand All @@ -87,24 +86,17 @@ impl<'texture, 'shader, 'shader_texture> RenderStates<'texture, 'shader, 'shader
Self {
blend_mode,
transform,
texture: match texture {
Some(tex) => tex,
None => ptr::null(),
},
texture,
shader: match shader {
Some(shader) => shader.raw(),
None => ptr::null(),
},
_texture: PhantomData,
_shader: PhantomData,
}
}
/// Sets the texture
pub fn set_texture(&mut self, texture: Option<&'texture Texture>) {
self.texture = match texture {
None => ptr::null(),
Some(tex) => tex,
};
self.texture = texture;
}
/// Sets the shader
pub fn set_shader(&mut self, shader: Option<&'shader Shader<'shader_texture>>) {
Expand All @@ -122,9 +114,8 @@ impl RenderStates<'static, 'static, 'static> {
pub const DEFAULT: Self = Self {
blend_mode: BlendMode::ALPHA,
transform: Transform::IDENTITY,
texture: ptr::null(),
texture: None,
shader: ptr::null(),
_texture: PhantomData,
_shader: PhantomData,
};
}
Expand Down

0 comments on commit 15b668b

Please sign in to comment.