Function macroquad::window::get_internal_gl
source · pub unsafe fn get_internal_gl<'a>() -> InternalGlContext<'a>
Examples found in repository?
examples/tree.rs (line 42)
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
async fn main() {
let camera = Camera2D {
zoom: vec2(1., 1.),
target: vec2(0.0, 0.5),
..Default::default()
};
set_camera(&camera);
loop {
clear_background(LIGHTGRAY);
draw_circle(0., 0., 0.03, DARKGRAY);
tree(unsafe { get_internal_gl().quad_gl }, get_time(), 0, 1., 0.3);
next_frame().await
}
}
More examples
examples/raw_miniquad.rs (line 8)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
async fn main() {
let stage = {
let InternalGlContext {
quad_context: ctx, ..
} = unsafe { get_internal_gl() };
raw_miniquad::Stage::new(ctx)
};
loop {
clear_background(LIGHTGRAY);
// Render some primitives in camera space
set_camera(&Camera2D {
zoom: vec2(1., screen_width() / screen_height()),
..Default::default()
});
draw_line(-0.4, 0.4, -0.8, 0.9, 0.05, BLUE);
draw_rectangle(-0.3, 0.3, 0.2, 0.2, GREEN);
draw_circle(0., 0., 0.1, YELLOW);
{
let mut gl = unsafe { get_internal_gl() };
// Ensure that macroquad's shapes are not going to be lost
gl.flush();
let t = get_time();
gl.quad_context.apply_pipeline(&stage.pipeline);
gl.quad_context
.begin_default_pass(miniquad::PassAction::Nothing);
gl.quad_context.apply_bindings(&stage.bindings);
for i in 0..10 {
let t = t + i as f64 * 0.3;
gl.quad_context
.apply_uniforms(miniquad::UniformsSource::table(
&raw_miniquad::shader::Uniforms {
offset: (t.sin() as f32 * 0.5, (t * 3.).cos() as f32 * 0.5),
},
));
gl.quad_context.draw(0, 6, 1);
}
gl.quad_context.end_render_pass();
}
// Back to screen space, render some text
set_default_camera();
draw_text("HELLO", 30.0, 200.0, 30.0, BLACK);
next_frame().await
}
}