fix missing `as_any` methods in the glutin backend

This commit is contained in:
József Sallai 2023-02-17 16:06:11 +02:00
parent d6715bccea
commit 1810bf6d5b
1 changed files with 87 additions and 78 deletions

View File

@ -1,17 +1,16 @@
use std::any::Any;
use std::cell::{RefCell, UnsafeCell};
use std::ffi::c_void;
use std::mem;
use std::rc::Rc;
use std::sync::Arc;
use glutin::{Api, ContextBuilder, GlProfile, GlRequest, PossiblyCurrent, WindowedContext};
use glutin::event::{ElementState, Event, TouchPhase, VirtualKeyCode, WindowEvent};
use glutin::event_loop::{ControlFlow, EventLoop};
use glutin::window::WindowBuilder;
use glutin::{Api, ContextBuilder, GlProfile, GlRequest, PossiblyCurrent, WindowedContext};
use imgui::{DrawCmdParams, DrawData, DrawIdx, DrawVert};
use crate::game::Game;
use crate::game::GAME_SUSPENDED;
use crate::common::Rect;
use crate::framework::backend::{Backend, BackendEventLoop, BackendRenderer, BackendTexture, SpriteBatchCommand};
use crate::framework::context::Context;
@ -19,6 +18,8 @@ use crate::framework::error::GameResult;
use crate::framework::gl;
use crate::framework::keyboard::ScanCode;
use crate::framework::render_opengl::{GLContext, OpenGLRenderer};
use crate::game::Game;
use crate::game::GAME_SUSPENDED;
use crate::input::touch_controls::TouchPoint;
pub struct GlutinBackend;
@ -44,6 +45,10 @@ impl Backend for GlutinBackend {
Ok(Box::new(GlutinEventLoop { refs: Rc::new(UnsafeCell::new(None)) }))
}
fn as_any(&self) -> &dyn Any {
self
}
}
pub struct GlutinEventLoop {
@ -367,6 +372,10 @@ impl BackendEventLoop for GlutinEventLoop {
Ok(Box::new(OpenGLRenderer::new(gl_context, UnsafeCell::new(imgui))))
}
fn as_any(&self) -> &dyn Any {
self
}
}
fn conv_keycode(code: VirtualKeyCode) -> Option<ScanCode> {