You are looking at historical revision 30729 of this page. It may differ significantly from its current revision.
CHICKEN GLFW3 Bindings
Description
Bindings to the GLFW OpenGL window and event management library, version 3.X.
Requirements
- Bind
Documentation
Direct bindings generated by 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.
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. 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] windowContains the GLFW window object that is created by make-window.
[syntax] (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 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.
(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.
Bug reports and patches welcome! Bugs can be reported via GitHub or to alex.n.charlton at gmail.
Author
Alex Charlton
Licence
BSD