Rename TextureEntry to Texture

This commit is contained in:
Cosmic Chip Socket 2020-07-13 21:16:07 -04:00
parent d9cc6c7499
commit d0c65f534d
2 changed files with 12 additions and 12 deletions

View File

@ -11,7 +11,7 @@ use glium::{
};
use image::{jpeg::JpegDecoder, ImageDecoder};
use imgui::*;
use imgui_glium_renderer::TextureEntry;
use imgui_glium_renderer::Texture;
mod support;
@ -30,7 +30,7 @@ impl CustomTexturesApp {
fn register_textures<F>(
&mut self,
gl_ctx: &F,
textures: &mut Textures<TextureEntry>,
textures: &mut Textures<Texture>,
) -> Result<(), Box<dyn Error>>
where
F: Facade,
@ -57,7 +57,7 @@ impl CustomTexturesApp {
format: ClientFormat::U8U8U8,
};
let gl_texture = Texture2d::new(gl_ctx, raw)?;
let texture = TextureEntry {
let texture = Texture {
texture: Rc::new(gl_texture),
mag_filter: MagnifySamplerFilter::Linear,
min_filter: MinifySamplerFilter::Linear,
@ -93,7 +93,7 @@ impl CustomTexturesApp {
}
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
F: Facade,
{
@ -111,7 +111,7 @@ impl Lenna {
format: ClientFormat::U8U8U8,
};
let gl_texture = Texture2d::new(gl_ctx, raw)?;
let texture = TextureEntry {
let texture = Texture {
texture: Rc::new(gl_texture),
mag_filter: MagnifySamplerFilter::Linear,
min_filter: MinifySamplerFilter::Linear,

View File

@ -86,7 +86,7 @@ impl From<DrawError> for RendererError {
}
}
pub struct TextureEntry {
pub struct Texture {
pub texture: Rc<Texture2d>,
pub mag_filter: MagnifySamplerFilter,
pub min_filter: MinifySamplerFilter,
@ -95,8 +95,8 @@ pub struct TextureEntry {
pub struct Renderer {
ctx: Rc<Context>,
program: Program,
font_texture: TextureEntry,
textures: Textures<TextureEntry>,
font_texture: Texture,
textures: Textures<Texture>,
}
impl Renderer {
@ -121,10 +121,10 @@ impl Renderer {
self.font_texture = upload_font_texture(ctx.fonts(), &self.ctx)?;
Ok(())
}
pub fn textures(&mut self) -> &mut Textures<TextureEntry> {
pub fn textures(&mut self) -> &mut Textures<Texture> {
&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 {
Ok(&self.font_texture)
} else if let Some(texture) = self.textures.get(texture_id) {
@ -238,7 +238,7 @@ impl Renderer {
fn upload_font_texture(
mut fonts: imgui::FontAtlasRefMut,
ctx: &Rc<Context>,
) -> Result<TextureEntry, RendererError> {
) -> Result<Texture, RendererError> {
let texture = fonts.build_rgba32_texture();
let data = RawImage2d {
data: Cow::Borrowed(texture.data),
@ -248,7 +248,7 @@ fn upload_font_texture(
};
let font_texture = Texture2d::with_mipmaps(ctx, data, MipmapsOption::NoMipmap)?;
fonts.tex_id = TextureId::from(usize::MAX);
Ok(TextureEntry {
Ok(Texture {
texture: Rc::new(font_texture),
mag_filter: MagnifySamplerFilter::Linear,
min_filter: MinifySamplerFilter::Linear,