Mercurial > touhou
comparison examples/eclrenderer.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::{Sprite, Vertex as FakeVertex}; | 12 use touhou::th06::anm0_vm::{Sprite, Vertex as FakeVertex}; |
13 use touhou::th06::ecl::{Ecl, Rank}; | 13 use touhou::th06::ecl::{Ecl, Rank}; |
80 } | 80 } |
81 | 81 |
82 #[derive(UniformInterface)] | 82 #[derive(UniformInterface)] |
83 struct ShaderInterface { | 83 struct ShaderInterface { |
84 // the 'static lifetime acts as “anything” here | 84 // the 'static lifetime acts as “anything” here |
85 color_map: Uniform<&'static BoundTexture<'static, Flat, Dim2, NormUnsigned>>, | 85 color_map: Uniform<&'static BoundTexture<'static, Dim2, NormUnsigned>>, |
86 | 86 |
87 #[uniform(name = "mvp")] | 87 #[uniform(name = "mvp")] |
88 mvp: Uniform<[[f32; 4]; 4]>, | 88 mvp: Uniform<[[f32; 4]; 4]>, |
89 } | 89 } |
90 | 90 |
196 .pipeline(&back_buffer, &PipelineState::default(), |pipeline, mut shd_gate| { | 196 .pipeline(&back_buffer, &PipelineState::default(), |pipeline, mut shd_gate| { |
197 // bind our fancy texture to the GPU: it gives us a bound texture we can use with the shader | 197 // bind our fancy texture to the GPU: it gives us a bound texture we can use with the shader |
198 let bound_tex = match &tex { | 198 let bound_tex = match &tex { |
199 LoadedTexture::Rgb(tex) => pipeline.bind_texture(tex), | 199 LoadedTexture::Rgb(tex) => pipeline.bind_texture(tex), |
200 LoadedTexture::Rgba(tex) => pipeline.bind_texture(tex), | 200 LoadedTexture::Rgba(tex) => pipeline.bind_texture(tex), |
201 LoadedTexture::RgbaArray(tex) => unreachable!(), | |
201 }; | 202 }; |
202 | 203 |
203 shd_gate.shade(&program, |iface, mut rdr_gate| { | 204 shd_gate.shade(&program, |iface, mut rdr_gate| { |
204 // update the texture; strictly speaking, this update doesn’t do much: it just tells the GPU | 205 // update the texture; strictly speaking, this update doesn’t do much: it just tells the GPU |
205 // to use the texture passed as argument (no allocation or copy is performed) | 206 // to use the texture passed as argument (no allocation or copy is performed) |