|
27 | 27 | glut-hide-soft-input |
28 | 28 | glut-event-get |
29 | 29 |
|
| 30 | + glut-init-window-size |
| 31 | + glut-init-window-position |
| 32 | + |
30 | 33 | glut-init-callback |
31 | 34 | glut-on-key-event-callback |
32 | 35 | glut-on-touch-event-callback |
|
45 | 48 |
|
46 | 49 | (define lib (load-lib lib-name)) |
47 | 50 |
|
| 51 | + (define-syntax define-glut |
| 52 | + (syntax-rules () |
| 53 | + ((_ ret name args) |
| 54 | + (define name |
| 55 | + (foreign-procedure (lower-camel-case (string-split (symbol->string 'name) #\- )) args ret))))) |
| 56 | + |
| 57 | + (define glut-init-proc '()) |
48 | 58 |
|
49 | 59 | (define glut-display-proc '()) |
50 | 60 | (define glut-reshape-proc '()) |
|
53 | 63 | (define glut-motion-event-proc '()) |
54 | 64 | (define glut-mouse-event-proc '()) |
55 | 65 |
|
56 | | - (define glut-init |
| 66 | + (define glut-init-op |
57 | 67 | (foreign-procedure "glut_init" () void)) |
| 68 | + |
| 69 | + (define (glut-init . args) |
| 70 | + (if (= 0 (length args) ) |
| 71 | + (glut-init-op) |
| 72 | + (if (procedure? (car args)) |
| 73 | + (begin |
| 74 | + (set! glut-init-proc (car args) ) |
| 75 | + (glut-init-op) |
| 76 | + ) |
| 77 | + ))) |
58 | 78 |
|
| 79 | + |
| 80 | + |
59 | 81 | (define glut-main-loop |
60 | 82 | (foreign-procedure "glut_main_loop" () void)) |
61 | 83 |
|
|
75 | 97 | (define glut-set-soft-input-mode |
76 | 98 | (foreign-procedure "glut_set_soft_input_mode" (int int) void)) |
77 | 99 |
|
| 100 | + ;;c function |
| 101 | + (define-glut void glut-init-window-size (int int ) ) |
| 102 | + (define-glut void glut-init-window-position (int int ) ) |
| 103 | + |
| 104 | + |
78 | 105 | (define is-soft-input-show #f) |
79 | 106 | (define glut-show-soft-input (lambda () |
80 | 107 | (if (not is-soft-input-show) |
|
90 | 117 | )) |
91 | 118 |
|
92 | 119 | (define (glut-init-callback) |
93 | | - 1 |
| 120 | + (if (procedure? glut-init-proc) |
| 121 | + (glut-init-proc) |
| 122 | + ) |
94 | 123 | ) |
95 | 124 |
|
96 | 125 | (define (glut-on-key-event-callback . args) |
97 | | - ;(glut-log (format "on-key-event callback arg==~a ~a\n" (length args) (car args) ) ) |
| 126 | + (glut-log (format "on-key-event callback arg==~a ~a\n" (length args) (car args) ) ) |
98 | 127 | (if (procedure? glut-key-event-proc) |
99 | 128 | (if (= 2 (length args) ) |
100 | 129 | (glut-key-event-proc (car args) (cadr args)) |
|
0 commit comments