{"id":15138230,"url":"https://github.com/gustafla/linux_demo","last_synced_at":"2025-08-28T09:07:25.714Z","repository":{"id":185032330,"uuid":"672357978","full_name":"gustafla/linux_demo","owner":"gustafla","description":"Make self-contained demoscene productions on Linux!","archived":false,"fork":false,"pushed_at":"2024-03-09T13:00:00.000Z","size":163,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-30T18:51:58.571Z","etag":null,"topics":["c99","demoscene","glsl","makefile","rocket"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gustafla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2023-07-29T19:54:51.000Z","updated_at":"2023-09-14T17:53:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"d251005f-5b76-401f-a975-1f07d0736d55","html_url":"https://github.com/gustafla/linux_demo","commit_stats":null,"previous_names":["gustafla/linux_demo"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gustafla%2Flinux_demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gustafla%2Flinux_demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gustafla%2Flinux_demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gustafla%2Flinux_demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gustafla","download_url":"https://codeload.github.com/gustafla/linux_demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237834751,"owners_count":19373785,"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":["c99","demoscene","glsl","makefile","rocket"],"created_at":"2024-09-26T07:21:15.267Z","updated_at":"2025-02-08T16:31:18.086Z","avatar_url":"https://github.com/gustafla.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Linux demo in C\n\nWelcome. This is a C99 codebase which will let you get started with creating\nnative OpenGL demos on Linux. The repository is structured so that\n[`data/`](data/) contains binary files (assets such as music),\n[`shaders/`](shaders/) contains shaders,\n[`src/`](src/) contains source code,\n[`scripts/`](scripts/) contains scripts\nthat are required for building the demo and\n[`lib/`](lib/) contains third-party libraries (git submodules).\n\nThe result is an executable which shows some GLSL shaders with music,\nsync and post processing, and won't depend on any other files.\nWe've chosen to compile and statically link all libraries except for libc,\nso that the released production depends on least possible stuff.\n\n## First-time setup\n\nWarning! This project fails to build if it is stored in a path with spaces.\nFor example `/home/user/My Projects/linux_demo` won't work. This is due to\nfundamental limitations in SDL2's build process.\n\nFirst we need to fetch some third-party libraries:\n\n```\ngit submodule update --init\n```\n\nYou will need a C compiler (`gcc` or `clang` recommended) and some library\nheaders. This repository does not use a fancy build system, opting to use just\nGNU `make` for simplicity.\n\n### Ubuntu and Debian\n\n```\nsudo apt install build-essential xxd libsdl2-dev\n```\n\n### Arch Linux\n\n```\nsudo pacman -S base-devel vim sdl2\n```\n\n## Building\n\nJust run\n\n```\nmake -j $(nproc)\n```\n\nThis will use all CPU cores you have available.\n\n## Default workflow\n\n0. Put your `music.ogg` file into `data` directory.\n1. Edit [`src/config.h`](src/config.h) to match your desired resolution and **your music track's BPM**! Don't skip this. Then run `make` once more.\n2. Open your [rocket](https://rocket.github.io/) editor. I prefer the default Qt-based rocket editor.\n3. Start `./build/demo`\n4. Open [`shaders/shader.frag`](shaders/shader.frag) in your editor.\n5. Hack on shaders! Uniforms prefixed with `r_` will automatically show up in rocket.\n6. Reload shaders and uniforms by pressing R. No `make` or restart needed.\n\n### What if my music track is not in .ogg vorbis format?\n\nIt can be encoded with the following command:\n\n```\nffmpeg -i YOUR_MUSIC_FILE -c:a libvorbis data/music.ogg\n```\n\n## Camera control\n\nThe default [`shaders/shader.frag`](shaders/shader.frag) includes a \"look at\"\n-style camera for SDF raymarching. It's variables will show up in Rocket as\ntracks, and before you set reasonable values to them, nothing will render.\n\n![Camera controls in Rocket](doc/rocketcam.png)\n\nA good starting point is to set Fov to some value between 45 and 90,\nPos.z to 3, leave Target as all zeroes (the origin).\nAlso try and see what other rocket tracks do.\n\n## Releasing\n\nYour demo is getting ready and you want to build a release build? Just run\n\n```\nmake -j $(nproc) DEBUG=0 SELF_CONTAINED=1\n```\n\nThis builds a `release/demo` which can be copied anywhere and won't need the\nrocket editor to run.\n\n:warning: **Please note: glibc version will prevent running the demo on older distro releases** :warning:\n\nFor example: if you build a release build on an Arch Linux which has `glibc 2.37`,\nthe demo cannot run on an Ubuntu 22.04 because it ships with `glibc 2.35`!\n\nTo avoid this gotcha, you must build your release on the same (or possibly older)\ndistribution release as the intended target platform (compo machine).\nOne way to do that is to use a container system like docker or [podman](https://podman.io/) to build your release.\n\nExample run for `podman`, as your normal user:\n```\nmake clean\npodman run -it --rm -v.:/build ubuntu:20.04\napt-get update \u0026\u0026 DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential xxd libsdl2-dev\ncd /build\nmake -j $(nproc) DEBUG=0 SELF_CONTAINED=1\nmv release/demo .\nmake clean\nexit\n```\n\nInstructions for installing podman on Arch Linux can be found on the [Arch Wiki](https://wiki.archlinux.org/title/Podman).\n\n### Other build options:\n\nThe Makefile also supports release builds without the `SELF_CONTAINED` feature.\nThese builds read files from the host filesystem directories `data/` and `shaders/`.\nIf you build without `SELF_CONTAINED=1`, you will have to distribute all data and\nshader files along with the executable.\n\nOpenGL ES 3.1 build on Linux can be enabled with the make option `GLES=1`.\n\nExperimental MinGW-w64 support also exists. Install `mingw-w64-sdl2` and\n`mingw-w64-make` from the AUR on Arch Linux, and run `x86_64-w64-mingw32-make`\ninstead of `make`.\n\n**Always remember to run `make clean` before changing build options or plaforms!**\n\n### Optional: compress the executable\n\n[`scripts/`](scripts/) has a [shell-dropping](https://in4k.github.io/wiki/linux#compression)\npacker. This can reduce about 10% from filesize (ymmv).\nHowever, this may reduce compatibility as it requires `xz-utils`\nto be installed and `/tmp` directory to allow executables.\n\n```\nscripts/pack.sh release/demo\n```\n\n## Overview of libraries and code\n\nWe use the industry-standard [SDL2](https://www.libsdl.org/) library as a base for audio output,\nkeyboard (quit-button), windowing and OpenGL context creation.\n\n[OpenGL](https://docs.gl) along with your graphics card drivers does the heavy lifting for\nrendering your demo.\n\n[stb_vorbis](https://github.com/nothings/stb/blob/master/stb_vorbis.c)\nis a single C source file audio codec library for OGG Vorbis,\nwhich we use to avoid having to release a huge file with uncompressed audio.\n\nAnd finally, [rocket](https://rocket.github.io/) is a sync tracker along with a library to edit\nyour demo's synchronization with music without having to change code and recompile.\n\nThe [`src/`](src/) directory contains about 1000 lines of commented C99 code,\nwhich you can read starting from any file.\n\nHere is is a list of the source units in (subjectively) decreasing order of importance:\n- [`main.c`](src/main.c): Initializes window, OpenGL context, audio, music player, rocket. Contains demo's main loop.\n- [`demo.c`](src/demo.c)/[`demo.h`](src/demo.h): Most OpenGL calls happen in this unit.\n- [`shader.c`](src/shader.c)/[`shader.h`](src/shader.h): Loading and compiling shaders.\n- [`preprocessor.c`](src/preprocessor.c)/[`preprocessor.h`](src/preprocessor.h): A limited GLSL preprocessor.\n- [`uniforms.c`](src/uniforms.c)/[`uniforms.h`](src/uniforms.h): Contains code for querying uniforms in shader programs.\n- [`music_player.c`](src/music_player.c)/[`music_player.h`](src/music_player.h): Music player with OGG Vorbis streaming, seeking and timing support for sync editor.\n- [`filesystem.c`](src/filesystem.c)/[`filesystem.h`](src/filesystem.h): Includes `data.c` which [`scripts/mkfs.sh`](scripts/mkfs.sh) generates at build time. Has functions for reading embedded files.\n- [`rand.c`](src/rand.c)/[`rand.h`](src/rand.h): A xoshiro PRNG implementation, mostly used for post processing noise.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgustafla%2Flinux_demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgustafla%2Flinux_demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgustafla%2Flinux_demo/lists"}