mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-14 15:08:36 +00:00
[glium-example] Pass GlContext and Textures to Ui loop
This commit is contained in:
parent
ecffa09e84
commit
ea8121b539
@ -32,7 +32,7 @@ impl Default for State {
|
||||
|
||||
fn main() {
|
||||
let mut state = State::default();
|
||||
support::run("color_button.rs".to_owned(), CLEAR_COLOR, |ui| {
|
||||
support::run("color_button.rs".to_owned(), CLEAR_COLOR, |ui, _, _| {
|
||||
example_selector(&mut state, ui);
|
||||
match state.example {
|
||||
1 => example_1(&mut state, ui),
|
||||
|
||||
@ -11,7 +11,9 @@ mod support;
|
||||
const CLEAR_COLOR: [f32; 4] = [1.0, 1.0, 1.0, 1.0];
|
||||
|
||||
fn main() {
|
||||
support::run("hello_world.rs".to_owned(), CLEAR_COLOR, hello_world);
|
||||
support::run("hello_world.rs".to_owned(), CLEAR_COLOR, |ui, _, _| {
|
||||
hello_world(ui)
|
||||
});
|
||||
}
|
||||
|
||||
fn hello_world<'a>(ui: &Ui<'a>) -> bool {
|
||||
|
||||
@ -1,8 +1,18 @@
|
||||
use glium::{
|
||||
backend::{Context, Facade},
|
||||
Texture2d,
|
||||
};
|
||||
use imgui::{FontGlyphRange, ImFontConfig, ImGui, Ui};
|
||||
use imgui_glutin_support;
|
||||
use std::rc::Rc;
|
||||
use std::time::Instant;
|
||||
|
||||
pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_ui: F) {
|
||||
pub type Textures = imgui::Textures<Texture2d>;
|
||||
|
||||
pub fn run<F>(title: String, clear_color: [f32; 4], mut run_ui: F)
|
||||
where
|
||||
F: FnMut(&Ui, &Rc<Context>, &mut Textures) -> bool,
|
||||
{
|
||||
use glium::glutin;
|
||||
use glium::{Display, Surface};
|
||||
use imgui_glium_renderer::Renderer;
|
||||
@ -80,7 +90,7 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
let frame_size = imgui_glutin_support::get_frame_size(&window, hidpi_factor).unwrap();
|
||||
|
||||
let ui = imgui.frame(frame_size, delta_s);
|
||||
if !run_ui(&ui) {
|
||||
if !run_ui(&ui, display.get_context(), renderer.textures()) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ fn main() {
|
||||
support::run(
|
||||
"test_drawing_channels_split".to_owned(),
|
||||
CLEAR_COLOR,
|
||||
|ui| {
|
||||
|ui, _, _| {
|
||||
let draw_list = ui.get_window_draw_list();
|
||||
// Will draw channel 0 first, then channel 1, whatever the order of
|
||||
// the calls in the code.
|
||||
|
||||
@ -8,7 +8,7 @@ mod support;
|
||||
const CLEAR_COLOR: [f32; 4] = [0.2, 0.2, 0.2, 1.0];
|
||||
|
||||
fn main() {
|
||||
support::run("test_window.rs".to_owned(), CLEAR_COLOR, |ui| {
|
||||
support::run("test_window.rs".to_owned(), CLEAR_COLOR, |ui, _, _| {
|
||||
let mut open = true;
|
||||
ui.show_demo_window(&mut open);
|
||||
open
|
||||
|
||||
@ -193,7 +193,7 @@ const CLEAR_COLOR: [f32; 4] = [114.0 / 255.0, 144.0 / 255.0, 154.0 / 255.0, 1.0]
|
||||
fn main() {
|
||||
let mut state = State::default();
|
||||
|
||||
support::run("test_window.rs".to_owned(), CLEAR_COLOR, |ui| {
|
||||
support::run("test_window.rs".to_owned(), CLEAR_COLOR, |ui, _, _| {
|
||||
let mut open = true;
|
||||
show_test_window(ui, &mut state, &mut open);
|
||||
open
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user