comparison examples/menu.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 eab7dde1164f
children
comparison
equal deleted inserted replaced
752:5e5e7136ac92 753:a662dddd4a2b
4 use luminance::pipeline::{BoundTexture, PipelineState}; 4 use luminance::pipeline::{BoundTexture, PipelineState};
5 use luminance::pixel::NormUnsigned; 5 use luminance::pixel::NormUnsigned;
6 use luminance::render_state::RenderState; 6 use luminance::render_state::RenderState;
7 use luminance::shader::program::{Program, Uniform}; 7 use luminance::shader::program::{Program, Uniform};
8 use luminance::tess::{Mode, TessBuilder}; 8 use luminance::tess::{Mode, TessBuilder};
9 use luminance::texture::{Dim2, Flat}; 9 use luminance::texture::Dim2;
10 use luminance_derive::{Semantics, Vertex, UniformInterface}; 10 use luminance_derive::{Semantics, Vertex, UniformInterface};
11 use luminance_glfw::{Action, Key, WindowEvent, GlfwSurface, Surface, WindowDim, WindowOpt}; 11 use luminance_glfw::{Action, Key, WindowEvent, GlfwSurface, Surface, WindowDim, WindowOpt};
12 use touhou::th06::pbg3; 12 use touhou::th06::pbg3;
13 use touhou::th06::anm0::Anm0; 13 use touhou::th06::anm0::Anm0;
14 use touhou::th06::anm0_vm::{AnmRunner, Sprite, Vertex as FakeVertex}; 14 use touhou::th06::anm0_vm::{AnmRunner, Sprite, Vertex as FakeVertex};
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
134 let background = common::upload_texture_from_rgb_image(&mut surface, image).expect("upload data to texture"); 134 let background = common::upload_texture_from_rgb_image(&mut surface, image).expect("upload data to texture");
135 135
136 let mut background = match background { 136 let mut background = match background {
137 LoadedTexture::Rgb(tex) => tex, 137 LoadedTexture::Rgb(tex) => tex,
138 LoadedTexture::Rgba(tex) => unreachable!(), 138 LoadedTexture::Rgba(tex) => unreachable!(),
139 LoadedTexture::RgbaArray(tex) => unreachable!(),
139 }; 140 };
140 141
141 // set the uniform interface to our type so that we can read textures from the shader 142 // set the uniform interface to our type so that we can read textures from the shader
142 let program = 143 let program =
143 Program::<Semantics, (), ShaderInterface>::from_strings(None, VS, None, FS).expect("program creation").ignore_warnings(); 144 Program::<Semantics, (), ShaderInterface>::from_strings(None, VS, None, FS).expect("program creation").ignore_warnings();