Skip to content

Instantly share code, notes, and snippets.

@ozkriff
Created March 26, 2014 11:26
Show Gist options
  • Save ozkriff/9781190 to your computer and use it in GitHub Desktop.
Save ozkriff/9781190 to your computer and use it in GitHub Desktop.
diff --git a/src/lib/lib.rs b/src/lib/lib.rs
index e5420c6..0393cbc 100644
--- a/src/lib/lib.rs
+++ b/src/lib/lib.rs
@@ -836,14 +836,14 @@ impl Window {
unsafe { ffi::glfwWindowShouldClose(self.ptr) == ffi::TRUE }
}
/// Wrapper for `glfwSetWindowShouldClose`.
- pub fn set_should_close(&self, value: bool) {
+ pub fn set_should_close(&mut self, value: bool) {
unsafe { ffi::glfwSetWindowShouldClose(self.ptr, value as c_int) }
}
/// Wrapper for `glfwSetWindowTitle`.
- pub fn set_title(&self, title: &str) {
+ pub fn set_title(&mut self, title: &str) {
unsafe {
title.with_c_str(|title| {
ffi::glfwSetWindowTitle(self.ptr, title);
});
@@ -860,9 +860,9 @@ impl Window {
}
}
/// Wrapper for `glfwSetWindowPos`.
- pub fn set_pos(&self, xpos: i32, ypos: i32) {
+ pub fn set_pos(&mut self, xpos: i32, ypos: i32) {
unsafe { ffi::glfwSetWindowPos(self.ptr, xpos as c_int, ypos as c_int); }
}
/// Wrapper for `glfwGetWindowSize`.
@@ -875,9 +875,9 @@ impl Window {
}
}
/// Wrapper for `glfwSetWindowSize`.
- pub fn set_size(&self, width: i32, height: i32) {
+ pub fn set_size(&mut self, width: i32, height: i32) {
unsafe { ffi::glfwSetWindowSize(self.ptr, width as c_int, height as c_int); }
}
/// Wrapper for `glfwGetFramebufferSize`.
@@ -890,24 +890,24 @@ impl Window {
}
}
/// Wrapper for `glfwIconifyWindow`.
- pub fn iconify(&self) {
+ pub fn iconify(&mut self) {
unsafe { ffi::glfwIconifyWindow(self.ptr); }
}
/// Wrapper for `glfwRestoreWindow`.
- pub fn restore(&self) {
+ pub fn restore(&mut self) {
unsafe { ffi::glfwRestoreWindow(self.ptr); }
}
/// Wrapper for `glfwShowWindow`.
- pub fn show(&self) {
+ pub fn show(&mut self) {
unsafe { ffi::glfwShowWindow(self.ptr); }
}
/// Wrapper for `glfwHideWindow`.
- pub fn hide(&self) {
+ pub fn hide(&mut self) {
unsafe { ffi::glfwHideWindow(self.ptr); }
}
/// Wrapper for `glfwGetWindowMonitor`.
@@ -989,13 +989,13 @@ impl Window {
unsafe { ffi::glfwGetWindowAttrib(self.ptr, ffi::DECORATED) == ffi::TRUE }
}
/// Wrapper for `glfwSetWindowPosCallback`.
- pub fn set_pos_polling(&self, should_poll: bool) {
+ pub fn set_pos_polling(&mut self, should_poll: bool) {
set_window_callback!(should_poll, glfwSetWindowPosCallback, window_pos_callback);
}
- pub fn set_all_polling(&self, should_poll: bool) {
+ pub fn set_all_polling(&mut self, should_poll: bool) {
self.set_pos_polling(should_poll);
self.set_size_polling(should_poll);
self.set_close_polling(should_poll);
self.set_refresh_polling(should_poll);
@@ -1015,29 +1015,29 @@ impl Window {
set_window_callback!(should_poll, glfwSetWindowSizeCallback, window_size_callback);
}
/// Wrapper for `glfwSetWindowCloseCallback`.
- pub fn set_close_polling(&self, should_poll: bool) {
+ pub fn set_close_polling(&mut self, should_poll: bool) {
set_window_callback!(should_poll, glfwSetWindowCloseCallback, window_close_callback);
}
/// Wrapper for `glfwSetWindowRefreshCallback`.
- pub fn set_refresh_polling(&self, should_poll: bool) {
+ pub fn set_refresh_polling(&mut self, should_poll: bool) {
set_window_callback!(should_poll, glfwSetWindowRefreshCallback, window_refresh_callback);
}
/// Wrapper for `glfwSetWindowFocusCallback`.
- pub fn set_focus_polling(&self, should_poll: bool) {
+ pub fn set_focus_polling(&mut self, should_poll: bool) {
set_window_callback!(should_poll, glfwSetWindowFocusCallback, window_focus_callback);
}
/// Wrapper for `glfwSetWindowIconifyCallback`.
- pub fn set_iconify_polling(&self, should_poll: bool) {
+ pub fn set_iconify_polling(&mut self, should_poll: bool) {
set_window_callback!(should_poll, glfwSetWindowIconifyCallback, window_iconify_callback);
}
/// Wrapper for `glfwSetFramebufferSizeCallback`.
- pub fn set_framebuffer_size_polling(&self, should_poll: bool) {
+ pub fn set_framebuffer_size_polling(&mut self, should_poll: bool) {
set_window_callback!(should_poll, glfwSetFramebufferSizeCallback, framebuffer_size_callback);
}
/// Wrapper for `glfwGetInputMode` called with `CURSOR`.
@@ -1045,9 +1045,9 @@ impl Window {
unsafe { cast::transmute(ffi::glfwGetInputMode(self.ptr, ffi::CURSOR)) }
}
/// Wrapper for `glfwSetInputMode` called with `CURSOR`.
- pub fn set_cursor_mode(&self, mode: CursorMode) {
+ pub fn set_cursor_mode(&mut self, mode: CursorMode) {
unsafe { ffi::glfwSetInputMode(self.ptr, ffi::CURSOR, mode as c_int); }
}
/// Wrapper for `glfwGetInputMode` called with `STICKY_KEYS`.
@@ -1055,9 +1055,9 @@ impl Window {
unsafe { ffi::glfwGetInputMode(self.ptr, ffi::STICKY_KEYS) == ffi::TRUE }
}
/// Wrapper for `glfwSetInputMode` called with `STICKY_KEYS`.
- pub fn set_sticky_keys(&self, value: bool) {
+ pub fn set_sticky_keys(&mut self, value: bool) {
unsafe { ffi::glfwSetInputMode(self.ptr, ffi::STICKY_KEYS, value as c_int); }
}
/// Wrapper for `glfwGetInputMode` called with `STICKY_MOUSE_BUTTONS`.
@@ -1065,9 +1065,9 @@ impl Window {
unsafe { ffi::glfwGetInputMode(self.ptr, ffi::STICKY_MOUSE_BUTTONS) == ffi::TRUE }
}
/// Wrapper for `glfwSetInputMode` called with `STICKY_MOUSE_BUTTONS`.
- pub fn set_sticky_mouse_buttons(&self, value: bool) {
+ pub fn set_sticky_mouse_buttons(&mut self, value: bool) {
unsafe { ffi::glfwSetInputMode(self.ptr, ffi::STICKY_MOUSE_BUTTONS, value as c_int); }
}
/// Wrapper for `glfwGetKey`.
@@ -1090,58 +1090,58 @@ impl Window {
}
}
/// Wrapper for `glfwSetCursorPos`.
- pub fn set_cursor_pos(&self, xpos: f64, ypos: f64) {
+ pub fn set_cursor_pos(&mut self, xpos: f64, ypos: f64) {
unsafe { ffi::glfwSetCursorPos(self.ptr, xpos as c_double, ypos as c_double); }
}
/// Wrapper for `glfwSetKeyCallback`.
- pub fn set_key_polling(&self, should_poll: bool) {
+ pub fn set_key_polling(&mut self, should_poll: bool) {
set_window_callback!(should_poll, glfwSetKeyCallback, key_callback);
}
/// Wrapper for `glfwSetCharCallback`.
- pub fn set_char_polling(&self, should_poll: bool) {
+ pub fn set_char_polling(&mut self, should_poll: bool) {
set_window_callback!(should_poll, glfwSetCharCallback, char_callback);
}
/// Wrapper for `glfwSetMouseButtonCallback`.
- pub fn set_mouse_button_polling(&self, should_poll: bool) {
+ pub fn set_mouse_button_polling(&mut self, should_poll: bool) {
set_window_callback!(should_poll, glfwSetMouseButtonCallback, mouse_button_callback);
}
/// Wrapper for `glfwSetCursorPosCallback`.
- pub fn set_cursor_pos_polling(&self, should_poll: bool) {
+ pub fn set_cursor_pos_polling(&mut self, should_poll: bool) {
set_window_callback!(should_poll, glfwSetCursorPosCallback, cursor_pos_callback);
}
/// Wrapper for `glfwSetCursorEnterCallback`.
- pub fn set_cursor_enter_polling(&self, should_poll: bool) {
+ pub fn set_cursor_enter_polling(&mut self, should_poll: bool) {
set_window_callback!(should_poll, glfwSetCursorEnterCallback, cursor_enter_callback);
}
/// Wrapper for `glfwSetScrollCallback`.
- pub fn set_scroll_polling(&self, should_poll: bool) {
+ pub fn set_scroll_polling(&mut self, should_poll: bool) {
set_window_callback!(should_poll, glfwSetScrollCallback, scroll_callback);
}
/// Wrapper for `glfwGetClipboardString`.
- pub fn set_clipboard_string(&self, string: &str) {
+ pub fn set_clipboard_string(&mut self, string: &str) {
unsafe {
string.with_c_str(|string| {
ffi::glfwSetClipboardString(self.ptr, string);
});
}
}
/// Wrapper for `glfwGetClipboardString`.
- pub fn get_clipboard_string(&self) -> ~str {
+ pub fn get_clipboard_string(&mut self) -> ~str {
unsafe { str::raw::from_c_str(ffi::glfwGetClipboardString(self.ptr)) }
}
/// Wrapper for `glfwMakeContextCurrent`.
- pub fn make_context_current(&self) {
+ pub fn make_context_current(&mut self) {
make_context_current(Some(self));
}
/// Wrapper for `glfwGetCurrentContext`
@@ -1149,9 +1149,9 @@ impl Window {
self.ptr == unsafe { ffi::glfwGetCurrentContext() }
}
/// Wrapper for `glfwSwapBuffers`.
- pub fn swap_buffers(&self) {
+ pub fn swap_buffers(&mut self) {
unsafe { ffi::glfwSwapBuffers(self.ptr); }
}
/// Wrapper for `glfwGetWin32Window`
@@ -1191,9 +1191,9 @@ impl Window {
}
}
/// Wrapper for `glfwMakeContextCurrent`.
-pub fn make_context_current(context: Option<&Window>) {
+pub fn make_context_current(context: Option<&mut Window>) {
match context {
Some(window) => unsafe { ffi::glfwMakeContextCurrent(window.ptr) },
None => unsafe { ffi::glfwMakeContextCurrent(ptr::null()) },
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment