Struct sfml::graphics::RenderTexture
[−]
[src]
pub struct RenderTexture { /* 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 texture(&self) -> &TextureRef
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
fn set_repeated(&mut self, repeated: bool)
Enable or disable texture repeating.
This function is similar to Texture::setRepeated. This parameter is disabled by default.
fn is_repeated(&self) -> bool
Tell whether the texture is repeated or not.
unsafe fn generate_mipmap(&mut self) -> bool
Generate a mipmap using the current texture data.
This function is similar to Texture::generate_mipmap
and operates on the texture used as
the target for drawing. Be aware that any draw operation may modify the base level
image data. For this reason, calling this function only makes sense after all drawing
is completed and display has been called. Not calling display after subsequent drawing
will lead to undefined behavior if a mipmap had been previously generated.
Trait Implementations
impl RenderTarget for RenderTexture
[src]
fn 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)
fn set_view(&mut self, view: &View)
fn view(&self) -> &ViewRef
Get the current active view of a render texture
Return the current active view
fn default_view(&self) -> &ViewRef
Get the default view of a render texture
Return the default view of the render texture
fn 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(&mut self, object: &Drawable)
fn draw_with_renderstates(
&mut self,
object: &Drawable,
render_states: RenderStates
)
&mut self,
object: &Drawable,
render_states: 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, rs: RenderStates)
Draw Text
fn draw_shape(&self, shape: &CustomShape, rs: RenderStates)
Draw Shape
fn draw_sprite(&self, sprite: &Sprite, rs: RenderStates)
Draw Sprite
fn draw_circle_shape(&self, circle_shape: &CircleShape, rs: RenderStates)
Draw CircleShape
fn draw_rectangle_shape(
&self,
rectangle_shape: &RectangleShape,
rs: RenderStates
)
&self,
rectangle_shape: &RectangleShape,
rs: RenderStates
)
Draw RectangleShape
fn draw_convex_shape(&self, convex_shape: &ConvexShape, rs: RenderStates)
Draw ConvexShape
fn draw_vertex_array(&self, vertex_array: &VertexArray, rs: RenderStates)
Draw VertexArray
fn draw_primitives(
&self,
vertices: &[Vertex],
ty: PrimitiveType,
rs: RenderStates
)
&self,
vertices: &[Vertex],
ty: PrimitiveType,
rs: RenderStates
)
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 SFML draw calls will work as expected.