mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
Rustup
This commit is contained in:
parent
63d2cd263e
commit
cedc85c550
4
build.rs
4
build.rs
|
@ -1,3 +1,5 @@
|
||||||
|
#![feature(convert)]
|
||||||
|
|
||||||
extern crate gl_generator;
|
extern crate gl_generator;
|
||||||
extern crate khronos_api;
|
extern crate khronos_api;
|
||||||
|
|
||||||
|
@ -7,7 +9,7 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let target = env::var("TARGET").unwrap();
|
let target = env::var("TARGET").unwrap();
|
||||||
let dest = PathBuf::new(&env::var("OUT_DIR").unwrap());
|
let dest = PathBuf::from(&env::var("OUT_DIR").unwrap());
|
||||||
|
|
||||||
if target.contains("windows") {
|
if target.contains("windows") {
|
||||||
let mut file = File::create(&dest.join("wgl_bindings.rs")).unwrap();
|
let mut file = File::create(&dest.join("wgl_bindings.rs")).unwrap();
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![feature(std_misc)]
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate android_glue;
|
extern crate android_glue;
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![feature(std_misc)]
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate android_glue;
|
extern crate android_glue;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![feature(std_misc)]
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate android_glue;
|
extern crate android_glue;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![feature(std_misc)]
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate android_glue;
|
extern crate android_glue;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![feature(std_misc)]
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate android_glue;
|
extern crate android_glue;
|
||||||
|
|
12
src/lib.rs
12
src/lib.rs
|
@ -1,4 +1,4 @@
|
||||||
#![feature(unsafe_destructor,core,std_misc)]
|
#![feature(collections, unsafe_destructor, os, core, std_misc, alloc)]
|
||||||
#![unstable]
|
#![unstable]
|
||||||
|
|
||||||
//! The purpose of this library is to provide an OpenGL context on as many
|
//! The purpose of this library is to provide an OpenGL context on as many
|
||||||
|
@ -32,17 +32,17 @@ extern crate libc;
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
extern crate winapi;
|
extern crate winapi;
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
extern crate "kernel32-sys" as kernel32;
|
extern crate kernel32_sys as kernel32;
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
extern crate "gdi32-sys" as gdi32;
|
extern crate gdi32_sys as gdi32;
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
extern crate "user32-sys" as user32;
|
extern crate user32_sys as user32;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
extern crate cocoa;
|
extern crate cocoa;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
extern crate core_foundation;
|
extern crate core_foundation;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
extern crate "glutin_core_graphics" as core_graphics;
|
extern crate glutin_core_graphics as core_graphics;
|
||||||
|
|
||||||
pub use events::*;
|
pub use events::*;
|
||||||
#[cfg(feature = "headless")]
|
#[cfg(feature = "headless")]
|
||||||
|
@ -86,7 +86,7 @@ pub enum CreationError {
|
||||||
impl CreationError {
|
impl CreationError {
|
||||||
fn to_string(&self) -> &str {
|
fn to_string(&self) -> &str {
|
||||||
match *self {
|
match *self {
|
||||||
CreationError::OsError(ref text) => text.as_slice(),
|
CreationError::OsError(ref text) => &text,
|
||||||
CreationError::NotSupported => "Some of the requested attributes are not supported",
|
CreationError::NotSupported => "Some of the requested attributes are not supported",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::sync::mpsc::{Sender, Receiver, channel};
|
use std::sync::mpsc::Sender;
|
||||||
|
|
||||||
use Event;
|
use Event;
|
||||||
use super::event;
|
use super::event;
|
||||||
|
@ -52,7 +52,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
||||||
};
|
};
|
||||||
|
|
||||||
if win == &window {
|
if win == &window {
|
||||||
unsafe { user32::PostQuitMessage(0); }
|
user32::PostQuitMessage(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
||||||
winapi::WM_CHAR => {
|
winapi::WM_CHAR => {
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use events::Event::ReceivedCharacter;
|
use events::Event::ReceivedCharacter;
|
||||||
let chr: char = unsafe { mem::transmute(wparam as u32) };
|
let chr: char = mem::transmute(wparam as u32);
|
||||||
send_event(window, ReceivedCharacter(chr));
|
send_event(window, ReceivedCharacter(chr));
|
||||||
0
|
0
|
||||||
},
|
},
|
||||||
|
@ -188,7 +188,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
||||||
0
|
0
|
||||||
},
|
},
|
||||||
|
|
||||||
_ => unsafe {
|
_ => {
|
||||||
user32::DefWindowProcW(window, msg, wparam, lparam)
|
user32::DefWindowProcW(window, msg, wparam, lparam)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,7 +235,7 @@ unsafe fn init(title: Vec<u16>, builder: BuilderAttribs<'static>,
|
||||||
// handling vsync
|
// handling vsync
|
||||||
if builder.vsync {
|
if builder.vsync {
|
||||||
if extra_functions.SwapIntervalEXT.is_loaded() {
|
if extra_functions.SwapIntervalEXT.is_loaded() {
|
||||||
let guard = try!(CurrentContextGuard::make_current(&real_window, &context));
|
let _guard = try!(CurrentContextGuard::make_current(&real_window, &context));
|
||||||
|
|
||||||
if extra_functions.SwapIntervalEXT(1) == 0 {
|
if extra_functions.SwapIntervalEXT(1) == 0 {
|
||||||
return Err(OsError(format!("wglSwapIntervalEXT failed")));
|
return Err(OsError(format!("wglSwapIntervalEXT failed")));
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use std::sync::atomic::AtomicBool;
|
use std::sync::atomic::AtomicBool;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::collections::VecDeque;
|
|
||||||
use std::sync::mpsc::Receiver;
|
use std::sync::mpsc::Receiver;
|
||||||
use libc;
|
use libc;
|
||||||
use {CreationError, Event, MouseCursor};
|
use {CreationError, Event, MouseCursor};
|
||||||
|
|
|
@ -2,6 +2,7 @@ use winapi;
|
||||||
use user32;
|
use user32;
|
||||||
|
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
use std::mem;
|
||||||
|
|
||||||
use native_monitor::NativeMonitorId;
|
use native_monitor::NativeMonitorId;
|
||||||
|
|
||||||
|
@ -83,15 +84,12 @@ impl Iterator for DeviceEnumerator {
|
||||||
|
|
||||||
fn wchar_as_string(wchar: &[winapi::WCHAR]) -> String {
|
fn wchar_as_string(wchar: &[winapi::WCHAR]) -> String {
|
||||||
String::from_utf16_lossy(wchar)
|
String::from_utf16_lossy(wchar)
|
||||||
.as_slice()
|
|
||||||
.trim_right_matches(0 as char)
|
.trim_right_matches(0 as char)
|
||||||
.to_string()
|
.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Win32 implementation of the main `get_available_monitors` function.
|
/// Win32 implementation of the main `get_available_monitors` function.
|
||||||
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
||||||
use std::{iter, mem, ptr};
|
|
||||||
|
|
||||||
// return value
|
// return value
|
||||||
let mut result = VecDeque::new();
|
let mut result = VecDeque::new();
|
||||||
|
|
||||||
|
@ -120,8 +118,8 @@ pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
||||||
// adding to the resulting list
|
// adding to the resulting list
|
||||||
result.push_back(MonitorID {
|
result.push_back(MonitorID {
|
||||||
adapter_name: adapter.DeviceName,
|
adapter_name: adapter.DeviceName,
|
||||||
monitor_name: wchar_as_string(monitor.DeviceName.as_slice()),
|
monitor_name: wchar_as_string(&monitor.DeviceName),
|
||||||
readable_name: wchar_as_string(monitor.DeviceString.as_slice()),
|
readable_name: wchar_as_string(&monitor.DeviceString),
|
||||||
flags: monitor.StateFlags,
|
flags: monitor.StateFlags,
|
||||||
position: position,
|
position: position,
|
||||||
dimensions: dimensions,
|
dimensions: dimensions,
|
||||||
|
@ -165,7 +163,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.
|
||||||
pub fn get_adapter_name(&self) -> &[winapi::WCHAR] {
|
pub fn get_adapter_name(&self) -> &[winapi::WCHAR] {
|
||||||
self.adapter_name.as_slice()
|
&self.adapter_name
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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
|
||||||
|
|
Loading…
Reference in a new issue