Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idle callback #20

Merged
merged 2 commits into from Jun 11, 2013
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Implement the idle callback

  • Loading branch information
pcwalton committed Jun 11, 2013
commit 7db24a19d25fbedca2898381ae0b13b723c14135
20 glut.rs
@@ -14,7 +14,7 @@ use glut::bindgen::{glutKeyboardFunc, glutGetModifiers, glutMotionFunc, glutPass
use glut::bindgen::{glutGet, glutGetWindow};
use glut::bindgen::{glutInit, glutInitDisplayMode, glutPostRedisplay, glutReshapeFunc};
use glut::bindgen::{glutReshapeWindow, glutSetWindow, glutSetWindowTitle, glutSwapBuffers};
use glut::bindgen::{glutTimerFunc};
use glut::bindgen::{glutTimerFunc, glutIdleFunc};
use core::libc::*;
use core::local_data::{local_data_get, local_data_set};
use core::ptr::{null, to_unsafe_ptr};
@@ -265,6 +265,24 @@ pub fn reshape_func(_window: Window, callback: @fn(x: c_int, y: c_int)) {
}
}

pub fn idle_callback_tls_key(_callback: @@fn()) {
// Empty.
}

pub extern fn idle_callback() {
unsafe {
let callback = local_data_get(idle_callback_tls_key).get();
(*callback)();
}
}

pub fn idle_func(callback: @fn()) {
unsafe {
local_data_set(idle_callback_tls_key, @callback);
glutIdleFunc(idle_callback);
}
}

// Mouse wheel handling.
//
// This is not part of the standard, but it's supported by freeglut and our Mac hack.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.