-
-
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
Conversation
Err.. I don't understand what you're trying to achieve, but don't duplicate winit. Just continue importing it even on emscripten, but just don't call any of its functions. |
That breaks because winit doesn't support emscripten:
Like it's impossible to get it to compile for emscripten, unless there's some flag or trick that I don't know about? |
Winit should get a "null" backend which always returns an error when you try to use it. |
winit's got this thing in
A fresh pull of the master branch of winit fails to compile with target
|
Yes, what I mean is that winit should be modified to add a "null" implementation that is used instead of this "this_platform_is_not_supported" thing. |
Ohhh okay, sorry! |
So I think I got the default platform thing working, but I can't test because of the winit API transition thing; glutin doesn't compile with either emscripten or linux against the tip of winit, with or without my changes... Any recommendations on what to do next? |
Oh, I forgot about that. |
src/api/emscripten/mod.rs
Outdated
winit_builder: winit::WindowBuilder) | ||
-> Result<Window, CreationError> { | ||
|
||
let winit_window = winit_builder.build().unwrap(); |
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.
src/api/emscripten/mod.rs
Outdated
@@ -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 comment
The 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.
Fixed both I think |
So I've got some work done on adding in the hooks for mouse/keyboard events as well, would those be good to add to this PR, or would opening a new PR after this one's merged be better? |
@cactorium As you wish. |
So I guess I'll see how far I get before winit 0.5.11 gets published and submit whatever work I get done by then? Most of the event stuff should be working pretty solidly right now; the biggest hole left is converting to keys to |
All's ready except for the version change |
I just want to mention that I started implementing emscripten plateform in winit there I included keyboard but mouse because there was an issue with mousemove when the cursor is grabbed |
I'm hesitating between putting the emscripten stuff in glutin or in winit. The initial reason why I wanted to stick to glutin is that you can only use OpenGL with emscripten anyway, and that the concept of a "window" is a bit blurry when it comes to web pages. But that's a pretty weak argument, so I'm not sure. |
I kind of agree with the idea of having it in glutin because of the fact
that you don't really control a window. On the other hand, I think
emscripten supports using SDL instead of OpenGL, so maybe it'd make sense
to put event processing stuff in winit to share it across the two?
On Wed, Feb 15, 2017, 11:10 AM tomaka <notifications@github.com> wrote:
I'm hesitating between putting the emscripten stuff in glutin or in winit.
The initial reason why I wanted to stick to glutin is that you can only use
OpenGL with emscripten anyway, and that the concept of a "window" is a bit
blurry when it comes to web pages.
That being said Android has the same problem where you're manipulating a
window but the whole screen.
But that's a pretty weak argument, so I'm not sure.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#857 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABcW37Qyj51Xj16U9yroFC1NCnxxbjNgks5rcyOGgaJpZM4L-nvg>
.
|
My bad, I missed the version bump on winit. Cargo.toml's updated |
grab mode use pointerlock https://www.w3.org/TR/pointerlock/ this behavior is not the same as other backend. I wanted this because as set_cursor_position is not available on emscripten backend. the only way to have a FPS camera is to use pointerlock. So you can use grab to have FPS camera on emscripten. also show_mouse is implement in javascript as in a pull request that hasn't been merged emscripten-core/emscripten#4616
more implementations
two fixes: * when mouse is grabbed send relative mousemove event * when mouse grabbed is refused, ask again.
Implement touch + fix mouse grab + catch more errors
I got an issue when I use serde before building window. |
What errors are you getting? It looks like it runs fine on my computer |
it works on
|
I rewrite the example. Now it fails also on beta also. Also I don't know if this is the right place for discussing on this issue. I think it is related to emscripten backend itself. |
I have an issue related to hidpi_factor. On some smartphone (I suspect with HDPI of 2) my game was only showing the bottom-left quarter of the expected view. I solved it by forcing hdpi_factor method to always return 1. Also I found that our implementation of get_inner_size is not coherent with winit implementation. I don't have any hardware with HDPI different from one to test. |
Would something like this fix it? You probably have more experience with dealing with emscripten than me at this point, but it looks like using
Also what versions of stuff are you running? I can't build against the latest of everything because of the new |
Any updates on this? |
Not as far as I know, but the code here's dated now, since winit switched the EventLoop thing at 0.6. I'm working on redoing the work here to the latest glutin, but there hasn't been any word from the maintainers about it. My fork's master branch might be usable right now, in case anyone needs emscripten working right now |
@cactorium actually your fork doesnt work out of the box, or am i missing something?
|
@aep Hmm, it looks like one of the pull requests I merged broke some stuff, and I can't be bothered with trying to fix it if it'll basically be stuck at the version 0.7 anyways. It looks like "emscripten_events" still builds correctly, so I guess you could use that one for now |
I'm guessing this PR has been subsumed by subsequent additions to winit? |
Closing for inactivity. |
Mostly backporting winit functions into emscripten's platform module. It compiles and works against a modified version of badboy's glium example: https://github.com/cactorium/spring-crabs/tree/emscripten