Skip to content

Commit 15b668b

Browse files
render_states: Use Option<&'texture> instead of *const Texture
1 parent 37fef9f commit 15b668b

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/graphics/render_states.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ pub struct RenderStates<'texture, 'shader, 'shader_texture: 'shader> {
6161
pub blend_mode: BlendMode,
6262
/// The transform
6363
pub transform: Transform,
64-
texture: *const Texture,
64+
texture: Option<&'texture Texture>,
6565
shader: *const ffi::sfShader,
66-
_texture: PhantomData<&'texture Texture>,
6766
_shader: PhantomData<&'shader Shader<'shader_texture>>,
6867
}
6968

@@ -87,24 +86,17 @@ impl<'texture, 'shader, 'shader_texture> RenderStates<'texture, 'shader, 'shader
8786
Self {
8887
blend_mode,
8988
transform,
90-
texture: match texture {
91-
Some(tex) => tex,
92-
None => ptr::null(),
93-
},
89+
texture,
9490
shader: match shader {
9591
Some(shader) => shader.raw(),
9692
None => ptr::null(),
9793
},
98-
_texture: PhantomData,
9994
_shader: PhantomData,
10095
}
10196
}
10297
/// Sets the texture
10398
pub fn set_texture(&mut self, texture: Option<&'texture Texture>) {
104-
self.texture = match texture {
105-
None => ptr::null(),
106-
Some(tex) => tex,
107-
};
99+
self.texture = texture;
108100
}
109101
/// Sets the shader
110102
pub fn set_shader(&mut self, shader: Option<&'shader Shader<'shader_texture>>) {
@@ -122,9 +114,8 @@ impl RenderStates<'static, 'static, 'static> {
122114
pub const DEFAULT: Self = Self {
123115
blend_mode: BlendMode::ALPHA,
124116
transform: Transform::IDENTITY,
125-
texture: ptr::null(),
117+
texture: None,
126118
shader: ptr::null(),
127-
_texture: PhantomData,
128119
_shader: PhantomData,
129120
};
130121
}

0 commit comments

Comments
 (0)