[][src]Struct beryllium::Renderer

#[repr(transparent)]
pub struct Renderer<'sdl, 'win> { /* fields omitted */ }

Handle to some SDL2 rendering state.

Helps you do things like upload data to the GPU and blit image data around.

To be clear: This is not a super fast renderer. It's easy to use and you can get an image on the screen, but if you want do much at all that's computationally expensive you'll need to use a proper hardware API (OpenGL, Vulkan, etc). Also, you cannot really mix this renderer with the hardware APIs. They both expect to have full control of the pixel process. Use this or a hardware API.

Methods

impl<'sdl, 'win> Renderer<'sdl, 'win>[src]

pub fn create_texture_from_surface<'ren>(
    &'ren self,
    surf: &Surface
) -> Result<Texture<'sdl, 'win, 'ren>, String>
[src]

Makes a texture with the contents of the surface specified.

The TextureAccess hint for textures from this is "static".

The pixel format might be different from the surface's pixel format.

pub fn draw_color(&self) -> Result<Color, String>[src]

Obtains the current draw color.

pub fn set_draw_color(&self, color: Color) -> Result<(), String>[src]

Assigns the color used for drawing.

pub fn clear(&self) -> Result<(), String>[src]

Clears the render target with the current draw color.

pub fn draw_line(
    &self,
    x1: i32,
    y1: i32,
    x2: i32,
    y2: i32
) -> Result<(), String>
[src]

Draws a line that includes both end points.

pub fn draw_lines(&self, points: &[Point]) -> Result<(), String>[src]

Using the slice of n points, draws n-1 lines end to end.

pub fn copy(
    &self,
    t: &Texture,
    src: Option<Rect>,
    dst: Option<Rect>
) -> Result<(), String>
[src]

Blits the texture to the rendering target.

  • src: Optional clip rect of where to copy from. If None, the whole texture is used.
  • dst: Optional clip rect of where to copy data to. If None, the whole render target is used.

The image is stretched as necessary if the src and dst are different sizes. This is a GPU operation, so it's fast no matter how much upscale or downscale you do.

pub fn present(&self)[src]

Presents the backbuffer to the user.

After a present, all backbuffer data should be assumed to be invalid, and you should also clear the backbuffer before doing the next render pass even if you intend to write to every pixel.

Trait Implementations

impl<'sdl, 'win> Drop for Renderer<'sdl, 'win>[src]

impl<'sdl, 'win> Debug for Renderer<'sdl, 'win>[src]

Auto Trait Implementations

impl<'sdl, 'win> !Send for Renderer<'sdl, 'win>

impl<'sdl, 'win> !Sync for Renderer<'sdl, 'win>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]