comparison examples/stdrenderer.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, TessSliceIndex}; 7 use luminance::tess::{Mode, TessBuilder, TessSliceIndex};
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::th06::std::{Stage, Position, Box2D}; 13 use touhou::th06::std::{Stage, Position, Box2D};
87 } 87 }
88 88
89 #[derive(UniformInterface)] 89 #[derive(UniformInterface)]
90 struct ShaderInterface { 90 struct ShaderInterface {
91 // the 'static lifetime acts as “anything” here 91 // the 'static lifetime acts as “anything” here
92 color_map: Uniform<&'static BoundTexture<'static, Flat, Dim2, NormUnsigned>>, 92 color_map: Uniform<&'static BoundTexture<'static, Dim2, NormUnsigned>>,
93 93
94 #[uniform(name = "mvp")] 94 #[uniform(name = "mvp")]
95 mvp: Uniform<[[f32; 4]; 4]>, 95 mvp: Uniform<[[f32; 4]; 4]>,
96 96
97 #[uniform(name = "instance_position")] 97 #[uniform(name = "instance_position")]
209 .pipeline(&back_buffer, &PipelineState::default(), |pipeline, mut shd_gate| { 209 .pipeline(&back_buffer, &PipelineState::default(), |pipeline, mut shd_gate| {
210 // bind our fancy texture to the GPU: it gives us a bound texture we can use with the shader 210 // bind our fancy texture to the GPU: it gives us a bound texture we can use with the shader
211 let bound_tex = match &tex { 211 let bound_tex = match &tex {
212 LoadedTexture::Rgb(tex) => pipeline.bind_texture(tex), 212 LoadedTexture::Rgb(tex) => pipeline.bind_texture(tex),
213 LoadedTexture::Rgba(tex) => pipeline.bind_texture(tex), 213 LoadedTexture::Rgba(tex) => pipeline.bind_texture(tex),
214 LoadedTexture::RgbaArray(tex) => unreachable!(),
214 }; 215 };
215 216
216 shd_gate.shade(&program, |iface, mut rdr_gate| { 217 shd_gate.shade(&program, |iface, mut rdr_gate| {
217 // update the texture; strictly speaking, this update doesn’t do much: it just tells the GPU 218 // update the texture; strictly speaking, this update doesn’t do much: it just tells the GPU
218 // to use the texture passed as argument (no allocation or copy is performed) 219 // to use the texture passed as argument (no allocation or copy is performed)