A C++/OpenGL Core3.0/WebGL2/OpenAL based application, built with CMake, targeting [Linux macOS Windows] and [HTML5/WebAssembly].
This project shows how to create a C++ based application for:
- Linux
- macOS
- Windows
- HTML5/WebAssembly leveraging the Emscripten SDK.
built with CMake for any target.
+-----+
| |===> C++ compiler ==> native x64 binary for Linux/macOS/Windows
| C++ |
| |===> Emscripten SDK ==> wasm binary for wasm supporting browsers
+-----+
The source code of the application consists of:
-
the arcade machine Galaga emulator written by Paolo Severini; it is 100% written in C++;
-
an hosting application 100% written in C++ based on:
This animation is recorded from Firefox Developer Edition 61.
Looking at Frame Per Seconds (FPS), the native app is 3x times faster than the WebAssembly one. Looking at Simulated Time over Real Time (SIMTIME) the native app is 2x times faster the WebAssembly one.
SIMTIME is the ratio between the time spent for simulating a second over a second, i.e.
SIMTIME = (time elapsed by GalagaMachine::Run(timeFraction)
) / (timeFraction
)
Results:
Platform | SIMTIME | FPS | Longer is faster |
---|---|---|---|
native app x86 on Windows 10 | 6% | 1100fps | ===================== |
native app x64 on macOS 10.13 | 8% | 620fps | ============ |
wasm app on Firefox61 DevEdition/Win10 | 9% | 400fps | ======== |
wasm app on Firefox61 DevEdition/macOS | 12% | 400fps | ======== |
wasm app on Chrome66/Win10 | 13% | 350fps | ======= |
wasm app on Chrome66/macOS | 25% | 230fps | ==== |
native app on Linux | ? | ? | ? |
Just use CMake ordinarily, such as:
-
create a build directory;
-
generate in the build directory your project files:
>cmake /path/to/sources/ -G "Unix Makefiles"
Note: do not run the cmake command from a shell for Emscripten (i.e. where emsdk_env.sh has been run!).
-
enjoy your generated project files with make/VisualStudio/XCode/Eclipse.
You need X11 development files, these are packages to install on Debian-derived distros:
>sudo apt-get install libx11-dev xorg-dev libglu1-mesa-dev libopenal-dev gdb
Ensure CMake 3.10 or newer is used, otherwise the /std:c++17
could not be set, and it needs to be specified manually from the project
properties (under C++->Languages).
Run from the build directory:
>emcmake cmake ./path/to/src/
>make -j
Obtain and install the Emscripten SDK.
- Create a build directory, that is where CMake is going to generate build files:
>mkdir builddirectory
- Set the environment variables for Emscripten:
>source path/to/emscripten/emsdk_env.sh
Note on Windows using cmd.exe, you just need to run 'emsdk_env.bat', the 'source' at the beginning it is not needed.
- run from the build directory:
>/path/to/emsdk/emsdk_env.sh
>emcmake cmake path/to/src
>make -j
- Install OpenAL 1.1 Core SDK from: http://openal.org/downloads/
- On a command prompt as admin (not a PowerShell one!):
>emsdk_env.bat
>set OPENALDIR=C:\Program Files (x86)\OpenAL 1.1 SDK\
>cd path/to/build/directory
>emcmake cmake path/to/sources/
In the repository there is a CMakeSettings.json file with preset configurations for Windows and Linux.
Set the correct IP address for the target Linux machine you want to build to, adding the address to the Connection Manager.
Run the following command from the build directory:
>cd path/to/build/directory
>emrun --no_browser --port=<AVAIL_PORT> --hostname=<IP-ADDRESS> .
Notes:
- You need to specify an IP-ADDRESS in case you want to connect to the hosting machine by another device e.g. mobile phone to test it out;
- Beware of the Firewall on the hosting machine: if you are not able to connect from the mobile phone to the server hosted on your laptop the Firewall is probably the cause.
Please remember that
GALAGA is a trademark of BANDAI NAMCO ENTERTAINMENT INC
This application requires the ROM images of the Galaga coinop produced by NAMCO.
Only if you own a real Galaga coinop you are entitled to create a dump of those and use them for your own personal use.
If you own the rights to use those file for personal use, copy them in to the /data/ directory. This is the list of files must be the following, named after the chip names:
- 2600j.bin
- prom-5.5n
- prom-4.2n
- prom-3.1c
- prom-2.5c
- prom-1.1d
- 2600j.bin
- 2700k.bin
- 2800l.bin
- 3200a.bin
- 3300b.bin
- 3400c.bin
- 3500d.bin
- 3600e.bin
- 3700g.bin
- 51xx.bin
- 54xx.bin