Struct macroquad::prelude::QuadGl

source ·
pub struct QuadGl { /* private fields */ }

Implementations§

source§

impl QuadGl

source

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

source

pub fn make_pipeline( &mut self, ctx: &mut dyn RenderingBackend, shader: ShaderSource<'_>, params: PipelineParams, uniforms: Vec<(String, UniformType)>, textures: Vec<String> ) -> Result<GlPipeline, Error>

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 dyn RenderingBackend, projection: Mat4)

source

pub fn get_projection_matrix(&self) -> Mat4

source

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

source

pub fn is_depth_test_enabled(&self) -> bool

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 viewport(&mut self, viewport: Option<(i32, i32, i32, i32)>)

source

pub fn get_viewport(&self) -> (i32, i32, i32, i32)

source

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

Examples found in repository?
examples/tree.rs (line 12)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
fn tree(gl: &mut QuadGl, time: f64, deep: u32, angle: f32, tall: f32) {
    if deep >= 8 {
        return;
    }

    // we can use normal macroquad drawing API here
    draw_rectangle(-0.01 / 2., 0., 0.01, tall, DARKGRAY);

    // and we can also modify internal macroquad render state with "gl" reference
    gl.push_model_matrix(glam::Mat4::from_translation(glam::vec3(0., tall, 0.)));

    // right leaf
    gl.push_model_matrix(glam::Mat4::from_rotation_z(angle + time.sin() as f32 * 0.1));
    tree(gl, time, deep + 1, angle * 0.7, tall * 0.8);
    gl.pop_model_matrix();

    // left leaf
    gl.push_model_matrix(glam::Mat4::from_rotation_z(
        -angle - time.cos() as f32 * 0.1,
    ));
    tree(gl, time, deep + 1, angle * 0.7, tall * 0.8);
    gl.pop_model_matrix();

    gl.pop_model_matrix();
}
source

pub fn pop_model_matrix(&mut self)

Examples found in repository?
examples/tree.rs (line 17)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
fn tree(gl: &mut QuadGl, time: f64, deep: u32, angle: f32, tall: f32) {
    if deep >= 8 {
        return;
    }

    // we can use normal macroquad drawing API here
    draw_rectangle(-0.01 / 2., 0., 0.01, tall, DARKGRAY);

    // and we can also modify internal macroquad render state with "gl" reference
    gl.push_model_matrix(glam::Mat4::from_translation(glam::vec3(0., tall, 0.)));

    // right leaf
    gl.push_model_matrix(glam::Mat4::from_rotation_z(angle + time.sin() as f32 * 0.1));
    tree(gl, time, deep + 1, angle * 0.7, tall * 0.8);
    gl.pop_model_matrix();

    // left leaf
    gl.push_model_matrix(glam::Mat4::from_rotation_z(
        -angle - time.cos() as f32 * 0.1,
    ));
    tree(gl, time, deep + 1, angle * 0.7, tall * 0.8);
    gl.pop_model_matrix();

    gl.pop_model_matrix();
}
source

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

source

pub fn draw_mode(&mut self, mode: DrawMode)

source

pub fn geometry( &mut self, vertices: &[impl Into<([f32; 3], [f32; 2], [f32; 4])> + Copy], indices: &[u16] )

source

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

source

pub fn set_uniform<T>(&mut self, pipeline: GlPipeline, name: &str, uniform: T)

source

pub fn set_texture( &mut self, pipeline: GlPipeline, name: &str, texture: Texture2D )

Auto Trait Implementations§

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.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

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.

§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

source§

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

§

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>,

§

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.
§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,