Version: pre-release (still in initial development)

Author: Timothy Bogdala


Project Description

glfw-gambit is a MIT licensed Gambit-C scheme wrapper for GLFW 2.x.

Tested Platforms

  • Gambit-C 4.6.6
  • Linux [Tested: Fedora 18]
  • Mac OS X [Tested: 10.7.5]


  • GLFW for Linux, Mac OS X and Windows hosts
  • Gambit-C scheme


The main API is located in glfw.scm. The other scheme files are test programs.

Compiling on Linux

Compile with:

    $ gsc -ld-options "-L/usr/local/lib -lglfw" -exe basic-test.scm

or, if you get a bunch of undefined references, you might need to link in more libraries:

    $ gsc -ld-options "-L/usr/local/lib -lglfw -lGLU -lGL -lX11 -lrt" -exe basic-test.scm

Compiling on Mac OS X

This platform is complicated by a few things. Gambit-C defaults to building for x86, however GLFW builds for x86_64 which will cause a problem on linking. Gambit-C can be configured and built from source like this:

    CFLAGS="-m64" ./configure --enable-single-host

[ed. note: using CFLAGS="-arch x86_64" failed the configure script. "--enable-gcc-opts" was not added to greatly reduce build time on my mac.]

After you have a 64 bit library of Gambit-C (check with "lipo -info /usr/local/Gambit-C/lib/libgambc.a"), you can build the tests of GLFW using a command line like below:

    gsc -cc-options "-I/usr/X11R6/include -I/usr/local/include -isysroot /Applications/" -ld-options "-L/usr/local/lib -lglfw" -exe basic-test.scm

Constant values

All #define constantes in glfw.h were ported as is, with no changes to naming.

Implemented Functions

  • glfw-init
  • glfw-terminate
  • glfw-get-version
  • glfw-open-window
  • glfw-open-window-hint
  • glfw-close-window
  • glfw-set-window-title
  • glfw-get-window-size
  • glfw-set-window-size
  • glfw-set-window-pos
  • glfw-iconify-window
  • glfw-restore-window
  • glfw-swap-buffers
  • glfw-swap-interval
  • glfw-get-window-param
  • glfw-poll-events
  • glfw-wait-events
  • glfw-get-key
  • glfw-get-mouse-button

Currently Unimplemented Functions

  • glfwSetWindowSizeCallback
  • glfwSetWindowCloseCallback
  • glfwSetWindowRefreshCallback
  • glfwGetVideoModes
  • glfwSetMousePos
  • glfwGetMouseWheel
  • glfwSetMouseWheel
  • glfwSetKeyCallback
  • glfwSetCharCallback
  • glfwSetMouseButtonCallback
  • glfwSetMousePosCallback
  • glfwSetMouseWheelCallback
  • glfwGetJoystickParam
  • glfwGetJoystickPos
  • glfwGetJoystickButtons
  • glfwGetTime
  • glfwSetTime
  • glfwSleep
  • glfwExtensionSupported
  • glfwGetProcAddress
  • glfwGetGLVersion
  • glfwCreateThread
  • glfwDestroyThread
  • glfwWaitThread
  • glfwGetThreadID
  • glfwCreateMutex
  • glfwDestroyMutex
  • glfwLockMutex
  • glfwUnlockMutex
  • glfwCreateCond
  • glfwDestroyCond
  • glfwWaitCond
  • glfwSignalCond
  • glfwBroadcastCond
  • glfwGetNumberOfProcessors
  • glfwEnable
  • glfwDisable
  • glfwReadImage
  • glfwReadMemoryImage
  • glfwFreeImage
  • glfwLoadTexture2D
  • glfwLoadMemoryTexture2D
  • glfwLoadTextureImage2D

Behavior Notes

All of the API should have the same parameters and behavior of the original C API. The following are the exceptions:


Returns a vector of #(major minor rev) representing the version number and does not take parameters.

struct GLFWvidmode

Any glfw-vidmode* type returned by the API must be deallocated by passing it to glfw-vidmode-free.

The following accessor functions exist to access data members:

  • glfw-vidmode->width
  • glfw-vidmode->height
  • glfw-vidmode->red-bits
  • glfw-vidmode->blue-bits
  • glfw-vidmode->green-bits


Returns a vector of #(width height) representing the window size and does not take parameters.


Returns a newly allocated glfw-vidmode* that must be deallocated with glfw-vidmode-free.


Takes a vector long enough to hold #(xpos ypos) as a parameter and populates the vector with the position.


All original code and assets in this distribution are released under the MIT license as described in the LICENSE file unless otherwise noted.