mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 22:31:30 +11:00
Fix OS X build.
This commit is contained in:
parent
862baf8220
commit
e12e4bf38f
8
build.rs
8
build.rs
|
@ -51,6 +51,14 @@ fn main() {
|
||||||
"1.5", "core", &mut file).unwrap();
|
"1.5", "core", &mut file).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if target.contains("darwin") {
|
||||||
|
let mut file = File::create(&dest.join("gl_bindings.rs")).unwrap();
|
||||||
|
gl_generator::generate_bindings(gl_generator::GlobalGenerator,
|
||||||
|
gl_generator::registry::Ns::Gl,
|
||||||
|
khronos_api::GL_XML,
|
||||||
|
vec!["GL_EXT_framebuffer_object".to_string()],
|
||||||
|
"3.2", "core", &mut file).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: only build the bindings below if we run tests/examples
|
// TODO: only build the bindings below if we run tests/examples
|
||||||
|
|
||||||
|
|
|
@ -11,36 +11,30 @@ use cocoa::base::{id, nil};
|
||||||
use cocoa::appkit::*;
|
use cocoa::appkit::*;
|
||||||
|
|
||||||
mod gl {
|
mod gl {
|
||||||
generate_gl_bindings! {
|
include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs"));
|
||||||
api: "gl",
|
|
||||||
profile: "core",
|
|
||||||
version: "3.2",
|
|
||||||
generator: "global",
|
|
||||||
extensions: ["GL_EXT_framebuffer_object"],
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static mut framebuffer: u32 = 0;
|
static mut framebuffer: u32 = 0;
|
||||||
static mut texture: u32 = 0;
|
static mut texture: u32 = 0;
|
||||||
|
|
||||||
pub struct HeadlessContext {
|
pub struct HeadlessContext {
|
||||||
width: usize,
|
width: u32,
|
||||||
height: usize,
|
height: u32,
|
||||||
context: id,
|
context: id,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HeadlessContext {
|
impl HeadlessContext {
|
||||||
pub fn new(builder: BuilderAttribs) -> Result<HeadlessContext, CreationError> {
|
pub fn new(builder: BuilderAttribs) -> Result<HeadlessContext, CreationError> {
|
||||||
let (width, height) = builder.dimensions;
|
let (width, height) = builder.dimensions.unwrap_or((1024, 768));
|
||||||
let context = unsafe {
|
let context = unsafe {
|
||||||
let attributes = [
|
let attributes = [
|
||||||
NSOpenGLPFADoubleBuffer as usize,
|
NSOpenGLPFADoubleBuffer as u32,
|
||||||
NSOpenGLPFAClosestPolicy as usize,
|
NSOpenGLPFAClosestPolicy as u32,
|
||||||
NSOpenGLPFAColorSize as usize, 24,
|
NSOpenGLPFAColorSize as u32, 24,
|
||||||
NSOpenGLPFAAlphaSize as usize, 8,
|
NSOpenGLPFAAlphaSize as u32, 8,
|
||||||
NSOpenGLPFADepthSize as usize, 24,
|
NSOpenGLPFADepthSize as u32, 24,
|
||||||
NSOpenGLPFAStencilSize as usize, 8,
|
NSOpenGLPFAStencilSize as u32, 8,
|
||||||
NSOpenGLPFAOffScreen as usize,
|
NSOpenGLPFAOffScreen as u32,
|
||||||
0
|
0
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -87,8 +81,8 @@ impl HeadlessContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_proc_address(&self, _addr: &str) -> *const () {
|
pub fn get_proc_address(&self, _addr: &str) -> *const () {
|
||||||
let symbol_name: CFString = from_str(_addr).unwrap();
|
let symbol_name: CFString = _addr.parse().unwrap();
|
||||||
let framework_name: CFString = from_str("com.apple.opengl").unwrap();
|
let framework_name: CFString = "com.apple.opengl".parse().unwrap();
|
||||||
let framework = unsafe {
|
let framework = unsafe {
|
||||||
CFBundleGetBundleWithIdentifier(framework_name.as_concrete_TypeRef())
|
CFBundleGetBundleWithIdentifier(framework_name.as_concrete_TypeRef())
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue