Struct QuadGl

Source
pub struct QuadGl { /* private fields */ }

Implementations§

Source§

impl QuadGl

Source

pub fn new(ctx: &mut Context) -> QuadGl

Examples found in repository?
examples/lines.rs (line 30)
26fn main() {
27    miniquad::start(conf::Conf::default(), |mut ctx| {
28        UserData::owning(
29            Stage {
30                gl: QuadGl::new(&mut ctx),
31            },
32            ctx,
33        )
34    });
35}
More examples
Hide additional examples
examples/tree.rs (line 63)
59fn main() {
60    miniquad::start(conf::Conf::default(), |mut ctx| {
61        UserData::owning(
62            Stage {
63                gl: QuadGl::new(&mut ctx),
64            },
65            ctx,
66        )
67    });
68}
examples/triangle.rs (line 29)
25fn main() {
26    miniquad::start(conf::Conf::default(), |mut ctx| {
27        UserData::owning(
28            Stage {
29                gl: QuadGl::new(&mut ctx),
30            },
31            ctx,
32        )
33    });
34}
Source

pub fn make_pipeline( &mut self, ctx: &mut Context, vertex_shader: &str, fragment_shader: &str, params: PipelineParams, uniforms: Vec<(String, UniformType)>, ) -> Result<GlPipeline, ShaderError>

Source

pub fn clear_draw_calls(&mut self)

Reset only draw calls state

Source

pub fn reset(&mut self)

Reset internal state to known default

Source

pub fn draw(&mut self, ctx: &mut Context)

Examples found in repository?
examples/tree.rs (line 55)
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    }
More examples
Hide additional 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    }
Source

pub fn get_projection_matrix(&self) -> Mat4

Source

pub fn get_active_render_pass(&self) -> Option<RenderPass>

Source

pub fn render_pass(&mut self, render_pass: Option<RenderPass>)

Source

pub fn depth_test(&mut self, enable: bool)

Source

pub fn texture(&mut self, texture: Option<Texture2D>)

Source

pub fn scissor(&mut self, clip: Option<(i32, i32, i32, i32)>)

Source

pub fn set_projection_matrix(&mut self, matrix: Mat4)

Source

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    }
Source

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    }
Source

pub fn pipeline(&mut self, pipeline: Option<GlPipeline>)

Source

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    }
Source

pub fn geometry( &mut self, vertices: &[impl Into<VertexInterop> + Copy], indices: &[u16], )

Examples found in repository?
examples/tree.rs (lines 9-17)
8fn rect(gl: &mut QuadGl, w: f32, h: f32) {
9    gl.geometry(
10        &[
11            Vertex::new(-w / 2., h, 0., 0., 0., RED),
12            Vertex::new(w / 2., h, 0., 0., 0., RED),
13            Vertex::new(-w / 2., 0., 0., 0., 0., RED),
14            Vertex::new(w / 2., 0., 0., 0., 0., RED),
15        ],
16        &[0, 1, 2, 1, 2, 3],
17    );
18}
More examples
Hide additional 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    }
Source

pub fn delete_pipeline(&mut self, pipeline: GlPipeline)

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.