pub struct QuadGl { /* private fields */ }
Implementations§
Source§impl QuadGl
impl QuadGl
pub fn make_pipeline( &mut self, ctx: &mut Context, vertex_shader: &str, fragment_shader: &str, params: PipelineParams, uniforms: Vec<(String, UniformType)>, ) -> Result<GlPipeline, ShaderError>
Sourcepub fn clear_draw_calls(&mut self)
pub fn clear_draw_calls(&mut self)
Reset only draw calls state
Sourcepub fn draw(&mut self, ctx: &mut Context)
pub fn draw(&mut self, ctx: &mut Context)
Examples found in repository?
More examples
examples/triangle.rs (line 21)
10 fn draw(&mut self, ctx: &mut Context) {
11 ctx.clear(Some((0., 1., 0., 1.)), None, None);
12
13 self.gl.geometry(
14 &[
15 Vertex::new(0., -0.5, 0., 0., 0., BLUE),
16 Vertex::new(0.5, 0.5, 0., 0., 0., RED),
17 Vertex::new(-0.5, 0.5, 0., 0., 0., GREEN),
18 ],
19 &[0, 1, 2],
20 );
21 self.gl.draw(ctx);
22 }
examples/lines.rs (line 22)
10 fn draw(&mut self, ctx: &mut Context) {
11 ctx.clear(Some((0., 1., 0., 1.)), None, None);
12
13 self.gl.draw_mode(DrawMode::Lines);
14 self.gl.geometry(
15 &[
16 Vertex::new(0., -0.5, 0., 0., 0., BLUE),
17 Vertex::new(0.5, 0.5, 0., 0., 0., RED),
18 Vertex::new(-0.5, 0.5, 0., 0., 0., GREEN),
19 ],
20 &[0, 1, 2, 0, 1, 2],
21 );
22 self.gl.draw(ctx);
23 }
pub fn get_projection_matrix(&self) -> Mat4
pub fn get_active_render_pass(&self) -> Option<RenderPass>
pub fn render_pass(&mut self, render_pass: Option<RenderPass>)
pub fn depth_test(&mut self, enable: bool)
pub fn texture(&mut self, texture: Option<Texture2D>)
pub fn scissor(&mut self, clip: Option<(i32, i32, i32, i32)>)
pub fn set_projection_matrix(&mut self, matrix: Mat4)
Sourcepub fn push_model_matrix(&mut self, matrix: Mat4)
pub fn push_model_matrix(&mut self, matrix: Mat4)
Examples found in repository?
examples/tree.rs (line 28)
20fn tree(gl: &mut QuadGl, time: f64, deep: u32, angle: f32, tall: f32) {
21 if deep >= 8 {
22 return;
23 }
24
25 // root
26 rect(gl, 0.01, tall);
27
28 gl.push_model_matrix(glam::Mat4::from_translation(glam::vec3(0., tall, 0.)));
29
30 // right leaf
31 gl.push_model_matrix(glam::Mat4::from_rotation_z(angle + time.sin() as f32 * 0.1));
32 tree(gl, time, deep + 1, angle * 0.7, tall * 0.8);
33 gl.pop_model_matrix();
34
35 // left leaf
36 gl.push_model_matrix(glam::Mat4::from_rotation_z(
37 -angle - time.cos() as f32 * 0.1,
38 ));
39 tree(gl, time, deep + 1, angle * 0.7, tall * 0.8);
40 gl.pop_model_matrix();
41
42 gl.pop_model_matrix();
43}
44impl EventHandler for Stage {
45 fn update(&mut self, _ctx: &mut Context) {}
46
47 fn draw(&mut self, ctx: &mut Context) {
48 ctx.clear(Some((0., 1., 0., 1.)), None, None);
49
50 self.gl
51 .push_model_matrix(glam::Mat4::from_translation(glam::vec3(0., -0.5, 0.)));
52 tree(&mut self.gl, miniquad::date::now(), 0, 1., 0.3);
53 self.gl.pop_model_matrix();
54
55 self.gl.draw(ctx);
56 }
Sourcepub fn pop_model_matrix(&mut self)
pub fn pop_model_matrix(&mut self)
Examples found in repository?
examples/tree.rs (line 33)
20fn tree(gl: &mut QuadGl, time: f64, deep: u32, angle: f32, tall: f32) {
21 if deep >= 8 {
22 return;
23 }
24
25 // root
26 rect(gl, 0.01, tall);
27
28 gl.push_model_matrix(glam::Mat4::from_translation(glam::vec3(0., tall, 0.)));
29
30 // right leaf
31 gl.push_model_matrix(glam::Mat4::from_rotation_z(angle + time.sin() as f32 * 0.1));
32 tree(gl, time, deep + 1, angle * 0.7, tall * 0.8);
33 gl.pop_model_matrix();
34
35 // left leaf
36 gl.push_model_matrix(glam::Mat4::from_rotation_z(
37 -angle - time.cos() as f32 * 0.1,
38 ));
39 tree(gl, time, deep + 1, angle * 0.7, tall * 0.8);
40 gl.pop_model_matrix();
41
42 gl.pop_model_matrix();
43}
44impl EventHandler for Stage {
45 fn update(&mut self, _ctx: &mut Context) {}
46
47 fn draw(&mut self, ctx: &mut Context) {
48 ctx.clear(Some((0., 1., 0., 1.)), None, None);
49
50 self.gl
51 .push_model_matrix(glam::Mat4::from_translation(glam::vec3(0., -0.5, 0.)));
52 tree(&mut self.gl, miniquad::date::now(), 0, 1., 0.3);
53 self.gl.pop_model_matrix();
54
55 self.gl.draw(ctx);
56 }
pub fn pipeline(&mut self, pipeline: Option<GlPipeline>)
Sourcepub fn draw_mode(&mut self, mode: DrawMode)
pub fn draw_mode(&mut self, mode: DrawMode)
Examples found in repository?
examples/lines.rs (line 13)
10 fn draw(&mut self, ctx: &mut Context) {
11 ctx.clear(Some((0., 1., 0., 1.)), None, None);
12
13 self.gl.draw_mode(DrawMode::Lines);
14 self.gl.geometry(
15 &[
16 Vertex::new(0., -0.5, 0., 0., 0., BLUE),
17 Vertex::new(0.5, 0.5, 0., 0., 0., RED),
18 Vertex::new(-0.5, 0.5, 0., 0., 0., GREEN),
19 ],
20 &[0, 1, 2, 0, 1, 2],
21 );
22 self.gl.draw(ctx);
23 }
Sourcepub fn geometry(
&mut self,
vertices: &[impl Into<VertexInterop> + Copy],
indices: &[u16],
)
pub fn geometry( &mut self, vertices: &[impl Into<VertexInterop> + Copy], indices: &[u16], )
Examples found in repository?
More examples
examples/triangle.rs (lines 13-20)
10 fn draw(&mut self, ctx: &mut Context) {
11 ctx.clear(Some((0., 1., 0., 1.)), None, None);
12
13 self.gl.geometry(
14 &[
15 Vertex::new(0., -0.5, 0., 0., 0., BLUE),
16 Vertex::new(0.5, 0.5, 0., 0., 0., RED),
17 Vertex::new(-0.5, 0.5, 0., 0., 0., GREEN),
18 ],
19 &[0, 1, 2],
20 );
21 self.gl.draw(ctx);
22 }
examples/lines.rs (lines 14-21)
10 fn draw(&mut self, ctx: &mut Context) {
11 ctx.clear(Some((0., 1., 0., 1.)), None, None);
12
13 self.gl.draw_mode(DrawMode::Lines);
14 self.gl.geometry(
15 &[
16 Vertex::new(0., -0.5, 0., 0., 0., BLUE),
17 Vertex::new(0.5, 0.5, 0., 0., 0., RED),
18 Vertex::new(-0.5, 0.5, 0., 0., 0., GREEN),
19 ],
20 &[0, 1, 2, 0, 1, 2],
21 );
22 self.gl.draw(ctx);
23 }
pub fn delete_pipeline(&mut self, pipeline: GlPipeline)
pub fn set_uniform<T>(&mut self, pipeline: GlPipeline, name: &str, uniform: T)
Auto Trait Implementations§
impl Freeze for QuadGl
impl RefUnwindSafe for QuadGl
impl Send for QuadGl
impl Sync for QuadGl
impl Unpin for QuadGl
impl UnwindSafe for QuadGl
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more