mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-12 22:18:36 +00:00
Pass texture id to imgui, and assert during rendering
This commit is contained in:
parent
775bcbc04e
commit
19a838104f
@ -1,10 +1,12 @@
|
||||
use glium::{
|
||||
index, program, texture, vertex,
|
||||
Blend, DrawError, DrawParameters, IndexBuffer, Program, Rect, Surface, Texture2d, VertexBuffer
|
||||
Blend, DrawError, DrawParameters, GlObject, IndexBuffer, Program, Rect, Surface, Texture2d,
|
||||
VertexBuffer
|
||||
};
|
||||
use glium::backend::{Context, Facade};
|
||||
use glium::index::PrimitiveType;
|
||||
use glium::texture::{ClientFormat, RawImage2d};
|
||||
use libc::uintptr_t;
|
||||
use std::borrow::Cow;
|
||||
use std::fmt;
|
||||
use std::rc::Rc;
|
||||
@ -97,13 +99,16 @@ impl Renderer {
|
||||
[ 0.0, 0.0, -1.0, 0.0 ],
|
||||
[ -1.0, 1.0, 0.0, 1.0 ]
|
||||
];
|
||||
let uniforms = uniform! {
|
||||
matrix: matrix,
|
||||
tex: &self.device_objects.texture
|
||||
};
|
||||
let font_texture_id = self.device_objects.texture.get_id() as uintptr_t;
|
||||
|
||||
let mut idx_start = 0;
|
||||
for cmd in draw_list.cmd_buffer {
|
||||
// We don't support custom textures...yet!
|
||||
assert!(cmd.texture_id as uintptr_t == font_texture_id);
|
||||
let uniforms = uniform! {
|
||||
matrix: matrix,
|
||||
tex: &self.device_objects.texture
|
||||
};
|
||||
let draw_params = DrawParameters {
|
||||
blend: Blend::alpha_blending(),
|
||||
scissor: Some(Rect {
|
||||
@ -165,6 +170,7 @@ impl DeviceObjects {
|
||||
};
|
||||
Texture2d::new(ctx, data)
|
||||
}));
|
||||
im_gui.set_texture_id(texture.get_id() as uintptr_t);
|
||||
|
||||
Ok(DeviceObjects {
|
||||
vertex_buffer: vertex_buffer,
|
||||
|
||||
@ -6,7 +6,7 @@ extern crate imgui_sys;
|
||||
|
||||
extern crate libc;
|
||||
|
||||
use libc::{c_char, c_float, c_int, c_uchar};
|
||||
use libc::{c_char, c_float, c_int, c_uchar, c_void, uintptr_t};
|
||||
use std::borrow::Cow;
|
||||
use std::convert::From;
|
||||
use std::ffi::CStr;
|
||||
@ -155,6 +155,11 @@ impl ImGui {
|
||||
})
|
||||
}
|
||||
}
|
||||
pub fn set_texture_id(&mut self, value: uintptr_t) {
|
||||
unsafe {
|
||||
(*self.io_mut().fonts).tex_id = value as *mut c_void;
|
||||
}
|
||||
}
|
||||
pub fn set_ini_filename(&mut self, value: Option<ImStr<'static>>) {
|
||||
{
|
||||
let io = self.io_mut();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user