My first attempt at writing a C++ based graphics demo
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
assets
src
.gitignore
.gitlab-ci.yml
LICENSE
Makefile
readme.md

readme.md

demo fun 🕹

This is my first take at writing demo code or any C++ graphics. Spawned into existence during the 2018 revision party 👯‍

All commits are automatically compiled to ASM.js code and can be viewed from the respective GitLab artifact. Just follow the green ✔ next to the commit on GitHub.

A list of noteworthy (lol) commits:

 Description  Preview  ASM  Commit
Perlin & rotating planets changing scene  web (broken colors) 3d2a99d6
 Colored rotating spheres arount a lightsource    web  33260db8
 Rotating spots over living Perlin noise    web  d9f9646
 Bugged moving Perlin noise that ends up looking like flames  n/a  f638eaa

C++

make build && make run

Autobuild

For ease of development the following commands will automatically build ASM.js output every time sources change and serve them to a web browser.

# build automatically if .cpp or .h files change using emscripten
make autobuild
# start up a live-reload server (npm i -g live-server)
make serve

Compile to Javascript

Install emscripten

brew install emscripten

Make sure that the main loop is handled by emscripten and not automatically started in main()

  #ifdef __EMSCRIPTEN__
    // 0 fps means to use requestAnimationFrame; non-0 means to use setTimeout.
    emscripten_set_main_loop(loop, 0, 1);
  #else
    while (!quit) {
      loop();
      SDL_Delay(16);
    }
  #endif
# build html (and js)
em++ *.cpp -o out.html -s USE_SDL=2 --shell-file shell_minimal.html

# run stuff
open out.html

License

Code is licensed under MIT

Attribution