Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// A marker trait saying that something is a label for a particular backend,
- /// with associated gfx-rs types for that backend.
- pub trait BackendSpec {
- /// Surface type
- type SurfaceType: gfx::format::Formatted;
- /// gfx resource type
- type Resources: gfx::Resources;
- /// gfx factory type
- type Factory: gfx::Factory<Self::Resources>;
- /// gfx command buffer type
- type CommandBuffer: gfx::CommandBuffer<Self::Resources>;
- /// gfx device type
- type Device: gfx::Device<Resources = Self::Resources, CommandBuffer = Self::CommandBuffer>;
- /// A helper function to take a RawShaderResourceView and turn it into a typed one based on
- /// the surface type defined in a `BackendSpec`
- fn raw_to_typed_shader_resource(texture_view: gfx::handle::RawShaderResourceView<Self::Resources>)
- -> gfx::handle::ShaderResourceView<Self::Resources, [f32;4]> {
- type ShaderType = <Self::SurfaceType as gfx::format::Formatted>::View;
- let typed_view: gfx::handle::ShaderResourceView<_, ShaderType> = gfx::memory::Typed::new(texture_view);
- typed_view
- }
- }
- // raw_to_typed_resource fails to compile with the message:
- /*
- error[E0401]: can't use type parameters from outer function
- --> src/graphics/mod.rs:69:29
- |
- 67 | fn raw_to_typed_shader_resource(texture_view: gfx::handle::RawShaderResourceView<Self::Resources>)
- | ---------------------------- try adding a local type parameter in this method instead
- 68 | -> gfx::handle::ShaderResourceView<Self::Resources, [f32;4]> {
- 69 | type ShaderType2 = <Self::SurfaceType as gfx::format::Formatted>::View;
- | ^^^^^^^^^^^^^^^^^ use of type variable from outer function
- */
- fn main() {
- }
Add Comment
Please, Sign In to add comment