{"id":15194133,"url":"https://github.com/rogerboesch/multi-platform-template","last_synced_at":"2026-01-26T07:32:58.841Z","repository":{"id":196614575,"uuid":"696757454","full_name":"rogerboesch/multi-platform-template","owner":"rogerboesch","description":"Project template I use to create multiplatform apps for Magic Leap 2, macOS, Windows and Linux","archived":false,"fork":false,"pushed_at":"2023-09-26T14:57:00.000Z","size":7823,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-04T08:23:16.289Z","etag":null,"topics":["c","cpp","linux","macosx","magicleap2","pixel-game","template-project","vector-game-dev","windows10"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rogerboesch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-26T11:32:34.000Z","updated_at":"2023-09-26T12:31:28.000Z","dependencies_parsed_at":"2023-09-26T14:59:49.690Z","dependency_job_id":null,"html_url":"https://github.com/rogerboesch/multi-platform-template","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"1e63d6a94b3020bb329fb4445865400c4dd348d1"},"previous_names":["rogerboesch/multi-platform-template"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rogerboesch/multi-platform-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogerboesch%2Fmulti-platform-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogerboesch%2Fmulti-platform-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogerboesch%2Fmulti-platform-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogerboesch%2Fmulti-platform-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rogerboesch","download_url":"https://codeload.github.com/rogerboesch/multi-platform-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogerboesch%2Fmulti-platform-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28769851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T06:37:25.426Z","status":"ssl_error","status_checked_at":"2026-01-26T06:37:23.039Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["c","cpp","linux","macosx","magicleap2","pixel-game","template-project","vector-game-dev","windows10"],"created_at":"2024-09-27T22:23:41.263Z","updated_at":"2026-01-26T07:32:58.826Z","avatar_url":"https://github.com/rogerboesch.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multiplatform template \n\nThis is a template that supports pixel/line based games and apps on Magic Leap 2, macOS, Windows and Linux\n\n## Magic Leap 2\n\n### Prerequisites\n\nRefer to https://developer.magicleap.cloud/learn/docs/guides/native/capi-getting-started\n\n**Define Environment Variables**\n\n```sh\n$ source {MLSDK_PATH}/envsetup.sh\n```\n\n**Build the app_framework (first)**\n\n```sh\n$ cd %MLSDK%\n$ cd samples\\c_api\\app_framework\n$ python3 build.py --build device\n$ set MAGICLEAP_APP_FRAMEWORK_ROOT=%MLSDK%\\samples\\c_api\\app_framework\\build\\install\n```\n\nNow you're ready to build the project code for the ML2!\n\nImportant:\nIt might be needed, depending on the code you have, that you switch off **-Werror**\nYou do that by removing it from line ```101``` in file ```FindMagicLeapAppFramework.cmake```\nDon't change in the original, but in the install folder %MAGICLEAP_APP_FRAMEWORK_ROOT%\\cmake\\FindMagicLeapAppFramework.cmake\n\n```python\n# asks for -Wall/-Werror\n99  if(ML_TARGET STREQUAL ml2)\n100    target_compile_options(app_framework INTERFACE -Wall -Werror ) \u003c- Remove here\n101 else()\n\n```\n\n### Build\n\n```sh\n$ gradlew assembleDebug\n```\n\n### Install app on device\n\n```sh\n$ adb install app/build/outputs/apk/ml2/debug/com.magicleap.rbo.MyApp-debug.apk\n```\n\n### Launch app on device\n\n```sh\n$ adb shell am start -a android.intent.action.MAIN -n com.magicleap.rbo.MyApp/android.appNativeActivity\n```\n\n### Log from device\n\n```sh\n$ adb logcat -s \"MyApp\"\n```\n\n### Stop app on device\n\n```sh\n$ adb shell am force-stop com.magicleap.rbo.MyApp\n```\n\n### Remove app from device\n\n```sh\n$ adb uninstall com.magicleap.rbo.MyApp\n```\n\n\n## macOS\n\nTo build ```MyApp.app``` you have to install ```SDL2``` on your macOS machine. For this I use homebrew (package manager).\n\n```sh\n    $ brew install sdl2\n    $ git clone https://github.com/rogerboesch/multi-platform-template.git\n    $ cd multi-platform-template/playground\n```\n\nafter that create the XCode project with\n\n```sh\n    $ cmake -B build -GXCode\n```\n\nNow you have a XCode solution ```MyApp.sln``` file which you can use in the ```build``` folder.\n\n\n## Windows 10/11\n\n1. Download SDL2 from https://github.com/libsdl-org/SDL/releases/download/release-2.26.2/SDL2-devel-2.26.2-VC.zip\n2. Copy the folder SDL2-2.26.2 to a folder (ex. C:\\Dev)\n\n```sh\n    C:\\\u003e SET SDL2DIR={PATH_TO_FOLDER}\n    C:\\\u003e git clone https://github.com/rogerboesch/multi-platform-template.git\n    C:\\\u003e cd multi-platform-template\\playground\n```\n\nafter that create the Visual Studio (I use 2022) project with\n\n```sh\n    C:\\\u003e cmake -B build -G\"Visual Studio 17 2022\"\n```\n\nNow you have a Visual Studio solution file ```MyApp.sln``` which you can use in the ```build``` folder.\nTo execute ```MyApp.exe``` from within Visual Studio, ```SDL2.dll``` has to be in the same folder as the executable.\n\n\n## Linux\n\nTo build Playground you have to install SDL2 on your Linux machine.\n\n```sh\n    $ sudo apt-get install libsdl2-dev\n    $ git clone https://github.com/rogerboesch/multi-platform-template.git\n    $ cd multi-platform-template\\playground\n```\n\nafter that create the make file with\n\n```sh\n    $ cmake .\n```\n\nNow you have a ```Makefile``` which you can use in the ```build``` folder. To build it you simply type in\n\n```sh\n    $ make\n```\n\nAfter you can execute it directly \n\n```sh\n    $ ./MyApp\n```\n\n## Your App\n\nThere is already a template app file in the folder ```app\\src\\main\\cpp\\myapp```\n\nThis is the starting point where you can add your platform independent app/game logic.\n\n\n```c++\n#include \"rb_base.h\"\n#include \"rb_platform.h\"\n\nextern \"C\" {\n    void on_app_start() {                                               // 1.)\n        // Called when app starts\n\n        // platform_on_init() must be called here\n        platform_on_init(\"MyApp\", 320, 240);                            // 2.)\n    }\n    void on_app_frame() {                                               // 3.)\n        // Called every frame\n    }\n    void on_app_stop() {                                                // 4.)\n        // Called before app quits\n    }\n\n    void on_app_key_pressed(int code, int state) {                      // 5.)\n        // Handle key pressed\n    }\n\n    rgb_color app_get_palette_color(byte color, byte brightness) {      // 6.)\n        // Return palette color\n        return { 255, 0, 0 };\n    }\n}\n```\n\n1. This function gets called on app start\n2. It's essential that you callback platform_init() (see below) inside of this function\n3. This function gets called every frame (normally 60fps)\n4. This function gets called before the app quits\n5. This function gets called when a key is pressed. The values from other input devices will also be translated to \"key codes\"\n6. The entire template works with palette colors. From this function you have to deliver RGB values for the palette color given \n\nSo those are the interface functions between the template and your code.\nOn the other hand there are several platform functions you can call.\nThe most important you find below: \n\n```c++\n    void platform_on_init(const char* name, int width, int height);                     // 1.)\n    void platform_set_pixel(int x, int y, byte color, int brightness);                  // 2.)\n    void platform_draw_line(int x1, int y1, int x2, int y2, byte color, int invert);    // 3.)\n```\n\n1. Initialize MyApp by pass an app name, screen with and height\n2. Draw a pixel (used for raster graphic games/apps)\n3. Draw a line (used for vector based games/apps)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogerboesch%2Fmulti-platform-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frogerboesch%2Fmulti-platform-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogerboesch%2Fmulti-platform-template/lists"}