mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-11 13:38:35 +00:00
Fix example
This commit is contained in:
parent
7b31db0526
commit
0544e3bed6
@ -6,10 +6,12 @@ use std::rc::Rc;
|
|||||||
use glium::{
|
use glium::{
|
||||||
backend::Facade,
|
backend::Facade,
|
||||||
texture::{ClientFormat, RawImage2d},
|
texture::{ClientFormat, RawImage2d},
|
||||||
|
uniforms::{MagnifySamplerFilter, MinifySamplerFilter},
|
||||||
Texture2d,
|
Texture2d,
|
||||||
};
|
};
|
||||||
use image::{jpeg::JpegDecoder, ImageDecoder};
|
use image::{jpeg::JpegDecoder, ImageDecoder};
|
||||||
use imgui::*;
|
use imgui::*;
|
||||||
|
use imgui_glium_renderer::TextureEntry;
|
||||||
|
|
||||||
mod support;
|
mod support;
|
||||||
|
|
||||||
@ -28,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<Rc<Texture2d>>,
|
textures: &mut Textures<TextureEntry>,
|
||||||
) -> Result<(), Box<dyn Error>>
|
) -> Result<(), Box<dyn Error>>
|
||||||
where
|
where
|
||||||
F: Facade,
|
F: Facade,
|
||||||
@ -55,7 +57,12 @@ 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_id = textures.insert(Rc::new(gl_texture));
|
let texture = TextureEntry {
|
||||||
|
texture: Rc::new(gl_texture),
|
||||||
|
mag_filter: MagnifySamplerFilter::Linear,
|
||||||
|
min_filter: MinifySamplerFilter::Linear,
|
||||||
|
};
|
||||||
|
let texture_id = textures.insert(texture);
|
||||||
|
|
||||||
self.my_texture_id = Some(texture_id);
|
self.my_texture_id = Some(texture_id);
|
||||||
}
|
}
|
||||||
@ -86,7 +93,7 @@ impl CustomTexturesApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Lenna {
|
impl Lenna {
|
||||||
fn new<F>(gl_ctx: &F, textures: &mut Textures<Rc<Texture2d>>) -> Result<Self, Box<dyn Error>>
|
fn new<F>(gl_ctx: &F, textures: &mut Textures<TextureEntry>) -> Result<Self, Box<dyn Error>>
|
||||||
where
|
where
|
||||||
F: Facade,
|
F: Facade,
|
||||||
{
|
{
|
||||||
@ -104,7 +111,12 @@ 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_id = textures.insert(Rc::new(gl_texture));
|
let texture = TextureEntry {
|
||||||
|
texture: Rc::new(gl_texture),
|
||||||
|
mag_filter: MagnifySamplerFilter::Linear,
|
||||||
|
min_filter: MinifySamplerFilter::Linear,
|
||||||
|
};
|
||||||
|
let texture_id = textures.insert(texture);
|
||||||
Ok(Lenna {
|
Ok(Lenna {
|
||||||
texture_id,
|
texture_id,
|
||||||
size: [width as f32, height as f32],
|
size: [width as f32, height as f32],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user