Skip to content
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

Blank backend support. #1120

Merged
merged 1 commit into from
Mar 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions glutin/src/os/blank.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#![cfg(not(any(
target_os = "ios",
target_os = "windows",
target_os = "linux",
target_os = "macos",
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "emscripten",
)))]

use crate::Context;

impl ContextTraitExt for Context {
type Handle = !;

#[inline]
unsafe fn raw_handle(&self) -> Self::Handle {
unimplemented!("Glutin-Blank: Platform unsupported")
}

#[inline]
unsafe fn get_egl_display(&self) -> Option<*const raw::c_void> {
unimplemented!("Glutin-Blank: Platform unsupported")
}
}
1 change: 1 addition & 0 deletions glutin/src/os/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub mod ios;
pub mod macos;
pub mod unix;
pub mod windows;
pub mod blank;

use std::os::raw;

Expand Down
2 changes: 1 addition & 1 deletion glutin/src/os/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
target_os = "openbsd",
))]

use crate::os::ContextTraitExt;
Expand Down
2 changes: 1 addition & 1 deletion glutin/src/os/windows.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg(target_os = "windows")]

use crate::os::ContextTraitExt;
pub use crate::platform::{RawHandle, RawContextExt};
pub use crate::platform::{RawContextExt, RawHandle};
use crate::Context;
pub use glutin_egl_sys::EGLContext;

Expand Down
78 changes: 78 additions & 0 deletions glutin/src/platform/blank/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#![cfg(not(any(
target_os = "ios",
target_os = "windows",
target_os = "linux",
target_os = "macos",
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "emscripten",
)))]

use crate::{
Api, ContextError, CreationError, GlAttributes, PixelFormat,
PixelFormatRequirements,
};

use winit::dpi;

pub enum Context {}

impl Context {
#[inline]
pub fn new_windowed(
_: winit::WindowBuilder,
_: &winit::EventsLoop,
_: &PixelFormatRequirements,
_: &GlAttributes<&Context>,
) -> Result<(winit::Window, Self), CreationError> {
unimplemented!("Glutin-Blank: Platform unsupported")
}

#[inline]
pub fn new_headless(
_: &winit::EventsLoop,
_: &PixelFormatRequirements,
_: &GlAttributes<&Context>,
_: dpi::PhysicalSize,
) -> Result<Self, CreationError> {
unimplemented!("Glutin-Blank: Platform unsupported")
}

#[inline]
pub fn resize(&self, _: u32, _: u32) {
unimplemented!("Glutin-Blank: Platform unsupported")
}

#[inline]
pub unsafe fn make_current(&self) -> Result<(), ContextError> {
unimplemented!("Glutin-Blank: Platform unsupported")
}

#[inline]
pub fn is_current(&self) -> bool {
unimplemented!("Glutin-Blank: Platform unsupported")
}

#[inline]
pub fn get_proc_address(&self, _: &str) -> *const () {
unimplemented!("Glutin-Blank: Platform unsupported")
}

#[inline]
pub fn swap_buffers(&self) -> Result<(), ContextError> {
unimplemented!("Glutin-Blank: Platform unsupported")
}

#[inline]
pub fn get_api(&self) -> Api {
unimplemented!("Glutin-Blank: Platform unsupported")
}

#[inline]
pub fn get_pixel_format(&self) -> PixelFormat {
unimplemented!("Glutin-Blank: Platform unsupported")
}
}
7 changes: 3 additions & 4 deletions glutin/src/platform/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
target_os = "openbsd",
))]

mod wayland;
Expand All @@ -12,11 +12,10 @@ mod x11;
use self::x11::X11Context;
use crate::api::osmesa;
use crate::{
ContextError, CreationError, GlAttributes, PixelFormat,
Api, ContextError, CreationError, GlAttributes, PixelFormat,
PixelFormatRequirements,
};

use winit;
use winit::dpi;
use winit::os::unix::EventsLoopExt;

Expand Down Expand Up @@ -202,7 +201,7 @@ impl Context {
}

#[inline]
pub fn get_api(&self) -> crate::Api {
pub fn get_api(&self) -> Api {
match *self {
Context::WindowedX11(ref ctx)
| Context::HeadlessX11(_, ref ctx) => ctx.get_api(),
Expand Down
29 changes: 15 additions & 14 deletions glutin/src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod platform;
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
target_os = "openbsd",
))]
#[path = "linux/mod.rs"]
mod platform;
Expand All @@ -25,16 +25,17 @@ mod platform;
#[path = "emscripten/mod.rs"]
mod platform;

#[cfg(all(
not(target_os = "ios"),
not(target_os = "windows"),
not(target_os = "linux"),
not(target_os = "macos"),
not(target_os = "android"),
not(target_os = "dragonfly"),
not(target_os = "freebsd"),
not(target_os = "netbsd"),
not(target_os = "openbsd"),
not(target_os = "emscripten")
))]
use this_platform_is_not_supported;
#[cfg(not(any(
target_os = "ios",
target_os = "windows",
target_os = "linux",
target_os = "macos",
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "emscripten",
)))]
#[path = "blank/mod.rs"]
mod platform;
3 changes: 2 additions & 1 deletion glutin/src/platform/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ impl Context {
_ => panic!(),
});
unsafe {
WglContext::new(&pf_reqs, &gl_attr_wgl, hwnd).map(Context::Wgl)
WglContext::new(&pf_reqs, &gl_attr_wgl, hwnd)
.map(Context::Wgl)
}
}
}
Expand Down
11 changes: 7 additions & 4 deletions glutin_examples/examples/raw_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ fn main() {

#[cfg(any(target_os = "linux", target_os = "windows"))]
mod this_example {
use glutin::ContextTrait;
use super::support;
use glutin::ContextTrait;

pub fn main() {
let (raw_context, mut el, win) = {
Expand Down Expand Up @@ -49,8 +49,9 @@ mod this_example {
} else {
let xconn = el.get_xlib_xconnection().unwrap();
let xwindow = win.get_xlib_window().unwrap();
raw_context =
glutin::Context::new_raw_x11_context(xconn, xwindow, cb);
raw_context = glutin::Context::new_raw_x11_context(
xconn, xwindow, cb,
);
}

(raw_context.unwrap(), el, win)
Expand Down Expand Up @@ -93,7 +94,9 @@ mod this_example {
},
..
}
| glutin::WindowEvent::CloseRequested => running = false,
| glutin::WindowEvent::CloseRequested => {
running = false
}
glutin::WindowEvent::Resized(logical_size) => {
let dpi_factor = win.get_hidpi_factor();
raw_context
Expand Down