mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-27 05:18:27 +00:00
Rename TextureEntry to Texture
This commit is contained in:
parent
d9cc6c7499
commit
d0c65f534d
@ -11,7 +11,7 @@ use glium::{
|
|||||||
};
|
};
|
||||||
use image::{jpeg::JpegDecoder, ImageDecoder};
|
use image::{jpeg::JpegDecoder, ImageDecoder};
|
||||||
use imgui::*;
|
use imgui::*;
|
||||||
use imgui_glium_renderer::TextureEntry;
|
use imgui_glium_renderer::Texture;
|
||||||
|
|
||||||
mod support;
|
mod support;
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ impl CustomTexturesApp {
|
|||||||
fn register_textures<F>(
|
fn register_textures<F>(
|
||||||
&mut self,
|
&mut self,
|
||||||
gl_ctx: &F,
|
gl_ctx: &F,
|
||||||
textures: &mut Textures<TextureEntry>,
|
textures: &mut Textures<Texture>,
|
||||||
) -> Result<(), Box<dyn Error>>
|
) -> Result<(), Box<dyn Error>>
|
||||||
where
|
where
|
||||||
F: Facade,
|
F: Facade,
|
||||||
@ -57,7 +57,7 @@ impl CustomTexturesApp {
|
|||||||
format: ClientFormat::U8U8U8,
|
format: ClientFormat::U8U8U8,
|
||||||
};
|
};
|
||||||
let gl_texture = Texture2d::new(gl_ctx, raw)?;
|
let gl_texture = Texture2d::new(gl_ctx, raw)?;
|
||||||
let texture = TextureEntry {
|
let texture = Texture {
|
||||||
texture: Rc::new(gl_texture),
|
texture: Rc::new(gl_texture),
|
||||||
mag_filter: MagnifySamplerFilter::Linear,
|
mag_filter: MagnifySamplerFilter::Linear,
|
||||||
min_filter: MinifySamplerFilter::Linear,
|
min_filter: MinifySamplerFilter::Linear,
|
||||||
@ -93,7 +93,7 @@ impl CustomTexturesApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Lenna {
|
impl Lenna {
|
||||||
fn new<F>(gl_ctx: &F, textures: &mut Textures<TextureEntry>) -> Result<Self, Box<dyn Error>>
|
fn new<F>(gl_ctx: &F, textures: &mut Textures<Texture>) -> Result<Self, Box<dyn Error>>
|
||||||
where
|
where
|
||||||
F: Facade,
|
F: Facade,
|
||||||
{
|
{
|
||||||
@ -111,7 +111,7 @@ impl Lenna {
|
|||||||
format: ClientFormat::U8U8U8,
|
format: ClientFormat::U8U8U8,
|
||||||
};
|
};
|
||||||
let gl_texture = Texture2d::new(gl_ctx, raw)?;
|
let gl_texture = Texture2d::new(gl_ctx, raw)?;
|
||||||
let texture = TextureEntry {
|
let texture = Texture {
|
||||||
texture: Rc::new(gl_texture),
|
texture: Rc::new(gl_texture),
|
||||||
mag_filter: MagnifySamplerFilter::Linear,
|
mag_filter: MagnifySamplerFilter::Linear,
|
||||||
min_filter: MinifySamplerFilter::Linear,
|
min_filter: MinifySamplerFilter::Linear,
|
||||||
|
|||||||
@ -86,7 +86,7 @@ impl From<DrawError> for RendererError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TextureEntry {
|
pub struct Texture {
|
||||||
pub texture: Rc<Texture2d>,
|
pub texture: Rc<Texture2d>,
|
||||||
pub mag_filter: MagnifySamplerFilter,
|
pub mag_filter: MagnifySamplerFilter,
|
||||||
pub min_filter: MinifySamplerFilter,
|
pub min_filter: MinifySamplerFilter,
|
||||||
@ -95,8 +95,8 @@ pub struct TextureEntry {
|
|||||||
pub struct Renderer {
|
pub struct Renderer {
|
||||||
ctx: Rc<Context>,
|
ctx: Rc<Context>,
|
||||||
program: Program,
|
program: Program,
|
||||||
font_texture: TextureEntry,
|
font_texture: Texture,
|
||||||
textures: Textures<TextureEntry>,
|
textures: Textures<Texture>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Renderer {
|
impl Renderer {
|
||||||
@ -121,10 +121,10 @@ impl Renderer {
|
|||||||
self.font_texture = upload_font_texture(ctx.fonts(), &self.ctx)?;
|
self.font_texture = upload_font_texture(ctx.fonts(), &self.ctx)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub fn textures(&mut self) -> &mut Textures<TextureEntry> {
|
pub fn textures(&mut self) -> &mut Textures<Texture> {
|
||||||
&mut self.textures
|
&mut self.textures
|
||||||
}
|
}
|
||||||
fn lookup_texture(&self, texture_id: TextureId) -> Result<&TextureEntry, RendererError> {
|
fn lookup_texture(&self, texture_id: TextureId) -> Result<&Texture, RendererError> {
|
||||||
if texture_id.id() == usize::MAX {
|
if texture_id.id() == usize::MAX {
|
||||||
Ok(&self.font_texture)
|
Ok(&self.font_texture)
|
||||||
} else if let Some(texture) = self.textures.get(texture_id) {
|
} else if let Some(texture) = self.textures.get(texture_id) {
|
||||||
@ -238,7 +238,7 @@ impl Renderer {
|
|||||||
fn upload_font_texture(
|
fn upload_font_texture(
|
||||||
mut fonts: imgui::FontAtlasRefMut,
|
mut fonts: imgui::FontAtlasRefMut,
|
||||||
ctx: &Rc<Context>,
|
ctx: &Rc<Context>,
|
||||||
) -> Result<TextureEntry, RendererError> {
|
) -> Result<Texture, RendererError> {
|
||||||
let texture = fonts.build_rgba32_texture();
|
let texture = fonts.build_rgba32_texture();
|
||||||
let data = RawImage2d {
|
let data = RawImage2d {
|
||||||
data: Cow::Borrowed(texture.data),
|
data: Cow::Borrowed(texture.data),
|
||||||
@ -248,7 +248,7 @@ fn upload_font_texture(
|
|||||||
};
|
};
|
||||||
let font_texture = Texture2d::with_mipmaps(ctx, data, MipmapsOption::NoMipmap)?;
|
let font_texture = Texture2d::with_mipmaps(ctx, data, MipmapsOption::NoMipmap)?;
|
||||||
fonts.tex_id = TextureId::from(usize::MAX);
|
fonts.tex_id = TextureId::from(usize::MAX);
|
||||||
Ok(TextureEntry {
|
Ok(Texture {
|
||||||
texture: Rc::new(font_texture),
|
texture: Rc::new(font_texture),
|
||||||
mag_filter: MagnifySamplerFilter::Linear,
|
mag_filter: MagnifySamplerFilter::Linear,
|
||||||
min_filter: MinifySamplerFilter::Linear,
|
min_filter: MinifySamplerFilter::Linear,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user