Struct sdl2::render::Renderer [] [src]

pub struct Renderer<'a> {
    // some fields omitted
}

2D rendering context

Methods

impl<'a> Renderer<'a>
[src]

fn from_surface(surface: Surface<'a>) -> SdlResult<Renderer<'a>>

Creates a 2D software rendering context for a surface.

This method should only fail if SDL2 is not built with rendering support, or there's an out-of-memory error.

fn info(&self) -> RendererInfo

Gets information about the rendering context.

fn window(&self) -> Option<&WindowRef>

Gets the associated window reference of the Renderer, if there is one.

fn window_mut(&mut self) -> Option<&mut WindowRef>

Gets the associated window reference of the Renderer, if there is one.

fn surface(&self) -> Option<&SurfaceRef>

Gets the associated surface reference of the Renderer, if there is one.

fn surface_mut(&mut self) -> Option<&mut SurfaceRef>

Gets the associated surface reference of the Renderer, if there is one.

fn into_window(self) -> Option<Window>

fn into_surface(self) -> Option<Surface<'a>>

unsafe fn raw(&self) -> *mut SDL_Renderer

Unwraps the window or surface the rendering context was created from.

unsafe fn from_ll(raw: *mut SDL_Renderer, parent: RendererParent) -> Renderer

impl<'a> Renderer<'a>
[src]

Texture-creating methods for the renderer

fn create_texture(&self, format: PixelFormatEnum, access: TextureAccess, (width, height): (u32, u32)) -> SdlResult<Texture>

Creates a texture for a rendering context.

size is the width and height of the texture.

fn create_texture_static(&self, format: PixelFormatEnum, size: (u32, u32)) -> SdlResult<Texture>

Shorthand for create_texture(format, TextureAccess::Static, size)

fn create_texture_streaming(&self, format: PixelFormatEnum, size: (u32, u32)) -> SdlResult<Texture>

Shorthand for create_texture(format, TextureAccess::Streaming, size)

fn create_texture_target(&self, format: PixelFormatEnum, size: (u32, u32)) -> SdlResult<Texture>

Shorthand for create_texture(format, TextureAccess::Target, size)

fn create_texture_from_surface<S: AsRef<SurfaceRef>>(&self, surface: S) -> SdlResult<Texture>

Creates a texture from an existing surface.

Remarks

The access hint for the created texture is TextureAccess::Static.

impl<'a> Renderer<'a>
[src]

Render target methods

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<'a> Renderer<'a>
[src]

Drawing methods

fn set_draw_color(&mut self, color: Color)

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

fn 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 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 output_size(&self) -> SdlResult<(u32, u32)>

Gets the output size of a rendering context.

fn set_logical_size(&mut self, width: u32, height: u32) -> SdlResult<()>

Sets a device independent resolution for rendering.

fn logical_size(&self) -> (u32, u32)

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 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.

If the rectangle is None, clipping will be disabled.

fn clip_rect(&self) -> Option<Rect>

Gets the clip rectangle for the current target.

Returns None if clipping is disabled.

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

Sets the drawing scale for rendering on the current target.

fn 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.

Trait Implementations

impl<'a> Drop for Renderer<'a>
[src]

fn drop(&mut self)

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