You are looking at historical revision 30729 of this page. It may differ significantly from its current revision.



Bindings to the GLFW OpenGL window and event management library, version 3.X.



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] window

Contains 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.


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))
   [(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))
      (unless (glfw:window-should-close (glfw:window))

Version history

Version 0.3.0

Version 0.2.0

Version 0.1.0

Source repository

Source available on GitHub.

Bug reports and patches welcome! Bugs can be reported via GitHub or to alex.n.charlton at gmail.


Alex Charlton