mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-23 18:36:34 +11:00
Started adding support for selection OpenGL versions on OS X. Needs issue #176 to be fixed.
This commit is contained in:
parent
29bf3385ad
commit
86af6b6387
1 changed files with 23 additions and 4 deletions
|
@ -44,6 +44,15 @@ static mut alt_pressed: bool = false;
|
||||||
static DELEGATE_NAME: &'static [u8] = b"glutin_window_delegate\0";
|
static DELEGATE_NAME: &'static [u8] = b"glutin_window_delegate\0";
|
||||||
static DELEGATE_STATE_IVAR: &'static [u8] = b"glutin_state";
|
static DELEGATE_STATE_IVAR: &'static [u8] = b"glutin_state";
|
||||||
|
|
||||||
|
// TODO: Should be added to cocoa bindings
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
#[deriving(Show)]
|
||||||
|
enum NSOpenGLPFAOpenGLProfiles {
|
||||||
|
NSOpenGLProfileVersionLegacy = 0x1000,
|
||||||
|
NSOpenGLProfileVersion3_2Core = 0x3200,
|
||||||
|
NSOpenGLProfileVersion4_1Core = 0x4100
|
||||||
|
}
|
||||||
|
|
||||||
struct DelegateState<'a> {
|
struct DelegateState<'a> {
|
||||||
is_closed: bool,
|
is_closed: bool,
|
||||||
context: id,
|
context: id,
|
||||||
|
@ -68,7 +77,7 @@ impl Window {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::new_impl(builder.dimensions, builder.title.as_slice(), builder.monitor, builder.vsync, builder.visible)
|
Window::new_impl(builder.dimensions, builder.title.as_slice(), builder.monitor, builder.vsync, builder.visible, builder.gl_version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +139,7 @@ extern fn window_did_resize(this: id, _: id) -> id {
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
fn new_impl(dimensions: Option<(uint, uint)>, title: &str, monitor: Option<MonitorID>,
|
fn new_impl(dimensions: Option<(uint, uint)>, title: &str, monitor: Option<MonitorID>,
|
||||||
vsync: bool, visible: bool) -> Result<Window, CreationError> {
|
vsync: bool, visible: bool, gl_version: Option<(uint, uint)>) -> Result<Window, CreationError> {
|
||||||
let app = match Window::create_app() {
|
let app = match Window::create_app() {
|
||||||
Some(app) => app,
|
Some(app) => app,
|
||||||
None => { return Err(OsError(format!("Couldn't create NSApplication"))); },
|
None => { return Err(OsError(format!("Couldn't create NSApplication"))); },
|
||||||
|
@ -144,7 +153,7 @@ impl Window {
|
||||||
None => { return Err(OsError(format!("Couldn't create NSView"))); },
|
None => { return Err(OsError(format!("Couldn't create NSView"))); },
|
||||||
};
|
};
|
||||||
|
|
||||||
let context = match Window::create_context(view, vsync) {
|
let context = match Window::create_context(view, vsync, gl_version) {
|
||||||
Some(context) => context,
|
Some(context) => context,
|
||||||
None => { return Err(OsError(format!("Couldn't create OpenGL context"))); },
|
None => { return Err(OsError(format!("Couldn't create OpenGL context"))); },
|
||||||
};
|
};
|
||||||
|
@ -260,7 +269,16 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_context(view: id, vsync: bool) -> Option<id> {
|
fn create_context(view: id, vsync: bool, gl_version: Option<(uint, uint)>) -> Option<id> {
|
||||||
|
let profile = {
|
||||||
|
match gl_version {
|
||||||
|
None => NSOpenGLPFAOpenGLProfiles::NSOpenGLProfileVersionLegacy as uint,
|
||||||
|
Some((0...2, _)) => NSOpenGLPFAOpenGLProfiles::NSOpenGLProfileVersionLegacy as uint,
|
||||||
|
Some((3, 0)) => NSOpenGLPFAOpenGLProfiles::NSOpenGLProfileVersionLegacy as uint,
|
||||||
|
Some((3, 1...2)) => NSOpenGLPFAOpenGLProfiles::NSOpenGLProfileVersion3_2Core as uint,
|
||||||
|
Some((_, _)) => NSOpenGLPFAOpenGLProfiles::NSOpenGLProfileVersion4_1Core as uint,
|
||||||
|
}
|
||||||
|
};
|
||||||
unsafe {
|
unsafe {
|
||||||
let attributes = [
|
let attributes = [
|
||||||
NSOpenGLPFADoubleBuffer as uint,
|
NSOpenGLPFADoubleBuffer as uint,
|
||||||
|
@ -269,6 +287,7 @@ impl Window {
|
||||||
NSOpenGLPFAAlphaSize as uint, 8,
|
NSOpenGLPFAAlphaSize as uint, 8,
|
||||||
NSOpenGLPFADepthSize as uint, 24,
|
NSOpenGLPFADepthSize as uint, 24,
|
||||||
NSOpenGLPFAStencilSize as uint, 8,
|
NSOpenGLPFAStencilSize as uint, 8,
|
||||||
|
NSOpenGLPFAOpenGLProfile as uint, profile,
|
||||||
0
|
0
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue