# CHICKEN GLFW3 Bindings ## Description Bindings to the [GLFW](http://www.glfw.org/) OpenGL window and event management library, version 3.X. ## Installation This repository is a [Chicken Scheme](http://call-cc.org/) egg. It is part of the [Chicken egg index](http://wiki.call-cc.org/chicken-projects/egg-index-4.html) and can be installed with `chicken-install glfw3`. ## Requirements * Bind ## Documentation Direct bindings generated by [bind](http://wiki.call-cc.org/eggref/4/bind). Names Scheme-ified, with GLFW prefixes removed. Constants surrounded by `+`s (e.g. `+alpha-bits+`) Version 3 of GLFW is not backwards compatible with previous major versions of GLFW. For information regarding the GLFW API, see the official [GLFW documentation](http://www.glfw.org/documentation.html). ### High-level interface [procedure] (make-window WIDTH HEIGHT NAME #!key (fullscreen? #f) resizable visible decorated red-bits green-bits blue-bits alpha-bits depth-bits stencil-bits accum-red-bits accum-green-bits accum-blue-bits accum-alpha-bits aux-buffers samples refresh-rate sterio srgb-capable client-api context-version-major context-version-minor context-robustness opengl-forward-compat opengl-debug-context opengl-profile) Create the window with title string `NAME` and dimensions `WIDTH` by `HEIGHT`. The keys correspond to the available [GLFW window hints](http://www.glfw.org/docs/latest/window.html#window_hints). `resizable`, `visible`, `decorated`, `sterio`, `srgb-capable`, `opengl-forward-compat`, `opengl-debug-context` accept boolean arguments, while all other accept either an integer or an appropriate GLFW constant as per the documentation. [parameter] window Contains the GLFW window object that is created by `make-window`. [macro] (with-window (WIDTH HEIGHT NAME . KEYS) BODY ...) Initializes GLFW, creates a window as per `make-window`, and runs `BODY` before cleaning up. If [opengl-glew](https://wiki.call-cc.org/eggref/4/opengl-glew) has been included in the same file that this macro is used, opengl-glew will also be initialized. ## Example This example must be compiled due to the external function definition. ``` Scheme (import foreign) (use (prefix glfw3 glfw:) (prefix opengl-glew gl:)) (define-external (keyCallback (c-pointer window) (int key) (int scancode) (int action) (int mods)) void (cond [(and (eq? key glfw:+key-escape+) (eq? action glfw:+press+)) (glfw:set-window-should-close window 1)])) (glfw:with-window (640 480 "Example" resizable: #f) (glfw:set-key-callback (glfw:window) #$keyCallback) (let loop () (glfw:swap-buffers (glfw:window)) (glfw:poll-events) (unless (glfw:window-should-close (glfw:window)) (loop)))) ``` ## Version history ### Version 0.3.0 * Make `*window*` a parameter named `window` ### Version 0.2.0 * Add `make-window`, `with-window` ### Version 0.1.0 * Initial release ## Source repository Source available on [GitHub](https://github.com/AlexCharlton/glfw3-chicken). Bug reports and patches welcome! Bugs can be reported via GitHub or to alex.n.charlton at gmail. ## Author Alex Charlton ## Licence BSD