Fix custom_textures example

This commit is contained in:
Joonas Javanainen 2019-06-27 22:26:23 +03:00
parent 6a6fc711b8
commit 1cd61f2a83
No known key found for this signature in database
GPG Key ID: D39CCA5CB19B9179

View File

@ -1,6 +1,7 @@
use std::borrow::Cow; use std::borrow::Cow;
use std::error::Error; use std::error::Error;
use std::io::Cursor; use std::io::Cursor;
use std::rc::Rc;
use glium::{ use glium::{
backend::Facade, backend::Facade,
@ -17,12 +18,12 @@ const CLEAR_COLOR: [f32; 4] = [1.0, 1.0, 1.0, 1.0];
#[derive(Default)] #[derive(Default)]
struct CustomTexturesApp { struct CustomTexturesApp {
my_texture_id: Option<ImTexture>, my_texture_id: Option<TextureId>,
lenna: Option<Lenna>, lenna: Option<Lenna>,
} }
struct Lenna { struct Lenna {
texture_id: ImTexture, texture_id: TextureId,
size: (f32, f32), size: (f32, f32),
} }
@ -57,7 +58,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_id = textures.insert(gl_texture); let texture_id = textures.insert(Rc::new(gl_texture));
self.my_texture_id = Some(texture_id); self.my_texture_id = Some(texture_id);
} }
@ -105,7 +106,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_id = textures.insert(gl_texture); let texture_id = textures.insert(Rc::new(gl_texture));
Ok(Lenna { Ok(Lenna {
texture_id, texture_id,
size: (width as f32, height as f32), size: (width as f32, height as f32),