aboutsummaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
authorFredrik Noren <fredrik.jw.noren@gmail.com>2016-01-08 00:03:54 -0500
committerFredrik Noren <fredrik.jw.noren@gmail.com>2016-01-08 00:03:54 -0500
commitc6c4dfdd1e1c28878d5049c825db377dd5c747ee (patch)
tree5aa5bfe603ecea745c69eaa661937e2437aca684 /src/api
parent88e64a87a9fcfd0b71803b1adab3cd12787fc90f (diff)
downloadglutin-c6c4dfdd1e1c28878d5049c825db377dd5c747ee.tar.gz
glutin-c6c4dfdd1e1c28878d5049c825db377dd5c747ee.zip
Fix cocoa headless
Diffstat (limited to 'src/api')
-rw-r--r--src/api/cocoa/headless.rs48
1 files changed, 9 insertions, 39 deletions
diff --git a/src/api/cocoa/headless.rs b/src/api/cocoa/headless.rs
index d0d59f3..c12f016 100644
--- a/src/api/cocoa/headless.rs
+++ b/src/api/cocoa/headless.rs
@@ -14,13 +14,6 @@ use cocoa::base::{id, nil};
use cocoa::appkit::*;
use PixelFormat;
-mod gl {
- include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs"));
-}
-
-static mut framebuffer: u32 = 0;
-static mut texture: u32 = 0;
-
pub struct HeadlessContext {
width: u32,
height: u32,
@@ -33,9 +26,14 @@ impl HeadlessContext {
{
let context = unsafe {
let attributes = [
- NSOpenGLPFAAccelerated as u32,
- NSOpenGLPFAAllowOfflineRenderers as u32,
NSOpenGLPFADoubleBuffer as u32,
+ NSOpenGLPFAClosestPolicy as u32,
+ NSOpenGLPFAColorSize as u32, 24,
+ NSOpenGLPFAAlphaSize as u32, 8,
+ NSOpenGLPFADepthSize as u32, 24,
+ NSOpenGLPFAStencilSize as u32, 8,
+
+ NSOpenGLPFAOpenGLProfile as u32, NSOpenGLProfileVersion3_2Core as u32,
0
];
@@ -56,9 +54,6 @@ impl HeadlessContext {
context: context,
};
- // Load the function pointers as we need them to create the FBO
- gl::load_with(|s| headless.get_proc_address(s) as *const c_void);
-
Ok(headless)
}
}
@@ -66,28 +61,12 @@ impl HeadlessContext {
impl GlContext for HeadlessContext {
unsafe fn make_current(&self) -> Result<(), ContextError> {
self.context.makeCurrentContext();
-
- gl::GenFramebuffersEXT(1, &mut framebuffer);
- gl::BindFramebufferEXT(gl::FRAMEBUFFER_EXT, framebuffer);
- gl::GenTextures(1, &mut texture);
- gl::BindTexture(gl::TEXTURE_2D, texture);
- gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_MAG_FILTER, gl::LINEAR as i32);
- gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_MIN_FILTER, gl::LINEAR as i32);
- gl::TexImage2D(gl::TEXTURE_2D, 0, gl::RGBA8 as i32, self.width as i32, self.height as i32,
- 0, gl::RGBA, gl::UNSIGNED_BYTE, ptr::null());
- gl::FramebufferTexture2DEXT(gl::FRAMEBUFFER_EXT, gl::COLOR_ATTACHMENT0_EXT,
- gl::TEXTURE_2D, texture, 0);
- let status = gl::CheckFramebufferStatusEXT(gl::FRAMEBUFFER_EXT);
- if status != gl::FRAMEBUFFER_COMPLETE_EXT {
- panic!("Error while creating the framebuffer");
- }
-
Ok(())
}
#[inline]
fn is_current(&self) -> bool {
- unimplemented!()
+ true
}
#[inline]
@@ -105,6 +84,7 @@ impl GlContext for HeadlessContext {
#[inline]
fn swap_buffers(&self) -> Result<(), ContextError> {
+ unsafe { self.context.flushBuffer(); }
Ok(())
}
@@ -121,13 +101,3 @@ impl GlContext for HeadlessContext {
unsafe impl Send for HeadlessContext {}
unsafe impl Sync for HeadlessContext {}
-
-impl Drop for HeadlessContext {
- #[inline]
- fn drop(&mut self) {
- unsafe {
- gl::DeleteTextures(1, &texture);
- gl::DeleteFramebuffersEXT(1, &framebuffer);
- }
- }
-}