Mercurial > touhou
comparison examples/anmrenderer.rs @ 753:a662dddd4a2b
examples: Use array textures for enemy PNGs
This requires luminance 0.39.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Tue, 25 Feb 2020 21:03:44 +0100 |
parents | 5e5e7136ac92 |
children |
comparison
equal
deleted
inserted
replaced
752:5e5e7136ac92 | 753:a662dddd4a2b |
---|---|
3 use luminance::pipeline::{BoundTexture, PipelineState}; | 3 use luminance::pipeline::{BoundTexture, PipelineState}; |
4 use luminance::pixel::NormUnsigned; | 4 use luminance::pixel::NormUnsigned; |
5 use luminance::render_state::RenderState; | 5 use luminance::render_state::RenderState; |
6 use luminance::shader::program::{Program, Uniform}; | 6 use luminance::shader::program::{Program, Uniform}; |
7 use luminance::tess::{Mode, TessBuilder}; | 7 use luminance::tess::{Mode, TessBuilder}; |
8 use luminance::texture::{Dim2, Flat}; | 8 use luminance::texture::Dim2; |
9 use luminance_derive::{Semantics, Vertex, UniformInterface}; | 9 use luminance_derive::{Semantics, Vertex, UniformInterface}; |
10 use luminance_glfw::{Action, Key, WindowEvent, GlfwSurface, Surface, WindowDim, WindowOpt}; | 10 use luminance_glfw::{Action, Key, WindowEvent, GlfwSurface, Surface, WindowDim, WindowOpt}; |
11 use touhou::th06::anm0::Anm0; | 11 use touhou::th06::anm0::Anm0; |
12 use touhou::th06::anm0_vm::{AnmRunner, Sprite, Vertex as FakeVertex}; | 12 use touhou::th06::anm0_vm::{AnmRunner, Sprite, Vertex as FakeVertex}; |
13 use touhou::util::math::{perspective, setup_camera}; | 13 use touhou::util::math::{perspective, setup_camera}; |
78 } | 78 } |
79 | 79 |
80 #[derive(UniformInterface)] | 80 #[derive(UniformInterface)] |
81 struct ShaderInterface { | 81 struct ShaderInterface { |
82 // the 'static lifetime acts as “anything” here | 82 // the 'static lifetime acts as “anything” here |
83 color_map: Uniform<&'static BoundTexture<'static, Flat, Dim2, NormUnsigned>>, | 83 color_map: Uniform<&'static BoundTexture<'static, Dim2, NormUnsigned>>, |
84 | 84 |
85 #[uniform(name = "mvp")] | 85 #[uniform(name = "mvp")] |
86 mvp: Uniform<[[f32; 4]; 4]>, | 86 mvp: Uniform<[[f32; 4]; 4]>, |
87 } | 87 } |
88 | 88 |
185 .pipeline(&back_buffer, &PipelineState::default(), |pipeline, mut shd_gate| { | 185 .pipeline(&back_buffer, &PipelineState::default(), |pipeline, mut shd_gate| { |
186 // bind our fancy texture to the GPU: it gives us a bound texture we can use with the shader | 186 // bind our fancy texture to the GPU: it gives us a bound texture we can use with the shader |
187 let bound_tex = match &tex { | 187 let bound_tex = match &tex { |
188 LoadedTexture::Rgb(tex) => pipeline.bind_texture(tex), | 188 LoadedTexture::Rgb(tex) => pipeline.bind_texture(tex), |
189 LoadedTexture::Rgba(tex) => pipeline.bind_texture(tex), | 189 LoadedTexture::Rgba(tex) => pipeline.bind_texture(tex), |
190 LoadedTexture::RgbaArray(tex) => unreachable!(), | |
190 }; | 191 }; |
191 | 192 |
192 shd_gate.shade(&program, |iface, mut rdr_gate| { | 193 shd_gate.shade(&program, |iface, mut rdr_gate| { |
193 // update the texture; strictly speaking, this update doesn’t do much: it just tells the GPU | 194 // update the texture; strictly speaking, this update doesn’t do much: it just tells the GPU |
194 // to use the texture passed as argument (no allocation or copy is performed) | 195 // to use the texture passed as argument (no allocation or copy is performed) |