add support for resetting the imgui renderer's texture map
This commit is contained in:
parent
457aa757cf
commit
f6ef1ee22e
|
@ -2,13 +2,7 @@ use ggdt::graphics::{BlendFunction, RgbaBitmap, RgbaPixelFormat, RGBA};
|
|||
use ggdt::math::{Rect, Vector2};
|
||||
use imgui::internal::RawWrapper;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Renderer {
|
||||
pub texture_map: imgui::Textures<RgbaBitmap>,
|
||||
}
|
||||
|
||||
impl Renderer {
|
||||
pub fn new(context: &mut imgui::Context) -> Self {
|
||||
fn create_default_texture_map(context: &mut imgui::Context) -> imgui::Textures<RgbaBitmap> {
|
||||
let mut texture_map = imgui::Textures::new();
|
||||
|
||||
// set up a bitmap with the imgui font atlas texture pixels and register a bitmap->texture mapping for it
|
||||
|
@ -25,7 +19,17 @@ impl Renderer {
|
|||
.unwrap(),
|
||||
);
|
||||
|
||||
Renderer { texture_map }
|
||||
texture_map
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Renderer {
|
||||
pub texture_map: imgui::Textures<RgbaBitmap>,
|
||||
}
|
||||
|
||||
impl Renderer {
|
||||
pub fn new(context: &mut imgui::Context) -> Self {
|
||||
Renderer { texture_map: create_default_texture_map(context) }
|
||||
}
|
||||
|
||||
pub fn render(&mut self, draw_data: &imgui::DrawData, dest: &mut RgbaBitmap) {
|
||||
|
@ -81,4 +85,8 @@ impl Renderer {
|
|||
}
|
||||
dest.set_clip_region(&original_clip_rect);
|
||||
}
|
||||
|
||||
pub fn reset_textures(&mut self, context: &mut imgui::Context) {
|
||||
self.texture_map = create_default_texture_map(context);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue