GithubHelp home page GithubHelp logo

abd-elrazek / node-websdl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from skerit/node-sdl-runtime

0.0 0.0 0.0 6.07 MB

:sparkles: Node.js + SDL for awesome Desktop Apps :sparkles:

Shell 5.33% JavaScript 94.67%

node-websdl's Introduction

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.

node-websdl's People

Contributors

cookiengineer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.