{"id":20332466,"url":"https://github.com/permutationlock/avengl_triangle","last_synced_at":"2025-03-04T12:42:32.973Z","repository":{"id":256299515,"uuid":"854859995","full_name":"permutationlock/avengl_triangle","owner":"permutationlock","description":"A simple OpenGL ES2 triangle cross compilable using libaven","archived":false,"fork":false,"pushed_at":"2024-11-02T23:17:16.000Z","size":1095,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-14T15:41:53.257Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/permutationlock.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":"2024-09-09T22:30:12.000Z","updated_at":"2024-11-02T23:17:20.000Z","dependencies_parsed_at":"2024-09-10T03:49:17.571Z","dependency_job_id":"0d149130-baa6-4fa2-acb3-bf2ba747fb14","html_url":"https://github.com/permutationlock/avengl_triangle","commit_stats":null,"previous_names":["permutationlock/avengl_triangle"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permutationlock%2Favengl_triangle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permutationlock%2Favengl_triangle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permutationlock%2Favengl_triangle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permutationlock%2Favengl_triangle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/permutationlock","download_url":"https://codeload.github.com/permutationlock/avengl_triangle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241851777,"owners_count":20030965,"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":[],"created_at":"2024-11-14T20:26:43.563Z","updated_at":"2025-03-04T12:42:32.923Z","avatar_url":"https://github.com/permutationlock.png","language":"C","readme":"# Aven GL Triangle\n\nThe repo contains a self-contained OpenGL ES2 application that can be built on\nmost systems with most C compilers[^1]. It primarily serves\nas an example of the [libaven][1] C build system.\n\n## Dependencies\n\nThere are no library or header build dependencies apart from a C compiler that\nsupports at least the C99 or C11 standards for POSIX or Windows.\n\nIn most cases dynamic linking/loading must be supported. The locally built\nand statically linked GLFW library will dynamically load the system shared\nobjects for OpenGL graphics and window managment. Thus, e.g. a static linking\nonly [musl][2] toolchain like `zig cc` with `-target x86_64-linux-musl` won't\nwork.\n\nIf you are targeting a special system that has its own GLFW implementation,\ne.g. the emulated POSIX environment of [Emscripten][3],\noptions are avaliable to omit locally building and linking GLFW and to link any\ndesired system libraries.\n\n## Building\n\nIf you are on a Linux machine with the `CC` environment variable set to either\n`gcc` or `clang`, then the build system can be compiled using\nthe provided tiny two command `Makefile`.\n\n```\nmake\n./build\n```\n\nThe build executable can also be built directly using practically any C\ncompiler, but some flags and/or macros will require tweaking for compilers\nother than `gcc` or `clang`.\n\n```\ngcc -o build build.c\n./build\n```\n\nThe TinyCC compiler needs either `-std=c11` flag or a definition of the\n`__BIGGEST_ALIGNMENT__` macro to the appropratiate\nvalue for the given system, e.g. 16 for `x86_64` Linux.\n\n```\ntcc -std=c11 -o build build.c\n./build\n```\n\nThe `cproc` compiler uses the system C preprocessor and is therefore not\nidentifiable from preprocessor macros. Thus we must manually inform the build\nsystem to use `cproc` for further compilation and linking.\n\n```\ncproc -DAVEN_BUILD_COMMON_DEFAULT_CC=\\\"cproc\\\" -o build build.c\n./build\n```\n\nOn a Windows machine there are several one line `.bat` files provided as\nexamples, but just as on Linux you should be able to simply compile the\n`build.c` file with e.g. `cl.exe`.\n\n```\ncl.exe /std:c11 /Fe:build.exe build.c\n.\\build.exe\n```\n\nMinGW and `clang` (MSVC and GNU) should also work out-of-the-box on Windows.\n\n```\ngcc.exe -o build.exe build.c\n.\\build.exe\n```\n\nA more involved example would be using the `zig` toolchain. The Zig C compiler\nis simply a wrapper around `clang` and thus is not identifiable\nvia the preprocessor. Arguments must be provided to indicate how\nthe Zig tools should run, e.g. `zig cc` for C compilation and linking and\n`zig rc` for Windows resource compilation. See `zig_make.bat` for an example\ncommand that should work on both Windows and Linux.\n\n## Source watching and hot reloading\n\nIf you have built the build system via any of the above methods, add a `watch`\nargument to run the `build` executable in hot reload mode.\n\n```\n./build watch\n```\n\nThe project will build and run while the build system watches for changes to\nsource files.\nIf a file in the root of `src/` is modified the application will close,\nrebuild, and run. However, if changes are made to files in\n`src/game/`, they will hot reload into the running executable.\n\n## Cross-compiling\n\nBuild defaults are set using the preprocessor macros defined by the C compiler\nthat is used to compile the build system. As seen above, these defaults can be\nmanually overridden by defining macros, or the corresponding flags can be set at\nruntime.\n\nTo see a full list of available command line options you can run the build\nexecutable witht the `help` argument.\n\n```\n./build help\n```\n\nHere is an example using command line arguments to do a release build\nof an `x86_64` Windows executable on a Linux mchine using MinGW-w64.\n\n```\ngcc -o build build.c\n./build -cc \"x86_64-w64-mingw32-gcc\" -ar \"x86_64-w64-mingw32-ar\" \\\n    -windres \"x86_64-w64-mingw32-windres\" -ccflags \"-DNDEBUG -O3\" \\\n    -glfw-ccflags \"-DNDEBUG -O3\" -stb-ccflags \"-DNDEBUG -O3\" -winutf8 1 \\\n    -exext \".exe\" -soext \".dll\" -obext \".o\" -wrext \".o\" \\\n    -syslibs \"kernel32 user32 shell32 gdi32\" -ldwinflag \"-mwindows\"\n```\n\n## Building for web\n\nWith the `emcc` compiler we can use the build system to make a web page to host\nour application. Emscripten provides its own emulated GLFW so we don't need to\nbuild our own.\n\n```\n./build -cc emcc -ccflags \"-DNDEBUG -O3\" -stb-ccflags \"-DNDEBUG -O3\" -no-glfw \\\n    -exext \".html .js .wasm\" -syslibs \"\" -ldflags \"-s ASYNCIFY -s USE_GLFW=3\"\n```\n\nHost the provided web page using your favorite web server, e.g. the provided\n`server.go`, open it in a browser, and voila! A graphical app in the web.\n\n```\ngo run server.go \u0026\nfirefox 127.0.0.1:8081/avengl_triangle.html\n```\n\n## Cleaning up\n\nRun the build executable with the `clean` argument to remove all build\nartifacts.\n\n```\n./build clean\n```\n\nNote that if you passed special command line arguments to the build command, you\nwill need to pass those same arguments to the clean command. The clean command\nonly attempts to remove files and directories that it is able to create.\n\n[^1]: No Apple support, and I have only tested on `x86_64` Linux and Windows.\n    Setting up a cross-compilation toolchain for\n    MacOS that supports the various graphical frameworks seems like a pain and\n    I have no Apple device to test with. The way that GLFW implements Mac\n    windowing support also looks suspect to me.\n\n[1]: https://github.com/permutationlock/libaven\n[2]: https://musl.libc.org/\n[3]: https://emscripten.org/\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpermutationlock%2Favengl_triangle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpermutationlock%2Favengl_triangle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpermutationlock%2Favengl_triangle/lists"}