aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2015-12-01 09:50:36 +0100
committertomaka <pierre.krieger1708@gmail.com>2015-12-01 09:50:36 +0100
commit8c3ffd2a4fe2dbb0033c1f830d384c0c2d8c88a1 (patch)
treead1cd324f08dc78d95225d3a49ce0c54fdb928f9
parent5b819eda9ab682e06bfbabe64ce52bc5444b7608 (diff)
parent816fbb2165e3d2f5656a3afa9d9553551c0c6b68 (diff)
downloadglutin-8c3ffd2a4fe2dbb0033c1f830d384c0c2d8c88a1.tar.gz
glutin-8c3ffd2a4fe2dbb0033c1f830d384c0c2d8c88a1.zip
Merge pull request #667 from tomaka/libc-update
Follow-up of #666
-rw-r--r--Cargo.toml8
-rw-r--r--src/api/cocoa/headless.rs4
-rw-r--r--src/api/dlopen.rs14
-rw-r--r--src/api/egl/mod.rs38
-rw-r--r--src/api/wgl/make_current_guard.rs6
-rw-r--r--src/api/wgl/mod.rs78
6 files changed, 74 insertions, 74 deletions
diff --git a/Cargo.toml b/Cargo.toml
index de9d2d0..56ec2b5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "glutin"
-version = "0.4.2"
+version = "0.4.3"
authors = ["tomaka <pierre.krieger1708@gmail.com>"]
description = "Cross-plaform OpenGL context provider."
keywords = ["windowing", "opengl"]
@@ -17,8 +17,8 @@ libc = "0.2"
shared_library = "0.1.0"
[build-dependencies]
-gl_generator = "0.2.0"
-khronos_api = "0.0.8"
+gl_generator = "0.4"
+khronos_api = "1.0"
[dev-dependencies]
clock_ticks = "0.1.0"
@@ -44,7 +44,7 @@ objc = "0.1.8"
[target.x86_64-apple-darwin.dependencies]
objc = "0.1.8"
cgl = "0.1"
-cocoa = "0.1.4"
+cocoa = "0.2"
core-foundation = "0"
core-graphics = "0"
diff --git a/src/api/cocoa/headless.rs b/src/api/cocoa/headless.rs
index 1318185..d0d59f3 100644
--- a/src/api/cocoa/headless.rs
+++ b/src/api/cocoa/headless.rs
@@ -4,7 +4,7 @@ use CreationError::OsError;
use GlAttributes;
use GlContext;
use PixelFormatRequirements;
-use libc;
+use std::os::raw::c_void;
use std::ptr;
use core_foundation::base::TCFType;
@@ -57,7 +57,7 @@ impl HeadlessContext {
};
// Load the function pointers as we need them to create the FBO
- gl::load_with(|s| headless.get_proc_address(s) as *const libc::c_void);
+ gl::load_with(|s| headless.get_proc_address(s) as *const c_void);
Ok(headless)
}
diff --git a/src/api/dlopen.rs b/src/api/dlopen.rs
index 1bb2a0a..bacdd2c 100644
--- a/src/api/dlopen.rs
+++ b/src/api/dlopen.rs
@@ -1,15 +1,15 @@
#![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))]
#![allow(dead_code)]
-use libc;
+use std::os::raw::{c_void, c_char, c_int};
-pub const RTLD_LAZY: libc::c_int = 0x001;
-pub const RTLD_NOW: libc::c_int = 0x002;
+pub const RTLD_LAZY: c_int = 0x001;
+pub const RTLD_NOW: c_int = 0x002;
#[link="dl"]
extern {
- pub fn dlopen(filename: *const libc::c_char, flag: libc::c_int) -> *mut libc::c_void;
- pub fn dlerror() -> *mut libc::c_char;
- pub fn dlsym(handle: *mut libc::c_void, symbol: *const libc::c_char) -> *mut libc::c_void;
- pub fn dlclose(handle: *mut libc::c_void) -> libc::c_int;
+ pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void;
+ pub fn dlerror() -> *mut c_char;
+ pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void;
+ pub fn dlclose(handle: *mut c_void) -> c_int;
}
diff --git a/src/api/egl/mod.rs b/src/api/egl/mod.rs
index 53f8fc9..5e80068 100644
--- a/src/api/egl/mod.rs
+++ b/src/api/egl/mod.rs
@@ -12,8 +12,8 @@ use PixelFormatRequirements;
use Robustness;
use Api;
-use libc;
use std::ffi::{CStr, CString};
+use std::os::raw::{c_void, c_int};
use std::{mem, ptr};
pub mod ffi;
@@ -46,13 +46,13 @@ pub struct Context {
#[cfg(target_os = "android")]
#[inline]
fn get_native_display(egl: &ffi::egl::Egl,
- native_display: NativeDisplay) -> *const libc::c_void {
+ native_display: NativeDisplay) -> *const c_void {
unsafe { egl.GetDisplay(ffi::egl::DEFAULT_DISPLAY as *mut _) }
}
#[cfg(not(target_os = "android"))]
fn get_native_display(egl: &ffi::egl::Egl,
- native_display: NativeDisplay) -> *const libc::c_void {
+ native_display: NativeDisplay) -> *const c_void {
// the first step is to query the list of extensions without any display, if supported
let dp_extensions = unsafe {
let p = egl.QueryString(ffi::egl::NO_DISPLAY, ffi::egl::EXTENSIONS as i32);
@@ -374,9 +374,9 @@ impl<'a> ContextPrototype<'a> {
pub fn finish_pbuffer(self, dimensions: (u32, u32)) -> Result<Context, CreationError> {
let attrs = &[
- ffi::egl::WIDTH as libc::c_int, dimensions.0 as libc::c_int,
- ffi::egl::HEIGHT as libc::c_int, dimensions.1 as libc::c_int,
- ffi::egl::NONE as libc::c_int,
+ ffi::egl::WIDTH as c_int, dimensions.0 as c_int,
+ ffi::egl::HEIGHT as c_int, dimensions.1 as c_int,
+ ffi::egl::NONE as c_int,
];
let surface = unsafe {
@@ -584,7 +584,7 @@ unsafe fn create_context(egl: &ffi::egl::Egl, display: ffi::egl::types::EGLDispl
Robustness::NoError => {
if extensions.iter().find(|s| s == &"EGL_KHR_create_context_no_error").is_some() {
- context_attributes.push(ffi::egl::CONTEXT_OPENGL_NO_ERROR_KHR as libc::c_int);
+ context_attributes.push(ffi::egl::CONTEXT_OPENGL_NO_ERROR_KHR as c_int);
context_attributes.push(1);
}
},
@@ -592,9 +592,9 @@ unsafe fn create_context(egl: &ffi::egl::Egl, display: ffi::egl::types::EGLDispl
Robustness::RobustNoResetNotification => {
if supports_robustness {
context_attributes.push(ffi::egl::CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY
- as libc::c_int);
- context_attributes.push(ffi::egl::NO_RESET_NOTIFICATION as libc::c_int);
- flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as libc::c_int;
+ as c_int);
+ context_attributes.push(ffi::egl::NO_RESET_NOTIFICATION as c_int);
+ flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as c_int;
} else {
return Err(CreationError::RobustnessNotSupported);
}
@@ -603,18 +603,18 @@ unsafe fn create_context(egl: &ffi::egl::Egl, display: ffi::egl::types::EGLDispl
Robustness::TryRobustNoResetNotification => {
if supports_robustness {
context_attributes.push(ffi::egl::CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY
- as libc::c_int);
- context_attributes.push(ffi::egl::NO_RESET_NOTIFICATION as libc::c_int);
- flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as libc::c_int;
+ as c_int);
+ context_attributes.push(ffi::egl::NO_RESET_NOTIFICATION as c_int);
+ flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as c_int;
}
},
Robustness::RobustLoseContextOnReset => {
if supports_robustness {
context_attributes.push(ffi::egl::CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY
- as libc::c_int);
- context_attributes.push(ffi::egl::LOSE_CONTEXT_ON_RESET as libc::c_int);
- flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as libc::c_int;
+ as c_int);
+ context_attributes.push(ffi::egl::LOSE_CONTEXT_ON_RESET as c_int);
+ flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as c_int;
} else {
return Err(CreationError::RobustnessNotSupported);
}
@@ -623,9 +623,9 @@ unsafe fn create_context(egl: &ffi::egl::Egl, display: ffi::egl::types::EGLDispl
Robustness::TryRobustLoseContextOnReset => {
if supports_robustness {
context_attributes.push(ffi::egl::CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY
- as libc::c_int);
- context_attributes.push(ffi::egl::LOSE_CONTEXT_ON_RESET as libc::c_int);
- flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as libc::c_int;
+ as c_int);
+ context_attributes.push(ffi::egl::LOSE_CONTEXT_ON_RESET as c_int);
+ flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as c_int;
}
},
}
diff --git a/src/api/wgl/make_current_guard.rs b/src/api/wgl/make_current_guard.rs
index b890c82..83e35b2 100644
--- a/src/api/wgl/make_current_guard.rs
+++ b/src/api/wgl/make_current_guard.rs
@@ -1,7 +1,7 @@
use std::marker::PhantomData;
+use std::os::raw::c_void;
use std::io;
-use libc;
use winapi;
use CreationError;
@@ -40,8 +40,8 @@ impl<'a, 'b> CurrentContextGuard<'a, 'b> {
impl<'a, 'b> Drop for CurrentContextGuard<'a, 'b> {
fn drop(&mut self) {
unsafe {
- gl::wgl::MakeCurrent(self.previous_hdc as *const libc::c_void,
- self.previous_hglrc as *const libc::c_void);
+ gl::wgl::MakeCurrent(self.previous_hdc as *const c_void,
+ self.previous_hglrc as *const c_void);
}
}
}
diff --git a/src/api/wgl/mod.rs b/src/api/wgl/mod.rs
index 0f6a944..77e3f83 100644
--- a/src/api/wgl/mod.rs
+++ b/src/api/wgl/mod.rs
@@ -13,8 +13,8 @@ use Api;
use self::make_current_guard::CurrentContextGuard;
-use libc;
use std::ffi::{CStr, CString, OsStr};
+use std::os::raw::{c_void, c_int};
use std::os::windows::ffi::OsStrExt;
use std::{mem, ptr};
use std::io;
@@ -168,7 +168,7 @@ impl GlContext for Context {
#[inline]
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 c_void }
}
fn get_proc_address(&self, addr: &str) -> *const () {
@@ -232,32 +232,32 @@ unsafe fn create_context(extra: Option<(&gl::wgl_extra::Wgl, &PixelFormatRequire
match opengl.version {
GlRequest::Latest => {},
GlRequest::Specific(Api::OpenGl, (major, minor)) => {
- attributes.push(gl::wgl_extra::CONTEXT_MAJOR_VERSION_ARB as libc::c_int);
- attributes.push(major as libc::c_int);
- attributes.push(gl::wgl_extra::CONTEXT_MINOR_VERSION_ARB as libc::c_int);
- attributes.push(minor as libc::c_int);
+ attributes.push(gl::wgl_extra::CONTEXT_MAJOR_VERSION_ARB as c_int);
+ attributes.push(major as c_int);
+ attributes.push(gl::wgl_extra::CONTEXT_MINOR_VERSION_ARB as c_int);
+ attributes.push(minor as c_int);
},
GlRequest::Specific(Api::OpenGlEs, (major, minor)) => {
if extensions.split(' ').find(|&i| i == "WGL_EXT_create_context_es2_profile")
.is_some()
{
- attributes.push(gl::wgl_extra::CONTEXT_PROFILE_MASK_ARB as libc::c_int);
- attributes.push(gl::wgl_extra::CONTEXT_ES2_PROFILE_BIT_EXT as libc::c_int);
+ attributes.push(gl::wgl_extra::CONTEXT_PROFILE_MASK_ARB as c_int);
+ attributes.push(gl::wgl_extra::CONTEXT_ES2_PROFILE_BIT_EXT as c_int);
} else {
return Err(CreationError::OpenGlVersionNotSupported);
}
- attributes.push(gl::wgl_extra::CONTEXT_MAJOR_VERSION_ARB as libc::c_int);
- attributes.push(major as libc::c_int);
- attributes.push(gl::wgl_extra::CONTEXT_MINOR_VERSION_ARB as libc::c_int);
- attributes.push(minor as libc::c_int);
+ attributes.push(gl::wgl_extra::CONTEXT_MAJOR_VERSION_ARB as c_int);
+ attributes.push(major as c_int);
+ attributes.push(gl::wgl_extra::CONTEXT_MINOR_VERSION_ARB as c_int);
+ attributes.push(minor as c_int);
},
GlRequest::Specific(_, _) => return Err(CreationError::OpenGlVersionNotSupported),
GlRequest::GlThenGles { opengl_version: (major, minor), .. } => {
- attributes.push(gl::wgl_extra::CONTEXT_MAJOR_VERSION_ARB as libc::c_int);
- attributes.push(major as libc::c_int);
- attributes.push(gl::wgl_extra::CONTEXT_MINOR_VERSION_ARB as libc::c_int);
- attributes.push(minor as libc::c_int);
+ attributes.push(gl::wgl_extra::CONTEXT_MAJOR_VERSION_ARB as c_int);
+ attributes.push(major as c_int);
+ attributes.push(gl::wgl_extra::CONTEXT_MINOR_VERSION_ARB as c_int);
+ attributes.push(minor as c_int);
},
}
@@ -270,8 +270,8 @@ unsafe fn create_context(extra: Option<(&gl::wgl_extra::Wgl, &PixelFormatRequire
GlProfile::Core =>
gl::wgl_extra::CONTEXT_CORE_PROFILE_BIT_ARB,
};
- attributes.push(gl::wgl_extra::CONTEXT_PROFILE_MASK_ARB as libc::c_int);
- attributes.push(flag as libc::c_int);
+ attributes.push(gl::wgl_extra::CONTEXT_PROFILE_MASK_ARB as c_int);
+ attributes.push(flag as c_int);
} else {
return Err(CreationError::NotSupported);
}
@@ -284,14 +284,14 @@ unsafe fn create_context(extra: Option<(&gl::wgl_extra::Wgl, &PixelFormatRequire
if extensions.split(' ').find(|&i| i == "WGL_ARB_create_context_robustness").is_some() {
match opengl.robustness {
Robustness::RobustNoResetNotification | Robustness::TryRobustNoResetNotification => {
- attributes.push(gl::wgl_extra::CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB as libc::c_int);
- attributes.push(gl::wgl_extra::NO_RESET_NOTIFICATION_ARB as libc::c_int);
- flags = flags | gl::wgl_extra::CONTEXT_ROBUST_ACCESS_BIT_ARB as libc::c_int;
+ attributes.push(gl::wgl_extra::CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB as c_int);
+ attributes.push(gl::wgl_extra::NO_RESET_NOTIFICATION_ARB as c_int);
+ flags = flags | gl::wgl_extra::CONTEXT_ROBUST_ACCESS_BIT_ARB as c_int;
},
Robustness::RobustLoseContextOnReset | Robustness::TryRobustLoseContextOnReset => {
- attributes.push(gl::wgl_extra::CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB as libc::c_int);
- attributes.push(gl::wgl_extra::LOSE_CONTEXT_ON_RESET_ARB as libc::c_int);
- flags = flags | gl::wgl_extra::CONTEXT_ROBUST_ACCESS_BIT_ARB as libc::c_int;
+ attributes.push(gl::wgl_extra::CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB as c_int);
+ attributes.push(gl::wgl_extra::LOSE_CONTEXT_ON_RESET_ARB as c_int);
+ flags = flags | gl::wgl_extra::CONTEXT_ROBUST_ACCESS_BIT_ARB as c_int;
},
Robustness::NotRobust => (),
Robustness::NoError => (),
@@ -306,19 +306,19 @@ unsafe fn create_context(extra: Option<(&gl::wgl_extra::Wgl, &PixelFormatRequire
}
if opengl.debug {
- flags = flags | gl::wgl_extra::CONTEXT_DEBUG_BIT_ARB as libc::c_int;
+ flags = flags | gl::wgl_extra::CONTEXT_DEBUG_BIT_ARB as c_int;
}
flags
};
- attributes.push(gl::wgl_extra::CONTEXT_FLAGS_ARB as libc::c_int);
+ attributes.push(gl::wgl_extra::CONTEXT_FLAGS_ARB as c_int);
attributes.push(flags);
attributes.push(0);
- let ctxt = extra_functions.CreateContextAttribsARB(hdc as *const libc::c_void,
- share as *const libc::c_void,
+ let ctxt = extra_functions.CreateContextAttribsARB(hdc as *const c_void,
+ share as *const c_void,
attributes.as_ptr());
if ctxt.is_null() {
@@ -333,14 +333,14 @@ unsafe fn create_context(extra: Option<(&gl::wgl_extra::Wgl, &PixelFormatRequire
share = ptr::null_mut();
}
- let ctxt = gl::wgl::CreateContext(hdc as *const libc::c_void);
+ let ctxt = gl::wgl::CreateContext(hdc as *const c_void);
if ctxt.is_null() {
return Err(CreationError::OsError(format!("wglCreateContext failed: {}",
format!("{}", io::Error::last_os_error()))));
}
if !share.is_null() {
- if gl::wgl::ShareLists(share as *const libc::c_void, ctxt) == 0 {
+ if gl::wgl::ShareLists(share as *const c_void, ctxt) == 0 {
return Err(CreationError::OsError(format!("wglShareLists failed: {}",
format!("{}", io::Error::last_os_error()))));
}
@@ -352,7 +352,7 @@ unsafe fn create_context(extra: Option<(&gl::wgl_extra::Wgl, &PixelFormatRequire
/// Enumerates the list of pixel formats without using WGL.
///
/// Gives less precise results than `enumerate_arb_pixel_formats`.
-unsafe fn enumerate_native_pixel_formats(hdc: winapi::HDC) -> Vec<(libc::c_int, PixelFormat)> {
+unsafe fn enumerate_native_pixel_formats(hdc: winapi::HDC) -> Vec<(c_int, PixelFormat)> {
let size_of_pxfmtdescr = mem::size_of::<winapi::PIXELFORMATDESCRIPTOR>() as u32;
let num = gdi32::DescribePixelFormat(hdc, 1, size_of_pxfmtdescr, ptr::null_mut());
@@ -397,12 +397,12 @@ unsafe fn enumerate_native_pixel_formats(hdc: winapi::HDC) -> Vec<(libc::c_int,
///
/// Gives more precise results than `enumerate_native_pixel_formats`.
unsafe fn enumerate_arb_pixel_formats(extra: &gl::wgl_extra::Wgl, extensions: &str,
- hdc: winapi::HDC) -> Vec<(libc::c_int, PixelFormat)>
+ hdc: winapi::HDC) -> Vec<(c_int, PixelFormat)>
{
let get_info = |index: u32, attrib: u32| {
let mut value = mem::uninitialized();
- extra.GetPixelFormatAttribivARB(hdc as *const _, index as libc::c_int,
- 0, 1, [attrib as libc::c_int].as_ptr(),
+ extra.GetPixelFormatAttribivARB(hdc as *const _, index as c_int,
+ 0, 1, [attrib as c_int].as_ptr(),
&mut value);
value as u32
};
@@ -429,7 +429,7 @@ unsafe fn enumerate_arb_pixel_formats(extra: &gl::wgl_extra::Wgl, extensions: &s
continue;
}
- result.push((index as libc::c_int, PixelFormat {
+ result.push((index as c_int, PixelFormat {
hardware_accelerated: true,
color_bits: get_info(index, gl::wgl_extra::RED_BITS_ARB) as u8 +
get_info(index, gl::wgl_extra::GREEN_BITS_ARB) as u8 +
@@ -463,7 +463,7 @@ unsafe fn enumerate_arb_pixel_formats(extra: &gl::wgl_extra::Wgl, extensions: &s
}
/// Calls `SetPixelFormat` on a window.
-unsafe fn set_pixel_format(hdc: winapi::HDC, id: libc::c_int) -> Result<(), CreationError> {
+unsafe fn set_pixel_format(hdc: winapi::HDC, id: c_int) -> Result<(), CreationError> {
let mut output: winapi::PIXELFORMATDESCRIPTOR = mem::zeroed();
if gdi32::DescribePixelFormat(hdc, id, mem::size_of::<winapi::PIXELFORMATDESCRIPTOR>()
@@ -564,14 +564,14 @@ unsafe fn load_extra_functions(window: winapi::HWND) -> Result<gl::wgl_extra::Wg
Ok(gl::wgl_extra::Wgl::load_with(|addr| {
let addr = CString::new(addr.as_bytes()).unwrap();
let addr = addr.as_ptr();
- gl::wgl::GetProcAddress(addr) as *const libc::c_void
+ gl::wgl::GetProcAddress(addr) as *const c_void
}))
}
/// Given a list of pixel formats, this function chooses one that is likely to be provided by
/// the main video driver of the system.
-fn choose_dummy_pixel_format<I>(iter: I) -> Result<libc::c_int, CreationError>
- where I: Iterator<Item=(libc::c_int, PixelFormat)>
+fn choose_dummy_pixel_format<I>(iter: I) -> Result<c_int, CreationError>
+ where I: Iterator<Item=(c_int, PixelFormat)>
{
let mut backup_id = None;