Binding of the OpenGL GLFW API for the Duktape JavaScript engine.
To use the binding just include duk_glfw.c
and duk_glfw.h
into your project and call dukopen_glfw
to load the module.
#include "duk_glfw.h"
int main() {
// Create Duktape heap...
// Load the module
duk_push_c_function(ctx, dukopen_glfw, 0);
duk_call(ctx, 0);
duk_put_global_string(ctx, "glfw");
}
Now you can call GLFW functions from JavaScript using the glfw
global object.
glfw.setErrorCallBack(myErrorHandler);
glfw.init();
var window = glfw.createWindow(480, 320, 'my(window');
See tests/glfw.js
for more examples.
The CMake script will download both GLFW and Duktape before building the tests.
mkdir build && cd build
cmake ..
make
./duk_glfw