Skip to content

🧰 Interface with canvas and other HTML DOM elements from C++ using Emscripten.

License

Notifications You must be signed in to change notification settings

alextyner/wasm-dom-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wasm-dom-cpp

Inspired by my previous C/DOM interaction project, wasm-canvas, and the Java/DOM interface included with the TeaVM project, this library aims to make proof-of-concept rendering and simple visualization highly accessible to a lower level language like C++.

This project provides a layer of abstraction for manipulating elements of the HTML DOM -- with a focus on the canvas element in particular -- from C++ compiled with Emscripten.

Colorful bouncing balls rendered in the browser with C++ code

test/physics/main.cpp

Goals

Ultimately, I'd like this C++ library to be as feature-complete as the one provided with TeaVM for Java. While possible, such a task would require a more involved approach on the C++ side to make up for the lack of elegant compiler trickery used for the Java implementation.

Usage

Headers

This is a header-only library. All headers can be found in the include/ directory.

You can include wasm-dom.hpp for all available functionality,

#include "wasm-dom.hpp"

or include individual headers.

#include "wasm-dom/HTMLCanvasElement.hpp"

Compiling

Compile your source code with Emscripten.

$ em++ -Wall main.cpp -o index.html

For more involved compilation examples, see the Makefiles for the projects linked below. They can be found within the test/ directory.

Examples

Canvas Rendering Function Tests

Basic Physics Simulation (warning: flashing visuals)

About

🧰 Interface with canvas and other HTML DOM elements from C++ using Emscripten.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published