use glutin/multi_window branch
This commit is contained in:
parent
ce43514eac
commit
a386788b67
4 changed files with 29 additions and 23 deletions
|
|
@ -31,7 +31,7 @@ pub fn main() {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let windowed_context = windowed_context.make_current().unwrap();
|
let windowed_context = windowed_context.make_current(todo!("derezzedex")).unwrap();
|
||||||
|
|
||||||
let gl = glow::Context::from_loader_function(|s| {
|
let gl = glow::Context::from_loader_function(|s| {
|
||||||
windowed_context.get_proc_address(s) as *const _
|
windowed_context.get_proc_address(s) as *const _
|
||||||
|
|
@ -181,7 +181,7 @@ pub fn main() {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
windowed_context.swap_buffers().unwrap();
|
windowed_context.swap_buffers(todo!("derezzedex")).unwrap();
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ version = "0.4"
|
||||||
|
|
||||||
[dependencies.glutin]
|
[dependencies.glutin]
|
||||||
version = "0.29"
|
version = "0.29"
|
||||||
git = "https://github.com/iced-rs/glutin"
|
git = "https://github.com/derezzedex/glutin"
|
||||||
rev = "da8d291486b4c9bec12487a46c119c4b1d386abf"
|
rev = "e72ea919f95106cfdfdce3e7dcfdbf71a432840a"
|
||||||
|
|
||||||
[dependencies.iced_native]
|
[dependencies.iced_native]
|
||||||
version = "0.7"
|
version = "0.7"
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ where
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe {
|
unsafe {
|
||||||
context.make_current().expect("Make OpenGL context current")
|
context.make_current(todo!()).expect("Make OpenGL context current")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -359,7 +359,7 @@ async fn run_instance<A, E, C>(
|
||||||
unsafe {
|
unsafe {
|
||||||
if !context.is_current() {
|
if !context.is_current() {
|
||||||
context = context
|
context = context
|
||||||
.make_current()
|
.make_current(todo!())
|
||||||
.expect("Make OpenGL context current");
|
.expect("Make OpenGL context current");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -415,7 +415,7 @@ async fn run_instance<A, E, C>(
|
||||||
&debug.overlay(),
|
&debug.overlay(),
|
||||||
);
|
);
|
||||||
|
|
||||||
context.swap_buffers().expect("Swap buffers");
|
context.swap_buffers(todo!()).expect("Swap buffers");
|
||||||
|
|
||||||
debug.render_finished();
|
debug.render_finished();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ where
|
||||||
runtime.enter(|| A::new(flags))
|
runtime.enter(|| A::new(flags))
|
||||||
};
|
};
|
||||||
|
|
||||||
let context = {
|
let (context, window) = {
|
||||||
let builder = settings.window.into_builder(
|
let builder = settings.window.into_builder(
|
||||||
&application.title(),
|
&application.title(),
|
||||||
event_loop.primary_monitor(),
|
event_loop.primary_monitor(),
|
||||||
|
|
@ -115,7 +115,14 @@ where
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe {
|
unsafe {
|
||||||
context.make_current().expect("Make OpenGL context current")
|
let (context, window) = context.split();
|
||||||
|
|
||||||
|
(
|
||||||
|
context
|
||||||
|
.make_current(&window)
|
||||||
|
.expect("Make OpenGL context current"),
|
||||||
|
window,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -137,6 +144,7 @@ where
|
||||||
debug,
|
debug,
|
||||||
receiver,
|
receiver,
|
||||||
context,
|
context,
|
||||||
|
window,
|
||||||
init_command,
|
init_command,
|
||||||
settings.exit_on_close_request,
|
settings.exit_on_close_request,
|
||||||
));
|
));
|
||||||
|
|
@ -205,7 +213,8 @@ async fn run_instance<A, E, C>(
|
||||||
mut receiver: mpsc::UnboundedReceiver<
|
mut receiver: mpsc::UnboundedReceiver<
|
||||||
glutin::event::Event<'_, Event<A::Message>>,
|
glutin::event::Event<'_, Event<A::Message>>,
|
||||||
>,
|
>,
|
||||||
context: glutin::ContextWrapper<glutin::PossiblyCurrent, Window>,
|
mut context: glutin::RawContext<glutin::PossiblyCurrent>,
|
||||||
|
window: Window,
|
||||||
init_command: Command<A::Message>,
|
init_command: Command<A::Message>,
|
||||||
_exit_on_close_request: bool,
|
_exit_on_close_request: bool,
|
||||||
) where
|
) where
|
||||||
|
|
@ -217,9 +226,9 @@ async fn run_instance<A, E, C>(
|
||||||
use glutin::event;
|
use glutin::event;
|
||||||
use iced_winit::futures::stream::StreamExt;
|
use iced_winit::futures::stream::StreamExt;
|
||||||
|
|
||||||
let mut clipboard = Clipboard::connect(context.window());
|
let mut clipboard = Clipboard::connect(&window);
|
||||||
let mut cache = user_interface::Cache::default();
|
let mut cache = user_interface::Cache::default();
|
||||||
let state = State::new(&application, context.window());
|
let state = State::new(&application, &window);
|
||||||
let user_interface = multi_window::build_user_interface(
|
let user_interface = multi_window::build_user_interface(
|
||||||
&application,
|
&application,
|
||||||
user_interface::Cache::default(),
|
user_interface::Cache::default(),
|
||||||
|
|
@ -229,9 +238,7 @@ async fn run_instance<A, E, C>(
|
||||||
window::Id::MAIN,
|
window::Id::MAIN,
|
||||||
);
|
);
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
let mut current_context_window = window.id();
|
||||||
let (mut context, window) = unsafe { context.split() };
|
|
||||||
|
|
||||||
let mut window_ids = HashMap::from([(window.id(), window::Id::MAIN)]);
|
let mut window_ids = HashMap::from([(window.id(), window::Id::MAIN)]);
|
||||||
let mut windows = HashMap::from([(window::Id::MAIN, window)]);
|
let mut windows = HashMap::from([(window::Id::MAIN, window)]);
|
||||||
let mut states = HashMap::from([(window::Id::MAIN, state)]);
|
let mut states = HashMap::from([(window::Id::MAIN, state)]);
|
||||||
|
|
@ -445,15 +452,19 @@ async fn run_instance<A, E, C>(
|
||||||
.get(&id)
|
.get(&id)
|
||||||
.and_then(|id| states.get_mut(id))
|
.and_then(|id| states.get_mut(id))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
let window =
|
||||||
|
window_ids.get(&id).and_then(|id| windows.get(id)).unwrap();
|
||||||
|
|
||||||
debug.render_started();
|
debug.render_started();
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe {
|
unsafe {
|
||||||
if !context.is_current() {
|
if current_context_window != id {
|
||||||
context = context
|
context = context
|
||||||
.make_current()
|
.make_current(window)
|
||||||
.expect("Make OpenGL context current");
|
.expect("Make OpenGL context current");
|
||||||
|
|
||||||
|
current_context_window = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -483,11 +494,6 @@ async fn run_instance<A, E, C>(
|
||||||
debug.draw_finished();
|
debug.draw_finished();
|
||||||
|
|
||||||
if new_mouse_interaction != mouse_interaction {
|
if new_mouse_interaction != mouse_interaction {
|
||||||
let window = window_ids
|
|
||||||
.get(&id)
|
|
||||||
.and_then(|id| windows.get_mut(id))
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
window.set_cursor_icon(conversion::mouse_interaction(
|
window.set_cursor_icon(conversion::mouse_interaction(
|
||||||
new_mouse_interaction,
|
new_mouse_interaction,
|
||||||
));
|
));
|
||||||
|
|
@ -513,7 +519,7 @@ async fn run_instance<A, E, C>(
|
||||||
&debug.overlay(),
|
&debug.overlay(),
|
||||||
);
|
);
|
||||||
|
|
||||||
context.swap_buffers().expect("Swap buffers");
|
context.swap_buffers(window).expect("Swap buffers");
|
||||||
|
|
||||||
debug.render_finished();
|
debug.render_finished();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue