mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2025-03-28 21:09:20 +00:00
get rid of some warnings
This commit is contained in:
parent
4d6768c015
commit
d484e8a183
|
@ -60,6 +60,8 @@ pub trait BackendRenderer {
|
||||||
|
|
||||||
fn imgui_texture_id(&self, texture: &Box<dyn BackendTexture>) -> GameResult<imgui::TextureId>;
|
fn imgui_texture_id(&self, texture: &Box<dyn BackendTexture>) -> GameResult<imgui::TextureId>;
|
||||||
|
|
||||||
|
fn prepare_imgui(&mut self, ui: &imgui::Ui) -> GameResult;
|
||||||
|
|
||||||
fn render_imgui(&mut self, draw_data: &DrawData) -> GameResult;
|
fn render_imgui(&mut self, draw_data: &DrawData) -> GameResult;
|
||||||
|
|
||||||
fn supports_vertex_draw(&self) -> bool {
|
fn supports_vertex_draw(&self) -> bool {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::any::Any;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use imgui::{DrawData, TextureId};
|
use imgui::{DrawData, TextureId, Ui};
|
||||||
|
|
||||||
use crate::common::{Color, Rect};
|
use crate::common::{Color, Rect};
|
||||||
use crate::framework::backend::{
|
use crate::framework::backend::{
|
||||||
|
@ -135,6 +135,10 @@ impl BackendRenderer for NullRenderer {
|
||||||
Ok(TextureId::from(0))
|
Ok(TextureId::from(0))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn prepare_imgui(&mut self, _ui: &Ui) -> GameResult {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn render_imgui(&mut self, _draw_data: &DrawData) -> GameResult {
|
fn render_imgui(&mut self, _draw_data: &DrawData) -> GameResult {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use std::rc::Rc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use imgui::internal::RawWrapper;
|
use imgui::internal::RawWrapper;
|
||||||
use imgui::{ConfigFlags, DrawCmd, DrawData, Key, MouseCursor, TextureId};
|
use imgui::{ConfigFlags, DrawCmd, DrawData, Key, MouseCursor, TextureId, Ui};
|
||||||
use sdl2::event::{Event, WindowEvent};
|
use sdl2::event::{Event, WindowEvent};
|
||||||
use sdl2::keyboard::Scancode;
|
use sdl2::keyboard::Scancode;
|
||||||
use sdl2::mouse::{Cursor, SystemCursor};
|
use sdl2::mouse::{Cursor, SystemCursor};
|
||||||
|
@ -602,6 +602,13 @@ impl BackendRenderer for SDL2Renderer {
|
||||||
Ok(TextureId::new(sdl_texture.texture.as_ref().map(|t| t.raw()).unwrap_or(null_mut()) as usize))
|
Ok(TextureId::new(sdl_texture.texture.as_ref().map(|t| t.raw()).unwrap_or(null_mut()) as usize))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn prepare_imgui(&mut self, ui: &Ui) -> GameResult {
|
||||||
|
let refs = self.refs.borrow_mut();
|
||||||
|
self.imgui_event.borrow_mut().prepare_render(ui, refs.canvas.window());
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn render_imgui(&mut self, draw_data: &DrawData) -> GameResult {
|
fn render_imgui(&mut self, draw_data: &DrawData) -> GameResult {
|
||||||
let mut refs = self.refs.borrow_mut();
|
let mut refs = self.refs.borrow_mut();
|
||||||
|
|
||||||
|
@ -1100,6 +1107,10 @@ impl ImguiSdl2 {
|
||||||
imgui.io_mut().key_super = super_;
|
imgui.io_mut().key_super = super_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.ignore_event(event) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
match *event {
|
match *event {
|
||||||
Event::MouseWheel { y, .. } => {
|
Event::MouseWheel { y, .. } => {
|
||||||
imgui.io_mut().mouse_wheel = y as f32;
|
imgui.io_mut().mouse_wheel = y as f32;
|
||||||
|
|
|
@ -128,6 +128,14 @@ pub fn imgui_texture_id(ctx: &Context, texture: &Box<dyn BackendTexture>) -> Gam
|
||||||
Err(GameError::RenderError("Rendering backend hasn't been initialized yet.".to_string()))
|
Err(GameError::RenderError("Rendering backend hasn't been initialized yet.".to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn prepare_imgui(ctx: &mut Context, ui: &imgui::Ui) -> GameResult {
|
||||||
|
if let Some(renderer) = ctx.renderer.as_mut() {
|
||||||
|
return renderer.prepare_imgui(ui);
|
||||||
|
}
|
||||||
|
|
||||||
|
Err(GameError::RenderError("Rendering backend hasn't been initialized yet.".to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn render_imgui(ctx: &mut Context, draw_data: &imgui::DrawData) -> GameResult {
|
pub fn render_imgui(ctx: &mut Context, draw_data: &imgui::DrawData) -> GameResult {
|
||||||
if let Some(renderer) = ctx.renderer.as_mut() {
|
if let Some(renderer) = ctx.renderer.as_mut() {
|
||||||
return renderer.render_imgui(draw_data);
|
return renderer.render_imgui(draw_data);
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![allow(unused)]
|
||||||
|
|
||||||
pub mod backend;
|
pub mod backend;
|
||||||
pub mod backend_null;
|
pub mod backend_null;
|
||||||
#[cfg(feature = "backend-glutin")]
|
#[cfg(feature = "backend-glutin")]
|
||||||
|
|
|
@ -6,7 +6,7 @@ use std::mem::MaybeUninit;
|
||||||
use std::ptr::null;
|
use std::ptr::null;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use imgui::{DrawCmd, DrawCmdParams, DrawData, DrawIdx, DrawVert, TextureId};
|
use imgui::{DrawCmd, DrawCmdParams, DrawData, DrawIdx, DrawVert, TextureId, Ui};
|
||||||
|
|
||||||
use crate::common::{Color, Rect};
|
use crate::common::{Color, Rect};
|
||||||
use crate::framework::backend::{BackendRenderer, BackendShader, BackendTexture, SpriteBatchCommand, VertexData};
|
use crate::framework::backend::{BackendRenderer, BackendShader, BackendTexture, SpriteBatchCommand, VertexData};
|
||||||
|
@ -1053,6 +1053,10 @@ impl BackendRenderer for OpenGLRenderer {
|
||||||
Ok(TextureId::new(gl_texture.texture_id as usize))
|
Ok(TextureId::new(gl_texture.texture_id as usize))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn prepare_imgui(&mut self, _ui: &Ui) -> GameResult {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn render_imgui(&mut self, draw_data: &DrawData) -> GameResult {
|
fn render_imgui(&mut self, draw_data: &DrawData) -> GameResult {
|
||||||
// https://github.com/michaelfairley/rust-imgui-opengl-renderer
|
// https://github.com/michaelfairley/rust-imgui-opengl-renderer
|
||||||
if let Some((_, gl)) = self.get_context() {
|
if let Some((_, gl)) = self.get_context() {
|
||||||
|
|
|
@ -6,6 +6,7 @@ use imgui::sys::*;
|
||||||
use crate::framework::context::Context;
|
use crate::framework::context::Context;
|
||||||
use crate::framework::error::GameResult;
|
use crate::framework::error::GameResult;
|
||||||
use crate::framework::graphics::{imgui_context, render_imgui};
|
use crate::framework::graphics::{imgui_context, render_imgui};
|
||||||
|
use crate::graphics::prepare_imgui;
|
||||||
use crate::live_debugger::LiveDebugger;
|
use crate::live_debugger::LiveDebugger;
|
||||||
use crate::scene::Scene;
|
use crate::scene::Scene;
|
||||||
use crate::shared_game_state::SharedGameState;
|
use crate::shared_game_state::SharedGameState;
|
||||||
|
@ -128,6 +129,7 @@ impl UI {
|
||||||
|
|
||||||
scene.imgui_draw(&mut self.components, state, ctx2, &mut ui)?;
|
scene.imgui_draw(&mut self.components, state, ctx2, &mut ui)?;
|
||||||
|
|
||||||
|
prepare_imgui(ctx2, &ui);
|
||||||
let draw_data = ui.render();
|
let draw_data = ui.render();
|
||||||
render_imgui(ctx2, draw_data)?;
|
render_imgui(ctx2, draw_data)?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue