mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 06:41:31 +11:00
Add #[inline] attributes
This commit is contained in:
parent
3820d307a3
commit
aa9cb99929
|
@ -36,25 +36,30 @@ pub struct MonitorID;
|
||||||
|
|
||||||
mod ffi;
|
mod ffi;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
||||||
let mut rb = VecDeque::new();
|
let mut rb = VecDeque::new();
|
||||||
rb.push_back(MonitorID);
|
rb.push_back(MonitorID);
|
||||||
rb
|
rb
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_primary_monitor() -> MonitorID {
|
pub fn get_primary_monitor() -> MonitorID {
|
||||||
MonitorID
|
MonitorID
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MonitorID {
|
impl MonitorID {
|
||||||
|
#[inline]
|
||||||
pub fn get_name(&self) -> Option<String> {
|
pub fn get_name(&self) -> Option<String> {
|
||||||
Some("Primary".to_string())
|
Some("Primary".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_native_identifier(&self) -> NativeMonitorId {
|
pub fn get_native_identifier(&self) -> NativeMonitorId {
|
||||||
NativeMonitorId::Unavailable
|
NativeMonitorId::Unavailable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_dimensions(&self) -> (u32, u32) {
|
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
@ -95,6 +100,7 @@ pub struct WaitEventsIterator<'a> {
|
||||||
impl<'a> Iterator for WaitEventsIterator<'a> {
|
impl<'a> Iterator for WaitEventsIterator<'a> {
|
||||||
type Item = Event;
|
type Item = Event;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn next(&mut self) -> Option<Event> {
|
fn next(&mut self) -> Option<Event> {
|
||||||
loop {
|
loop {
|
||||||
// calling poll_events()
|
// calling poll_events()
|
||||||
|
@ -134,26 +140,33 @@ impl Window {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn is_closed(&self) -> bool {
|
pub fn is_closed(&self) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_title(&self, _: &str) {
|
pub fn set_title(&self, _: &str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn show(&self) {
|
pub fn show(&self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn hide(&self) {
|
pub fn hide(&self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_position(&self) -> Option<(i32, i32)> {
|
pub fn get_position(&self) -> Option<(i32, i32)> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_position(&self, _x: i32, _y: i32) {
|
pub fn set_position(&self, _x: i32, _y: i32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
||||||
let native_window = unsafe { android_glue::get_native_window() };
|
let native_window = unsafe { android_glue::get_native_window() };
|
||||||
|
|
||||||
|
@ -167,55 +180,68 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
||||||
self.get_inner_size()
|
self.get_inner_size()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_inner_size(&self, _x: u32, _y: u32) {
|
pub fn set_inner_size(&self, _x: u32, _y: u32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn create_window_proxy(&self) -> WindowProxy {
|
pub fn create_window_proxy(&self) -> WindowProxy {
|
||||||
WindowProxy
|
WindowProxy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn poll_events(&self) -> PollEventsIterator {
|
pub fn poll_events(&self) -> PollEventsIterator {
|
||||||
PollEventsIterator {
|
PollEventsIterator {
|
||||||
window: self
|
window: self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn wait_events(&self) -> WaitEventsIterator {
|
pub fn wait_events(&self) -> WaitEventsIterator {
|
||||||
WaitEventsIterator {
|
WaitEventsIterator {
|
||||||
window: self
|
window: self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn platform_display(&self) -> *mut libc::c_void {
|
pub fn platform_display(&self) -> *mut libc::c_void {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn platform_window(&self) -> *mut libc::c_void {
|
pub fn platform_window(&self) -> *mut libc::c_void {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_pixel_format(&self) -> PixelFormat {
|
pub fn get_pixel_format(&self) -> PixelFormat {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor(&self, _: MouseCursor) {
|
pub fn set_cursor(&self, _: MouseCursor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
|
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn hidpi_factor(&self) -> f32 {
|
pub fn hidpi_factor(&self) -> f32 {
|
||||||
1.0
|
1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()> {
|
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()> {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
@ -225,26 +251,32 @@ unsafe impl Send for Window {}
|
||||||
unsafe impl Sync for Window {}
|
unsafe impl Sync for Window {}
|
||||||
|
|
||||||
impl GlContext for Window {
|
impl GlContext for Window {
|
||||||
|
#[inline]
|
||||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||||
self.context.make_current()
|
self.context.make_current()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_current(&self) -> bool {
|
fn is_current(&self) -> bool {
|
||||||
self.context.is_current()
|
self.context.is_current()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
||||||
self.context.get_proc_address(addr)
|
self.context.get_proc_address(addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||||
self.context.swap_buffers()
|
self.context.swap_buffers()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_api(&self) -> Api {
|
fn get_api(&self) -> Api {
|
||||||
self.context.get_api()
|
self.context.get_api()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_pixel_format(&self) -> PixelFormat {
|
fn get_pixel_format(&self) -> PixelFormat {
|
||||||
self.context.get_pixel_format()
|
self.context.get_pixel_format()
|
||||||
}
|
}
|
||||||
|
@ -255,6 +287,7 @@ impl GlContext for Window {
|
||||||
pub struct WindowProxy;
|
pub struct WindowProxy;
|
||||||
|
|
||||||
impl WindowProxy {
|
impl WindowProxy {
|
||||||
|
#[inline]
|
||||||
pub fn wakeup_event_loop(&self) {
|
pub fn wakeup_event_loop(&self) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
@ -279,26 +312,32 @@ unsafe impl Send for HeadlessContext {}
|
||||||
unsafe impl Sync for HeadlessContext {}
|
unsafe impl Sync for HeadlessContext {}
|
||||||
|
|
||||||
impl GlContext for HeadlessContext {
|
impl GlContext for HeadlessContext {
|
||||||
|
#[inline]
|
||||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||||
self.0.make_current()
|
self.0.make_current()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_current(&self) -> bool {
|
fn is_current(&self) -> bool {
|
||||||
self.0.is_current()
|
self.0.is_current()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
||||||
self.0.get_proc_address(addr)
|
self.0.get_proc_address(addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||||
self.0.swap_buffers()
|
self.0.swap_buffers()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_api(&self) -> Api {
|
fn get_api(&self) -> Api {
|
||||||
self.0.get_api()
|
self.0.get_api()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_pixel_format(&self) -> PixelFormat {
|
fn get_pixel_format(&self) -> PixelFormat {
|
||||||
self.0.get_pixel_format()
|
self.0.get_pixel_format()
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ pub struct Window {
|
||||||
pub struct WindowProxy;
|
pub struct WindowProxy;
|
||||||
|
|
||||||
impl WindowProxy {
|
impl WindowProxy {
|
||||||
|
#[inline]
|
||||||
pub fn wakeup_event_loop(&self) {
|
pub fn wakeup_event_loop(&self) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
@ -40,22 +41,27 @@ impl WindowProxy {
|
||||||
|
|
||||||
pub struct MonitorID;
|
pub struct MonitorID;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
||||||
VecDeque::new()
|
VecDeque::new()
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
pub fn get_primary_monitor() -> MonitorID {
|
pub fn get_primary_monitor() -> MonitorID {
|
||||||
MonitorID
|
MonitorID
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MonitorID {
|
impl MonitorID {
|
||||||
|
#[inline]
|
||||||
pub fn get_name(&self) -> Option<String> {
|
pub fn get_name(&self) -> Option<String> {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_native_identifier(&self) -> ::native_monitor::NativeMonitorId {
|
pub fn get_native_identifier(&self) -> ::native_monitor::NativeMonitorId {
|
||||||
::native_monitor::NativeMonitorId::Unavailable
|
::native_monitor::NativeMonitorId::Unavailable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_dimensions(&self) -> (u32, u32) {
|
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
@ -68,6 +74,7 @@ pub struct PollEventsIterator<'a> {
|
||||||
impl<'a> Iterator for PollEventsIterator<'a> {
|
impl<'a> Iterator for PollEventsIterator<'a> {
|
||||||
type Item = Event;
|
type Item = Event;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn next(&mut self) -> Option<Event> {
|
fn next(&mut self) -> Option<Event> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -80,6 +87,7 @@ pub struct WaitEventsIterator<'a> {
|
||||||
impl<'a> Iterator for WaitEventsIterator<'a> {
|
impl<'a> Iterator for WaitEventsIterator<'a> {
|
||||||
type Item = Event;
|
type Item = Event;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn next(&mut self) -> Option<Event> {
|
fn next(&mut self) -> Option<Event> {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
@ -138,94 +146,117 @@ impl Window {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_title(&self, title: &str) {
|
pub fn set_title(&self, title: &str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn show(&self) {
|
pub fn show(&self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn hide(&self) {
|
pub fn hide(&self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_position(&self) -> Option<(i32, i32)> {
|
pub fn get_position(&self) -> Option<(i32, i32)> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_position(&self, x: i32, y: i32) {
|
pub fn set_position(&self, x: i32, y: i32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
||||||
Some(self.opengl.get_dimensions())
|
Some(self.opengl.get_dimensions())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
||||||
self.get_inner_size()
|
self.get_inner_size()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_inner_size(&self, _x: u32, _y: u32) {
|
pub fn set_inner_size(&self, _x: u32, _y: u32) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn create_window_proxy(&self) -> WindowProxy {
|
pub fn create_window_proxy(&self) -> WindowProxy {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn poll_events(&self) -> PollEventsIterator {
|
pub fn poll_events(&self) -> PollEventsIterator {
|
||||||
PollEventsIterator {
|
PollEventsIterator {
|
||||||
window: self
|
window: self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn wait_events(&self) -> WaitEventsIterator {
|
pub fn wait_events(&self) -> WaitEventsIterator {
|
||||||
WaitEventsIterator {
|
WaitEventsIterator {
|
||||||
window: self
|
window: self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn platform_display(&self) -> *mut libc::c_void {
|
pub fn platform_display(&self) -> *mut libc::c_void {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn platform_window(&self) -> *mut libc::c_void {
|
pub fn platform_window(&self) -> *mut libc::c_void {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_pixel_format(&self) -> PixelFormat {
|
pub fn get_pixel_format(&self) -> PixelFormat {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor(&self, cursor: MouseCursor) {
|
pub fn set_cursor(&self, cursor: MouseCursor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
|
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn hidpi_factor(&self) -> f32 {
|
pub fn hidpi_factor(&self) -> f32 {
|
||||||
1.0
|
1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()> {
|
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlContext for Window {
|
impl GlContext for Window {
|
||||||
|
#[inline]
|
||||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||||
self.opengl.make_current()
|
self.opengl.make_current()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_current(&self) -> bool {
|
fn is_current(&self) -> bool {
|
||||||
self.opengl.is_current()
|
self.opengl.is_current()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
||||||
self.opengl.get_proc_address(addr)
|
self.opengl.get_proc_address(addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let canvas = (self.libcaca.caca_get_canvas)(self.display);
|
let canvas = (self.libcaca.caca_get_canvas)(self.display);
|
||||||
|
@ -244,16 +275,19 @@ impl GlContext for Window {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_api(&self) -> Api {
|
fn get_api(&self) -> Api {
|
||||||
self.opengl.get_api()
|
self.opengl.get_api()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_pixel_format(&self) -> PixelFormat {
|
fn get_pixel_format(&self) -> PixelFormat {
|
||||||
self.opengl.get_pixel_format()
|
self.opengl.get_pixel_format()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Window {
|
impl Drop for Window {
|
||||||
|
#[inline]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
(self.libcaca.caca_free_dither)(self.dither);
|
(self.libcaca.caca_free_dither)(self.dither);
|
||||||
|
|
|
@ -85,10 +85,12 @@ impl GlContext for HeadlessContext {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_current(&self) -> bool {
|
fn is_current(&self) -> bool {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_proc_address(&self, _addr: &str) -> *const libc::c_void {
|
fn get_proc_address(&self, _addr: &str) -> *const libc::c_void {
|
||||||
let symbol_name: CFString = _addr.parse().unwrap();
|
let symbol_name: CFString = _addr.parse().unwrap();
|
||||||
let framework_name: CFString = "com.apple.opengl".parse().unwrap();
|
let framework_name: CFString = "com.apple.opengl".parse().unwrap();
|
||||||
|
@ -101,14 +103,17 @@ impl GlContext for HeadlessContext {
|
||||||
symbol as *const libc::c_void
|
symbol as *const libc::c_void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_api(&self) -> ::Api {
|
fn get_api(&self) -> ::Api {
|
||||||
::Api::OpenGl
|
::Api::OpenGl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_pixel_format(&self) -> PixelFormat {
|
fn get_pixel_format(&self) -> PixelFormat {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
@ -118,6 +123,7 @@ unsafe impl Send for HeadlessContext {}
|
||||||
unsafe impl Sync for HeadlessContext {}
|
unsafe impl Sync for HeadlessContext {}
|
||||||
|
|
||||||
impl Drop for HeadlessContext {
|
impl Drop for HeadlessContext {
|
||||||
|
#[inline]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
gl::DeleteTextures(1, &texture);
|
gl::DeleteTextures(1, &texture);
|
||||||
|
|
|
@ -568,10 +568,12 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn show(&self) {
|
pub fn show(&self) {
|
||||||
unsafe { NSWindow::makeKeyAndOrderFront_(*self.window, nil); }
|
unsafe { NSWindow::makeKeyAndOrderFront_(*self.window, nil); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn hide(&self) {
|
pub fn hide(&self) {
|
||||||
unsafe { NSWindow::orderOut_(*self.window, nil); }
|
unsafe { NSWindow::orderOut_(*self.window, nil); }
|
||||||
}
|
}
|
||||||
|
@ -606,6 +608,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let view_frame = NSView::frame(*self.view);
|
let view_frame = NSView::frame(*self.view);
|
||||||
|
@ -613,6 +616,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let window_frame = NSWindow::frame(*self.window);
|
let window_frame = NSWindow::frame(*self.window);
|
||||||
|
@ -620,22 +624,26 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_inner_size(&self, width: u32, height: u32) {
|
pub fn set_inner_size(&self, width: u32, height: u32) {
|
||||||
unsafe {
|
unsafe {
|
||||||
NSWindow::setContentSize_(*self.window, NSSize::new(width as f64, height as f64));
|
NSWindow::setContentSize_(*self.window, NSSize::new(width as f64, height as f64));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn create_window_proxy(&self) -> WindowProxy {
|
pub fn create_window_proxy(&self) -> WindowProxy {
|
||||||
WindowProxy
|
WindowProxy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn poll_events(&self) -> PollEventsIterator {
|
pub fn poll_events(&self) -> PollEventsIterator {
|
||||||
PollEventsIterator {
|
PollEventsIterator {
|
||||||
window: self
|
window: self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn wait_events(&self) -> WaitEventsIterator {
|
pub fn wait_events(&self) -> WaitEventsIterator {
|
||||||
WaitEventsIterator {
|
WaitEventsIterator {
|
||||||
window: self
|
window: self
|
||||||
|
@ -652,14 +660,17 @@ impl Window {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn platform_display(&self) -> *mut libc::c_void {
|
pub fn platform_display(&self) -> *mut libc::c_void {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn platform_window(&self) -> *mut libc::c_void {
|
pub fn platform_window(&self) -> *mut libc::c_void {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_window_resize_callback(&mut self, callback: Option<fn(u32, u32)>) {
|
pub fn set_window_resize_callback(&mut self, callback: Option<fn(u32, u32)>) {
|
||||||
self.delegate.state.resize_handler = callback;
|
self.delegate.state.resize_handler = callback;
|
||||||
}
|
}
|
||||||
|
@ -723,24 +734,28 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn hidpi_factor(&self) -> f32 {
|
pub fn hidpi_factor(&self) -> f32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
NSWindow::backingScaleFactor(*self.window) as f32
|
NSWindow::backingScaleFactor(*self.window) as f32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()> {
|
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()> {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlContext for Window {
|
impl GlContext for Window {
|
||||||
|
#[inline]
|
||||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||||
let _: () = msg_send![*self.context, update];
|
let _: () = msg_send![*self.context, update];
|
||||||
self.context.makeCurrentContext();
|
self.context.makeCurrentContext();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_current(&self) -> bool {
|
fn is_current(&self) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let current = NSOpenGLContext::currentContext(nil);
|
let current = NSOpenGLContext::currentContext(nil);
|
||||||
|
@ -765,15 +780,18 @@ impl GlContext for Window {
|
||||||
symbol as *const _
|
symbol as *const _
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||||
unsafe { self.context.flushBuffer(); }
|
unsafe { self.context.flushBuffer(); }
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_api(&self) -> ::Api {
|
fn get_api(&self) -> ::Api {
|
||||||
::Api::OpenGl
|
::Api::OpenGl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_pixel_format(&self) -> PixelFormat {
|
fn get_pixel_format(&self) -> PixelFormat {
|
||||||
self.pixel_format.clone()
|
self.pixel_format.clone()
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
||||||
monitors
|
monitors
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_primary_monitor() -> MonitorID {
|
pub fn get_primary_monitor() -> MonitorID {
|
||||||
let id = unsafe {
|
let id = unsafe {
|
||||||
MonitorID(display::CGMainDisplayID())
|
MonitorID(display::CGMainDisplayID())
|
||||||
|
@ -37,6 +38,7 @@ impl MonitorID {
|
||||||
Some(format!("Monitor #{}", screen_num))
|
Some(format!("Monitor #{}", screen_num))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_native_identifier(&self) -> NativeMonitorId {
|
pub fn get_native_identifier(&self) -> NativeMonitorId {
|
||||||
let MonitorID(display_id) = *self;
|
let MonitorID(display_id) = *self;
|
||||||
NativeMonitorId::Numeric(display_id)
|
NativeMonitorId::Numeric(display_id)
|
||||||
|
|
|
@ -44,6 +44,7 @@ pub struct Context {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
|
#[inline]
|
||||||
fn get_native_display(egl: &ffi::egl::Egl,
|
fn get_native_display(egl: &ffi::egl::Egl,
|
||||||
native_display: NativeDisplay) -> *const libc::c_void {
|
native_display: NativeDisplay) -> *const libc::c_void {
|
||||||
unsafe { egl.GetDisplay(ffi::egl::DEFAULT_DISPLAY as *mut _) }
|
unsafe { egl.GetDisplay(ffi::egl::DEFAULT_DISPLAY as *mut _) }
|
||||||
|
@ -278,6 +279,7 @@ impl GlContext for Context {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_current(&self) -> bool {
|
fn is_current(&self) -> bool {
|
||||||
unsafe { self.egl.GetCurrentContext() == self.context }
|
unsafe { self.egl.GetCurrentContext() == self.context }
|
||||||
}
|
}
|
||||||
|
@ -290,6 +292,7 @@ impl GlContext for Context {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||||
let ret = unsafe {
|
let ret = unsafe {
|
||||||
self.egl.SwapBuffers(self.display, self.surface)
|
self.egl.SwapBuffers(self.display, self.surface)
|
||||||
|
@ -306,10 +309,12 @@ impl GlContext for Context {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_api(&self) -> Api {
|
fn get_api(&self) -> Api {
|
||||||
self.api
|
self.api
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_pixel_format(&self) -> PixelFormat {
|
fn get_pixel_format(&self) -> PixelFormat {
|
||||||
self.pixel_format.clone()
|
self.pixel_format.clone()
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ pub struct PollEventsIterator<'a> {
|
||||||
impl<'a> Iterator for PollEventsIterator<'a> {
|
impl<'a> Iterator for PollEventsIterator<'a> {
|
||||||
type Item = Event;
|
type Item = Event;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn next(&mut self) -> Option<Event> {
|
fn next(&mut self) -> Option<Event> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -35,6 +36,7 @@ pub struct WaitEventsIterator<'a> {
|
||||||
impl<'a> Iterator for WaitEventsIterator<'a> {
|
impl<'a> Iterator for WaitEventsIterator<'a> {
|
||||||
type Item = Event;
|
type Item = Event;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn next(&mut self) -> Option<Event> {
|
fn next(&mut self) -> Option<Event> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -44,6 +46,7 @@ impl<'a> Iterator for WaitEventsIterator<'a> {
|
||||||
pub struct WindowProxy;
|
pub struct WindowProxy;
|
||||||
|
|
||||||
impl WindowProxy {
|
impl WindowProxy {
|
||||||
|
#[inline]
|
||||||
pub fn wakeup_event_loop(&self) {
|
pub fn wakeup_event_loop(&self) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
@ -51,21 +54,25 @@ impl WindowProxy {
|
||||||
|
|
||||||
pub struct MonitorID;
|
pub struct MonitorID;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
||||||
let mut list = VecDeque::new();
|
let mut list = VecDeque::new();
|
||||||
list.push_back(MonitorID);
|
list.push_back(MonitorID);
|
||||||
list
|
list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_primary_monitor() -> MonitorID {
|
pub fn get_primary_monitor() -> MonitorID {
|
||||||
MonitorID
|
MonitorID
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MonitorID {
|
impl MonitorID {
|
||||||
|
#[inline]
|
||||||
pub fn get_name(&self) -> Option<String> {
|
pub fn get_name(&self) -> Option<String> {
|
||||||
Some("Canvas".to_string())
|
Some("Canvas".to_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_dimensions(&self) -> (u32, u32) {
|
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
@ -109,13 +116,16 @@ impl Window {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_title(&self, _title: &str) {
|
pub fn set_title(&self, _title: &str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_position(&self) -> Option<(i32, i32)> {
|
pub fn get_position(&self) -> Option<(i32, i32)> {
|
||||||
Some((0, 0))
|
Some((0, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_position(&self, _: i32, _: i32) {
|
pub fn set_position(&self, _: i32, _: i32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,10 +145,12 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
||||||
self.get_inner_size()
|
self.get_inner_size()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_inner_size(&self, width: u32, height: u32) {
|
pub fn set_inner_size(&self, width: u32, height: u32) {
|
||||||
unsafe {
|
unsafe {
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
@ -147,52 +159,64 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn poll_events(&self) -> PollEventsIterator {
|
pub fn poll_events(&self) -> PollEventsIterator {
|
||||||
PollEventsIterator {
|
PollEventsIterator {
|
||||||
window: self,
|
window: self,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn wait_events(&self) -> WaitEventsIterator {
|
pub fn wait_events(&self) -> WaitEventsIterator {
|
||||||
WaitEventsIterator {
|
WaitEventsIterator {
|
||||||
window: self,
|
window: self,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn create_window_proxy(&self) -> WindowProxy {
|
pub fn create_window_proxy(&self) -> WindowProxy {
|
||||||
WindowProxy
|
WindowProxy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn show(&self) {}
|
pub fn show(&self) {}
|
||||||
|
#[inline]
|
||||||
pub fn hide(&self) {}
|
pub fn hide(&self) {}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn platform_display(&self) -> *mut libc::c_void {
|
pub fn platform_display(&self) -> *mut libc::c_void {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn platform_window(&self) -> *mut libc::c_void {
|
pub fn platform_window(&self) -> *mut libc::c_void {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor(&self, _cursor: MouseCursor) {
|
pub fn set_cursor(&self, _cursor: MouseCursor) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn hidpi_factor(&self) -> f32 {
|
pub fn hidpi_factor(&self) -> f32 {
|
||||||
1.0
|
1.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlContext for Window {
|
impl GlContext for Window {
|
||||||
|
#[inline]
|
||||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||||
// TOOD: check if == EMSCRIPTEN_RESULT
|
// TOOD: check if == EMSCRIPTEN_RESULT
|
||||||
ffi::emscripten_webgl_make_context_current(self.context);
|
ffi::emscripten_webgl_make_context_current(self.context);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_current(&self) -> bool {
|
fn is_current(&self) -> bool {
|
||||||
true // FIXME:
|
true // FIXME:
|
||||||
}
|
}
|
||||||
|
@ -206,15 +230,18 @@ impl GlContext for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||||
unsafe { ffi::emscripten_sleep(1); } // FIXME:
|
unsafe { ffi::emscripten_sleep(1); } // FIXME:
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_api(&self) -> Api {
|
fn get_api(&self) -> Api {
|
||||||
Api::WebGl
|
Api::WebGl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_pixel_format(&self) -> PixelFormat {
|
fn get_pixel_format(&self) -> PixelFormat {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@ impl GlContext for Context {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_current(&self) -> bool {
|
fn is_current(&self) -> bool {
|
||||||
unsafe { self.glx.GetCurrentContext() == self.context }
|
unsafe { self.glx.GetCurrentContext() == self.context }
|
||||||
}
|
}
|
||||||
|
@ -89,16 +90,19 @@ impl GlContext for Context {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||||
// TODO: glutin needs some internal changes for proper error recovery
|
// TODO: glutin needs some internal changes for proper error recovery
|
||||||
unsafe { self.glx.SwapBuffers(self.display as *mut _, self.window); }
|
unsafe { self.glx.SwapBuffers(self.display as *mut _, self.window); }
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_api(&self) -> ::Api {
|
fn get_api(&self) -> ::Api {
|
||||||
::Api::OpenGl
|
::Api::OpenGl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_pixel_format(&self) -> PixelFormat {
|
fn get_pixel_format(&self) -> PixelFormat {
|
||||||
self.pixel_format.clone()
|
self.pixel_format.clone()
|
||||||
}
|
}
|
||||||
|
@ -129,6 +133,7 @@ pub struct ContextPrototype<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ContextPrototype<'a> {
|
impl<'a> ContextPrototype<'a> {
|
||||||
|
#[inline]
|
||||||
pub fn get_visual_infos(&self) -> &ffi::XVisualInfo {
|
pub fn get_visual_infos(&self) -> &ffi::XVisualInfo {
|
||||||
&self.visual_infos
|
&self.visual_infos
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,7 @@ struct DelegateState {
|
||||||
|
|
||||||
|
|
||||||
impl DelegateState {
|
impl DelegateState {
|
||||||
|
#[inline]
|
||||||
fn new(window: id, controller:id, view: id, size: (u32,u32), scale: f32) -> DelegateState {
|
fn new(window: id, controller:id, view: id, size: (u32,u32), scale: f32) -> DelegateState {
|
||||||
DelegateState {
|
DelegateState {
|
||||||
events_queue: VecDeque::new(),
|
events_queue: VecDeque::new(),
|
||||||
|
@ -147,26 +148,30 @@ impl DelegateState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
||||||
let mut rb = VecDeque::new();
|
let mut rb = VecDeque::new();
|
||||||
rb.push_back(MonitorID);
|
rb.push_back(MonitorID);
|
||||||
rb
|
rb
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_primary_monitor() -> MonitorID {
|
pub fn get_primary_monitor() -> MonitorID {
|
||||||
MonitorID
|
MonitorID
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MonitorID {
|
impl MonitorID {
|
||||||
|
#[inline]
|
||||||
pub fn get_name(&self) -> Option<String> {
|
pub fn get_name(&self) -> Option<String> {
|
||||||
Some("Primary".to_string())
|
Some("Primary".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_native_identifier(&self) -> NativeMonitorId {
|
pub fn get_native_identifier(&self) -> NativeMonitorId {
|
||||||
NativeMonitorId::Unavailable
|
NativeMonitorId::Unavailable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_dimensions(&self) -> (u32, u32) {
|
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
@ -262,81 +267,101 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn start_app() {
|
fn start_app() {
|
||||||
unsafe {
|
unsafe {
|
||||||
UIApplicationMain(0, ptr::null(), nil, NSString::alloc(nil).init_str("AppDelegate"));
|
UIApplicationMain(0, ptr::null(), nil, NSString::alloc(nil).init_str("AppDelegate"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_title(&self, _: &str) {
|
pub fn set_title(&self, _: &str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn show(&self) {
|
pub fn show(&self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn hide(&self) {
|
pub fn hide(&self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_position(&self) -> Option<(i32, i32)> {
|
pub fn get_position(&self) -> Option<(i32, i32)> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_position(&self, _x: i32, _y: i32) {
|
pub fn set_position(&self, _x: i32, _y: i32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
||||||
unsafe { Some((&*self.delegate_state).size) }
|
unsafe { Some((&*self.delegate_state).size) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
||||||
self.get_inner_size()
|
self.get_inner_size()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_inner_size(&self, _x: u32, _y: u32) {
|
pub fn set_inner_size(&self, _x: u32, _y: u32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn poll_events(&self) -> PollEventsIterator {
|
pub fn poll_events(&self) -> PollEventsIterator {
|
||||||
PollEventsIterator {
|
PollEventsIterator {
|
||||||
window: self
|
window: self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn wait_events(&self) -> WaitEventsIterator {
|
pub fn wait_events(&self) -> WaitEventsIterator {
|
||||||
WaitEventsIterator {
|
WaitEventsIterator {
|
||||||
window: self
|
window: self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn platform_display(&self) -> *mut libc::c_void {
|
pub fn platform_display(&self) -> *mut libc::c_void {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn platform_window(&self) -> *mut libc::c_void {
|
pub fn platform_window(&self) -> *mut libc::c_void {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_pixel_format(&self) -> PixelFormat {
|
pub fn get_pixel_format(&self) -> PixelFormat {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor(&self, _: MouseCursor) {
|
pub fn set_cursor(&self, _: MouseCursor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor_state(&self, _: CursorState) -> Result<(), String> {
|
pub fn set_cursor_state(&self, _: CursorState) -> Result<(), String> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn hidpi_factor(&self) -> f32 {
|
pub fn hidpi_factor(&self) -> f32 {
|
||||||
unsafe { (&*self.delegate_state) }.scale
|
unsafe { (&*self.delegate_state) }.scale
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor_position(&self, _x: i32, _y: i32) -> Result<(), ()> {
|
pub fn set_cursor_position(&self, _x: i32, _y: i32) -> Result<(), ()> {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn create_window_proxy(&self) -> WindowProxy {
|
pub fn create_window_proxy(&self) -> WindowProxy {
|
||||||
WindowProxy
|
WindowProxy
|
||||||
}
|
}
|
||||||
|
@ -344,6 +369,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlContext for Window {
|
impl GlContext for Window {
|
||||||
|
#[inline]
|
||||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||||
let res: BOOL = msg_send![Class::get("EAGLContext").unwrap(), setCurrentContext: self.eagl_context];
|
let res: BOOL = msg_send![Class::get("EAGLContext").unwrap(), setCurrentContext: self.eagl_context];
|
||||||
if res == YES {
|
if res == YES {
|
||||||
|
@ -353,6 +379,7 @@ impl GlContext for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_current(&self) -> bool {
|
fn is_current(&self) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
@ -366,6 +393,7 @@ impl GlContext for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let res: BOOL = msg_send![self.eagl_context, presentRenderbuffer: gles::RENDERBUFFER];
|
let res: BOOL = msg_send![self.eagl_context, presentRenderbuffer: gles::RENDERBUFFER];
|
||||||
|
@ -377,16 +405,19 @@ impl GlContext for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_api(&self) -> Api {
|
fn get_api(&self) -> Api {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_pixel_format(&self) -> PixelFormat {
|
fn get_pixel_format(&self) -> PixelFormat {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowProxy {
|
impl WindowProxy {
|
||||||
|
#[inline]
|
||||||
pub fn wakeup_event_loop(&self) {
|
pub fn wakeup_event_loop(&self) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
@ -396,6 +427,7 @@ impl WindowProxy {
|
||||||
impl<'a> Iterator for WaitEventsIterator<'a> {
|
impl<'a> Iterator for WaitEventsIterator<'a> {
|
||||||
type Item = Event;
|
type Item = Event;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn next(&mut self) -> Option<Event> {
|
fn next(&mut self) -> Option<Event> {
|
||||||
loop {
|
loop {
|
||||||
if let Some(ev) = self.window.poll_events().next() {
|
if let Some(ev) = self.window.poll_events().next() {
|
||||||
|
|
|
@ -27,6 +27,7 @@ pub enum OsMesaCreationError {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<CreationError> for OsMesaCreationError {
|
impl From<CreationError> for OsMesaCreationError {
|
||||||
|
#[inline]
|
||||||
fn from(e: CreationError) -> OsMesaCreationError {
|
fn from(e: CreationError) -> OsMesaCreationError {
|
||||||
OsMesaCreationError::CreationError(e)
|
OsMesaCreationError::CreationError(e)
|
||||||
}
|
}
|
||||||
|
@ -67,21 +68,25 @@ impl OsMesaContext {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_framebuffer(&self) -> &[u32] {
|
pub fn get_framebuffer(&self) -> &[u32] {
|
||||||
&self.buffer
|
&self.buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_dimensions(&self) -> (u32, u32) {
|
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||||
(self.width, self.height)
|
(self.width, self.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
// TODO: can we remove this without causing havoc?
|
// TODO: can we remove this without causing havoc?
|
||||||
|
#[inline]
|
||||||
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlContext for OsMesaContext {
|
impl GlContext for OsMesaContext {
|
||||||
|
#[inline]
|
||||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||||
let ret = osmesa_sys::OSMesaMakeCurrent(self.context, self.buffer.as_ptr()
|
let ret = osmesa_sys::OSMesaMakeCurrent(self.context, self.buffer.as_ptr()
|
||||||
as *mut libc::c_void, 0x1401, self.width
|
as *mut libc::c_void, 0x1401, self.width
|
||||||
|
@ -96,6 +101,7 @@ impl GlContext for OsMesaContext {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_current(&self) -> bool {
|
fn is_current(&self) -> bool {
|
||||||
unsafe { osmesa_sys::OSMesaGetCurrentContext() == self.context }
|
unsafe { osmesa_sys::OSMesaGetCurrentContext() == self.context }
|
||||||
}
|
}
|
||||||
|
@ -107,20 +113,24 @@ impl GlContext for OsMesaContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_api(&self) -> Api {
|
fn get_api(&self) -> Api {
|
||||||
Api::OpenGl
|
Api::OpenGl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_pixel_format(&self) -> PixelFormat {
|
fn get_pixel_format(&self) -> PixelFormat {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for OsMesaContext {
|
impl Drop for OsMesaContext {
|
||||||
|
#[inline]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe { osmesa_sys::OSMesaDestroyContext(self.context) }
|
unsafe { osmesa_sys::OSMesaDestroyContext(self.context) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ lazy_static! {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn is_available() -> bool {
|
pub fn is_available() -> bool {
|
||||||
WAYLAND_CONTEXT.is_some()
|
WAYLAND_CONTEXT.is_some()
|
||||||
}
|
}
|
||||||
|
@ -56,6 +57,7 @@ enum ShellWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ShellWindow {
|
impl ShellWindow {
|
||||||
|
#[inline]
|
||||||
fn get_shell(&mut self) -> ShellGuard {
|
fn get_shell(&mut self) -> ShellGuard {
|
||||||
match self {
|
match self {
|
||||||
&mut ShellWindow::Plain(ref mut s) => {
|
&mut ShellWindow::Plain(ref mut s) => {
|
||||||
|
@ -98,6 +100,8 @@ enum ShellGuard<'a> {
|
||||||
|
|
||||||
impl<'a> Deref for ShellGuard<'a> {
|
impl<'a> Deref for ShellGuard<'a> {
|
||||||
type Target = ShellSurface<EGLSurface>;
|
type Target = ShellSurface<EGLSurface>;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn deref(&self) -> &ShellSurface<EGLSurface> {
|
fn deref(&self) -> &ShellSurface<EGLSurface> {
|
||||||
match self {
|
match self {
|
||||||
&ShellGuard::Plain(ref s) => s,
|
&ShellGuard::Plain(ref s) => s,
|
||||||
|
@ -107,6 +111,7 @@ impl<'a> Deref for ShellGuard<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DerefMut for ShellGuard<'a> {
|
impl<'a> DerefMut for ShellGuard<'a> {
|
||||||
|
#[inline]
|
||||||
fn deref_mut(&mut self) -> &mut ShellSurface<EGLSurface> {
|
fn deref_mut(&mut self) -> &mut ShellSurface<EGLSurface> {
|
||||||
match self {
|
match self {
|
||||||
&mut ShellGuard::Plain(ref mut s) => s,
|
&mut ShellGuard::Plain(ref mut s) => s,
|
||||||
|
@ -152,6 +157,7 @@ impl Window {
|
||||||
pub struct WindowProxy;
|
pub struct WindowProxy;
|
||||||
|
|
||||||
impl WindowProxy {
|
impl WindowProxy {
|
||||||
|
#[inline]
|
||||||
pub fn wakeup_event_loop(&self) {
|
pub fn wakeup_event_loop(&self) {
|
||||||
if let Some(ref ctxt) = *WAYLAND_CONTEXT {
|
if let Some(ref ctxt) = *WAYLAND_CONTEXT {
|
||||||
ctxt.display.sync();
|
ctxt.display.sync();
|
||||||
|
@ -164,9 +170,11 @@ pub struct MonitorID {
|
||||||
output: Arc<Output>
|
output: Arc<Output>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
||||||
WAYLAND_CONTEXT.as_ref().unwrap().outputs.iter().map(|o| MonitorID::new(o.clone())).collect()
|
WAYLAND_CONTEXT.as_ref().unwrap().outputs.iter().map(|o| MonitorID::new(o.clone())).collect()
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
pub fn get_primary_monitor() -> MonitorID {
|
pub fn get_primary_monitor() -> MonitorID {
|
||||||
match WAYLAND_CONTEXT.as_ref().unwrap().outputs.iter().next() {
|
match WAYLAND_CONTEXT.as_ref().unwrap().outputs.iter().next() {
|
||||||
Some(o) => MonitorID::new(o.clone()),
|
Some(o) => MonitorID::new(o.clone()),
|
||||||
|
@ -185,6 +193,7 @@ impl MonitorID {
|
||||||
Some(format!("{} - {}", self.output.manufacturer(), self.output.model()))
|
Some(format!("{} - {}", self.output.manufacturer(), self.output.model()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_native_identifier(&self) -> ::native_monitor::NativeMonitorId {
|
pub fn get_native_identifier(&self) -> ::native_monitor::NativeMonitorId {
|
||||||
::native_monitor::NativeMonitorId::Unavailable
|
::native_monitor::NativeMonitorId::Unavailable
|
||||||
}
|
}
|
||||||
|
@ -336,19 +345,23 @@ impl Window {
|
||||||
guard.get_shell().set_title(&ctitle);
|
guard.get_shell().set_title(&ctitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn show(&self) {
|
pub fn show(&self) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn hide(&self) {
|
pub fn hide(&self) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_position(&self) -> Option<(i32, i32)> {
|
pub fn get_position(&self) -> Option<(i32, i32)> {
|
||||||
// not available with wayland
|
// not available with wayland
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_position(&self, _x: i32, _y: i32) {
|
pub fn set_position(&self, _x: i32, _y: i32) {
|
||||||
// not available with wayland
|
// not available with wayland
|
||||||
}
|
}
|
||||||
|
@ -362,84 +375,102 @@ impl Window {
|
||||||
Some((w as u32, h as u32))
|
Some((w as u32, h as u32))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
||||||
// maybe available if we draw the border ourselves ?
|
// maybe available if we draw the border ourselves ?
|
||||||
// but for now, no.
|
// but for now, no.
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_inner_size(&self, x: u32, y: u32) {
|
pub fn set_inner_size(&self, x: u32, y: u32) {
|
||||||
self.shell_window.lock().unwrap().resize(x as i32, y as i32, 0, 0)
|
self.shell_window.lock().unwrap().resize(x as i32, y as i32, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn create_window_proxy(&self) -> WindowProxy {
|
pub fn create_window_proxy(&self) -> WindowProxy {
|
||||||
WindowProxy
|
WindowProxy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn poll_events(&self) -> PollEventsIterator {
|
pub fn poll_events(&self) -> PollEventsIterator {
|
||||||
PollEventsIterator {
|
PollEventsIterator {
|
||||||
window: self
|
window: self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn wait_events(&self) -> WaitEventsIterator {
|
pub fn wait_events(&self) -> WaitEventsIterator {
|
||||||
WaitEventsIterator {
|
WaitEventsIterator {
|
||||||
window: self
|
window: self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_window_resize_callback(&mut self, callback: Option<fn(u32, u32)>) {
|
pub fn set_window_resize_callback(&mut self, callback: Option<fn(u32, u32)>) {
|
||||||
self.resize_callback = callback;
|
self.resize_callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor(&self, cursor: MouseCursor) {
|
pub fn set_cursor(&self, cursor: MouseCursor) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
|
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
|
||||||
// TODO
|
// TODO
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn hidpi_factor(&self) -> f32 {
|
pub fn hidpi_factor(&self) -> f32 {
|
||||||
1.0
|
1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()> {
|
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()> {
|
||||||
// TODO
|
// TODO
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn platform_display(&self) -> *mut libc::c_void {
|
pub fn platform_display(&self) -> *mut libc::c_void {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn platform_window(&self) -> *mut libc::c_void {
|
pub fn platform_window(&self) -> *mut libc::c_void {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlContext for Window {
|
impl GlContext for Window {
|
||||||
|
#[inline]
|
||||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||||
self.context.make_current()
|
self.context.make_current()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_current(&self) -> bool {
|
fn is_current(&self) -> bool {
|
||||||
self.context.is_current()
|
self.context.is_current()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
||||||
self.context.get_proc_address(addr)
|
self.context.get_proc_address(addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||||
self.context.swap_buffers()
|
self.context.swap_buffers()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_api(&self) -> ::Api {
|
fn get_api(&self) -> ::Api {
|
||||||
self.context.get_api()
|
self.context.get_api()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_pixel_format(&self) -> PixelFormat {
|
fn get_pixel_format(&self) -> PixelFormat {
|
||||||
self.context.get_pixel_format().clone()
|
self.context.get_pixel_format().clone()
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ pub struct Context {
|
||||||
struct WindowWrapper(winapi::HWND, winapi::HDC);
|
struct WindowWrapper(winapi::HWND, winapi::HDC);
|
||||||
|
|
||||||
impl Drop for WindowWrapper {
|
impl Drop for WindowWrapper {
|
||||||
|
#[inline]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
user32::DestroyWindow(self.0);
|
user32::DestroyWindow(self.0);
|
||||||
|
@ -60,6 +61,7 @@ impl Drop for WindowWrapper {
|
||||||
struct ContextWrapper(winapi::HGLRC);
|
struct ContextWrapper(winapi::HGLRC);
|
||||||
|
|
||||||
impl Drop for ContextWrapper {
|
impl Drop for ContextWrapper {
|
||||||
|
#[inline]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
gl::wgl::DeleteContext(self.0 as *const _);
|
gl::wgl::DeleteContext(self.0 as *const _);
|
||||||
|
@ -150,12 +152,14 @@ impl Context {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the raw HGLRC.
|
/// Returns the raw HGLRC.
|
||||||
|
#[inline]
|
||||||
pub fn get_hglrc(&self) -> winapi::HGLRC {
|
pub fn get_hglrc(&self) -> winapi::HGLRC {
|
||||||
self.context.0
|
self.context.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlContext for Context {
|
impl GlContext for Context {
|
||||||
|
#[inline]
|
||||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||||
if gl::wgl::MakeCurrent(self.hdc as *const _, self.context.0 as *const _) != 0 {
|
if gl::wgl::MakeCurrent(self.hdc as *const _, self.context.0 as *const _) != 0 {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -164,6 +168,7 @@ impl GlContext for Context {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_current(&self) -> bool {
|
fn is_current(&self) -> bool {
|
||||||
unsafe { gl::wgl::GetCurrentContext() == self.context.0 as *const libc::c_void }
|
unsafe { gl::wgl::GetCurrentContext() == self.context.0 as *const libc::c_void }
|
||||||
}
|
}
|
||||||
|
@ -179,6 +184,7 @@ impl GlContext for Context {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||||
// TODO: decide how to handle the error
|
// TODO: decide how to handle the error
|
||||||
/*if unsafe { gdi32::SwapBuffers(self.hdc) } != 0 {
|
/*if unsafe { gdi32::SwapBuffers(self.hdc) } != 0 {
|
||||||
|
@ -190,11 +196,13 @@ impl GlContext for Context {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_api(&self) -> Api {
|
fn get_api(&self) -> Api {
|
||||||
// FIXME: can be opengl es
|
// FIXME: can be opengl es
|
||||||
Api::OpenGl
|
Api::OpenGl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_pixel_format(&self) -> PixelFormat {
|
fn get_pixel_format(&self) -> PixelFormat {
|
||||||
self.pixel_format.clone()
|
self.pixel_format.clone()
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,7 @@ enum Context {
|
||||||
pub struct WindowWrapper(pub winapi::HWND, pub winapi::HDC);
|
pub struct WindowWrapper(pub winapi::HWND, pub winapi::HDC);
|
||||||
|
|
||||||
impl Drop for WindowWrapper {
|
impl Drop for WindowWrapper {
|
||||||
|
#[inline]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
user32::DestroyWindow(self.0);
|
user32::DestroyWindow(self.0);
|
||||||
|
@ -84,6 +85,7 @@ pub struct WindowProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowProxy {
|
impl WindowProxy {
|
||||||
|
#[inline]
|
||||||
pub fn wakeup_event_loop(&self) {
|
pub fn wakeup_event_loop(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
user32::PostMessageA(self.hwnd, *WAKEUP_MSG_ID, 0, 0);
|
user32::PostMessageA(self.hwnd, *WAKEUP_MSG_ID, 0, 0);
|
||||||
|
@ -119,12 +121,14 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn show(&self) {
|
pub fn show(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
user32::ShowWindow(self.window.0, winapi::SW_SHOW);
|
user32::ShowWindow(self.window.0, winapi::SW_SHOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn hide(&self) {
|
pub fn hide(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
user32::ShowWindow(self.window.0, winapi::SW_HIDE);
|
user32::ShowWindow(self.window.0, winapi::SW_HIDE);
|
||||||
|
@ -158,6 +162,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See the docs in the crate root file.
|
/// See the docs in the crate root file.
|
||||||
|
#[inline]
|
||||||
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
||||||
let mut rect: winapi::RECT = unsafe { mem::uninitialized() };
|
let mut rect: winapi::RECT = unsafe { mem::uninitialized() };
|
||||||
|
|
||||||
|
@ -172,6 +177,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See the docs in the crate root file.
|
/// See the docs in the crate root file.
|
||||||
|
#[inline]
|
||||||
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
||||||
let mut rect: winapi::RECT = unsafe { mem::uninitialized() };
|
let mut rect: winapi::RECT = unsafe { mem::uninitialized() };
|
||||||
|
|
||||||
|
@ -196,11 +202,13 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn create_window_proxy(&self) -> WindowProxy {
|
pub fn create_window_proxy(&self) -> WindowProxy {
|
||||||
WindowProxy { hwnd: self.window.0 }
|
WindowProxy { hwnd: self.window.0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See the docs in the crate root file.
|
/// See the docs in the crate root file.
|
||||||
|
#[inline]
|
||||||
pub fn poll_events(&self) -> PollEventsIterator {
|
pub fn poll_events(&self) -> PollEventsIterator {
|
||||||
PollEventsIterator {
|
PollEventsIterator {
|
||||||
window: self,
|
window: self,
|
||||||
|
@ -208,12 +216,14 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See the docs in the crate root file.
|
/// See the docs in the crate root file.
|
||||||
|
#[inline]
|
||||||
pub fn wait_events(&self) -> WaitEventsIterator {
|
pub fn wait_events(&self) -> WaitEventsIterator {
|
||||||
WaitEventsIterator {
|
WaitEventsIterator {
|
||||||
window: self,
|
window: self,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn platform_display(&self) -> *mut libc::c_void {
|
pub fn platform_display(&self) -> *mut libc::c_void {
|
||||||
// What should this return on win32?
|
// What should this return on win32?
|
||||||
// It could be GetDC(NULL), but that requires a ReleaseDC()
|
// It could be GetDC(NULL), but that requires a ReleaseDC()
|
||||||
|
@ -221,13 +231,16 @@ impl Window {
|
||||||
ptr::null_mut()
|
ptr::null_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn platform_window(&self) -> *mut libc::c_void {
|
pub fn platform_window(&self) -> *mut libc::c_void {
|
||||||
self.window.0 as *mut libc::c_void
|
self.window.0 as *mut libc::c_void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor(&self, _cursor: MouseCursor) {
|
pub fn set_cursor(&self, _cursor: MouseCursor) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
@ -297,6 +310,7 @@ impl Window {
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn hidpi_factor(&self) -> f32 {
|
pub fn hidpi_factor(&self) -> f32 {
|
||||||
1.0
|
1.0
|
||||||
}
|
}
|
||||||
|
@ -322,6 +336,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlContext for Window {
|
impl GlContext for Window {
|
||||||
|
#[inline]
|
||||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||||
match self.context {
|
match self.context {
|
||||||
Context::Wgl(ref c) => c.make_current(),
|
Context::Wgl(ref c) => c.make_current(),
|
||||||
|
@ -329,6 +344,7 @@ impl GlContext for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_current(&self) -> bool {
|
fn is_current(&self) -> bool {
|
||||||
match self.context {
|
match self.context {
|
||||||
Context::Wgl(ref c) => c.is_current(),
|
Context::Wgl(ref c) => c.is_current(),
|
||||||
|
@ -336,6 +352,7 @@ impl GlContext for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
||||||
match self.context {
|
match self.context {
|
||||||
Context::Wgl(ref c) => c.get_proc_address(addr),
|
Context::Wgl(ref c) => c.get_proc_address(addr),
|
||||||
|
@ -343,6 +360,7 @@ impl GlContext for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||||
match self.context {
|
match self.context {
|
||||||
Context::Wgl(ref c) => c.swap_buffers(),
|
Context::Wgl(ref c) => c.swap_buffers(),
|
||||||
|
@ -350,6 +368,7 @@ impl GlContext for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_api(&self) -> Api {
|
fn get_api(&self) -> Api {
|
||||||
match self.context {
|
match self.context {
|
||||||
Context::Wgl(ref c) => c.get_api(),
|
Context::Wgl(ref c) => c.get_api(),
|
||||||
|
@ -357,6 +376,7 @@ impl GlContext for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_pixel_format(&self) -> PixelFormat {
|
fn get_pixel_format(&self) -> PixelFormat {
|
||||||
match self.context {
|
match self.context {
|
||||||
Context::Wgl(ref c) => c.get_pixel_format(),
|
Context::Wgl(ref c) => c.get_pixel_format(),
|
||||||
|
@ -372,6 +392,7 @@ pub struct PollEventsIterator<'a> {
|
||||||
impl<'a> Iterator for PollEventsIterator<'a> {
|
impl<'a> Iterator for PollEventsIterator<'a> {
|
||||||
type Item = Event;
|
type Item = Event;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn next(&mut self) -> Option<Event> {
|
fn next(&mut self) -> Option<Event> {
|
||||||
self.window.events_receiver.try_recv().ok()
|
self.window.events_receiver.try_recv().ok()
|
||||||
}
|
}
|
||||||
|
@ -384,12 +405,14 @@ pub struct WaitEventsIterator<'a> {
|
||||||
impl<'a> Iterator for WaitEventsIterator<'a> {
|
impl<'a> Iterator for WaitEventsIterator<'a> {
|
||||||
type Item = Event;
|
type Item = Event;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn next(&mut self) -> Option<Event> {
|
fn next(&mut self) -> Option<Event> {
|
||||||
self.window.events_receiver.recv().ok()
|
self.window.events_receiver.recv().ok()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Window {
|
impl Drop for Window {
|
||||||
|
#[inline]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
// we don't call MakeCurrent(0, 0) because we are not sure that the context
|
// we don't call MakeCurrent(0, 0) because we are not sure that the context
|
||||||
|
|
|
@ -151,16 +151,19 @@ pub fn get_primary_monitor() -> MonitorID {
|
||||||
|
|
||||||
impl MonitorID {
|
impl MonitorID {
|
||||||
/// See the docs if the crate root file.
|
/// See the docs if the crate root file.
|
||||||
|
#[inline]
|
||||||
pub fn get_name(&self) -> Option<String> {
|
pub fn get_name(&self) -> Option<String> {
|
||||||
Some(self.readable_name.clone())
|
Some(self.readable_name.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See the docs of the crate root file.
|
/// See the docs of the crate root file.
|
||||||
|
#[inline]
|
||||||
pub fn get_native_identifier(&self) -> NativeMonitorId {
|
pub fn get_native_identifier(&self) -> NativeMonitorId {
|
||||||
NativeMonitorId::Name(self.monitor_name.clone())
|
NativeMonitorId::Name(self.monitor_name.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See the docs if the crate root file.
|
/// See the docs if the crate root file.
|
||||||
|
#[inline]
|
||||||
pub fn get_dimensions(&self) -> (u32, u32) {
|
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||||
// TODO: retreive the dimensions every time this is called
|
// TODO: retreive the dimensions every time this is called
|
||||||
self.dimensions
|
self.dimensions
|
||||||
|
@ -168,6 +171,7 @@ impl MonitorID {
|
||||||
|
|
||||||
/// This is a Win32-only function for `MonitorID` that returns the system name of the adapter
|
/// This is a Win32-only function for `MonitorID` that returns the system name of the adapter
|
||||||
/// device.
|
/// device.
|
||||||
|
#[inline]
|
||||||
pub fn get_adapter_name(&self) -> &[winapi::WCHAR] {
|
pub fn get_adapter_name(&self) -> &[winapi::WCHAR] {
|
||||||
&self.adapter_name
|
&self.adapter_name
|
||||||
}
|
}
|
||||||
|
@ -175,6 +179,7 @@ impl MonitorID {
|
||||||
/// This is a Win32-only function for `MonitorID` that returns the position of the
|
/// This is a Win32-only function for `MonitorID` that returns the position of the
|
||||||
/// monitor on the desktop.
|
/// monitor on the desktop.
|
||||||
/// A window that is positionned at these coordinates will overlap the monitor.
|
/// A window that is positionned at these coordinates will overlap the monitor.
|
||||||
|
#[inline]
|
||||||
pub fn get_position(&self) -> (u32, u32) {
|
pub fn get_position(&self) -> (u32, u32) {
|
||||||
self.position
|
self.position
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ pub fn get_available_monitors(x: &Arc<XConnection>) -> VecDeque<MonitorID> {
|
||||||
monitors
|
monitors
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_primary_monitor(x: &Arc<XConnection>) -> MonitorID {
|
pub fn get_primary_monitor(x: &Arc<XConnection>) -> MonitorID {
|
||||||
let primary_monitor = unsafe { (x.xlib.XDefaultScreen)(x.display) };
|
let primary_monitor = unsafe { (x.xlib.XDefaultScreen)(x.display) };
|
||||||
MonitorID(x.clone(), primary_monitor as u32)
|
MonitorID(x.clone(), primary_monitor as u32)
|
||||||
|
@ -26,6 +27,7 @@ impl MonitorID {
|
||||||
Some(format!("Monitor #{}", screen_num))
|
Some(format!("Monitor #{}", screen_num))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_native_identifier(&self) -> NativeMonitorId {
|
pub fn get_native_identifier(&self) -> NativeMonitorId {
|
||||||
NativeMonitorId::Numeric(self.1)
|
NativeMonitorId::Numeric(self.1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -613,6 +613,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_position(&self) -> Option<(i32, i32)> {
|
pub fn get_position(&self) -> Option<(i32, i32)> {
|
||||||
self.get_geometry().map(|(x, y, _, _, _)| (x, y))
|
self.get_geometry().map(|(x, y, _, _, _)| (x, y))
|
||||||
}
|
}
|
||||||
|
@ -621,45 +622,53 @@ impl Window {
|
||||||
unsafe { (self.x.display.xlib.XMoveWindow)(self.x.display.display, self.x.window, x as libc::c_int, y as libc::c_int); }
|
unsafe { (self.x.display.xlib.XMoveWindow)(self.x.display.display, self.x.window, x as libc::c_int, y as libc::c_int); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
||||||
self.get_geometry().map(|(_, _, w, h, _)| (w, h))
|
self.get_geometry().map(|(_, _, w, h, _)| (w, h))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
||||||
self.get_geometry().map(|(_, _, w, h, b)| (w + b, h + b)) // TODO: is this really outside?
|
self.get_geometry().map(|(_, _, w, h, b)| (w + b, h + b)) // TODO: is this really outside?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_inner_size(&self, x: u32, y: u32) {
|
pub fn set_inner_size(&self, x: u32, y: u32) {
|
||||||
unsafe { (self.x.display.xlib.XResizeWindow)(self.x.display.display, self.x.window, x as libc::c_uint, y as libc::c_uint); }
|
unsafe { (self.x.display.xlib.XResizeWindow)(self.x.display.display, self.x.window, x as libc::c_uint, y as libc::c_uint); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn create_window_proxy(&self) -> WindowProxy {
|
pub fn create_window_proxy(&self) -> WindowProxy {
|
||||||
WindowProxy {
|
WindowProxy {
|
||||||
data: self.x.window_proxy_data.clone()
|
data: self.x.window_proxy_data.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn poll_events(&self) -> PollEventsIterator {
|
pub fn poll_events(&self) -> PollEventsIterator {
|
||||||
PollEventsIterator {
|
PollEventsIterator {
|
||||||
window: self
|
window: self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn wait_events(&self) -> WaitEventsIterator {
|
pub fn wait_events(&self) -> WaitEventsIterator {
|
||||||
WaitEventsIterator {
|
WaitEventsIterator {
|
||||||
window: self
|
window: self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn platform_display(&self) -> *mut libc::c_void {
|
pub fn platform_display(&self) -> *mut libc::c_void {
|
||||||
self.x.display.display as *mut libc::c_void
|
self.x.display.display as *mut libc::c_void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn platform_window(&self) -> *mut libc::c_void {
|
pub fn platform_window(&self) -> *mut libc::c_void {
|
||||||
self.x.window as *mut libc::c_void
|
self.x.window as *mut libc::c_void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -754,6 +763,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn hidpi_factor(&self) -> f32 {
|
pub fn hidpi_factor(&self) -> f32 {
|
||||||
1.0
|
1.0
|
||||||
}
|
}
|
||||||
|
@ -768,6 +778,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlContext for Window {
|
impl GlContext for Window {
|
||||||
|
#[inline]
|
||||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||||
match self.x.context {
|
match self.x.context {
|
||||||
Context::Glx(ref ctxt) => ctxt.make_current(),
|
Context::Glx(ref ctxt) => ctxt.make_current(),
|
||||||
|
@ -776,6 +787,7 @@ impl GlContext for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_current(&self) -> bool {
|
fn is_current(&self) -> bool {
|
||||||
match self.x.context {
|
match self.x.context {
|
||||||
Context::Glx(ref ctxt) => ctxt.is_current(),
|
Context::Glx(ref ctxt) => ctxt.is_current(),
|
||||||
|
@ -784,6 +796,7 @@ impl GlContext for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
||||||
match self.x.context {
|
match self.x.context {
|
||||||
Context::Glx(ref ctxt) => ctxt.get_proc_address(addr),
|
Context::Glx(ref ctxt) => ctxt.get_proc_address(addr),
|
||||||
|
@ -792,6 +805,7 @@ impl GlContext for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||||
match self.x.context {
|
match self.x.context {
|
||||||
Context::Glx(ref ctxt) => ctxt.swap_buffers(),
|
Context::Glx(ref ctxt) => ctxt.swap_buffers(),
|
||||||
|
@ -800,6 +814,7 @@ impl GlContext for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_api(&self) -> Api {
|
fn get_api(&self) -> Api {
|
||||||
match self.x.context {
|
match self.x.context {
|
||||||
Context::Glx(ref ctxt) => ctxt.get_api(),
|
Context::Glx(ref ctxt) => ctxt.get_api(),
|
||||||
|
@ -808,6 +823,7 @@ impl GlContext for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_pixel_format(&self) -> PixelFormat {
|
fn get_pixel_format(&self) -> PixelFormat {
|
||||||
match self.x.context {
|
match self.x.context {
|
||||||
Context::Glx(ref ctxt) => ctxt.get_pixel_format(),
|
Context::Glx(ref ctxt) => ctxt.get_pixel_format(),
|
||||||
|
|
|
@ -98,6 +98,7 @@ impl XConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for XConnection {
|
impl Drop for XConnection {
|
||||||
|
#[inline]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe { (self.xlib.XCloseDisplay)(self.display) };
|
unsafe { (self.xlib.XCloseDisplay)(self.display) };
|
||||||
}
|
}
|
||||||
|
@ -113,12 +114,14 @@ pub enum XNotSupported {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ffi::OpenError> for XNotSupported {
|
impl From<ffi::OpenError> for XNotSupported {
|
||||||
|
#[inline]
|
||||||
fn from(err: ffi::OpenError) -> XNotSupported {
|
fn from(err: ffi::OpenError) -> XNotSupported {
|
||||||
XNotSupported::LibraryOpenError(err)
|
XNotSupported::LibraryOpenError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error for XNotSupported {
|
impl Error for XNotSupported {
|
||||||
|
#[inline]
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
match *self {
|
match *self {
|
||||||
XNotSupported::LibraryOpenError(_) => "Failed to load one of xlib's shared libraries",
|
XNotSupported::LibraryOpenError(_) => "Failed to load one of xlib's shared libraries",
|
||||||
|
@ -126,6 +129,7 @@ impl Error for XNotSupported {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn cause(&self) -> Option<&Error> {
|
fn cause(&self) -> Option<&Error> {
|
||||||
match *self {
|
match *self {
|
||||||
XNotSupported::LibraryOpenError(ref err) => Some(err),
|
XNotSupported::LibraryOpenError(ref err) => Some(err),
|
||||||
|
|
|
@ -28,6 +28,7 @@ pub struct HeadlessRendererBuilder<'a> {
|
||||||
|
|
||||||
impl<'a> HeadlessRendererBuilder<'a> {
|
impl<'a> HeadlessRendererBuilder<'a> {
|
||||||
/// Initializes a new `HeadlessRendererBuilder` with default values.
|
/// Initializes a new `HeadlessRendererBuilder` with default values.
|
||||||
|
#[inline]
|
||||||
pub fn new(width: u32, height: u32) -> HeadlessRendererBuilder<'a> {
|
pub fn new(width: u32, height: u32) -> HeadlessRendererBuilder<'a> {
|
||||||
HeadlessRendererBuilder {
|
HeadlessRendererBuilder {
|
||||||
dimensions: (width, height),
|
dimensions: (width, height),
|
||||||
|
@ -37,6 +38,7 @@ impl<'a> HeadlessRendererBuilder<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets how the backend should choose the OpenGL API and version.
|
/// Sets how the backend should choose the OpenGL API and version.
|
||||||
|
#[inline]
|
||||||
pub fn with_gl(mut self, request: GlRequest) -> HeadlessRendererBuilder<'a> {
|
pub fn with_gl(mut self, request: GlRequest) -> HeadlessRendererBuilder<'a> {
|
||||||
self.opengl.version = request;
|
self.opengl.version = request;
|
||||||
self
|
self
|
||||||
|
@ -46,12 +48,14 @@ impl<'a> HeadlessRendererBuilder<'a> {
|
||||||
///
|
///
|
||||||
/// The default value for this flag is `cfg!(ndebug)`, which means that it's enabled
|
/// The default value for this flag is `cfg!(ndebug)`, which means that it's enabled
|
||||||
/// when you run `cargo build` and disabled when you run `cargo build --release`.
|
/// when you run `cargo build` and disabled when you run `cargo build --release`.
|
||||||
|
#[inline]
|
||||||
pub fn with_gl_debug_flag(mut self, flag: bool) -> HeadlessRendererBuilder<'a> {
|
pub fn with_gl_debug_flag(mut self, flag: bool) -> HeadlessRendererBuilder<'a> {
|
||||||
self.opengl.debug = flag;
|
self.opengl.debug = flag;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the robustness of the OpenGL context. See the docs of `Robustness`.
|
/// Sets the robustness of the OpenGL context. See the docs of `Robustness`.
|
||||||
|
#[inline]
|
||||||
pub fn with_gl_robustness(mut self, robustness: Robustness) -> HeadlessRendererBuilder<'a> {
|
pub fn with_gl_robustness(mut self, robustness: Robustness) -> HeadlessRendererBuilder<'a> {
|
||||||
self.opengl.robustness = robustness;
|
self.opengl.robustness = robustness;
|
||||||
self
|
self
|
||||||
|
@ -61,6 +65,7 @@ impl<'a> HeadlessRendererBuilder<'a> {
|
||||||
///
|
///
|
||||||
/// Error should be very rare and only occur in case of permission denied, incompatible system,
|
/// Error should be very rare and only occur in case of permission denied, incompatible system,
|
||||||
/// out of memory, etc.
|
/// out of memory, etc.
|
||||||
|
#[inline]
|
||||||
pub fn build(self) -> Result<HeadlessContext, CreationError> {
|
pub fn build(self) -> Result<HeadlessContext, CreationError> {
|
||||||
platform::HeadlessContext::new(self.dimensions, &self.pf_reqs, &self.opengl)
|
platform::HeadlessContext::new(self.dimensions, &self.pf_reqs, &self.opengl)
|
||||||
.map(|w| HeadlessContext { context: w })
|
.map(|w| HeadlessContext { context: w })
|
||||||
|
@ -70,6 +75,7 @@ impl<'a> HeadlessRendererBuilder<'a> {
|
||||||
///
|
///
|
||||||
/// The context is build in a *strict* way. That means that if the backend couldn't give
|
/// The context is build in a *strict* way. That means that if the backend couldn't give
|
||||||
/// you what you requested, an `Err` will be returned.
|
/// you what you requested, an `Err` will be returned.
|
||||||
|
#[inline]
|
||||||
pub fn build_strict(self) -> Result<HeadlessContext, CreationError> {
|
pub fn build_strict(self) -> Result<HeadlessContext, CreationError> {
|
||||||
self.build()
|
self.build()
|
||||||
}
|
}
|
||||||
|
@ -105,41 +111,50 @@ impl HeadlessContext {
|
||||||
/// Returns the API that is currently provided by this window.
|
/// Returns the API that is currently provided by this window.
|
||||||
///
|
///
|
||||||
/// See `Window::get_api` for more infos.
|
/// See `Window::get_api` for more infos.
|
||||||
|
#[inline]
|
||||||
pub fn get_api(&self) -> Api {
|
pub fn get_api(&self) -> Api {
|
||||||
self.context.get_api()
|
self.context.get_api()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl gl_common::GlFunctionsSource for HeadlessContext {
|
impl gl_common::GlFunctionsSource for HeadlessContext {
|
||||||
|
#[inline]
|
||||||
fn get_proc_addr(&self, addr: &str) -> *const libc::c_void {
|
fn get_proc_addr(&self, addr: &str) -> *const libc::c_void {
|
||||||
self.get_proc_address(addr)
|
self.get_proc_address(addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlContext for HeadlessContext {
|
impl GlContext for HeadlessContext {
|
||||||
|
#[inline]
|
||||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||||
self.context.make_current()
|
self.context.make_current()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_current(&self) -> bool {
|
fn is_current(&self) -> bool {
|
||||||
self.context.is_current()
|
self.context.is_current()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
||||||
self.context.get_proc_address(addr)
|
self.context.get_proc_address(addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||||
self.context.swap_buffers()
|
self.context.swap_buffers()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_api(&self) -> Api {
|
fn get_api(&self) -> Api {
|
||||||
self.context.get_api()
|
self.context.get_api()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_pixel_format(&self) -> PixelFormat {
|
fn get_pixel_format(&self) -> PixelFormat {
|
||||||
self.context.get_pixel_format()
|
self.context.get_pixel_format()
|
||||||
}
|
}
|
||||||
|
|
|
@ -478,6 +478,7 @@ impl PixelFormatRequirements {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for PixelFormatRequirements {
|
impl Default for PixelFormatRequirements {
|
||||||
|
#[inline]
|
||||||
fn default() -> PixelFormatRequirements {
|
fn default() -> PixelFormatRequirements {
|
||||||
PixelFormatRequirements {
|
PixelFormatRequirements {
|
||||||
multisampling: None,
|
multisampling: None,
|
||||||
|
@ -532,6 +533,7 @@ pub struct WindowAttributes {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for WindowAttributes {
|
impl Default for WindowAttributes {
|
||||||
|
#[inline]
|
||||||
fn default() -> WindowAttributes {
|
fn default() -> WindowAttributes {
|
||||||
WindowAttributes {
|
WindowAttributes {
|
||||||
dimensions: None,
|
dimensions: None,
|
||||||
|
@ -585,6 +587,7 @@ pub struct GlAttributes<S> {
|
||||||
|
|
||||||
impl<S> GlAttributes<S> {
|
impl<S> GlAttributes<S> {
|
||||||
/// Turns the `sharing` parameter into another type by calling a closure.
|
/// Turns the `sharing` parameter into another type by calling a closure.
|
||||||
|
#[inline]
|
||||||
pub fn map_sharing<F, T>(self, f: F) -> GlAttributes<T> where F: FnOnce(S) -> T {
|
pub fn map_sharing<F, T>(self, f: F) -> GlAttributes<T> where F: FnOnce(S) -> T {
|
||||||
GlAttributes {
|
GlAttributes {
|
||||||
sharing: self.sharing.map(f),
|
sharing: self.sharing.map(f),
|
||||||
|
@ -598,6 +601,7 @@ impl<S> GlAttributes<S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S> Default for GlAttributes<S> {
|
impl<S> Default for GlAttributes<S> {
|
||||||
|
#[inline]
|
||||||
fn default() -> GlAttributes<S> {
|
fn default() -> GlAttributes<S> {
|
||||||
GlAttributes {
|
GlAttributes {
|
||||||
sharing: None,
|
sharing: None,
|
||||||
|
|
|
@ -10,32 +10,39 @@ pub struct HeadlessContext(Window);
|
||||||
|
|
||||||
impl HeadlessContext {
|
impl HeadlessContext {
|
||||||
/// See the docs in the crate root file.
|
/// See the docs in the crate root file.
|
||||||
|
#[inline]
|
||||||
pub fn new(builder: BuilderAttribs) -> Result<HeadlessContext, CreationError> {
|
pub fn new(builder: BuilderAttribs) -> Result<HeadlessContext, CreationError> {
|
||||||
Window::new(builder).map(|w| HeadlessContext(w))
|
Window::new(builder).map(|w| HeadlessContext(w))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlContext for HeadlessContext {
|
impl GlContext for HeadlessContext {
|
||||||
|
#[inline]
|
||||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||||
self.0.make_current()
|
self.0.make_current()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_current(&self) -> bool {
|
fn is_current(&self) -> bool {
|
||||||
self.0.is_current()
|
self.0.is_current()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
||||||
self.0.get_proc_address(addr)
|
self.0.get_proc_address(addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||||
self.0.swap_buffers()
|
self.0.swap_buffers()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_api(&self) -> Api {
|
fn get_api(&self) -> Api {
|
||||||
self.0.get_api()
|
self.0.get_api()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_pixel_format(&self) -> PixelFormat {
|
fn get_pixel_format(&self) -> PixelFormat {
|
||||||
self.0.get_pixel_format()
|
self.0.get_pixel_format()
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ pub enum WindowProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowProxy {
|
impl WindowProxy {
|
||||||
|
#[inline]
|
||||||
pub fn wakeup_event_loop(&self) {
|
pub fn wakeup_event_loop(&self) {
|
||||||
match self {
|
match self {
|
||||||
&WindowProxy::X(ref wp) => wp.wakeup_event_loop(),
|
&WindowProxy::X(ref wp) => wp.wakeup_event_loop(),
|
||||||
|
@ -77,6 +78,7 @@ pub enum MonitorID {
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
||||||
match *BACKEND {
|
match *BACKEND {
|
||||||
Backend::Wayland => wayland::get_available_monitors()
|
Backend::Wayland => wayland::get_available_monitors()
|
||||||
|
@ -91,6 +93,7 @@ pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_primary_monitor() -> MonitorID {
|
pub fn get_primary_monitor() -> MonitorID {
|
||||||
match *BACKEND {
|
match *BACKEND {
|
||||||
Backend::Wayland => MonitorID::Wayland(wayland::get_primary_monitor()),
|
Backend::Wayland => MonitorID::Wayland(wayland::get_primary_monitor()),
|
||||||
|
@ -100,6 +103,7 @@ pub fn get_primary_monitor() -> MonitorID {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MonitorID {
|
impl MonitorID {
|
||||||
|
#[inline]
|
||||||
pub fn get_name(&self) -> Option<String> {
|
pub fn get_name(&self) -> Option<String> {
|
||||||
match self {
|
match self {
|
||||||
&MonitorID::X(ref m) => m.get_name(),
|
&MonitorID::X(ref m) => m.get_name(),
|
||||||
|
@ -108,6 +112,7 @@ impl MonitorID {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_native_identifier(&self) -> ::native_monitor::NativeMonitorId {
|
pub fn get_native_identifier(&self) -> ::native_monitor::NativeMonitorId {
|
||||||
match self {
|
match self {
|
||||||
&MonitorID::X(ref m) => m.get_native_identifier(),
|
&MonitorID::X(ref m) => m.get_native_identifier(),
|
||||||
|
@ -116,6 +121,7 @@ impl MonitorID {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_dimensions(&self) -> (u32, u32) {
|
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||||
match self {
|
match self {
|
||||||
&MonitorID::X(ref m) => m.get_dimensions(),
|
&MonitorID::X(ref m) => m.get_dimensions(),
|
||||||
|
@ -136,6 +142,7 @@ pub enum PollEventsIterator<'a> {
|
||||||
impl<'a> Iterator for PollEventsIterator<'a> {
|
impl<'a> Iterator for PollEventsIterator<'a> {
|
||||||
type Item = Event;
|
type Item = Event;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn next(&mut self) -> Option<Event> {
|
fn next(&mut self) -> Option<Event> {
|
||||||
match self {
|
match self {
|
||||||
&mut PollEventsIterator::X(ref mut it) => it.next(),
|
&mut PollEventsIterator::X(ref mut it) => it.next(),
|
||||||
|
@ -154,6 +161,7 @@ pub enum WaitEventsIterator<'a> {
|
||||||
impl<'a> Iterator for WaitEventsIterator<'a> {
|
impl<'a> Iterator for WaitEventsIterator<'a> {
|
||||||
type Item = Event;
|
type Item = Event;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn next(&mut self) -> Option<Event> {
|
fn next(&mut self) -> Option<Event> {
|
||||||
match self {
|
match self {
|
||||||
&mut WaitEventsIterator::X(ref mut it) => it.next(),
|
&mut WaitEventsIterator::X(ref mut it) => it.next(),
|
||||||
|
@ -163,6 +171,7 @@ impl<'a> Iterator for WaitEventsIterator<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
|
#[inline]
|
||||||
pub fn new(window: &WindowAttributes, pf_reqs: &PixelFormatRequirements,
|
pub fn new(window: &WindowAttributes, pf_reqs: &PixelFormatRequirements,
|
||||||
opengl: &GlAttributes<&Window>) -> Result<Window, CreationError>
|
opengl: &GlAttributes<&Window>) -> Result<Window, CreationError>
|
||||||
{
|
{
|
||||||
|
@ -189,6 +198,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_title(&self, title: &str) {
|
pub fn set_title(&self, title: &str) {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.set_title(title),
|
&Window::X(ref w) => w.set_title(title),
|
||||||
|
@ -196,6 +206,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn show(&self) {
|
pub fn show(&self) {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.show(),
|
&Window::X(ref w) => w.show(),
|
||||||
|
@ -203,6 +214,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn hide(&self) {
|
pub fn hide(&self) {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.hide(),
|
&Window::X(ref w) => w.hide(),
|
||||||
|
@ -210,6 +222,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_position(&self) -> Option<(i32, i32)> {
|
pub fn get_position(&self) -> Option<(i32, i32)> {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.get_position(),
|
&Window::X(ref w) => w.get_position(),
|
||||||
|
@ -217,6 +230,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_position(&self, x: i32, y: i32) {
|
pub fn set_position(&self, x: i32, y: i32) {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.set_position(x, y),
|
&Window::X(ref w) => w.set_position(x, y),
|
||||||
|
@ -224,6 +238,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.get_inner_size(),
|
&Window::X(ref w) => w.get_inner_size(),
|
||||||
|
@ -231,6 +246,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.get_outer_size(),
|
&Window::X(ref w) => w.get_outer_size(),
|
||||||
|
@ -238,6 +254,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_inner_size(&self, x: u32, y: u32) {
|
pub fn set_inner_size(&self, x: u32, y: u32) {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.set_inner_size(x, y),
|
&Window::X(ref w) => w.set_inner_size(x, y),
|
||||||
|
@ -245,6 +262,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn create_window_proxy(&self) -> WindowProxy {
|
pub fn create_window_proxy(&self) -> WindowProxy {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => WindowProxy::X(w.create_window_proxy()),
|
&Window::X(ref w) => WindowProxy::X(w.create_window_proxy()),
|
||||||
|
@ -252,6 +270,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn poll_events(&self) -> PollEventsIterator {
|
pub fn poll_events(&self) -> PollEventsIterator {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => PollEventsIterator::X(w.poll_events()),
|
&Window::X(ref w) => PollEventsIterator::X(w.poll_events()),
|
||||||
|
@ -259,6 +278,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn wait_events(&self) -> WaitEventsIterator {
|
pub fn wait_events(&self) -> WaitEventsIterator {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => WaitEventsIterator::X(w.wait_events()),
|
&Window::X(ref w) => WaitEventsIterator::X(w.wait_events()),
|
||||||
|
@ -266,6 +286,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_window_resize_callback(&mut self, callback: Option<fn(u32, u32)>) {
|
pub fn set_window_resize_callback(&mut self, callback: Option<fn(u32, u32)>) {
|
||||||
match self {
|
match self {
|
||||||
&mut Window::X(ref mut w) => w.set_window_resize_callback(callback),
|
&mut Window::X(ref mut w) => w.set_window_resize_callback(callback),
|
||||||
|
@ -273,6 +294,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor(&self, cursor: MouseCursor) {
|
pub fn set_cursor(&self, cursor: MouseCursor) {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.set_cursor(cursor),
|
&Window::X(ref w) => w.set_cursor(cursor),
|
||||||
|
@ -280,6 +302,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
|
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.set_cursor_state(state),
|
&Window::X(ref w) => w.set_cursor_state(state),
|
||||||
|
@ -287,6 +310,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn hidpi_factor(&self) -> f32 {
|
pub fn hidpi_factor(&self) -> f32 {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.hidpi_factor(),
|
&Window::X(ref w) => w.hidpi_factor(),
|
||||||
|
@ -294,6 +318,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()> {
|
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()> {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.set_cursor_position(x, y),
|
&Window::X(ref w) => w.set_cursor_position(x, y),
|
||||||
|
@ -301,6 +326,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn platform_display(&self) -> *mut libc::c_void {
|
pub fn platform_display(&self) -> *mut libc::c_void {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.platform_display(),
|
&Window::X(ref w) => w.platform_display(),
|
||||||
|
@ -308,6 +334,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn platform_window(&self) -> *mut libc::c_void {
|
pub fn platform_window(&self) -> *mut libc::c_void {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.platform_window(),
|
&Window::X(ref w) => w.platform_window(),
|
||||||
|
@ -317,6 +344,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlContext for Window {
|
impl GlContext for Window {
|
||||||
|
#[inline]
|
||||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.make_current(),
|
&Window::X(ref w) => w.make_current(),
|
||||||
|
@ -324,6 +352,7 @@ impl GlContext for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_current(&self) -> bool {
|
fn is_current(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.is_current(),
|
&Window::X(ref w) => w.is_current(),
|
||||||
|
@ -331,6 +360,7 @@ impl GlContext for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.get_proc_address(addr),
|
&Window::X(ref w) => w.get_proc_address(addr),
|
||||||
|
@ -338,6 +368,7 @@ impl GlContext for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.swap_buffers(),
|
&Window::X(ref w) => w.swap_buffers(),
|
||||||
|
@ -345,6 +376,7 @@ impl GlContext for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_api(&self) -> ::Api {
|
fn get_api(&self) -> ::Api {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.get_api(),
|
&Window::X(ref w) => w.get_api(),
|
||||||
|
@ -352,6 +384,7 @@ impl GlContext for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_pixel_format(&self) -> PixelFormat {
|
fn get_pixel_format(&self) -> PixelFormat {
|
||||||
match self {
|
match self {
|
||||||
&Window::X(ref w) => w.get_pixel_format(),
|
&Window::X(ref w) => w.get_pixel_format(),
|
||||||
|
|
|
@ -59,6 +59,7 @@ pub struct Window(win32::Window);
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
/// See the docs in the crate root file.
|
/// See the docs in the crate root file.
|
||||||
|
#[inline]
|
||||||
pub fn new(window: &WindowAttributes, pf_reqs: &PixelFormatRequirements,
|
pub fn new(window: &WindowAttributes, pf_reqs: &PixelFormatRequirements,
|
||||||
opengl: &GlAttributes<&Window>) -> Result<Window, CreationError>
|
opengl: &GlAttributes<&Window>) -> Result<Window, CreationError>
|
||||||
{
|
{
|
||||||
|
@ -70,12 +71,14 @@ impl Window {
|
||||||
impl Deref for Window {
|
impl Deref for Window {
|
||||||
type Target = win32::Window;
|
type Target = win32::Window;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn deref(&self) -> &win32::Window {
|
fn deref(&self) -> &win32::Window {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DerefMut for Window {
|
impl DerefMut for Window {
|
||||||
|
#[inline]
|
||||||
fn deref_mut(&mut self) -> &mut win32::Window {
|
fn deref_mut(&mut self) -> &mut win32::Window {
|
||||||
&mut self.0
|
&mut self.0
|
||||||
}
|
}
|
||||||
|
@ -114,6 +117,7 @@ impl HeadlessContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlContext for HeadlessContext {
|
impl GlContext for HeadlessContext {
|
||||||
|
#[inline]
|
||||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||||
match self {
|
match self {
|
||||||
&HeadlessContext::HiddenWindow(ref ctxt) => ctxt.make_current(),
|
&HeadlessContext::HiddenWindow(ref ctxt) => ctxt.make_current(),
|
||||||
|
@ -121,6 +125,7 @@ impl GlContext for HeadlessContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_current(&self) -> bool {
|
fn is_current(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
&HeadlessContext::HiddenWindow(ref ctxt) => ctxt.is_current(),
|
&HeadlessContext::HiddenWindow(ref ctxt) => ctxt.is_current(),
|
||||||
|
@ -128,6 +133,7 @@ impl GlContext for HeadlessContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
||||||
match self {
|
match self {
|
||||||
&HeadlessContext::HiddenWindow(ref ctxt) => ctxt.get_proc_address(addr),
|
&HeadlessContext::HiddenWindow(ref ctxt) => ctxt.get_proc_address(addr),
|
||||||
|
@ -135,6 +141,7 @@ impl GlContext for HeadlessContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||||
match self {
|
match self {
|
||||||
&HeadlessContext::HiddenWindow(ref ctxt) => ctxt.swap_buffers(),
|
&HeadlessContext::HiddenWindow(ref ctxt) => ctxt.swap_buffers(),
|
||||||
|
@ -142,6 +149,7 @@ impl GlContext for HeadlessContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_api(&self) -> Api {
|
fn get_api(&self) -> Api {
|
||||||
match self {
|
match self {
|
||||||
&HeadlessContext::HiddenWindow(ref ctxt) => ctxt.get_api(),
|
&HeadlessContext::HiddenWindow(ref ctxt) => ctxt.get_api(),
|
||||||
|
@ -149,6 +157,7 @@ impl GlContext for HeadlessContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_pixel_format(&self) -> PixelFormat {
|
fn get_pixel_format(&self) -> PixelFormat {
|
||||||
match self {
|
match self {
|
||||||
&HeadlessContext::HiddenWindow(ref ctxt) => ctxt.get_pixel_format(),
|
&HeadlessContext::HiddenWindow(ref ctxt) => ctxt.get_pixel_format(),
|
||||||
|
|
|
@ -36,6 +36,7 @@ pub struct WindowBuilder<'a> {
|
||||||
|
|
||||||
impl<'a> WindowBuilder<'a> {
|
impl<'a> WindowBuilder<'a> {
|
||||||
/// Initializes a new `WindowBuilder` with default values.
|
/// Initializes a new `WindowBuilder` with default values.
|
||||||
|
#[inline]
|
||||||
pub fn new() -> WindowBuilder<'a> {
|
pub fn new() -> WindowBuilder<'a> {
|
||||||
WindowBuilder {
|
WindowBuilder {
|
||||||
pf_reqs: Default::default(),
|
pf_reqs: Default::default(),
|
||||||
|
@ -47,12 +48,14 @@ impl<'a> WindowBuilder<'a> {
|
||||||
/// Requests the window to be of specific dimensions.
|
/// Requests the window to be of specific dimensions.
|
||||||
///
|
///
|
||||||
/// Width and height are in pixels.
|
/// Width and height are in pixels.
|
||||||
|
#[inline]
|
||||||
pub fn with_dimensions(mut self, width: u32, height: u32) -> WindowBuilder<'a> {
|
pub fn with_dimensions(mut self, width: u32, height: u32) -> WindowBuilder<'a> {
|
||||||
self.window.dimensions = Some((width, height));
|
self.window.dimensions = Some((width, height));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Requests a specific title for the window.
|
/// Requests a specific title for the window.
|
||||||
|
#[inline]
|
||||||
pub fn with_title(mut self, title: String) -> WindowBuilder<'a> {
|
pub fn with_title(mut self, title: String) -> WindowBuilder<'a> {
|
||||||
self.window.title = title;
|
self.window.title = title;
|
||||||
self
|
self
|
||||||
|
@ -61,6 +64,7 @@ impl<'a> WindowBuilder<'a> {
|
||||||
/// Requests fullscreen mode.
|
/// Requests fullscreen mode.
|
||||||
///
|
///
|
||||||
/// If you don't specify dimensions for the window, it will match the monitor's.
|
/// If you don't specify dimensions for the window, it will match the monitor's.
|
||||||
|
#[inline]
|
||||||
pub fn with_fullscreen(mut self, monitor: MonitorID) -> WindowBuilder<'a> {
|
pub fn with_fullscreen(mut self, monitor: MonitorID) -> WindowBuilder<'a> {
|
||||||
let MonitorID(monitor) = monitor;
|
let MonitorID(monitor) = monitor;
|
||||||
self.window.monitor = Some(monitor);
|
self.window.monitor = Some(monitor);
|
||||||
|
@ -70,18 +74,21 @@ impl<'a> WindowBuilder<'a> {
|
||||||
/// The created window will share all its OpenGL objects with the window in the parameter.
|
/// The created window will share all its OpenGL objects with the window in the parameter.
|
||||||
///
|
///
|
||||||
/// There are some exceptions, like FBOs or VAOs. See the OpenGL documentation.
|
/// There are some exceptions, like FBOs or VAOs. See the OpenGL documentation.
|
||||||
|
#[inline]
|
||||||
pub fn with_shared_lists(mut self, other: &'a Window) -> WindowBuilder<'a> {
|
pub fn with_shared_lists(mut self, other: &'a Window) -> WindowBuilder<'a> {
|
||||||
self.opengl.sharing = Some(&other.window);
|
self.opengl.sharing = Some(&other.window);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets how the backend should choose the OpenGL API and version.
|
/// Sets how the backend should choose the OpenGL API and version.
|
||||||
|
#[inline]
|
||||||
pub fn with_gl(mut self, request: GlRequest) -> WindowBuilder<'a> {
|
pub fn with_gl(mut self, request: GlRequest) -> WindowBuilder<'a> {
|
||||||
self.opengl.version = request;
|
self.opengl.version = request;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the desired OpenGL context profile.
|
/// Sets the desired OpenGL context profile.
|
||||||
|
#[inline]
|
||||||
pub fn with_gl_profile(mut self, profile: GlProfile) -> WindowBuilder<'a> {
|
pub fn with_gl_profile(mut self, profile: GlProfile) -> WindowBuilder<'a> {
|
||||||
self.opengl.profile = Some(profile);
|
self.opengl.profile = Some(profile);
|
||||||
self
|
self
|
||||||
|
@ -91,24 +98,28 @@ impl<'a> WindowBuilder<'a> {
|
||||||
///
|
///
|
||||||
/// The default value for this flag is `cfg!(debug_assertions)`, which means that it's enabled
|
/// The default value for this flag is `cfg!(debug_assertions)`, which means that it's enabled
|
||||||
/// when you run `cargo build` and disabled when you run `cargo build --release`.
|
/// when you run `cargo build` and disabled when you run `cargo build --release`.
|
||||||
|
#[inline]
|
||||||
pub fn with_gl_debug_flag(mut self, flag: bool) -> WindowBuilder<'a> {
|
pub fn with_gl_debug_flag(mut self, flag: bool) -> WindowBuilder<'a> {
|
||||||
self.opengl.debug = flag;
|
self.opengl.debug = flag;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the robustness of the OpenGL context. See the docs of `Robustness`.
|
/// Sets the robustness of the OpenGL context. See the docs of `Robustness`.
|
||||||
|
#[inline]
|
||||||
pub fn with_gl_robustness(mut self, robustness: Robustness) -> WindowBuilder<'a> {
|
pub fn with_gl_robustness(mut self, robustness: Robustness) -> WindowBuilder<'a> {
|
||||||
self.opengl.robustness = robustness;
|
self.opengl.robustness = robustness;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Requests that the window has vsync enabled.
|
/// Requests that the window has vsync enabled.
|
||||||
|
#[inline]
|
||||||
pub fn with_vsync(mut self) -> WindowBuilder<'a> {
|
pub fn with_vsync(mut self) -> WindowBuilder<'a> {
|
||||||
self.opengl.vsync = true;
|
self.opengl.vsync = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets whether the window will be initially hidden or visible.
|
/// Sets whether the window will be initially hidden or visible.
|
||||||
|
#[inline]
|
||||||
pub fn with_visibility(mut self, visible: bool) -> WindowBuilder<'a> {
|
pub fn with_visibility(mut self, visible: bool) -> WindowBuilder<'a> {
|
||||||
self.window.visible = visible;
|
self.window.visible = visible;
|
||||||
self
|
self
|
||||||
|
@ -119,6 +130,7 @@ impl<'a> WindowBuilder<'a> {
|
||||||
/// # Panic
|
/// # Panic
|
||||||
///
|
///
|
||||||
/// Will panic if `samples` is not a power of two.
|
/// Will panic if `samples` is not a power of two.
|
||||||
|
#[inline]
|
||||||
pub fn with_multisampling(mut self, samples: u16) -> WindowBuilder<'a> {
|
pub fn with_multisampling(mut self, samples: u16) -> WindowBuilder<'a> {
|
||||||
assert!(samples.is_power_of_two());
|
assert!(samples.is_power_of_two());
|
||||||
self.pf_reqs.multisampling = Some(samples);
|
self.pf_reqs.multisampling = Some(samples);
|
||||||
|
@ -126,18 +138,21 @@ impl<'a> WindowBuilder<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the number of bits in the depth buffer.
|
/// Sets the number of bits in the depth buffer.
|
||||||
|
#[inline]
|
||||||
pub fn with_depth_buffer(mut self, bits: u8) -> WindowBuilder<'a> {
|
pub fn with_depth_buffer(mut self, bits: u8) -> WindowBuilder<'a> {
|
||||||
self.pf_reqs.depth_bits = Some(bits);
|
self.pf_reqs.depth_bits = Some(bits);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the number of bits in the stencil buffer.
|
/// Sets the number of bits in the stencil buffer.
|
||||||
|
#[inline]
|
||||||
pub fn with_stencil_buffer(mut self, bits: u8) -> WindowBuilder<'a> {
|
pub fn with_stencil_buffer(mut self, bits: u8) -> WindowBuilder<'a> {
|
||||||
self.pf_reqs.stencil_bits = Some(bits);
|
self.pf_reqs.stencil_bits = Some(bits);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the number of bits in the color buffer.
|
/// Sets the number of bits in the color buffer.
|
||||||
|
#[inline]
|
||||||
pub fn with_pixel_format(mut self, color_bits: u8, alpha_bits: u8) -> WindowBuilder<'a> {
|
pub fn with_pixel_format(mut self, color_bits: u8, alpha_bits: u8) -> WindowBuilder<'a> {
|
||||||
self.pf_reqs.color_bits = Some(color_bits);
|
self.pf_reqs.color_bits = Some(color_bits);
|
||||||
self.pf_reqs.alpha_bits = Some(alpha_bits);
|
self.pf_reqs.alpha_bits = Some(alpha_bits);
|
||||||
|
@ -145,30 +160,35 @@ impl<'a> WindowBuilder<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Request the backend to be stereoscopic.
|
/// Request the backend to be stereoscopic.
|
||||||
|
#[inline]
|
||||||
pub fn with_stereoscopy(mut self) -> WindowBuilder<'a> {
|
pub fn with_stereoscopy(mut self) -> WindowBuilder<'a> {
|
||||||
self.pf_reqs.stereoscopy = true;
|
self.pf_reqs.stereoscopy = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets whether sRGB should be enabled on the window. `None` means "I don't care".
|
/// Sets whether sRGB should be enabled on the window. `None` means "I don't care".
|
||||||
|
#[inline]
|
||||||
pub fn with_srgb(mut self, srgb_enabled: Option<bool>) -> WindowBuilder<'a> {
|
pub fn with_srgb(mut self, srgb_enabled: Option<bool>) -> WindowBuilder<'a> {
|
||||||
self.pf_reqs.srgb = srgb_enabled;
|
self.pf_reqs.srgb = srgb_enabled;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets whether the background of the window should be transparent.
|
/// Sets whether the background of the window should be transparent.
|
||||||
|
#[inline]
|
||||||
pub fn with_transparency(mut self, transparent: bool) -> WindowBuilder<'a> {
|
pub fn with_transparency(mut self, transparent: bool) -> WindowBuilder<'a> {
|
||||||
self.window.transparent = transparent;
|
self.window.transparent = transparent;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets whether the window should have a border, a title bar, etc.
|
/// Sets whether the window should have a border, a title bar, etc.
|
||||||
|
#[inline]
|
||||||
pub fn with_decorations(mut self, decorations: bool) -> WindowBuilder<'a> {
|
pub fn with_decorations(mut self, decorations: bool) -> WindowBuilder<'a> {
|
||||||
self.window.decorations = decorations;
|
self.window.decorations = decorations;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enables multitouch
|
/// Enables multitouch
|
||||||
|
#[inline]
|
||||||
pub fn with_multitouch(mut self) -> WindowBuilder<'a> {
|
pub fn with_multitouch(mut self) -> WindowBuilder<'a> {
|
||||||
self.window.multitouch = true;
|
self.window.multitouch = true;
|
||||||
self
|
self
|
||||||
|
@ -198,6 +218,7 @@ impl<'a> WindowBuilder<'a> {
|
||||||
///
|
///
|
||||||
/// The context is build in a *strict* way. That means that if the backend couldn't give
|
/// The context is build in a *strict* way. That means that if the backend couldn't give
|
||||||
/// you what you requested, an `Err` will be returned.
|
/// you what you requested, an `Err` will be returned.
|
||||||
|
#[inline]
|
||||||
pub fn build_strict(self) -> Result<Window, CreationError> {
|
pub fn build_strict(self) -> Result<Window, CreationError> {
|
||||||
self.build()
|
self.build()
|
||||||
}
|
}
|
||||||
|
@ -231,6 +252,7 @@ pub struct Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Window {
|
impl Default for Window {
|
||||||
|
#[inline]
|
||||||
fn default() -> Window {
|
fn default() -> Window {
|
||||||
Window::new().unwrap()
|
Window::new().unwrap()
|
||||||
}
|
}
|
||||||
|
@ -438,11 +460,13 @@ impl Window {
|
||||||
/// - On Windows and OS/X, this always returns `OpenGl`.
|
/// - On Windows and OS/X, this always returns `OpenGl`.
|
||||||
/// - On Android, this always returns `OpenGlEs`.
|
/// - On Android, this always returns `OpenGlEs`.
|
||||||
/// - On Linux, it must be checked at runtime.
|
/// - On Linux, it must be checked at runtime.
|
||||||
|
#[inline]
|
||||||
pub fn get_api(&self) -> Api {
|
pub fn get_api(&self) -> Api {
|
||||||
self.window.get_api()
|
self.window.get_api()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the pixel format of this window.
|
/// Returns the pixel format of this window.
|
||||||
|
#[inline]
|
||||||
pub fn get_pixel_format(&self) -> PixelFormat {
|
pub fn get_pixel_format(&self) -> PixelFormat {
|
||||||
self.window.get_pixel_format()
|
self.window.get_pixel_format()
|
||||||
}
|
}
|
||||||
|
@ -459,6 +483,7 @@ impl Window {
|
||||||
/// Sets a resize callback that is called by Mac (and potentially other
|
/// Sets a resize callback that is called by Mac (and potentially other
|
||||||
/// operating systems) during resize operations. This can be used to repaint
|
/// operating systems) during resize operations. This can be used to repaint
|
||||||
/// during window resizing.
|
/// during window resizing.
|
||||||
|
#[inline]
|
||||||
pub fn set_window_resize_callback(&mut self, callback: Option<fn(u32, u32)>) {
|
pub fn set_window_resize_callback(&mut self, callback: Option<fn(u32, u32)>) {
|
||||||
self.window.set_window_resize_callback(callback);
|
self.window.set_window_resize_callback(callback);
|
||||||
}
|
}
|
||||||
|
@ -472,11 +497,13 @@ impl Window {
|
||||||
/// Returns the ratio between the backing framebuffer resolution and the
|
/// Returns the ratio between the backing framebuffer resolution and the
|
||||||
/// window size in screen pixels. This is typically one for a normal display
|
/// window size in screen pixels. This is typically one for a normal display
|
||||||
/// and two for a retina display.
|
/// and two for a retina display.
|
||||||
|
#[inline]
|
||||||
pub fn hidpi_factor(&self) -> f32 {
|
pub fn hidpi_factor(&self) -> f32 {
|
||||||
self.window.hidpi_factor()
|
self.window.hidpi_factor()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Changes the position of the cursor in window coordinates.
|
/// Changes the position of the cursor in window coordinates.
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()> {
|
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()> {
|
||||||
self.window.set_cursor_position(x, y)
|
self.window.set_cursor_position(x, y)
|
||||||
}
|
}
|
||||||
|
@ -484,38 +511,46 @@ impl Window {
|
||||||
/// Sets how glutin handles the cursor. See the documentation of `CursorState` for details.
|
/// Sets how glutin handles the cursor. See the documentation of `CursorState` for details.
|
||||||
///
|
///
|
||||||
/// Has no effect on Android.
|
/// Has no effect on Android.
|
||||||
|
#[inline]
|
||||||
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
|
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
|
||||||
self.window.set_cursor_state(state)
|
self.window.set_cursor_state(state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl gl_common::GlFunctionsSource for Window {
|
impl gl_common::GlFunctionsSource for Window {
|
||||||
|
#[inline]
|
||||||
fn get_proc_addr(&self, addr: &str) -> *const libc::c_void {
|
fn get_proc_addr(&self, addr: &str) -> *const libc::c_void {
|
||||||
self.get_proc_address(addr)
|
self.get_proc_address(addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlContext for Window {
|
impl GlContext for Window {
|
||||||
|
#[inline]
|
||||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||||
self.make_current()
|
self.make_current()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_current(&self) -> bool {
|
fn is_current(&self) -> bool {
|
||||||
self.is_current()
|
self.is_current()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
||||||
self.get_proc_address(addr)
|
self.get_proc_address(addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||||
self.swap_buffers()
|
self.swap_buffers()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_api(&self) -> Api {
|
fn get_api(&self) -> Api {
|
||||||
self.get_api()
|
self.get_api()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_pixel_format(&self) -> PixelFormat {
|
fn get_pixel_format(&self) -> PixelFormat {
|
||||||
self.get_pixel_format()
|
self.get_pixel_format()
|
||||||
}
|
}
|
||||||
|
@ -544,10 +579,12 @@ pub struct PollEventsIterator<'a>(platform::PollEventsIterator<'a>);
|
||||||
impl<'a> Iterator for PollEventsIterator<'a> {
|
impl<'a> Iterator for PollEventsIterator<'a> {
|
||||||
type Item = Event;
|
type Item = Event;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn next(&mut self) -> Option<Event> {
|
fn next(&mut self) -> Option<Event> {
|
||||||
self.0.next()
|
self.0.next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
self.0.size_hint()
|
self.0.size_hint()
|
||||||
}
|
}
|
||||||
|
@ -559,10 +596,12 @@ pub struct WaitEventsIterator<'a>(platform::WaitEventsIterator<'a>);
|
||||||
impl<'a> Iterator for WaitEventsIterator<'a> {
|
impl<'a> Iterator for WaitEventsIterator<'a> {
|
||||||
type Item = Event;
|
type Item = Event;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn next(&mut self) -> Option<Event> {
|
fn next(&mut self) -> Option<Event> {
|
||||||
self.0.next()
|
self.0.next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
self.0.size_hint()
|
self.0.size_hint()
|
||||||
}
|
}
|
||||||
|
@ -578,22 +617,26 @@ pub struct AvailableMonitorsIter {
|
||||||
impl Iterator for AvailableMonitorsIter {
|
impl Iterator for AvailableMonitorsIter {
|
||||||
type Item = MonitorID;
|
type Item = MonitorID;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn next(&mut self) -> Option<MonitorID> {
|
fn next(&mut self) -> Option<MonitorID> {
|
||||||
self.data.next().map(|id| MonitorID(id))
|
self.data.next().map(|id| MonitorID(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
self.data.size_hint()
|
self.data.size_hint()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the list of all available monitors.
|
/// Returns the list of all available monitors.
|
||||||
|
#[inline]
|
||||||
pub fn get_available_monitors() -> AvailableMonitorsIter {
|
pub fn get_available_monitors() -> AvailableMonitorsIter {
|
||||||
let data = platform::get_available_monitors();
|
let data = platform::get_available_monitors();
|
||||||
AvailableMonitorsIter{ data: data.into_iter() }
|
AvailableMonitorsIter{ data: data.into_iter() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the primary monitor of the system.
|
/// Returns the primary monitor of the system.
|
||||||
|
#[inline]
|
||||||
pub fn get_primary_monitor() -> MonitorID {
|
pub fn get_primary_monitor() -> MonitorID {
|
||||||
MonitorID(platform::get_primary_monitor())
|
MonitorID(platform::get_primary_monitor())
|
||||||
}
|
}
|
||||||
|
@ -603,18 +646,21 @@ pub struct MonitorID(platform::MonitorID);
|
||||||
|
|
||||||
impl MonitorID {
|
impl MonitorID {
|
||||||
/// Returns a human-readable name of the monitor.
|
/// Returns a human-readable name of the monitor.
|
||||||
|
#[inline]
|
||||||
pub fn get_name(&self) -> Option<String> {
|
pub fn get_name(&self) -> Option<String> {
|
||||||
let &MonitorID(ref id) = self;
|
let &MonitorID(ref id) = self;
|
||||||
id.get_name()
|
id.get_name()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the native platform identifier for this monitor.
|
/// Returns the native platform identifier for this monitor.
|
||||||
|
#[inline]
|
||||||
pub fn get_native_identifier(&self) -> NativeMonitorId {
|
pub fn get_native_identifier(&self) -> NativeMonitorId {
|
||||||
let &MonitorID(ref id) = self;
|
let &MonitorID(ref id) = self;
|
||||||
id.get_native_identifier()
|
id.get_native_identifier()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the number of pixels currently displayed on the monitor.
|
/// Returns the number of pixels currently displayed on the monitor.
|
||||||
|
#[inline]
|
||||||
pub fn get_dimensions(&self) -> (u32, u32) {
|
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||||
let &MonitorID(ref id) = self;
|
let &MonitorID(ref id) = self;
|
||||||
id.get_dimensions()
|
id.get_dimensions()
|
||||||
|
|
Loading…
Reference in a new issue