-
-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Emscripten support #857
Closed
Closed
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
191cd57
Buildable for emscripten
cactorium d9dac49
Minor cleanup
cactorium 3af812b
Remove duplication of winit from emscripten platform
cactorium a6c7877
Remove winit_window from emscripten target
cactorium dfa621d
Add mouse callbacks
cactorium aa471ad
Add keyboard callbacks
cactorium 600e1a6
Update key to virtual code mapping
cactorium af606e2
Remove excessive logging
cactorium 8ca74e5
Update winit version to 0.5.11 and remove unnecssary use statements
cactorium 7c1c4b9
Use canvas coordinates instead of client coordinates
cactorium 84848af
fix warnings
acd4405
implement hidpi factor
10b3b77
impl get set size
b8cdab7
impl fullscreen and window dimensions
e844235
impl set_cursor_state
4cb2ea0
Merge pull request #1 from thiolliere/master
cactorium 35322ce
implement of touchevent
9e3fab2
fix mouse grab
352e3ee
catch more error
51ce5a3
coding style
791260b
consume event for pointerlock and fullscreen change
f2f099c
check result of get pointer lock status
21af3ab
Merge pull request #2 from thiolliere/master
cactorium 599ef9f
Merge branch 'master' into master
cactorium File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,13 +14,18 @@ use PixelFormat; | |
use PixelFormatRequirements; | ||
use WindowAttributes; | ||
|
||
use winit; | ||
pub use winit::WindowProxy; | ||
|
||
|
||
use std::collections::VecDeque; | ||
use platform::PlatformSpecificWindowBuilderAttributes; | ||
|
||
mod ffi; | ||
|
||
pub struct Window { | ||
context: ffi::EMSCRIPTEN_WEBGL_CONTEXT_HANDLE, | ||
winit_window: winit::Window, | ||
} | ||
|
||
pub struct PollEventsIterator<'a> { | ||
|
@@ -32,6 +37,7 @@ impl<'a> Iterator for PollEventsIterator<'a> { | |
|
||
#[inline] | ||
fn next(&mut self) -> Option<Event> { | ||
// TODO | ||
None | ||
} | ||
} | ||
|
@@ -45,56 +51,20 @@ impl<'a> Iterator for WaitEventsIterator<'a> { | |
|
||
#[inline] | ||
fn next(&mut self) -> Option<Event> { | ||
// TODO | ||
None | ||
} | ||
} | ||
|
||
#[derive(Clone)] | ||
pub struct WindowProxy; | ||
|
||
impl WindowProxy { | ||
#[inline] | ||
pub fn wakeup_event_loop(&self) { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
#[derive(Clone)] | ||
pub struct MonitorId; | ||
|
||
#[inline] | ||
pub fn get_available_monitors() -> VecDeque<MonitorId> { | ||
let mut list = VecDeque::new(); | ||
list.push_back(MonitorId); | ||
list | ||
} | ||
|
||
#[inline] | ||
pub fn get_primary_monitor() -> MonitorId { | ||
MonitorId | ||
} | ||
|
||
impl MonitorId { | ||
#[inline] | ||
pub fn get_name(&self) -> Option<String> { | ||
Some("Canvas".to_owned()) | ||
} | ||
|
||
#[inline] | ||
pub fn get_native_identifier(&self) -> ::native_monitor::NativeMonitorId { | ||
::native_monitor::NativeMonitorId::Unavailable | ||
} | ||
|
||
#[inline] | ||
pub fn get_dimensions(&self) -> (u32, u32) { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
impl Window { | ||
pub fn new(window: &WindowAttributes, pf_reqs: &PixelFormatRequirements, | ||
opengl: &GlAttributes<&Window>, _: &PlatformSpecificWindowBuilderAttributes) -> Result<Window, CreationError> | ||
{ | ||
pub fn new(_: &WindowAttributes, | ||
pf_reqs: &PixelFormatRequirements, | ||
opengl: &GlAttributes<&Window>, | ||
_: &PlatformSpecificWindowBuilderAttributes, | ||
winit_builder: winit::WindowBuilder) | ||
-> Result<Window, CreationError> { | ||
|
||
let winit_window = winit_builder.build().unwrap(); | ||
// getting the default values of attributes | ||
let mut attributes = unsafe { | ||
use std::mem; | ||
|
@@ -127,7 +97,8 @@ impl Window { | |
// TODO: emscripten_set_webglcontextrestored_callback | ||
|
||
Ok(Window { | ||
context: context | ||
context: context, | ||
winit_window: winit_window | ||
}) | ||
} | ||
|
||
|
@@ -190,7 +161,7 @@ impl Window { | |
|
||
#[inline] | ||
pub fn create_window_proxy(&self) -> WindowProxy { | ||
WindowProxy | ||
self.winit_window.create_window_proxy() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's fine to panic! here. Nobody uses the window proxy, and it's going to be removed soon. |
||
} | ||
|
||
#[inline] | ||
|
@@ -210,6 +181,7 @@ impl Window { | |
|
||
#[inline] | ||
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) { | ||
// TODO | ||
} | ||
|
||
#[inline] | ||
|
@@ -230,6 +202,31 @@ impl Window { | |
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()> { | ||
Ok(()) | ||
} | ||
|
||
#[inline] | ||
pub fn get_inner_size_points(&self) -> Option<(u32, u32)> { | ||
unimplemented!(); | ||
} | ||
|
||
#[inline] | ||
pub fn get_inner_size_pixels(&self) -> Option<(u32, u32)> { | ||
unimplemented!(); | ||
} | ||
|
||
#[inline] | ||
pub fn as_winit_window(&self) -> &winit::Window { | ||
&self.winit_window | ||
} | ||
|
||
#[inline] | ||
pub fn as_winit_window_mut(&mut self) -> &mut winit::Window { | ||
&mut self.winit_window | ||
} | ||
|
||
#[inline] | ||
pub fn hdpi_factor(&self) -> f32 { | ||
unimplemented!(); | ||
} | ||
} | ||
|
||
impl GlContext for Window { | ||
|
@@ -295,3 +292,5 @@ fn error_to_str(code: ffi::EMSCRIPTEN_RESULT) -> &'static str { | |
_ => "Undocumented error" | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is that you wouldn't use winit at all. Just don't call it, and remove the
winit_window
field from the struct.