Struct sfml::graphics::RenderTexture [] [src]

pub struct RenderTexture {
    // some fields omitted
}

Target for off-screen 2D rendering into a texture

Methods

impl RenderTexture
[src]

fn new(width: u32, height: u32, depth_buffer: bool) -> Option<RenderTexture>

Construct a new render texture

Arguments

  • width - Width of the render texture
  • height - Height of the render texture
  • depthBuffer - Do you want a depth-buffer attached? (useful only if you're doing 3D OpenGL on the rendertexture)

Return Some(RenderTexture) or None

fn display(&self)

Update the contents of the target texture

fn set_active(&mut self, active: bool) -> bool

Activate or deactivate a render texture as the current target for rendering

Arguments

  • active - true to activate, false to deactivate

fn get_texture(&self) -> Option<Texture>

Get the target texture of a render texture

Return the target texture

fn set_smooth(&mut self, smooth: bool)

Enable or disable the smooth filter on a render texture

Arguments

  • smooth - true to enable smoothing, false to disable it

fn is_smooth(&self) -> bool

Tell whether the smooth filter is enabled or not for a render texture

Return true if smoothing is enabled, false if it is disabled

Trait Implementations

impl RenderTarget for RenderTexture
[src]

fn get_size(&self) -> Vector2u

Get the size of the rendering region of a render texture

Return the size in pixels

fn clear(&mut self, color: &Color)

Clear the rendertexture with the given color

Arguments

  • color - Fill color

fn set_view(&mut self, view: &View)

Change the current active view of a render texture

Arguments

  • view - the new view

fn get_view(&self) -> View

Get the current active view of a render texture

Return the current active view

fn get_default_view(&self) -> View

Get the default view of a render texture

Return the default view of the render texture

fn get_viewport(&self, view: &View) -> IntRect

Get the viewport of a view applied to this target

Arguments

  • view - Target view

Return the viewport rectangle, expressed in pixels in the current target

fn map_pixel_to_coords(&self, point: &Vector2i, view: &View) -> Vector2f

Convert a point from texture coordinates to world coordinates

This function finds the 2D position that matches the given pixel of the render-texture. In other words, it does the inverse of what the graphics card does, to find the initial position of a rendered pixel.

Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render texture, this assertion is not true anymore, ie. a point located at (10, 50) in your render-texture may map to the point (150, 75) in your 2D world -- if the view is translated by (140, 25).

This function is typically used to find which point (or object) is located below the mouse cursor.

This version uses a custom view for calculations, see map_pixel_to_coords if you want to use the current view of the render-texture.

Arguments

  • point - Pixel to convert
  • view - The view to use for converting the point

Return the converted point, in "world" units

fn map_pixel_to_coords_current_view(&self, point: &Vector2i) -> Vector2f

Convert a point from texture coordinates to world coordinates

This function finds the 2D position that matches the given pixel of the render-texture. In other words, it does the inverse of what the graphics card does, to find the initial position of a rendered pixel.

Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render texture, this assertion is not true anymore, ie. a point located at (10, 50) in your render-texture may map to the point (150, 75) in your 2D world -- if the view is translated by (140, 25).

This function is typically used to find which point (or object) is located below the mouse cursor.

This version the current view for calculations, see map_pixel_to_coordss if you want to use a custom view

Arguments

  • point - Pixel to convert

Return the converted point, in "world" units

fn map_coords_to_pixel(&self, point: &Vector2f, view: &View) -> Vector2i

Convert a point from world coordinates to render texture coordinates

This function finds the pixel of the render-texture that matches the given 2D point. In other words, it goes through the same process as the graphics card, to compute the final position of a rendered point.

Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render texture, this assertion is not true anymore, ie. a point located at (150, 75) in your 2D world may map to the pixel (10, 50) of your render-texture -- if the view is translated by (140, 25).

This version uses a custom view for calculations, see map_coords_to_pixel_current_view if you want to use the current view of the render-texture.

Arguments

  • point - Point to convert
  • view - The view to use for converting the point

fn map_coords_to_pixel_current_view(&self, point: &Vector2f) -> Vector2i

Convert a point from world coordinates to render texture coordinates

This function finds the pixel of the render-texture that matches the given 2D point. In other words, it goes through the same process as the graphics card, to compute the final position of a rendered point.

Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render texture, this assertion is not true anymore, ie. a point located at (150, 75) in your 2D world may map to the pixel (10, 50) of your render-texture -- if the view is translated by (140, 25).

This version uses the default view for calculations, see map_coords_to_pixel if you want to use as custom view.

Arguments

  • point - Point to convert

fn draw<T: Drawable>(&mut self, object: &T)

Draw a drawable object to the render-target

Arguments

  • object - Object to draw

fn draw_with_renderstates<T: Drawable>(&mut self, object: &T, render_states: &mut RenderStates)

Draw a drawable object to the render-target

Arguments

  • object - Object to draw
  • renderStates - The RenderStates to associate to the object

fn draw_with_renderstates_rc<T: Drawable>(&mut self, object: &T, render_states: &mut RenderStates)

Draw a drawable object to the render-target

Arguments

  • object - Object to draw
  • renderStates - The RenderStates to associate to the object

fn draw_text(&self, text: &Text)

Draw Text

fn draw_text_rc(&self, text: &Text)

Draw Text

fn draw_shape(&self, shape: &Shape)

Draw Shape

fn draw_shape_rc(&self, shape: &Shape)

Draw Shape

fn draw_sprite(&self, sprite: &Sprite)

Draw Sprite

fn draw_sprite_rc(&self, sprite: &Sprite)

Draw Sprite

fn draw_circle_shape(&self, circle_shape: &CircleShape)

Draw CircleShape

fn draw_circle_shape_rc(&self, circle_shape: &CircleShape)

Draw CircleShape

fn draw_rectangle_shape(&self, rectangle_shape: &RectangleShape)

Draw RectangleShape

fn draw_rectangle_shape_rc(&self, rectangle_shape: &RectangleShape)

Draw RectangleShape

fn draw_convex_shape(&self, convex_shape: &ConvexShape)

Draw ConvexShape

fn draw_convex_shape_rc(&self, convex_shape: &ConvexShape)

Draw ConvexShape

fn draw_vertex_array(&self, vertex_array: &VertexArray)

Draw VertexArray

fn draw_text_rs(&self, text: &Text, rs: &mut RenderStates)

Draw Text

fn draw_text_rs_rc(&self, text: &Text, rs: &mut RenderStates)

Draw Text

fn draw_shape_rs(&self, shape: &Shape, rs: &mut RenderStates)

Draw Shape

fn draw_shape_rs_rc(&self, shape: &Shape, rs: &mut RenderStates)

Draw Shape

fn draw_sprite_rs(&self, sprite: &Sprite, rs: &mut RenderStates)

Draw Sprite

fn draw_sprite_rs_rc(&self, sprite: &Sprite, rs: &mut RenderStates)

Draw Sprite

fn draw_circle_shape_rs(&self, circle_shape: &CircleShape, rs: &mut RenderStates)

Draw CircleShape

fn draw_circle_shape_rs_rc(&self, circle_shape: &CircleShape, rs: &mut RenderStates)

Draw CircleShape

fn draw_rectangle_shape_rs(&self, rectangle_shape: &RectangleShape, rs: &mut RenderStates)

Draw RectangleShape

fn draw_rectangle_shape_rs_rc(&self, rectangle_shape: &RectangleShape, rs: &mut RenderStates)

Draw RectangleShape

fn draw_convex_shape_rs(&self, convex_shape: &ConvexShape, rs: &mut RenderStates)

Draw ConvexShape

fn draw_convex_shape_rs_rc(&self, convex_shape: &ConvexShape, rs: &mut RenderStates)

Draw ConvexShape

fn draw_vertex_array_rs(&self, vertex_array: &VertexArray, rs: &mut RenderStates)

Draw VertexArray

fn draw_vertex_array_rs_rc(&self, vertex_array: &VertexArray, rs: &mut RenderStates)

Draw VertexArray

fn draw_primitives_rs(&self, vertices: &[Vertex], ty: PrimitiveType, rs: &mut RenderStates)

draw primitives

fn draw_primitives(&self, vertices: &[Vertex], ty: PrimitiveType)

draw primitives

fn push_gl_states(&mut self)

Save the current OpenGL render states and matrices

This function can be used when you mix SFML drawing and direct OpenGL rendering. Combined with popGLStates, it ensures that: SFML's internal states are not messed up by your OpenGL code and that your OpenGL states are not modified by a call to a SFML function

Note that this function is quite expensive: it saves all the possible OpenGL states and matrices, even the ones you don't care about. Therefore it should be used wisely. It is provided for convenience, but the best results will be achieved if you handle OpenGL states yourself (because you know which states have really changed, and need to be saved and restored). Take a look at the resetGLStates function if you do so.

fn pop_gl_states(&mut self)

Restore the previously saved OpenGL render states and matrices

fn reset_gl_states(&mut self)

Reset the internal OpenGL states so that the target is ready for drawing

This function can be used when you mix SFML drawing and direct OpenGL rendering, if you choose not to use pushGLStates/popGLStates. It makes sure that all OpenGL states needed by SFML are set, so that subsequent sfRenderWindow_draw*() calls will work as expected.

impl Drop for RenderTexture
[src]

fn drop(&mut self)

A method called when the value goes out of scope. Read more