;;;; glut.scm (module glut * (import scheme chicken (except foreign foreign-declare)) (use easyffi) #> #ifdef C_MACOSX #include "GLUT/glut.h" #else #include "GL/glut.h" #endif <# (foreign-parse #< i))) (define-external (display_cb) void (find-callback 'display (cut <>))) (define-external (reshape_cb (int w) (int h)) void (find-callback 'reshape (cut <> w h))) (define-external (keyboard_cb (char k) (int x) (int y)) void (find-callback 'keyboard (cut <> k x y))) (define-external (mouse_cb (int button) (int state) (int x) (int y)) void (find-callback 'mouse (cut <> button state x y))) (define-external (motion_cb (int x) (int y)) void (find-callback 'motion (cut <> x y))) (define-external (passive_motion_cb (int x) (int y)) void (find-callback 'passive-motion (cut <> x y))) (define-external (entry_cb (int state)) void (find-callback 'entry (cut <> state))) (define-external (visibility_cb (int state)) void (find-callback 'visibility (cut <> state))) (define-external (idle_cb) void (find-callback 'idle (cut <>))) (define-external (timer_cb (int i)) void (find-callback 'timer (cut <> i))) (define-external (menu_state_cb (int state)) void (find-callback 'menu-state (cut <> state))) (define-external (special_cb (int key) (int x) (int y)) void (find-callback 'special (cut <> key x y))) (define-external (spaceball_motion_cb (int key) (int x) (int y)) void (find-callback 'spaceball-motion (cut <> key x y))) (define-external (spaceball_rotate_cb (int key) (int x) (int y)) void (find-callback 'spaceball-rotate (cut <> key x y))) (define-external (spaceball_button_cb (int key) (int x)) void (find-callback 'spaceball-button (cut <> key x))) (define-external (button_box_cb (int key) (int x)) void (find-callback 'button-box (cut <> key x))) (define-external (dials_cb (int key) (int x)) void (find-callback 'dials (cut <> key x))) (define-external (tablet_motion_cb (int key) (int x)) void (find-callback 'tablet-motion (cut <> key x))) (define-external (tablet_button_cb (int key) (int state) (int x) (int y)) void (find-callback 'tablet-button (cut <> key state x y))) (define-external (menu_status_cb (int status) (int x) (int y)) void (find-callback 'menu-status (cut <> status x y))) (define-external (overlay_display_cb) void (find-callback 'overlay-display (cut <>))) (define-external (window_status_cb (int s)) void (find-callback 'window-status (cut <> s))) (define-external (keyboard_up_cb (unsigned-char k) (int x) (int y)) void (find-callback 'keyboard-up (cut <> k x y))) (define-external (special_up_cb (int k) (int x) (int y)) void (find-callback 'special-up (cut <> k x y))) (define-external (joystick_cb (unsigned-int b) (int x) (int y) (int z)) void (find-callback 'joystick (cut <> b x y z))) (define glut:CreateMenu (let ([old glut:CreateMenu]) (lambda (proc) (old (location create_menu_cb)) (set-callback 'create-menu proc)))) (define glut:DisplayFunc (let ([old glut:DisplayFunc]) (lambda (proc) (old (location display_cb)) (set-callback 'display proc)))) (define glut:ReshapeFunc (let ([old glut:ReshapeFunc]) (lambda (proc) (old (location reshape_cb)) (set-callback 'reshape proc)))) (define glut:KeyboardFunc (let ([old glut:KeyboardFunc]) (lambda (proc) (old (location keyboard_cb)) (set-callback 'keyboard proc)))) (define glut:MouseFunc (let ([old glut:MouseFunc]) (lambda (proc) (old (location mouse_cb)) (set-callback 'mouse proc)))) (define glut:MotionFunc (let ([old glut:MotionFunc]) (lambda (proc) (old (location motion_cb)) (set-callback 'motion proc)))) (define glut:PassiveMotionFunc (let ([old glut:PassiveMotionFunc]) (lambda (proc) (old (location passive_motion_cb)) (set-callback 'passive-motion proc)))) (define glut:EntryFunc (let ([old glut:EntryFunc]) (lambda (proc) (old (location entry_cb)) (set-callback 'entry proc)))) (define glut:VisibilityFunc (let ([old glut:VisibilityFunc]) (lambda (proc) (old (location visibility_cb)) (set-callback 'visibility proc)))) (define glut:IdleFunc (let ([old glut:IdleFunc]) (lambda (proc) (old (location idle_cb)) (set-callback 'idle proc)))) (define glut:TimerFunc (let ([old glut:TimerFunc]) (lambda (ms proc val) (old ms (location timer_cb) val) (set-callback 'timer proc)))) (define glut:MenuStateFunc (let ([old glut:MenuStateFunc]) (lambda (proc) (old (location menu_state_cb)) (set-callback 'menu-state proc)))) (define glut:SpecialFunc (let ([old glut:SpecialFunc]) (lambda (proc) (old (location special_cb)) (set-callback 'special proc)))) (define glut:SpaceballMotionFunc (let ([old glut:SpaceballMotionFunc]) (lambda (proc) (old (location spaceball_motion_cb)) (set-callback 'spaceball-motion proc)))) (define glut:SpaceballRotateFunc (let ([old glut:SpaceballRotateFunc]) (lambda (proc) (old (location spaceball_rotate_cb)) (set-callback 'spaceball-rotate proc)))) (define glut:SpaceballButtonFunc (let ([old glut:SpaceballButtonFunc]) (lambda (proc) (old (location spaceball_button_cb)) (set-callback 'spaceball-button proc)))) (define glut:ButtonBoxFunc (let ([old glut:ButtonBoxFunc]) (lambda (proc) (old (location button_box_cb)) (set-callback 'button-box proc)))) (define glut:DialsFunc (let ([old glut:DialsFunc]) (lambda (proc) (old (location dials_cb)) (set-callback 'dials proc)))) (define glut:TabletMotionFunc (let ([old glut:TabletMotionFunc]) (lambda (proc) (old (location tablet_motion_cb)) (set-callback 'tablet-motion proc)))) (define glut:TabletButtonFunc (let ([old glut:TabletButtonFunc]) (lambda (proc) (old (location tablet_button_cb)) (set-callback 'tablet-button proc)))) (define glut:MenuStatusFunc (let ([old glut:MenuStatusFunc]) (lambda (proc) (old (location menu_status_cb)) (set-callback 'menu-status proc)))) (define glut:OverlayDisplayFunc (let ([old glut:OverlayDisplayFunc]) (lambda (proc) (old (location overlay_display_cb)) (set-callback 'overlay-display proc)))) (define glut:WindowStatusFunc (let ([old glut:WindowStatusFunc]) (lambda (proc) (old (location window_status_cb)) (set-callback 'window-status proc)))) (define glut:KeyboardUpFunc (let ([old glut:KeyboardUpFunc]) (lambda (proc) (old (location keyboard_up_cb)) (set-callback 'keyboard-up proc)))) (define glut:SpecialUpFunc (let ([old glut:SpecialUpFunc]) (lambda (proc) (old (location special_up_cb)) (set-callback 'special-up proc)))) (define glut:JoystickFunc (let ([old glut:JoystickFunc]) (lambda (proc interval) (old (location joystick_cb) interval) (set-callback 'joystick proc)))) (define-foreign-variable GLUT_STROKE_ROMAN c-pointer) (define-foreign-variable GLUT_STROKE_MONO_ROMAN c-pointer) (define-foreign-variable GLUT_BITMAP_9_BY_15 c-pointer) (define-foreign-variable GLUT_BITMAP_8_BY_13 c-pointer) (define-foreign-variable GLUT_BITMAP_TIMES_ROMAN_10 c-pointer) (define-foreign-variable GLUT_BITMAP_TIMES_ROMAN_24 c-pointer) (define-foreign-variable GLUT_BITMAP_HELVETICA_10 c-pointer) (define-foreign-variable GLUT_BITMAP_HELVETICA_12 c-pointer) (define-foreign-variable GLUT_BITMAP_HELVETICA_18 c-pointer) (define glut:STROKE_ROMAN GLUT_STROKE_ROMAN) (define glut:STROKE_MONO_ROMAN GLUT_STROKE_MONO_ROMAN) (define glut:BITMAP_9_BY_15 GLUT_BITMAP_9_BY_15) (define glut:BITMAP_8_BY_13 GLUT_BITMAP_8_BY_13) (define glut:BITMAP_TIMES_ROMAN_10 GLUT_BITMAP_TIMES_ROMAN_10) (define glut:BITMAP_TIMES_ROMAN_24 GLUT_BITMAP_TIMES_ROMAN_24) (define glut:BITMAP_HELVETICA_10 GLUT_BITMAP_HELVETICA_10) (define glut:BITMAP_HELVETICA_12 GLUT_BITMAP_HELVETICA_12) (define glut:BITMAP_HELVETICA_18 GLUT_BITMAP_HELVETICA_18) (foreign-code "glutInit(&C_main_argc, C_main_argv);") )