Created
August 30, 2011 00:07
-
-
Save creationix/1179757 to your computer and use it in GitHub Desktop.
A simple sample showing how to use my "sdl" and "webgl" node libraries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To test on Ubuntu, install the requirements to build | |
// `apt-get install libsdl-image1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libgles2-mesa-dev` | |
// Then load the node libraries needed `npm install sdl webgl` | |
// Then run this script! | |
SDL = require('sdl'); | |
gl = require('webgl'); | |
SDL.init(SDL.INIT.VIDEO); | |
var screen = SDL.setVideoMode(640, 480, 0, SDL.SURFACE.OPENGL); | |
SDL.events.on("QUIT", process.exit) | |
SDL.events.on("KEYDOWN", function (evt) { if (evt.sym === 27) process.exit() }); | |
process.on('exit', function () { SDL.quit(); }); | |
gl.viewport(0, 0, screen.w, screen.h); | |
gl.clearColor(0, 0.5, 0, 1); | |
gl.clear(gl.COLOR_BUFFER_BIT); | |
SDL.GL.swapBuffers(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've been trying to get this to work, but I can't get past the first line of code "SDL = require('sdl');
Are there more details orbetter-yet, a full working version I can obtain? I included a copy of require.js and this code hangs or ends in the function 'function'. I also have those dev libraries, but not sure how this all comes together? Help is appreciated. Just trying to get webgl working with SDL.