{"id":16612532,"url":"https://github.com/lukka/cppopenglwebassemblycmake","last_synced_at":"2025-07-03T07:36:57.204Z","repository":{"id":45709313,"uuid":"136691765","full_name":"lukka/CppOpenGLWebAssemblyCMake","owner":"lukka","description":"A C++/OpenGL/OpenAL based application built with CMake for Linux/Windows/macOS/WebAssembly","archived":false,"fork":false,"pushed_at":"2022-04-16T06:05:47.000Z","size":6486,"stargazers_count":73,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-03T21:42:50.515Z","etag":null,"topics":["application","cmake","cpp","emscripten","glfw","glm","glsl","linux","macos","openal","opengl","opengl-es","visualstudio","webassembly","windows"],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lukka.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-09T04:52:04.000Z","updated_at":"2024-09-10T05:21:33.000Z","dependencies_parsed_at":"2022-09-15T20:50:45.553Z","dependency_job_id":null,"html_url":"https://github.com/lukka/CppOpenGLWebAssemblyCMake","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lukka/CppOpenGLWebAssemblyCMake","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukka%2FCppOpenGLWebAssemblyCMake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukka%2FCppOpenGLWebAssemblyCMake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukka%2FCppOpenGLWebAssemblyCMake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukka%2FCppOpenGLWebAssemblyCMake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukka","download_url":"https://codeload.github.com/lukka/CppOpenGLWebAssemblyCMake/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukka%2FCppOpenGLWebAssemblyCMake/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263284135,"owners_count":23442473,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["application","cmake","cpp","emscripten","glfw","glm","glsl","linux","macos","openal","opengl","opengl-es","visualstudio","webassembly","windows"],"created_at":"2024-10-12T01:42:29.028Z","updated_at":"2025-07-03T07:36:57.094Z","avatar_url":"https://github.com/lukka.png","language":"HTML","readme":"# A C++/OpenGL Core3.0/WebGL2/OpenAL based application, built with CMake, targeting [Linux macOS Windows] and [HTML5/WebAssembly].\n\nThis project shows how to create a C++ based application for:\n  - Linux\n  - macOS\n  - Windows \n  - HTML5/[WebAssembly](https://webassembly.org/) leveraging the [Emscripten SDK](https://kripken.github.io/emscripten-site/docs/introducing_emscripten/index.html).\n\nbuilt with CMake for any target.\n\n![hosted-wasm-macos-linux](https://github.com/lukka/CppOpenGLWebAssemblyCMake/workflows/hosted-wasm-macos-linux/badge.svg)[![Build Status](https://dev.azure.com/CppBuild/CppBuildTasks/_apis/build/status/wasm-and-native-win-linux-lukka.CppOpenGLWebAssemblyCMake?branchName=master)](https://dev.azure.com/CppBuild/CppBuildTasks/_build/latest?definitionId=8\u0026branchName=master)\n\n```\n+-----+\n|     |===\u003e    C++ compiler  ==\u003e  native x64 binary for Linux/macOS/Windows\n| C++ |\n|     |===\u003e  Emscripten SDK  ==\u003e  wasm binary for wasm supporting browsers \n+-----+\n```\n\nThe source code of the application consists of:\n \n - [the arcade machine Galaga emulator](https://paoloseverini.wordpress.com/2016/02/13/galaga-an-arcade-machine-emulator-for-windows-and-html5/) written by Paolo Severini; it is 100% written in C++;\n\n - an hosting application 100% written in C++ based on:\n   - [C++17](https://isocpp.org) as the only programming language;\n   - [CMake](https://cmake.org) for building;\n   - [OpenGL](https://opengl.org) and [OpenAL](https://www.openal.org) for graphics and sound rendering;\n   - [GLFW](http://www.glfw.org/) library for canvas/fullscreen management;\n   - [GLM](https://glm.g-truc.net/0.9.8/index.html) for mathematics;\n\n## Preview\n\nThis animation is recorded from the native app:\n\n\u003cimg src=\"images/animation.gif\"\n     alt=\"game animation\"\n     style=\"margin-right: 10px;\" /\u003e\n\n## Benchmarks\n\nLooking at Frame Per Seconds (FPS), the native app is 3x times faster than the WebAssembly one.\nLooking at Simulated Time over Real Time (SIMTIME) the native app is 2x times faster the WebAssembly one.\n\nSIMTIME is the ratio between the time spent for simulating a second over a second, i.e. \n\n__SIMTIME__ = (time elapsed by ```GalagaMachine::Run(timeFraction)```) / (```timeFraction```)\n\nResults:\n\n| Platform | SIMTIME | FPS | Longer is faster|\n|--- | :--- | :---: | :--- |\nnative app x86 on Windows 10| 6% | 1100fps | ```=====================```\nnative app x64 on macOS 10.13 | 8% | 620fps | ```============```\nwasm app on Firefox61 DevEdition/Win10|9%|400fps|```========```\nwasm app on Firefox61 DevEdition/macOS|12%|400fps|```========```\nwasm app on Chrome66/Win10 |13%|350fps|```=======```\nwasm app on Chrome66/macOS|25%|230fps|```====```\nnative app on Linux | ?|?|```?```\n\n## Building and running the project\n\n### With VSCode using Docker\n\nThe provided [Dockerfile](.devcontainer/Dockerfile) contains all you need to build and run this project (e.g. Emscripten SDK version 2.0+, gcc, CMake, Ninja).\n\nOpen the folder with VSCode using \"Remote-Container: Open folder in container\", \n\nEnable the CMake Tools extension for VSCode.\n\n### Building the WebAssembly based application with Emscripten SDK\n\nCreate a running container from the [Dockerfile](.devcontainer/Dockerfile), mount the root of the repository onto /workspace/CppOpenGLWebAssemblyCMake/,\nand run:\n\n  ```bash\n    \u003ecd /workspace/CppOpenGLWebAssemblyCMake/\n    \u003emkdir build \u0026\u0026 cd build\n    \u003eemcmake cmake -GNinja ..\n    \u003ecmake --build .\n  ```\n\n### Building the native application for Linux/macOS/Windows\n\n  ```bash\n    \u003emkdir build \u0026\u0026 cd build\n    \u003ecmake -GNinja ..\n    \u003ecmake --build .\n  ```\n\nYou can replace Ninja with any project file generator you like, e.g. make/VisualStudio/XCode/Eclipse.\n\n### Run the native application \n\nRun the executable created in the build directory.\n\n#### Using OpenFolder/CMake on Visual Studio\n\nIn the repository there is a CMakeSettings.json file with preset configurations for Windows and Linux.\n\nSet the correct IP address for the target Linux machine you want to build to, adding the address to the [Connection Manager](https://docs.microsoft.com/en-us/cpp/linux/connect-to-your-remote-linux-computer).\n\n##### Linux special notes\n\nYou need X11 development files, these are packages to install on Debian-derived distros:\n\n```bash\n   \u003esudo apt-get install libx11-dev xorg-dev libglu1-mesa-dev libopenal-dev gdb\n```\n\n##### Windows/Visual Studio special notes\n \nEnsure 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 \nproperties (under C++-\u003eLanguages).\n\n## Run the WebAssembly application with ```emrun```\n\nRun the following command from the build directory:\n\n  ```bash\n    \u003ecd path/to/build/directory\n    \u003eemrun --no_browser --serve_after_close --serve_after_exit --port=6931 --hostname=0.0.0.0 .\n  ```\n\nNotes:\n1. You need to specify an IP-ADDRESS in case you want to connect to the hosting machine\n   by another device e.g. mobile phone to test it out;\n2. Beware of the Firewall on the hosting machine: if you are not able to connect from\n   the mobile phone to the server hosted on your laptop the Firewall is probably the\n   cause.\n\n## Galaga ROM files\n\nPlease remember that\n\n**GALAGA is a trademark of BANDAI NAMCO ENTERTAINMENT INC**\n\nThis application requires the ROM images of the Galaga coinop produced by NAMCO.\n\nOnly if you own a real Galaga coinop you are entitled to create a dump of those and use them for your own personal use.\n\nIf you own the rights to use those file for personal use, copy them in to the /data/ directory.\nThis is the list of files must be the following, named after the chip names:\n\n - 2600j.bin\n - prom-5.5n\n - prom-4.2n\n - prom-3.1c\n - prom-2.5c\n - prom-1.1d\n - 2600j.bin\n - 2700k.bin\n - 2800l.bin\n - 3200a.bin\n - 3300b.bin\n - 3400c.bin\n - 3500d.bin\n - 3600e.bin\n - 3700g.bin\n - 51xx.bin\n - 54xx.bin\n\nThis is the picture of the coin-op:\u003cbr\u003e\n\u003cimg src=\"images/galaga_coinop.jpeg\"\u003e\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukka%2Fcppopenglwebassemblycmake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukka%2Fcppopenglwebassemblycmake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukka%2Fcppopenglwebassemblycmake/lists"}