• Stars
    star
    206
  • Rank 190,504 (Top 4 %)
  • Language
    C++
  • Created almost 7 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Minimal example of animating the HTML5 canvas from C++ using SDL through WebAssembly

Live demo: https://timhutton.github.io/sdl-canvas-wasm/

(If you want more sophisticated drawing than SDL can offer (e.g. 3D), then you should probably start here instead.)

Instructions:

  1. Install Emscripten:

    http://emscripten.org

  2. Clone this repo:

    git clone https://github.com/timhutton/sdl-canvas-wasm.git

    cd sdl-canvas-wasm

  3. Build index.js and index.wasm:

    emcc core.cpp -s WASM=1 -s USE_SDL=2 -O3 -o index.js

  4. Open index.html in a web browser. You should see a moving blue square in a red square:

    image

    Chrome doesn't support file:// XHR requests, so you need to first start a webserver, e.g.:

    with Python 2: python -m SimpleHTTPServer 8080

    with Python 3: python -m http.server 8080

    and then open this URL:

    http://localhost:8080/

MIT license:

Copyright (c) 2018 Tim Hutton

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

More Repositories

1

twitter-archive-parser

Python code to parse a Twitter archive and output in various ways
Python
2,396
star
2

opengl-canvas-wasm

Minimal example of animating the HTML5 canvas from C++ using OpenGL through WebAssembly
C++
339
star
3

GravityIsNotAForce

Visualising the spacetime geodesics of general relativity
JavaScript
212
star
4

hyperplay

Explore tilings on the hyperbolic plane
HTML
86
star
5

crochet-simulator

Predicting the 3D shape from a crochet pattern.
HTML
57
star
6

mobius-transforms

Exploring Mรถbius transformations and implementing the book Indra's Pearls
HTML
38
star
7

vtkpowercrust

A VTK port of the PowerCrust surface reconstruction algorithm
C++
31
star
8

klein-quartic

Exploring the Klein Quartic's geometry.
Python
28
star
9

livingphysics

Artificial chemistry game
JavaScript
27
star
10

mandelstir

Animating fractional iterations in the Mandelbrot Set and Julia Sets.
C++
27
star
11

zomes

Zomes are polar zonohedron domes, made from rhombi.
HTML
20
star
12

squirm3

Artificial chemistry
C++
18
star
13

cmake-swig-java

Minimal example of using SWIG to call C++ code from Java, with a CMake cross-platform build system.
CMake
15
star
14

latticegas

Lattice Gas Explorer, previously at http://code.google.com/p/latticegas
C++
15
star
15

PseudosphereGeodesics

Visualising straight lines (geodesics) on the pseudosphere and related geometries.
JavaScript
10
star
16

slinker

Generating Slitherlink puzzles, previously at http://code.google.com/p/slinker
C++
9
star
17

linear-enzymes

Artificial chemistry where chains of atoms can catalyse reactions
C++
7
star
18

voronoi-honeycombs

Making space-filling polyhedra using Voronoi cells
Python
3
star
19

chessviz

Visualizing the space of chess moves
HTML
3
star
20

turmite-trajectories

Analysing the trajectories of turmites
C++
2
star
21

circle-squaring

Cutting up a circle to make a square - how close can you get?
HTML
2
star
22

terminatingturmites

Searching for Busy Beaver Turing machines and their higher-dimensional cousins the Terminating Turmites. Previously at http://code.google.com/p/terminatingturmites
C++
2
star
23

geofun

Exploring location-based fun
JavaScript
2
star
24

povray-polyhedra

Script to render different polyhedra for Wikipedia
POV-Ray SDL
2
star
25

grid-physics

Flexible movement on a grid
C++
2
star
26

image-based-fractals

Image-based fractal rendering
HTML
2
star
27

timhutton.github.io

Blog:
Python
1
star
28

twisty-quads

Playing around with an optical illusion doodle
HTML
1
star
29

curved-mirrors

What does it look like when you are standing in a hall of mirrors and the walls curve inwards or outwards?
POV-Ray SDL
1
star
30

hat-freedom

Exploring the degrees of freedom in the new aperiodic monotile, 'the hat'.
JavaScript
1
star