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

Wrap mouse input functions #8

Merged
merged 1 commit into from Apr 17, 2013
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Wrap mouse functions

  • Loading branch information
Chinmay Garde
Chinmay Garde committed Apr 17, 2013
commit acffe2bdad8a4540987195583ec0a7bab77e7c01
56 glut.rs
@@ -9,7 +9,7 @@

/* automatically generated by rust-bindgen */

use glut::bindgen::{glutCreateWindow, glutDestroyWindow, glutDisplayFunc, glutGet, glutGetWindow};
use glut::bindgen::{glutCreateWindow, glutDestroyWindow, glutDisplayFunc, glutMouseFunc, glutMotionFunc, glutPassiveMotionFunc, glutGet, glutGetWindow};
use glut::bindgen::{glutInit, glutInitDisplayMode, glutPostRedisplay, glutReshapeFunc};
use glut::bindgen::{glutReshapeWindow, glutSetWindow, glutSwapBuffers, glutTimerFunc};
use core::libc::*;
@@ -111,6 +111,60 @@ pub fn display_func(callback: @fn()) {
}
}

pub fn mouse_callback_tls_key(_callback: @@fn(button: c_int, state: c_int, x: c_int, y: c_int)) {
// Empty.
}

pub extern fn mouse_callback(button: c_int, state: c_int, x: c_int, y: c_int) {
unsafe {
let callback = local_data_get(mouse_callback_tls_key).get();
(*callback)(button, state, x, y);
}
}

pub fn mouse_func(callback: @fn(button: c_int, state: c_int, x: c_int, y: c_int)) {
unsafe {
local_data_set(mouse_callback_tls_key, @callback);
glutMouseFunc(mouse_callback);
}
}

pub fn motion_callback_tls_key(_callback: @@fn(x: c_int, y: c_int)) {
// Empty.
}

pub extern fn motion_callback(x: c_int, y: c_int) {
unsafe {
let callback = local_data_get(motion_callback_tls_key).get();
(*callback)(x, y);
}
}

pub fn motion_func(callback: @fn(x: c_int, y: c_int)) {
unsafe {
local_data_set(motion_callback_tls_key, @callback);
glutMotionFunc(motion_callback);
}
}

pub fn passive_motion_callback_tls_key(_callback: @@fn(x: c_int, y: c_int)) {
// Empty.
}

pub extern fn passive_motion_callback(x: c_int, y: c_int) {
unsafe {
let callback = local_data_get(passive_motion_callback_tls_key).get();
(*callback)(x, y);
}
}

pub fn passive_motion_func(callback: @fn(x: c_int, y: c_int)) {
unsafe {
local_data_set(passive_motion_callback_tls_key, @callback);
glutPassiveMotionFunc(passive_motion_callback);
}
}

pub fn timer_callback_tls_key(_callback: @~[@fn()]) {
// Empty.
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.