Struct imgui_wgpu::Texture
source · pub struct Texture { /* private fields */ }Expand description
A container for a bindable texture.
Implementations§
source§impl Texture
impl Texture
sourcepub fn from_raw_parts(
texture: Texture,
view: TextureView,
bind_group: BindGroup,
size: Extent3d
) -> Self
pub fn from_raw_parts(
texture: Texture,
view: TextureView,
bind_group: BindGroup,
size: Extent3d
) -> Self
Create a Texture from its raw parts.
sourcepub fn new(
device: &Device,
renderer: &Renderer,
config: TextureConfig<'_>
) -> Self
pub fn new(
device: &Device,
renderer: &Renderer,
config: TextureConfig<'_>
) -> Self
Create a new GPU texture width the specified config.
Examples found in repository?
src/lib.rs (line 744)
727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749
pub fn reload_font_texture(&mut self, imgui: &mut Context, device: &Device, queue: &Queue) {
let mut fonts = imgui.fonts();
// Remove possible font atlas texture.
self.textures.remove(fonts.tex_id);
// Create font texture and upload it.
let handle = fonts.build_rgba32_texture();
let font_texture_cnfig = TextureConfig {
label: Some("imgui-wgpu font atlas"),
size: Extent3d {
width: handle.width,
height: handle.height,
..Default::default()
},
..Default::default()
};
let font_texture = Texture::new(device, self, font_texture_cnfig);
font_texture.write(queue, handle.data, handle.width, handle.height);
fonts.tex_id = self.textures.insert(font_texture);
// Clear imgui texture data to save memory.
fonts.clear_tex_data();
}sourcepub fn write(&self, queue: &Queue, data: &[u8], width: u32, height: u32)
pub fn write(&self, queue: &Queue, data: &[u8], width: u32, height: u32)
Write data to the texture.
data: 32-bit RGBA bitmap data.width: The width of the source bitmap (data) in pixels.height: The height of the source bitmap (data) in pixels.
Examples found in repository?
src/lib.rs (line 745)
727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749
pub fn reload_font_texture(&mut self, imgui: &mut Context, device: &Device, queue: &Queue) {
let mut fonts = imgui.fonts();
// Remove possible font atlas texture.
self.textures.remove(fonts.tex_id);
// Create font texture and upload it.
let handle = fonts.build_rgba32_texture();
let font_texture_cnfig = TextureConfig {
label: Some("imgui-wgpu font atlas"),
size: Extent3d {
width: handle.width,
height: handle.height,
..Default::default()
},
..Default::default()
};
let font_texture = Texture::new(device, self, font_texture_cnfig);
font_texture.write(queue, handle.data, handle.width, handle.height);
fonts.tex_id = self.textures.insert(font_texture);
// Clear imgui texture data to save memory.
fonts.clear_tex_data();
}sourcepub fn view(&self) -> &TextureView
pub fn view(&self) -> &TextureView
The wgpu::TextureView of the underlying texture.