Skip to content

✨ Node.js + SDL for awesome Desktop Apps ✨

Notifications You must be signed in to change notification settings

Abd-Elrazek/node-websdl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-websdl

SDL for the Web and ECMAScript - as it should be.

This project contains opinionated bindings for the SDL library and ships a shared library with its installation.

The bindings are made for ECMAScript 2016+, so most static pointer-using APIs have been refactored to allow much cleaner usage.

Example

This demo requires an image.png (preferably 128x128 pixels) in the same folder.

let window   = SDL.createWindow('Basic Test', 100, 100, 640, 480, SDL.WINDOW.shown | SDL.WINDOW.resizable);
let renderer = SDL.createRenderer(window, -1, SDL.RENDERER.accelerated);
let texture  = SDL.createTexture(renderer, __dirname + '/image.png');
let dest     = new SDL.Rect({
    x: 32,
    y: 32,
    w: 128,
    h: 128
});


setInterval(function() {

	renderer.setDrawColor(128, 128, 128, 255);

	renderer.clear();
	renderer.copy(texture, null, dest);
	renderer.present();

}, 1000 / 30);

Installation Quirks

  • Have libpng12 installed
  • npm install - if it fails go to next point
  • Clone https://github.com/node-ffi/node-ffi.git to node_modules/ffi
  • Do a node-gyp rebuild inside node_modules/ffi
  • Newest libSDL2-2.0.so should be shipped in src/lib/linux/x64 folder
  • In case you need to recompile sdl2 and sdl2_image, rebuild accordingly to libsdl.org.

About

✨ Node.js + SDL for awesome Desktop Apps ✨

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 94.7%
  • Shell 5.3%