-
-
Notifications
You must be signed in to change notification settings - Fork 477
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
Add the windows-static-egl
Cargo feature
#998
Conversation
Should mozangle be mentioned in the doc as a possible way to use this feature? Should mozangle be added as in #[cfg(not(windows))]
fn main() {
println!("This example only runs on Windows.");
}
#[cfg(windows)] extern crate mozangle;
#[cfg(windows)] extern crate glutin;
#[cfg(windows)]
fn main() {
use glutin::GlContext;
use glutin::os::GlContextExt;
use glutin::os::windows::RawHandle;
use mozangle::egl::get_proc_address;
use mozangle::gles::ffi as gl;
let mut events_loop = glutin::EventsLoop::new();
let window = glutin::WindowBuilder::new();
let context = glutin::ContextBuilder::new()
// Requesting OpenGlEs is required to make glutin try to use EGL.
.with_gl(glutin::GlRequest::Specific(glutin::Api::OpenGlEs, (2, 0)));
let gl_window = glutin::GlWindow::new(window, context, &events_loop).unwrap();
let handle = unsafe {
gl_window.context().raw_handle()
};
match handle {
RawHandle::Egl(_) => {},
RawHandle::Wgl(_) => panic!("Expected an EGL context, found a WGL one.")
}
assert_ne!(gl_window.get_proc_address("glClearColor"), 0 as _);
assert_eq!(gl_window.get_proc_address("glClearColor"), get_proc_address("glClearColor") as _);
unsafe {
gl_window.make_current().unwrap();
gl::ClearColor(0., 0.5, 0., 1.);
}
events_loop.run_forever(|event| {
match event {
glutin::Event::WindowEvent { event, .. } => match event {
glutin::WindowEvent::Closed => return glutin::ControlFlow::Break,
glutin::WindowEvent::Resized(w, h) => gl_window.resize(w, h),
_ => (),
},
_ => ()
}
unsafe {
gl::Clear(gl::COLOR_BUFFER_BIT);
}
gl_window.swap_buffers().unwrap();
glutin::ControlFlow::Continue
});
} |
a003e17
to
9b17572
Compare
The example program in the previous comment is subject to rust-windowing/winit#415. (Maybe Clear + swap_buffers is slow in debug mode? And re-rendering on non-resize events is unnecessary.) |
Switch from servo/angle to the mozangle crate https://github.com/servo/mozangle This is a step towards #2420. (The next step is blocked on rust-windowing/glutin#998.) <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2492) <!-- Reviewable:end -->
Switch from servo/angle to the mozangle crate https://github.com/servo/mozangle This is a step towards #2420. (The next step is blocked on rust-windowing/glutin#998.) <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2492) <!-- Reviewable:end -->
This allows using Glutin together with https://crates.io/crates/mozangle
9b17572
to
dfbab24
Compare
I'm not fan of this feature but I guess I will merge anyway. Please solve the conflict, and also please remove the example because for such a niche feature I don't think an example really makes sense. |
I’m not really a fan of it either. I think it’s preferable for WebRender/Wrench to use winit + EGL instead of this: servo/webrender#2529 |
Fixes #997: this allows using Glutin together with https://crates.io/crates/mozangle