[][src]Trait sixtyfps_corelib::graphics::GraphicsBackend

pub trait GraphicsBackend: Sized {
    type LowLevelRenderingPrimitive;
    type Frame: Frame<LowLevelRenderingPrimitive = Self::LowLevelRenderingPrimitive>;
    type RenderingPrimitivesBuilder: RenderingPrimitivesBuilder<LowLevelRenderingPrimitive = Self::LowLevelRenderingPrimitive>;
    pub fn new_rendering_primitives_builder(
        &mut self
    ) -> Self::RenderingPrimitivesBuilder;
pub fn finish_primitives(
        &mut self,
        builder: Self::RenderingPrimitivesBuilder
    );
pub fn new_frame(
        &mut self,
        width: u32,
        height: u32,
        clear_color: &Color
    ) -> Self::Frame;
pub fn present_frame(&mut self, frame: Self::Frame);
pub fn window(&self) -> &Window; }

GraphicsBackend is the trait that the the SixtyFPS run-time uses to convert HighLevelRenderingPrimitive to an internal representation that is optimal for the backend, in order to render it later. The internal representation is opaque but must be provided via the GraphicsBackend::LowLevelRenderingPrimitive associated type.

The backend operates in two modes:

  1. It can be used to create new rendering primitives, by calling GraphicsBackend::new_rendering_primitives_builder. This is usually an expensive step, that involves uploading data to the GPU or performing other pre-calculations.

  2. A series of low-level rendering primitives can be rendered into a frame, that's started using GraphicsBackend::new_frame. The low-level rendering primitives are intended to be fast and ready for rendering.

Associated Types

type LowLevelRenderingPrimitive[src]

This associated type is typically opaque and is produced by the RenderingPrimitivesBuilder. For example it may contain handles that refer to data that was uploaded to the GPU.

type Frame: Frame<LowLevelRenderingPrimitive = Self::LowLevelRenderingPrimitive>[src]

This associated type ties the Frame trait together with this trait's LowLevelRenderingPrimitive.

type RenderingPrimitivesBuilder: RenderingPrimitivesBuilder<LowLevelRenderingPrimitive = Self::LowLevelRenderingPrimitive>[src]

This associated type ties the RenderingPrimitivesBuilder trait with this trait's LowLevelRenderingPrimitive.

Loading content...

Required methods

pub fn new_rendering_primitives_builder(
    &mut self
) -> Self::RenderingPrimitivesBuilder
[src]

Creates a new RenderingPrimitivesBuilder for the allocation of any GPU side data of different primitives. Call GraphicsBackend::finish_primitives when done.

pub fn finish_primitives(&mut self, builder: Self::RenderingPrimitivesBuilder)[src]

When all low-level rendering primitives have been created needed to render your scene, then this method needs to be called to complete the process.

Arguments:

pub fn new_frame(
    &mut self,
    width: u32,
    height: u32,
    clear_color: &Color
) -> Self::Frame
[src]

Begins the process of rendering a new frame into what is typically the window back-buffer. Call GraphicsBackend::present_frame when all rendering primitives have been queued for rendering.

Arguments:

  • width: The width of the window to render.
  • height: The height of the window to render.
  • clear_color: The color to clear the back-buffer with.

pub fn present_frame(&mut self, frame: Self::Frame)[src]

When all rendering primitives have been queued for rendering with the Frame API, pass the frame instance to this function and thereby complete the rendering. The backend then will present the contents on the screen inside the window, for example by flushing the backing store or swapping OpenGL buffers.

Arguments:

pub fn window(&self) -> &Window[src]

Returns the window that the backend is associated with.

Loading content...

Implementors

Loading content...