-
Notifications
You must be signed in to change notification settings - Fork 0
/
plum.rkt
40 lines (30 loc) · 1.03 KB
/
plum.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#lang racket
(require ffi/unsafe
ffi/unsafe/define
data/queue)
(define-ffi-definer define-plumgraphics
(ffi-lib "libplumgraphics"))
(define _Context-pointer (_cpointer 'Context-pointer))
(define-plumgraphics program (_fun -> _int))
(define-plumgraphics initialize (_fun -> _Context-pointer))
(define-plumgraphics probe_event (_fun _Context-pointer -> _int))
(define-plumgraphics poll_events (_fun -> _void))
(define-plumgraphics window_should_close (_fun _Context-pointer -> _bool))
(define-plumgraphics set_window_should_close (_fun _Context-pointer _bool -> _void))
(define NO_EVENT -1)
(define KEY_ESCAPE 256)
;;; Initialize GLFW and show window
(define context (initialize))
;;; Queue for VAO creating/uploading
(define vao)
;;; Main game loop
(define (game-loop)
(unless (window_should_close context)
(poll_events)
(event-handler (probe_event context))
(game-loop)))
(define (event-handler event)
(case event
[(256) (display "Window close!\n")]
[(105) (display "What? I???\n")])) ; FIXME constant
(game-loop)