Is there a way in macroquad to draw to a texture? I want to kind of draw a background which does not need to be redrawn every time, but could be drawn from some kind of buffer texture from time to time.
I tried something like
set_camera(&self.camera);
clear_background(RED);
// draw stuff to the texture
set_default_camera();
draw_texture(self.render_target.texture, 0., 0., WHITE);
//draw something that is changed every time
the camera itself is created with
obj.camera = Camera2D {
zoom: vec2(2.0 / screen_width() as f32, -2.0 / screen_height() as f32),
target: vec2(screen_width() / 2.0, screen_height() / 2.0),
//viewport: Some((0, 0, screen_width() as i32, screen_height() as i32)),
render_target: Some(obj.render_target),
..Default::default()
but the texture is either not drawn to, or is not drawn.
Has someone an example for this, how this can be done?
kr