Trait ggez::graphics::BackendSpec[][src]

pub trait BackendSpec: Debug {
    type Resources: Resources;
    type Factory: Factory<Self::Resources> + Clone;
    type CommandBuffer: CommandBuffer<Self::Resources>;
    type Device: Device<Resources = Self::Resources, CommandBuffer = Self::CommandBuffer>;
    fn version_tuple(&self) -> (u8, u8);
fn api(&self) -> Api;
fn shaders(&self) -> (&'static [u8], &'static [u8]);
fn info(&self, device: &Self::Device) -> String;
fn init<'a>(
        &self,
        window_builder: WindowBuilder,
        gl_builder: ContextBuilder<'a, NotCurrent>,
        events_loop: &EventLoop<()>,
        color_format: Format,
        depth_format: Format
    ) -> Result<(WindowedContext<PossiblyCurrent>, Self::Device, Self::Factory, RawRenderTargetView<Self::Resources>, RawDepthStencilView<Self::Resources>), CreationError>;
fn encoder(
        factory: &mut Self::Factory
    ) -> Encoder<Self::Resources, Self::CommandBuffer>;
fn resize_viewport(
        &self,
        color_view: &RawRenderTargetView<Self::Resources>,
        depth_view: &RawDepthStencilView<Self::Resources>,
        color_format: Format,
        depth_format: Format,
        window: &WindowedContext<PossiblyCurrent>
    ) -> Option<(RawRenderTargetView<Self::Resources>, RawDepthStencilView<Self::Resources>)>; fn raw_to_typed_shader_resource(
        &self,
        texture_view: RawShaderResourceView<Self::Resources>
    ) -> ShaderResourceView<<Self as BackendSpec>::Resources, [f32; 4]> { ... }
fn raw_to_typed_texture(
        &self,
        texture_view: RawTexture<Self::Resources>
    ) -> Texture<<Self as BackendSpec>::Resources, <Srgba8 as Formatted>::Surface> { ... } }
Expand description

A trait providing methods for working with a particular backend, such as OpenGL, with associated gfx-rs types for that backend. As a user you probably don’t need to touch this unless you want to write a new graphics backend for ggez. (Trust me, you don’t.)

Associated Types

gfx resource type

gfx factory type

gfx command buffer type

gfx device type

Required methods

Returns the version of the backend, (major, minor).

So for instance if the backend is using OpenGL version 3.2, it would return (3, 2).

Returns the glutin Api enum for this backend.

Returns the text of the vertex and fragment shader files to create default shaders for this backend.

Returns a string containing some backend-dependent info.

Creates the window.

Create an Encoder for the backend.

Resizes the viewport for the backend. (right now assumes a Glutin window…)

Provided methods

A helper function to take a RawShaderResourceView and turn it into a typed one based on the surface type defined in a BackendSpec.

But right now we only allow surfaces that use [f32;4] colors, so we can freely hardcode this in the ShaderResourceType type.

Helper function that turns a raw to typed texture. A bit hacky since we can’t really specify surface formats as part of this that well, alas. There’s some functions, like gfx::Encoder::update_texture(), that don’t seem to have a _raw() counterpart, so we need this, so we need BuggoSurfaceFormat to keep fixed at compile time what texture format we’re actually using. Oh well!

Implementors