(&self, pass: RenderPass<'_, T>)
| 92 | } |
| 93 | |
| 94 | pub fn draw<T>(&self, pass: RenderPass<'_, T>) |
| 95 | where |
| 96 | T: Target, |
| 97 | { |
| 98 | unsafe { |
| 99 | pass.target.bind(self); |
| 100 | |
| 101 | self.state.gl.bind_vertex_array(Some(self.state.vao)); |
| 102 | self.bind_vertex_buffer(Some(pass.mesh.raw.vertex_buffer)); |
| 103 | self.bind_index_buffer(Some(pass.mesh.raw.index_buffer)); |
| 104 | self.bind_shader(Some(pass.shader.raw.id)); |
| 105 | self.bind_texture(Some(pass.texture.raw.id)); |
| 106 | |
| 107 | let proj = self |
| 108 | .state |
| 109 | .gl |
| 110 | .get_uniform_location(pass.shader.raw.id, "u_projection") |
| 111 | .unwrap(); |
| 112 | |
| 113 | let (target_width, target_height) = pass.target.size(); |
| 114 | |
| 115 | self.state.gl.uniform_matrix_4_f32_slice( |
| 116 | Some(&proj), |
| 117 | false, |
| 118 | Mat4::orthographic_rh_gl( |
| 119 | 0.0, |
| 120 | target_width as f32, |
| 121 | if T::FLIPPED { |
| 122 | 0.0 |
| 123 | } else { |
| 124 | target_height as f32 |
| 125 | }, |
| 126 | if T::FLIPPED { |
| 127 | target_height as f32 |
| 128 | } else { |
| 129 | 0.0 |
| 130 | }, |
| 131 | -1.0, |
| 132 | 1.0, |
| 133 | ) |
| 134 | .as_ref(), |
| 135 | ); |
| 136 | |
| 137 | self.state.gl.viewport(0, 0, target_width, target_height); |
| 138 | |
| 139 | self.state.gl.draw_elements( |
| 140 | glow::TRIANGLES, |
| 141 | pass.index_count as i32, |
| 142 | glow::UNSIGNED_INT, |
| 143 | (pass.index_start * std::mem::size_of::<u32>()) as i32, |
| 144 | ); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | pub fn bind_vertex_buffer(&self, buffer: Option<glow::Buffer>) { |
| 149 | unsafe { |
nothing calls this directly
no test coverage detected