Skip to content

Commit 46fda29

Browse files
committed
Remove unneeded wglMakeCurrent & minor fixes
1 parent ca5fce1 commit 46fda29

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/platform/with_wgl/native_gl_context.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,11 @@ impl NativeGLContextMethods for NativeGLContext {
113113
};
114114
match unsafe { utils::create_offscreen(render_ctx, &WGLAttributes::default()) } {
115115
Ok(ref res) => {
116-
117116
let ctx = NativeGLContext {
118117
render_ctx: res.0,
119118
device_ctx: res.1,
120119
weak: false,
121120
};
122-
ctx.make_current().unwrap();
123121
Ok(ctx)
124122
}
125123
Err(s) => {
@@ -160,15 +158,15 @@ impl NativeGLContextMethods for NativeGLContext {
160158
if wgl::MakeCurrent(self.device_ctx as *const _, self.render_ctx as *const _) != 0 {
161159
Ok(())
162160
} else {
163-
Err("wgl::makeCurrent failed")
161+
Err("WGL::makeCurrent failed")
164162
}
165163
}
166164
}
167165

168166
fn unbind(&self) -> Result<(), &'static str> {
169167
unsafe {
170168
if self.is_current() && wgl::MakeCurrent(ptr::null_mut(), ptr::null_mut()) == 0 {
171-
Err("gwl::MakeCurrent (on unbind)")
169+
Err("WGL::MakeCurrent (on unbind)")
172170
} else {
173171
Ok(())
174172
}

src/platform/with_wgl/utils.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,14 @@ unsafe fn create_full_context(settings: &WGLAttributes,
8888
hdc: winapi::HDC,
8989
share: winapi::HGLRC)
9090
-> Result<(winapi::HGLRC, winapi::HDC), String> {
91-
if extensions.split(' ').find(|&i| i == "WGL_ARB_create_context").is_none() {
91+
let mut extensions = extensions.split(' ');
92+
if extensions.find(|&i| i == "WGL_ARB_create_context").is_none() {
9293
return create_basic_context(hdc, share);
9394
}
9495

9596
let mut attributes = Vec::new();
9697
if settings.opengl_es {
97-
if extensions.split(' ').find(|&i| i == "WGL_EXT_create_context_es2_profile").is_some() {
98+
if extensions.find(|&i| i == "WGL_EXT_create_context_es2_profile").is_some() {
9899
attributes.push(wgl_ext::CONTEXT_PROFILE_MASK_ARB as c_int);
99100
attributes.push(wgl_ext::CONTEXT_ES2_PROFILE_BIT_EXT as c_int);
100101
} else {
@@ -127,9 +128,11 @@ unsafe fn create_full_context(settings: &WGLAttributes,
127128
io::Error::last_os_error()));
128129
}
129130

131+
if wgl::MakeCurrent(hdc as *const _, ctx as *const _) == 0 {
132+
return Err("wglMakeCurrent failed".to_owned());
133+
}
130134
// Disable or enable vsync
131-
if extensions.split(' ').find(|&i| i == "WGL_EXT_swap_control").is_some() {
132-
let _guard = try!(CurrentContextGuard::make_current(hdc, ctx as winapi::HGLRC));
135+
if extensions.find(|&i| i == "WGL_EXT_swap_control").is_some() {
133136
if extra.SwapIntervalEXT(if settings.vsync { 1 } else { 0 }) == 0 {
134137
return Err("wglSwapIntervalEXT failed".to_owned());
135138
}
@@ -139,7 +142,6 @@ unsafe fn create_full_context(settings: &WGLAttributes,
139142
}
140143

141144
unsafe fn create_hidden_window() -> Result<winapi::HWND, &'static str> {
142-
143145
let class_name = register_window_class();
144146
let mut rect = winapi::RECT {
145147
left: 0,

0 commit comments

Comments
 (0)