Skip to content

Commit

Permalink
Upgrade glutin to use winapi 0.3 (#975)
Browse files Browse the repository at this point in the history
* Upgrade glutin to use winapi 0.3

* Update CHANGELOG.md
  • Loading branch information
bbrown683 authored and tomaka committed Jan 3, 2018
1 parent d74cba0 commit bda8dbe
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 104 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Unreleased

- Add support for winapi 0.3

15 changes: 8 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ cocoa = "0.13"
core-foundation = "0.4"
core-graphics = "0.12"

[target.'cfg(target_os = "windows")'.dependencies]
winapi = "0.2"
shell32-sys = "0.1"
gdi32-sys = "0.1"
user32-sys = "~0.1.2"
kernel32-sys = "0.2"
dwmapi-sys = "0.1"
[target.'cfg(target_os = "windows")'.dependencies.winapi]
version = "0.3.2"
features = [
"winnt",
"winuser",
"wingdi",
"libloaderapi",
]

[target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os="dragonfly", target_os="openbsd"))'.dependencies]
osmesa-sys = "0.1.0"
Expand Down
2 changes: 1 addition & 1 deletion src/api/egl/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub type EGLNativeDisplayType = *const libc::c_void;
pub type EGLNativePixmapType = *const libc::c_void; // FIXME: egl_native_pixmap_t instead

#[cfg(target_os = "windows")]
pub type EGLNativeWindowType = winapi::HWND;
pub type EGLNativeWindowType = winapi::shared::windef::HWND;
#[cfg(target_os = "linux")]
pub type EGLNativeWindowType = *const libc::c_void;
#[cfg(target_os = "android")]
Expand Down
12 changes: 6 additions & 6 deletions src/api/wgl/make_current_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ use std::marker::PhantomData;
use std::os::raw::c_void;
use std::io;

use winapi;
use winapi::shared::windef::{HDC, HGLRC};
use CreationError;

use super::gl;
/// A guard for when you want to make the context current. Destroying the guard restores the
/// previously-current context.
pub struct CurrentContextGuard<'a, 'b> {
previous_hdc: winapi::HDC,
previous_hglrc: winapi::HGLRC,
previous_hdc: HDC,
previous_hglrc: HGLRC,
marker1: PhantomData<&'a ()>,
marker2: PhantomData<&'b ()>,
}

impl<'a, 'b> CurrentContextGuard<'a, 'b> {
pub unsafe fn make_current(hdc: winapi::HDC, context: winapi::HGLRC)
pub unsafe fn make_current(hdc: HDC, context: HGLRC)
-> Result<CurrentContextGuard<'a, 'b>, CreationError>
{
let previous_hdc = gl::wgl::GetCurrentDC() as winapi::HDC;
let previous_hglrc = gl::wgl::GetCurrentContext() as winapi::HGLRC;
let previous_hdc = gl::wgl::GetCurrentDC() as HDC;
let previous_hglrc = gl::wgl::GetCurrentContext() as HGLRC;

let result = gl::wgl::MakeCurrent(hdc as *const _, context as *const _);
if result == 0 {
Expand Down
Loading

0 comments on commit bda8dbe

Please sign in to comment.