Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

Emscripten implements SDL in JavaScript, rendering to a Canvas element. It supports both RGB and fixed palettes.

There is also some experimental work to translate (a subset of) OpenGL to WebGL.



sort by: page size:

Emscripten has an SDL implementation so you can just SDL_BlitSurface inside a <canvas>.

it might be more of a canvas issue than anything. emscripten gets some good results most of the time (something like 10x speed down compared to g++ -O3).

Canvas (and webGL notably) support is there, but its super flaky and hard to make fast.


It's not really clear to me how graphics are being displayed. I assume they're not converting SDL/OpenGL to Javascript. Is there a Canvas library you can link, or something?

I'm currently working on an web ide that use the Canvas instead of the DOM. The Canvas is very nice to work with, it's high level and hardware accelerated.

No, he's right, an HTML canvas has no palette. It's a software emulation in JavaScript.

This looks very interesting. I've always been disappointed that Canvas totally eclipsed SVG in browsers- SVG elements are in the DOM, so it makes things like click actions a lot easier. It looks like processing.js goes some way to help with the pain of using Canvas.

More specifically, canvas based rendering.

Nothing special, just plain Typescript and canvas rendering.

What keeps one from implementing a pure javascript implementation that renders to canvas? Do we need browsers to support formats anymore? With WebGL, WebCL, high speed JS and the canvas tag don't we have everything we need?

Canvas and webgl is lovely in the way it quickly lets you get something on the screen... Pixel pushing on canvas is, easy and accessible.

It makes me wonder if anyone has created some sort of port to a standalone app with no browser involved where you could use javascript/canvas-api/webgl to draw pixels on a canvas-like surface... without the fatness of the browser. Just spawning some window, that would be a lovely scripting/game-dev environment, maybe with some sdl-bindings or whatever. Anyway just rambling, does such a project exist? Anyone knows? :)


Is playcanvas using emscriptem or is it written directly in js? nice project by the way. Also what does the worker do? does it have access to the canvas context or it just does some calculations and communicate with the main thread via serialized data.

An efficient javascript engine would enable, finally, awesome javascript graphics (via canvas).

Nice! How do you like the JavaScript canvas api? I found it hard to be productive with but I plan on taking another stab soon. I’ve had more luck with svg animations and pixi.js but I want to learn enough of the canvas api to solidify my opinion of it.

SDL API is used to interface with HTML5 canvas operations so that SDL doesn't need to be compiled: the entire SDL API is literally a primitive in your browser.

I don't think you can use JS to get how the model looks on screen with this, whereas a canvas can be converted to an RGB grid

It does support <canvas>, with limited support but still.

See: https://github.com/c-smile/sciter-js-sdk/tree/main/samples/c...

Sciter also supports immediate mode painting on any element (like in DearIMGUI):

    element.paintBackground = function(gfx) {

      ... drawing operations here ...
    }
See: https://github.com/c-smile/sciter-js-sdk/tree/main/samples.s...

If you're going to port to JavaScript, it looks like it would be much better suited for SVG rather than canvas.

eh, not really. It's true that Canvas is its own rendering context, but it's just a drawing API. There is a whole suite of technology needed for applications that is currently only available to html/js. Things like accessibility, text input, etc. What I'm imagining is a rendering context that, like the html document, provides those things out of the box.

Then what is stopping browser vendors from implementing canvas directly in gl directly, making canvas more or less a wrapper?
next

Legal | privacy