Closed lipx1508 closed 8 months ago
let mut main_layer = rl
.load_render_texture(&thread, GAME_WIDTH, GAME_HEIGHT)
.expect("could not create texture");
let mut d = rl.begin_drawing(&thread);
d.clear_background(Color::BLACK);
{
let mut d = d.begin_texture_mode(&thread, &mut main_layer);
d.clear_background(Color::BLACK);
// do drawing rendertexture2d stuff in here
// at the end of this scope, EndTextureMode() will be called automatically
}
Thank you!
Most of the API is close to raylib, the main diff being that you don't have to call End
functions because the drop check will call it when scope ends, so:
BeginDrawing();
BeginTextureMode();
// drawing things into the render texture here
EndTextureMode();
EndDrawing();
the rust equiv is:
// using brackets and only calling begin because at the end of scope, End() will be called
{
let mut d = rl.begin_drawing();
{
let mut d = d.begin_texture_mode(&thread, &mut render_texture);
// we shadow d in this scope! you don't have to though if its confusing
// drawing things into the render texture here
// EndTextureMode(); automatically gets called at end of bracket scope
}
// EndDrawing(); automatically gets called at end of bracket scope
}
Title. I tried searching a lot through the documentation but I still can't find it. Was this feature implemented yet?