README.md 2.11 KB
Newer Older
ForkCreativeMedia's avatar
ForkCreativeMedia committed
1
# Basic web demos
ForkCreativeMedia's avatar
ForkCreativeMedia committed
2

ForkCreativeMedia's avatar
ForkCreativeMedia committed
3 4
In this repository we provide some simple examples on how to use Emscripten to bring C++ code to JavaScript/WebAssembly.

ForkCreativeMedia's avatar
ForkCreativeMedia committed
5 6 7 8 9 10 11
# Dependencies

**Required:**

- Emscripten is needed to create the web build. Emscripten is is available under 2 licenses, the MIT license and the
University of Illinois/NCSA Open Source License. For more information about Emscripten visit: https://emscripten.org

ForkCreativeMedia's avatar
ForkCreativeMedia committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

# Creating the web demos

First make sure you have the Emscripten toolchain correctly installed. This includes that the environment variables are set correctly.

Download or clone this repository. Navigate to the basic_web_demos folder in your terminal and type:

```powershell
#Create BUILD and BUILD_INSTALL directories and navigate to the BUILD folder.
mkdir BUILD
mkdir BUILD_INSTALL
cd BUILD

#Create the build files for the basic web demos (JavaScript only):
emcmake cmake .. -DCMAKE_INSTALL_PREFIX="../BUILD_INSTALL"

#Linux build and install
make install

#Windows build and install
mingw32-make.exe install

#Platform independant build and install
cmake --build . --target install

```

**Configuration options:**
- If you want to create a WebAssembly build add `-DBUILD_WASM=ON` to the emcmake command.

# Testing the web demos
Open the HTML demos from the `BUILD_INSTALL/bin` directory inside your browser. The simple demos should work without starting a local web server if you created a JavaScript only build.
In case you build to WebAssembly you should launch a local web server. For this you can use the following tool provided by emscripten:

```python
#This launches a local web server and runs the firefox browser displaying the content from the ../BUILD_INSTALL/bin directory. 
#(Assuming you're still inside the BUILD directory). 
emrun --browser firefox ../BUILD_INSTALL/bin

#Click on the HTML page you wish to view.
```

# License

This collection of source code is licensed under the MIT license.

Copyright (c) 2019 [ForK contributors](https://skylab.vc.h-brs.de/fork-project/fork_documentation/blob/master/FORK_CONTRIBUTORS.md).


# Acknowledgements

The project was funded by the European Regional Development Fund (EFRE).