Make it compile on Linux
This commit is contained in:
parent
b4d4fee8b6
commit
16f76b2407
11 changed files with 16 additions and 729 deletions
|
|
@ -4,15 +4,10 @@ pub use api::x11::{WaitEventsIterator, PollEventsIterator};*/
|
|||
use std::collections::VecDeque;
|
||||
use std::sync::Arc;
|
||||
|
||||
use ContextError;
|
||||
use CreationError;
|
||||
use CursorState;
|
||||
use Event;
|
||||
use GlAttributes;
|
||||
use GlContext;
|
||||
use MouseCursor;
|
||||
use PixelFormat;
|
||||
use PixelFormatRequirements;
|
||||
use WindowAttributes;
|
||||
use libc;
|
||||
|
||||
|
|
@ -174,30 +169,22 @@ impl<'a> Iterator for WaitEventsIterator<'a> {
|
|||
|
||||
impl Window {
|
||||
#[inline]
|
||||
pub fn new(window: &WindowAttributes, pf_reqs: &PixelFormatRequirements,
|
||||
opengl: &GlAttributes<&Window>, _: &PlatformSpecificWindowBuilderAttributes)
|
||||
pub fn new(window: &WindowAttributes, _: &PlatformSpecificWindowBuilderAttributes)
|
||||
-> Result<Window, CreationError>
|
||||
{
|
||||
match *BACKEND {
|
||||
Backend::Wayland => {
|
||||
let opengl = opengl.clone().map_sharing(|w| match w {
|
||||
&Window::Wayland(ref w) => w,
|
||||
_ => panic!() // TODO: return an error
|
||||
});
|
||||
|
||||
wayland::Window::new(window, pf_reqs, &opengl).map(Window::Wayland)
|
||||
wayland::Window::new(window).map(Window::Wayland)
|
||||
},
|
||||
|
||||
Backend::X(ref connec) => {
|
||||
let opengl = opengl.clone().map_sharing(|w| match w {
|
||||
&Window::X(ref w) => w,
|
||||
_ => panic!() // TODO: return an error
|
||||
});
|
||||
|
||||
x11::Window::new(connec, window, pf_reqs, &opengl).map(Window::X)
|
||||
x11::Window::new(connec, window).map(Window::X)
|
||||
},
|
||||
|
||||
Backend::Error(ref error) => Err(CreationError::NoBackendAvailable(Box::new(error.clone())))
|
||||
Backend::Error(ref error) => {
|
||||
panic!() // FIXME: supposed to return an error
|
||||
//Err(CreationError::NoBackendAvailable(Box::new(error.clone())))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -346,56 +333,6 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
impl GlContext for Window {
|
||||
#[inline]
|
||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||
match self {
|
||||
&Window::X(ref w) => w.make_current(),
|
||||
&Window::Wayland(ref w) => w.make_current()
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_current(&self) -> bool {
|
||||
match self {
|
||||
&Window::X(ref w) => w.is_current(),
|
||||
&Window::Wayland(ref w) => w.is_current()
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_proc_address(&self, addr: &str) -> *const () {
|
||||
match self {
|
||||
&Window::X(ref w) => w.get_proc_address(addr),
|
||||
&Window::Wayland(ref w) => w.get_proc_address(addr)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||
match self {
|
||||
&Window::X(ref w) => w.swap_buffers(),
|
||||
&Window::Wayland(ref w) => w.swap_buffers()
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_api(&self) -> ::Api {
|
||||
match self {
|
||||
&Window::X(ref w) => w.get_api(),
|
||||
&Window::Wayland(ref w) => w.get_api()
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_pixel_format(&self) -> PixelFormat {
|
||||
match self {
|
||||
&Window::X(ref w) => w.get_pixel_format(),
|
||||
&Window::Wayland(ref w) => w.get_pixel_format()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe extern "C" fn x_error_callback(dpy: *mut x11::ffi::Display, event: *mut x11::ffi::XErrorEvent)
|
||||
-> libc::c_int
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,71 +1,7 @@
|
|||
#![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))]
|
||||
|
||||
use Api;
|
||||
use ContextError;
|
||||
use CreationError;
|
||||
use GlAttributes;
|
||||
use GlContext;
|
||||
use PixelFormat;
|
||||
use PixelFormatRequirements;
|
||||
|
||||
use api::osmesa::{self, OsMesaContext};
|
||||
|
||||
pub use self::api_dispatch::{Window, WindowProxy, MonitorId, get_available_monitors, get_primary_monitor};
|
||||
pub use self::api_dispatch::{WaitEventsIterator, PollEventsIterator};
|
||||
pub use self::api_dispatch::PlatformSpecificWindowBuilderAttributes;
|
||||
|
||||
mod api_dispatch;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct PlatformSpecificHeadlessBuilderAttributes;
|
||||
|
||||
pub struct HeadlessContext(OsMesaContext);
|
||||
|
||||
impl HeadlessContext {
|
||||
pub fn new(dimensions: (u32, u32), pf_reqs: &PixelFormatRequirements,
|
||||
opengl: &GlAttributes<&HeadlessContext>,
|
||||
_: &PlatformSpecificHeadlessBuilderAttributes)
|
||||
-> Result<HeadlessContext, CreationError>
|
||||
{
|
||||
let opengl = opengl.clone().map_sharing(|c| &c.0);
|
||||
|
||||
match OsMesaContext::new(dimensions, pf_reqs, &opengl) {
|
||||
Ok(c) => return Ok(HeadlessContext(c)),
|
||||
Err(osmesa::OsMesaCreationError::NotSupported) => (),
|
||||
Err(osmesa::OsMesaCreationError::CreationError(e)) => return Err(e),
|
||||
};
|
||||
|
||||
Err(CreationError::NotSupported)
|
||||
}
|
||||
}
|
||||
|
||||
impl GlContext for HeadlessContext {
|
||||
#[inline]
|
||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||
self.0.make_current()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_current(&self) -> bool {
|
||||
self.0.is_current()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_proc_address(&self, addr: &str) -> *const () {
|
||||
self.0.get_proc_address(addr)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||
self.0.swap_buffers()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_api(&self) -> Api {
|
||||
self.0.get_api()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_pixel_format(&self) -> PixelFormat {
|
||||
self.0.get_pixel_format()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue