34 | 34 |
VERTEX_SHADER,
|
35 | 35 |
FRAGMENT_SHADER,
|
36 | 36 |
None).unwrap();
|
37 | |
let tex = Texture2d::new(&disp, t).unwrap();
|
| 37 |
let tex = Texture2d::with_format(&disp,
|
| 38 |
t,
|
| 39 |
glium::texture::UncompressedFloatFormat::U8U8U8,
|
| 40 |
glium::texture::MipmapsOption::NoMipmap).unwrap();
|
38 | 41 |
Graphics {
|
39 | 42 |
disp: disp,
|
40 | 43 |
rt: 0.0,
|
41 | 44 |
px: 0.0,
|
42 | |
py: 0.0,
|
| 45 |
py: 0.01,
|
43 | 46 |
pz: 0.0,
|
44 | 47 |
light: [-1.0, 0.4, 0.9f32],
|
45 | 48 |
model: m,
|
|
65 | 68 |
24 => self.rt -= 0.1,
|
66 | 69 |
25 => self.py -= DX,
|
67 | 70 |
26 => self.rt += 0.1,
|
68 | |
38 => self.px -= DX,
|
| 71 |
38 => self.px += DX,
|
69 | 72 |
39 => self.py += DX,
|
70 | |
40 => self.px += DX,
|
| 73 |
40 => self.px -= DX,
|
71 | 74 |
44 => self.pz -= DX,
|
72 | 75 |
45 => self.pz += DX,
|
73 | 76 |
_ => {},
|
|
88 | 91 |
|
89 | 92 |
impl<'a> Target<'a> {
|
90 | 93 |
fn step(&mut self, g: &mut Graphics) -> bool {
|
91 | |
let uniforms = uniform! {
|
92 | |
perspective: self.perspective(),
|
93 | |
u_light: g.light,
|
94 | |
matrix: self.matrix(g),
|
95 | |
tx: &g.tex,
|
96 | |
};
|
97 | 94 |
|
98 | 95 |
let params = glium::DrawParameters {
|
99 | 96 |
depth: glium::Depth {
|
|
107 | 104 |
let vbuf = g.model.get_vbuf(&g.disp);
|
108 | 105 |
let idxs = g.model.get_ibuf(&g.disp);
|
109 | 106 |
self.frame.clear_color_and_depth((0.0, 0.0, 0.0, 1.0), 1.0);
|
| 107 |
|
| 108 |
let per = self.perspective();
|
| 109 |
let m1 = self.matrix(g, g.px, g.py);
|
| 110 |
let m2 = self.matrix(g, g.px+0.01, g.py);
|
| 111 |
let m3 = self.matrix(g, g.px-0.01, g.py);
|
| 112 |
|
| 113 |
let mytex = glium::uniforms::Sampler::new(&g.tex)
|
| 114 |
.minify_filter(glium::uniforms::MinifySamplerFilter::Nearest)
|
| 115 |
.magnify_filter(glium::uniforms::MagnifySamplerFilter::Nearest);
|
| 116 |
|
110 | 117 |
self.frame.draw(&vbuf,
|
111 | 118 |
&idxs,
|
112 | 119 |
&g.program,
|
113 | |
&uniforms,
|
| 120 |
&uniform! {
|
| 121 |
perspective: per,
|
| 122 |
u_light: g.light,
|
| 123 |
matrix: m1,
|
| 124 |
tx: mytex,
|
| 125 |
},
|
114 | 126 |
¶ms).unwrap();
|
| 127 |
|
| 128 |
self.frame.draw(&vbuf,
|
| 129 |
&idxs,
|
| 130 |
&g.program,
|
| 131 |
&uniform! {
|
| 132 |
perspective: per,
|
| 133 |
u_light: g.light,
|
| 134 |
matrix: m2,
|
| 135 |
tx: mytex,
|
| 136 |
},
|
| 137 |
¶ms).unwrap();
|
| 138 |
|
| 139 |
self.frame.draw(&vbuf,
|
| 140 |
&idxs,
|
| 141 |
&g.program,
|
| 142 |
&uniform! {
|
| 143 |
perspective: per,
|
| 144 |
u_light: g.light,
|
| 145 |
matrix: m3,
|
| 146 |
tx: mytex,
|
| 147 |
},
|
| 148 |
¶ms).unwrap();
|
| 149 |
|
115 | 150 |
return true;
|
116 | 151 |
}
|
117 | 152 |
|
118 | |
fn matrix(&self, g: &Graphics) -> [[f32;4];4] {
|
| 153 |
fn matrix(&self, g: &Graphics, px: f32, py: f32) -> [[f32;4];4] {
|
119 | 154 |
let rt = g.rt;
|
120 | |
let px = g.px;
|
121 | |
let py = g.py;
|
122 | 155 |
let pz = g.pz;
|
123 | 156 |
[ [ rt.cos() * SX, 0.0, -rt.sin() * SX, 0.0 ],
|
124 | 157 |
[ 0.0, SX, 0.0, 0.0 ],
|