[−][src]Struct sfml::graphics::RenderStates
Define the states used for drawing to a RenderTarget
.
There are four global states that can be applied to the drawn objects:
- the blend mode: how pixels of the object are blended with the background
- the transform: how the object is positioned/rotated/scaled
- the texture: what image is mapped to the object
- the shader: what custom effect is applied to the object
High-level objects such as sprites or text force some of these states when they are drawn. For example, a sprite will set its own texture, so that you don't have to care about it when drawing the sprite.
The transform is a special case: sprites, texts and shapes
(and it's a good idea to do it with your own drawable classes too) combine their transform
with the one that is passed in the RenderStates
structure.
So that you can use a "global" transform on top of each object's transform.
Most objects, especially high-level drawables, can be drawn directly without defining render states explicitly – the default set of states is ok in most cases.
window.draw(sprite);
To draw with a specific render state, use RenderTarget::draw_with_renderstates
.
let mut states = RenderStates::default(); states.shader = Some(&shader); window.draw_with_renderstates(&sprite, states);
When you're inside the draw
function of a drawable object (implementing Drawable
),
you can either pass the render states unmodified, or change some of them.
For example, a transformable object will combine the current transform with its own transform.
A sprite will set its texture. Etc.
Fields
blend_mode: BlendMode
Blending mode.
transform: Transform
Transform
texture: Option<&'texture Texture>
Texture
shader: Option<&'shader Shader<'shader_texture>>
Shader
Methods
impl<'texture, 'shader, 'shader_texture> RenderStates<'texture, 'shader, 'shader_texture>
[src]
pub fn new(
blend_mode: BlendMode,
transform: Transform,
texture: Option<&'texture Texture>,
shader: Option<&'shader Shader<'shader_texture>>
) -> Self
[src]
blend_mode: BlendMode,
transform: Transform,
texture: Option<&'texture Texture>,
shader: Option<&'shader Shader<'shader_texture>>
) -> Self
Create a new RenderStates.
Arguments
- blend_mode - The BlendMode
- transform - The transform
- texture - Some(texture) if there is a texture, None otherwise
- shader - Some(shader) if there is a shader, None otherwise
Return a new default RenderStates
Trait Implementations
impl<'texture, 'shader, 'shader_texture: 'shader> Clone for RenderStates<'texture, 'shader, 'shader_texture>
[src]
fn clone(&self) -> RenderStates<'texture, 'shader, 'shader_texture>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'texture, 'shader, 'shader_texture: 'shader> Copy for RenderStates<'texture, 'shader, 'shader_texture>
[src]
impl<'texture, 'shader, 'shader_texture: 'shader> Default for RenderStates<'texture, 'shader, 'shader_texture>
[src]
fn default() -> RenderStates<'texture, 'shader, 'shader_texture>
[src]
impl<'texture, 'shader, 'shader_texture: 'shader> Debug for RenderStates<'texture, 'shader, 'shader_texture>
[src]
Auto Trait Implementations
impl<'texture, 'shader, 'shader_texture> !Send for RenderStates<'texture, 'shader, 'shader_texture>
impl<'texture, 'shader, 'shader_texture> !Sync for RenderStates<'texture, 'shader, 'shader_texture>
impl<'texture, 'shader, 'shader_texture> Unpin for RenderStates<'texture, 'shader, 'shader_texture> where
'shader_texture: 'shader,
'shader_texture: 'shader,
impl<'texture, 'shader, 'shader_texture> UnwindSafe for RenderStates<'texture, 'shader, 'shader_texture>
impl<'texture, 'shader, 'shader_texture> RefUnwindSafe for RenderStates<'texture, 'shader, 'shader_texture>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,