From bbcb4c8beab5de681f2f19ba30160e6b5ead3a32 Mon Sep 17 00:00:00 2001 From: Tomaka17 Date: Wed, 29 Oct 2014 19:00:32 +0100 Subject: [PATCH] Remove call to glFlush() before swap_buffers We may not want to call `swap_buffers` in the same thread as the current thread, so we're moving the call to `glFlush` out of the scope of glutin. --- README.md | 1 + examples/support/mod.rs | 4 ++++ src/win32/ffi.rs | 3 --- src/win32/mod.rs | 3 --- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 20c74954..55de3fcd 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ fn main() { ### Win32 + - You must call `glFlush` before `swap_buffers`, or else on Windows 8 nothing will be visible on the window - Pixel formats are not implemented - If you don't have MinGW installed, you will need to provide `libgdi32.a` and `libopengl32.a` ; you can put them in `C:\Users\you\.rust` - If you don't have `make` in your PATH, you can pass `--no-default-features --features "window"` when compiling ([see also](http://crates.io/manifest.html#the-[features]-section)) diff --git a/examples/support/mod.rs b/examples/support/mod.rs index 12aa68c9..1e61165c 100644 --- a/examples/support/mod.rs +++ b/examples/support/mod.rs @@ -57,6 +57,8 @@ impl Context { self.gl.Color3f(0.0, 0.0, 1.0); self.gl.Vertex2f(0.5, -0.5); self.gl.End(); + + self.gl.Flush(); } #[cfg(target_os = "android")] @@ -78,6 +80,8 @@ impl Context { self.gl.DrawArrays(gl::TRIANGLES, 0, 3); self.gl.DisableClientState(gl::VERTEX_ARRAY); self.gl.DisableClientState(gl::COLOR_ARRAY); + + self.gl.Flush(); } } diff --git a/src/win32/ffi.rs b/src/win32/ffi.rs index 71f8d55a..1d8156dc 100644 --- a/src/win32/ffi.rs +++ b/src/win32/ffi.rs @@ -720,9 +720,6 @@ extern "system" { // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633519(v=vs.85).aspx pub fn GetWindowRect(hWnd: HWND, lpRect: *mut RECT) -> BOOL; - // - pub fn glFlush(); - // http://msdn.microsoft.com/en-us/library/windows/desktop/ms684175(v=vs.85).aspx pub fn LoadLibraryW(lpFileName: LPCWSTR) -> HMODULE; diff --git a/src/win32/mod.rs b/src/win32/mod.rs index 3cfdc7ee..35e71697 100644 --- a/src/win32/mod.rs +++ b/src/win32/mod.rs @@ -228,9 +228,6 @@ impl Window { /// See the docs in the crate root file. pub fn swap_buffers(&self) { unsafe { - // calling glFlush is necessary on Windows 8 - ffi::glFlush(); - ffi::SwapBuffers(self.hdc); } }