Hi. I am very very new to rust.
This is a very noob question, but I am kinda stuck so hoping someone can help me out please.
I want to create a window for wgpu purposes.
- Create window.
- Load content while showing loading process text on window.
The problem is that once you run the event loop you can't return the window data.
So what I was thinking is doing:
- Create and cache event loop instance.
- Create window instance.
- Return to caller who will in turn call a run function to start the event loop.
I can't seem to cache the event loop.
It feels like I am missing something obvious.
use winit::{
event::*,
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
};
use winit::window::Window;
#[derive(Debug)]
pub struct Application {
event_loop: EventLoop<T>,
window: Window
}
impl Application {
pub fn new() -> Application {
let event_loop = EventLoop::new();
let window = WindowBuilder::new().build(Self.event_loop).unwrap();
Application {
event_loop,
window
}
}
}
The error I am getting is
error[E0412]: cannot find type `T` in this scope
--> src\.\core\application.rs:11:27
|
11 | event_loop: EventLoop<T>,
| ^ not found in this scope
|
help: there is an enum variant `crate::application::VirtualKeyCode::T` and 1 other; try using the variant's enum
|
11 | event_loop: EventLoop<crate::application::VirtualKeyCode>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11 | event_loop: EventLoop<winit::event::VirtualKeyCode>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: you might be missing a type parameter
|
10 | pub struct Application<T> {
| ^^^