23

I've been looking all over the internet for this. I'd like to know if there is any Node.js packages/bindigs/libraries that allow you to make an application that draws on the screen without node-webkit(NW.js)/Electron or other implementations based on browsers. Maybe something that binds to opengl with support for 2D graphics?

Let me know if you know some names or links. If not I might have to write something myself.

Thank you guys.

Zorgatone
  • 4,176
  • 4
  • 30
  • 47
  • 2
    I think three.js is what you looking for – greedsin Nov 12 '15 at 16:40
  • 5
    That's for the browser canvas @lolio – Zorgatone Nov 12 '15 at 16:41
  • 1
    Yes that's true ,but then I don't understand your question :( maybe you can give me an example on what you are trying to achieve – greedsin Nov 12 '15 at 16:43
  • 1
    I'm trying to do a desktop application with node-js (like a game). I mean without a browser, just using node-js (server/desktop javascript) – Zorgatone Nov 12 '15 at 16:44
  • Where do you want this application to run? In your console? – ant45de Nov 12 '15 at 16:49
  • 3
    I want to run `node my-app.js` and have it create a window (or go fullscreen), display some graphics, and even better get some keyboard/mouse input and audio. Basically let's say I want to make a videogame for a desktop computer in JavaScript. But I don't want to rely on a specific browser platform, just on Node.JS and the V8 Engine. Are there any bidings to GL or something similar? – Zorgatone Nov 12 '15 at 16:51
  • 1
    I found V8-GL,which is a Toolkit for creating Desktop Hardware Accelerated Graphics with JS – greedsin Nov 12 '15 at 17:18
  • 2
    Here is a link,but I don't know,if this works correctly https://github.com/philogb/V8-GL – greedsin Nov 12 '15 at 17:19
  • that's actually very interesting, I will look and see how it works :D – Zorgatone Nov 12 '15 at 17:22
  • @Zorgatone Why cant you use nw.js and phaser for example? ships chromium, so you know the platform and the rest.. just works.. it also gives you the whole build system and shipping to all platforms. – webdeb Nov 15 '15 at 01:42
  • I could do that. But I was interested to know if there were valid alternatives or not – Zorgatone Nov 15 '15 at 07:19
  • 1
    Three.js uses WebGL, not OpenGL. @lolio. OP is asking for opengl bindings using Javascript. – NiCk Newman Feb 17 '16 at 01:48
  • Some Qt bindings for node like [this one](https://github.com/arturadib/node-qt) might be a good option as well – Zorgatone Jan 16 '17 at 14:51
  • take a look at Node-gir (recent project): https://github.com/Place1/node-gir - allows you to use any Gnome lib from Node, especially GTK etc. What you are really looking for is a native GUI lib binding in Node ... you should extend your search to those terms instead of just drawing ... since you wont be able to "draw" without something like a native UI window handle of some sort, at least on most common desktop platforms. – Tchakabam Jun 02 '18 at 14:07
  • @Zorgatone Node Vulkan API for JavaScript/TypeScript https://github.com/maierfelix/nvk – Maksim Shamihulau Dec 02 '22 at 21:48

4 Answers4

9

There is an experimental project : https://github.com/creationix/node-sdl

This basically provides bindings to the SDL library:

Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.

If you can get it compiled, you can try the example scripts in nodejs.

S.D.
  • 29,290
  • 3
  • 79
  • 130
4

node-opencv or OpenCV in general should allow you this. At least it has a HighGUI class, which gives you native window contexts to display image data. With a lot of hacking you can build something you require. But I would suggest using browser contexts and HTMLCanvas anyhow. It gives you all you need out of the box. You just need to set it up properly.

Edit: As per @Zorgatone's suggestion, GTK could be a very good library for that purpose, though node bindings are very stale.

eljefedelrodeodeljefe
  • 6,304
  • 7
  • 29
  • 61
  • It kinda sucks for me to rely on a browser anyway.. I believe there should be some bindings of Cairo/GTK out there that I could use, but I haven't tried those though. – Zorgatone Nov 09 '15 at 07:27
  • 1
    GTK is a really good suggestion. I think the bindings though are really old. But do investigate on it or write your own. Should be a very good path. – eljefedelrodeodeljefe Nov 09 '15 at 07:55
  • Ok, I will try. Thanks – Zorgatone Nov 09 '15 at 07:57
  • I think opencv doesn't actually implement any rendering - as you said it depends on DOM canvas int he browser/node and on third party on the server to actually rendering to a display or even to files. – cancerbero Sep 01 '19 at 16:26
4

There are projects that brings

but unfortunately the last commits seem to be for old node.js versions.

It will be substantial work to make the bindings work with a recent version of node but those a interesting starting points.

Jerome WAGNER
  • 21,986
  • 8
  • 62
  • 77
2

V8-GL intends to provide bindings for creating 2D-3D graphics on the desktop with javascript.The Status is not completed yet, but maybe it is enough for what you are trying to do https://github.com/philogb/V8-GL Another thing i just found out is, that it actually uses immediate mode, which is deprecated but still works.

greedsin
  • 1,252
  • 1
  • 24
  • 49