Guest User

Untitled

a guest
May 27th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. /// A marker trait saying that something is a label for a particular backend,
  2. /// with associated gfx-rs types for that backend.
  3. pub trait BackendSpec {
  4. /// Surface type
  5. type SurfaceType: gfx::format::Formatted;
  6. /// gfx resource type
  7. type Resources: gfx::Resources;
  8. /// gfx factory type
  9. type Factory: gfx::Factory<Self::Resources>;
  10. /// gfx command buffer type
  11. type CommandBuffer: gfx::CommandBuffer<Self::Resources>;
  12. /// gfx device type
  13. type Device: gfx::Device<Resources = Self::Resources, CommandBuffer = Self::CommandBuffer>;
  14.  
  15. /// A helper function to take a RawShaderResourceView and turn it into a typed one based on
  16. /// the surface type defined in a `BackendSpec`
  17. fn raw_to_typed_shader_resource(texture_view: gfx::handle::RawShaderResourceView<Self::Resources>)
  18. -> gfx::handle::ShaderResourceView<Self::Resources, [f32;4]> {
  19. type ShaderType = <Self::SurfaceType as gfx::format::Formatted>::View;
  20. let typed_view: gfx::handle::ShaderResourceView<_, ShaderType> = gfx::memory::Typed::new(texture_view);
  21. typed_view
  22. }
  23. }
  24.  
  25. // raw_to_typed_resource fails to compile with the message:
  26. /*
  27. error[E0401]: can't use type parameters from outer function
  28. --> src/graphics/mod.rs:69:29
  29. |
  30. 67 | fn raw_to_typed_shader_resource(texture_view: gfx::handle::RawShaderResourceView<Self::Resources>)
  31. | ---------------------------- try adding a local type parameter in this method instead
  32. 68 | -> gfx::handle::ShaderResourceView<Self::Resources, [f32;4]> {
  33. 69 | type ShaderType2 = <Self::SurfaceType as gfx::format::Formatted>::View;
  34. | ^^^^^^^^^^^^^^^^^ use of type variable from outer function
  35.  
  36. */
  37.  
  38.  
  39. fn main() {
  40.  
  41. }
Add Comment
Please, Sign In to add comment