Struct sdl2::render::RenderDrawer [] [src]

pub struct RenderDrawer<'renderer> {
    // some fields omitted
}

Drawing functionality for the render context.

Methods

impl<'renderer> RenderDrawer<'renderer>
[src]

Render target methods for the drawer

fn render_target_supported(&self) -> bool

Determine whether a window supports the use of render targets.

fn render_target(&mut self) -> Option<RenderTarget>

Gets the render target handle.

Returns None if the window does not support the use of render targets.

impl<'renderer> RenderDrawer<'renderer>
[src]

Drawing methods

fn set_draw_color(&mut self, color: Color)

Sets the color used for drawing operations (Rect, Line and Clear).

fn get_draw_color(&self) -> Color

Gets the color used for drawing operations (Rect, Line and Clear).

fn set_blend_mode(&mut self, blend: BlendMode)

Sets the blend mode used for drawing operations (Fill and Line).

fn get_blend_mode(&self) -> BlendMode

Gets the blend mode used for drawing operations.

fn clear(&mut self)

Clears the current rendering target with the drawing color.

fn present(&mut self)

Updates the screen with any rendering performed since the previous call.

SDL's rendering functions operate on a backbuffer; that is, calling a rendering function such as draw_line() does not directly put a line on the screen, but rather updates the backbuffer. As such, you compose your entire scene and present the composed backbuffer to the screen as a complete picture.

fn get_output_size(&self) -> SdlResult<(i32, i32)>

Gets the output size of a rendering context.

fn set_logical_size(&mut self, width: i32, height: i32)

Sets a device independent resolution for rendering.

fn get_logical_size(&self) -> (i32, i32)

Gets device independent resolution for rendering.

fn set_viewport(&mut self, rect: Option<Rect>)

Sets the drawing area for rendering on the current target.

fn get_viewport(&self) -> Rect

Gets the drawing area for the current target.

fn set_clip_rect(&mut self, rect: Option<Rect>)

Sets the clip rectangle for rendering on the specified target.

fn get_clip_rect(&self) -> Rect

Gets the clip rectangle for the current target.

fn set_scale(&mut self, scale_x: f32, scale_y: f32)

Sets the drawing scale for rendering on the current target.

fn get_scale(&self) -> (f32, f32)

Gets the drawing scale for the current target.

fn draw_point(&mut self, point: Point)

Draws a point on the current rendering target.

Panics

Panics if drawing fails for any reason (e.g. driver failure)

fn draw_points(&mut self, points: &[Point])

Draws multiple points on the current rendering target.

Panics

Panics if drawing fails for any reason (e.g. driver failure)

fn draw_line(&mut self, start: Point, end: Point)

Panics

Panics if drawing fails for any reason (e.g. driver failure)

fn draw_lines(&mut self, points: &[Point])

Draws a series of connected lines on the current rendering target.

Panics

Panics if drawing fails for any reason (e.g. driver failure)

fn draw_rect(&mut self, rect: Rect)

Draws a rectangle on the current rendering target.

Panics

Panics if drawing fails for any reason (e.g. driver failure)

fn draw_rects(&mut self, rects: &[Rect])

Draws some number of rectangles on the current rendering target.

Panics

Panics if drawing fails for any reason (e.g. driver failure)

fn fill_rect(&mut self, rect: Rect)

Fills a rectangle on the current rendering target with the drawing color.

Panics

Panics if drawing fails for any reason (e.g. driver failure)

fn fill_rects(&mut self, rects: &[Rect])

Fills some number of rectangles on the current rendering target with the drawing color.

Panics

Panics if drawing fails for any reason (e.g. driver failure)

fn copy(&mut self, texture: &Texture, src: Option<Rect>, dst: Option<Rect>)

Copies a portion of the texture to the current rendering target.

  • If src is None, the entire texture is copied.
  • If dst is None, the texture will be stretched to fill the given rectangle.

Panics

Panics if drawing fails for any reason (e.g. driver failure), or if the provided texture does not belong to the renderer.

fn copy_ex(&mut self, texture: &Texture, src: Option<Rect>, dst: Option<Rect>, angle: f64, center: Option<Point>, (flip_horizontal, flip_vertical): (bool, bool))

Copies a portion of the texture to the current rendering target, optionally rotating it by angle around the given center and also flipping it top-bottom and/or left-right.

  • If src is None, the entire texture is copied.
  • If dst is None, the texture will be stretched to fill the given rectangle.
  • If center is None, rotation will be done around the center point of dst, or src if dst is None.

Panics

Panics if drawing fails for any reason (e.g. driver failure), if the provided texture does not belong to the renderer, or if the driver does not support RenderCopyEx.

fn read_pixels(&self, rect: Option<Rect>, format: PixelFormatEnum) -> SdlResult<Vec<u8>>

Reads pixels from the current rendering target.

Remarks

WARNING: This is a very slow operation, and should not be used frequently.