[−][src]Trait ggez::graphics::BackendSpec
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
type Resources: Resources
gfx resource type
type Factory: Factory<Self::Resources> + Clone
gfx factory type
type CommandBuffer: CommandBuffer<Self::Resources>
gfx command buffer type
type Device: Device<Resources = Self::Resources, CommandBuffer = Self::CommandBuffer>
gfx device type
Required methods
fn version_tuple(&self) -> (u8, u8)
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)
.
fn api(&self) -> Api
Returns the glutin Api
enum for this backend.
fn shaders(&self) -> (&'static [u8], &'static [u8])
Returns the text of the vertex and fragment shader files to create default shaders for this backend.
fn info(&self, device: &Self::Device) -> String
Returns a string containing some backend-dependent info.
fn init<'a>(
&self,
window_builder: WindowBuilder,
gl_builder: ContextBuilder<'a>,
events_loop: &EventsLoop,
color_format: Format,
depth_format: Format
) -> Result<(WindowedContext, Self::Device, Self::Factory, RawRenderTargetView<Self::Resources>, RawDepthStencilView<Self::Resources>), CreationError>
&self,
window_builder: WindowBuilder,
gl_builder: ContextBuilder<'a>,
events_loop: &EventsLoop,
color_format: Format,
depth_format: Format
) -> Result<(WindowedContext, Self::Device, Self::Factory, RawRenderTargetView<Self::Resources>, RawDepthStencilView<Self::Resources>), CreationError>
Creates the window.
fn encoder(
factory: &mut Self::Factory
) -> Encoder<Self::Resources, Self::CommandBuffer>
factory: &mut Self::Factory
) -> Encoder<Self::Resources, Self::CommandBuffer>
Create an Encoder for the backend.
fn resize_viewport(
&self,
color_view: &RawRenderTargetView<Self::Resources>,
depth_view: &RawDepthStencilView<Self::Resources>,
color_format: Format,
depth_format: Format,
window: &WindowedContext
) -> Option<(RawRenderTargetView<Self::Resources>, RawDepthStencilView<Self::Resources>)>
&self,
color_view: &RawRenderTargetView<Self::Resources>,
depth_view: &RawDepthStencilView<Self::Resources>,
color_format: Format,
depth_format: Format,
window: &WindowedContext
) -> Option<(RawRenderTargetView<Self::Resources>, RawDepthStencilView<Self::Resources>)>
Resizes the viewport for the backend. (right now assumes a Glutin window...)
Provided methods
fn raw_to_typed_shader_resource(
&self,
texture_view: RawShaderResourceView<Self::Resources>
) -> ShaderResourceView<Self::Resources, [f32; 4]>
&self,
texture_view: RawShaderResourceView<Self::Resources>
) -> ShaderResourceView<Self::Resources, [f32; 4]>
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.
fn raw_to_typed_texture(
&self,
texture_view: RawTexture<Self::Resources>
) -> Texture<Self::Resources, <Srgba8 as Formatted>::Surface>
&self,
texture_view: RawTexture<Self::Resources>
) -> Texture<Self::Resources, <Srgba8 as Formatted>::Surface>
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
impl BackendSpec for GlBackendSpec
[src]
type Resources = Resources
type Factory = Factory
type CommandBuffer = CommandBuffer
type Device = Device
fn version_tuple(&self) -> (u8, u8)
[src]
fn api(&self) -> Api
[src]
fn shaders(&self) -> (&'static [u8], &'static [u8])
[src]
fn init<'a>(
&self,
window_builder: WindowBuilder,
gl_builder: ContextBuilder<'a>,
events_loop: &EventsLoop,
color_format: Format,
depth_format: Format
) -> Result<(WindowedContext, Self::Device, Self::Factory, RawRenderTargetView<Self::Resources>, RawDepthStencilView<Self::Resources>), CreationError>
[src]
&self,
window_builder: WindowBuilder,
gl_builder: ContextBuilder<'a>,
events_loop: &EventsLoop,
color_format: Format,
depth_format: Format
) -> Result<(WindowedContext, Self::Device, Self::Factory, RawRenderTargetView<Self::Resources>, RawDepthStencilView<Self::Resources>), CreationError>
fn info(&self, device: &Self::Device) -> String
[src]
fn encoder(
factory: &mut Self::Factory
) -> Encoder<Self::Resources, Self::CommandBuffer>
[src]
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
) -> Option<(RawRenderTargetView<Self::Resources>, RawDepthStencilView<Self::Resources>)>
[src]
&self,
color_view: &RawRenderTargetView<Self::Resources>,
depth_view: &RawDepthStencilView<Self::Resources>,
color_format: Format,
depth_format: Format,
window: &WindowedContext
) -> Option<(RawRenderTargetView<Self::Resources>, RawDepthStencilView<Self::Resources>)>