Struct QuadGl

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

Implementations§

Source§

impl QuadGl

Source

pub fn new( ctx: &mut dyn RenderingBackend, max_vertices: usize, max_indices: usize, ) -> QuadGl

Source

pub fn make_pipeline( &mut self, ctx: &mut dyn RenderingBackend, shader: ShaderSource<'_>, params: PipelineParams, uniforms: Vec<UniformDesc>, 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 const fn get_active_render_pass(&self) -> Option<RenderPass>

Source

pub const 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)
3fn tree(gl: &mut QuadGl, time: f64, deep: u32, angle: f32, tall: f32) {
4    if deep >= 8 {
5        return;
6    }
7
8    // we can use normal macroquad drawing API here
9    draw_rectangle(-0.01 / 2., 0., 0.01, tall, DARKGRAY);
10
11    // and we can also modify internal macroquad render state with "gl" reference
12    gl.push_model_matrix(glam::Mat4::from_translation(glam::vec3(0., tall, 0.)));
13
14    // right leaf
15    gl.push_model_matrix(glam::Mat4::from_rotation_z(angle + time.sin() as f32 * 0.1));
16    tree(gl, time, deep + 1, angle * 0.7, tall * 0.8);
17    gl.pop_model_matrix();
18
19    // left leaf
20    gl.push_model_matrix(glam::Mat4::from_rotation_z(
21        -angle - time.cos() as f32 * 0.1,
22    ));
23    tree(gl, time, deep + 1, angle * 0.7, tall * 0.8);
24    gl.pop_model_matrix();
25
26    gl.pop_model_matrix();
27}
Source

pub fn pop_model_matrix(&mut self)

Examples found in repository?
examples/tree.rs (line 17)
3fn tree(gl: &mut QuadGl, time: f64, deep: u32, angle: f32, tall: f32) {
4    if deep >= 8 {
5        return;
6    }
7
8    // we can use normal macroquad drawing API here
9    draw_rectangle(-0.01 / 2., 0., 0.01, tall, DARKGRAY);
10
11    // and we can also modify internal macroquad render state with "gl" reference
12    gl.push_model_matrix(glam::Mat4::from_translation(glam::vec3(0., tall, 0.)));
13
14    // right leaf
15    gl.push_model_matrix(glam::Mat4::from_rotation_z(angle + time.sin() as f32 * 0.1));
16    tree(gl, time, deep + 1, angle * 0.7, tall * 0.8);
17    gl.pop_model_matrix();
18
19    // left leaf
20    gl.push_model_matrix(glam::Mat4::from_rotation_z(
21        -angle - time.cos() as f32 * 0.1,
22    ));
23    tree(gl, time, deep + 1, angle * 0.7, tall * 0.8);
24    gl.pop_model_matrix();
25
26    gl.pop_model_matrix();
27}
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: &[Vertex], 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_uniform_array<T: ToBytes>( &mut self, pipeline: GlPipeline, name: &str, uniform: &[T], )

Source

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

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<S> FromSample<S> for S

Source§

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.

Source§

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

Source§

fn to_sample_(self) -> U

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

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