Home

Awesome

<h1 align="center"><a href="https://bit.ly/fwk2023">F·W·K</a></h1> <p align="center"> 3D game engine/framework in C.<br/> </p> <p align="center"> <img src="https://i.imgur.com/sInbRoA.gif"/><br/> <img src="https://raw.githubusercontent.com/r-lyeh/FWK.2022/master/demos/99-cubemap.png" width="204px"/> <img src="https://raw.githubusercontent.com/r-lyeh/FWK.2022/master/demos/99-font.png" width="204px"/> <img src="https://raw.githubusercontent.com/r-lyeh/FWK.2022/master/demos/99-instanced.png" width="204px"/> <img src="https://raw.githubusercontent.com/r-lyeh/FWK.2022/master/demos/99-material.png" width="204px"/> <img src="https://raw.githubusercontent.com/r-lyeh/FWK.2022/master/demos/99-sprite.png" width="204px"/> <img src="https://raw.githubusercontent.com/r-lyeh/FWK.2022/master/demos/99-video.png" width="204px"/> <img src="https://raw.githubusercontent.com/r-lyeh/FWK.2022/master/demos/04-actor.png" width="204px"/> <img src="https://raw.githubusercontent.com/r-lyeh/FWK.2022/master/demos/00-ui.png" width="204px"/> <img src="https://raw.githubusercontent.com/r-lyeh/FWK.2022/master/demos/01-sprite.png" width="204px"/> <img src="https://raw.githubusercontent.com/r-lyeh/FWK.2022/master/demos/02-ddraw.png" width="204px"/> <!--img src="https://raw.githubusercontent.com/r-lyeh/FWK.2022/master/demos/03-anims.png" width="204px"/--> <img src="https://raw.githubusercontent.com/r-lyeh/FWK.2022/master/demos/06-pbr.png" width="204px"/> <img src="https://raw.githubusercontent.com/r-lyeh/FWK.2022/master/tools/editor/editor.png" width="204px"/> </p>

Goals

Features ᕦ(ᐛ)ᕤ

Roadmap ᕕ(ᐛ)ᕗ

<!-- ## Roadmap (2025) ᕕ(ᐛ)ᕗ - [x] Net Every struct: 1-byte field type + 4-byte size field + [contents] Every channel: When connection is established, first thing you send is a VersionNumber message. Warn: Focus on NAT punching and reconnection stability, because if your devices are mobile, they will almost 100% be behind carrier NAT, have their IP addresses change without notice, app being put to sleep, etc. - [x] Editor: - [ ] Scene: add more objv2 coverage for low-level components (MeshRenderer, AudioSource, ...) - [ ] Editor.Gizmo v2 - [ ] Editor.SubMode: Procedural content, voxels, brushes, noise and CSG. - [ ] Tools: VCS integrations. - [ ] Editor.SubMode: Timeline and data tracks. - [ ] World.BVH: PVS, occluders, frustum culling. - [ ] World: level streaming and async loading. - [ ] Editor.Network: server + sharded db + offline rendering + virtual input. - [ ] World: auto/VM replication. manual/replication channels, node sharding/clustering (p2p FS). - [x] Renderer: - [ ] FX: kawaii physics, decals, clothes, breakables. - [ ] Text: Layout and shaping, underlining, soft/hard shadows, outlines. M/SDF. Subtitles and unicode. - [x] Engine: - [ ] Network: NAT traversal. Socketless API, message API and pub/sub wrappers (enet/websocket). - [ ] Network pass: dead reckoning, interpolation, extrapolation, bandwidth budgets - [ ] Message pipeline and replication: manual/replication channels, node sharding/clustering. - [ ] Digital signals, message buffering and event polling. - [ ] Server/client architecture. Hybrid P2P. - [ ] Data quantization: half, quant, microfloat. zigzag, vle. rle, compress, crypt. - [ ] VFS: zip0 seek-vfs optimization. vfs_reload(). zip_append_file is suboptimal, and requires tons of contiguous memory for giant files. - [ ] Tools: Docs/Refl/Meta binding tool (at cook time). - [ ] Cleanup: docs, leaks and todos. - [x] Data-driven Game Engines: - [ ] Text Adventure (70) (z) - [ ] 2DY Pong (70) - [ ] 2DXY Platformer (80) (dizzy, rick dangerous) screens - [ ] 2DXY+ Platformer (80) (megaman) scroll - [ ] 2DXY Arcade (80) (snowbros, bomberman) screens - [ ] 2DXZ Racing (outrun) - [ ] 2DXYZ Isometric adventure (knight lore, diablo) - [ ] AGI/Scumm (maniac) - [ ] First person shooter (80-90) (wolf3d > doom > hl1) - [ ] First person adventure (bloodwych) - [ ] Dialogue, quests and inventory (rpg). - [ ] Input gestures and combos, hitboxes (fight engine). - [ ] Integrated cinematics QTE. ## Rationale - Fun, direct, minimalist API style - Focused on eliminating dev friction at the cost of hidding implementation details. - Consistency: same naming conventions can be found within the whole codebase. - Less is more, DOD, KISS. - Heap allocations under control. - No installation, no makefiles, fast compilation times. - Generic 3D editor, that can be decoupled from the project. - Generic asset pipeline, that can be decoupled from the project. - JSON5 workflow: still mergeable, still human-readable, still binary-convertible (via mpack). - Inspiration from: ands, bitsquid, ccxvii, jo, krig, ocornut, procedural, rjm, rlk, sgorsten, stb, vurtun. ## Roadmap ᕕ(ᐛ)ᕗ - [x] 00 Project structure, build system and makefiles. - [x] 01 Debug, callstacks, console, leaks, cvars and profiling. - [x] 02 Window, rendering contexts and game loop. - [x] 03 File formats, hashing, encryption and compression. - [x] 04 Timers, tweens, easings and interpolation. - [*] 05 Input bindings✱, digital+analog buttons✱, filters, gestures, chords✱ and combos. - [x] 06 Linear math, geometry, volumes and collisions. - [x] 07 Cameras and frustum culling. - [ ] 08 Regions, triggers, trees and spatial partioning. - [*] 09 Data pipeline✱ and asset journaling. - [ ] 10 World streaming and level loading. - [x] 11 2D/2.5D/3D/VR renderer and post-effects. - [x] 12 Fonts, atlases and text rendering. - [x] 13 Debug draw and debug UI. - [ ] 14 Procedural content, brushes, voxels, noise and CSG. - [*] 15 Static meshes✱, decals, skyboxes✱ and skydomes. - [*] 16 Sprites, sheets and spines✱. - [ ] 17 Particles, billboards✱, emitters, trails and paths. - [*] 18 Skeletal animation✱, blending✱, blendspaces, IKs. - [*] 19 LODs✱, mesh instancing✱ and scenegraphs. - [ ] 20 Server/client architecture. - [ ] 21 Message pipeline and serialization✱. - [ ] 22 Digital signals, message buffering and event polling. - [ ] 23 Object/component/systems and world replication. - [*] 24 Scripting, bindings✱ and game modules. - [*] 25 Navpoints, navmesh traversal and pathfinding✱. - [*] 26 AI, H/FSM, behavior trees and flocking✱. - [ ] 27 Game flow and game UI. - [*] 28 Localization✱, subtitles and unicode✱. - [*] 29 2D✱/3D audio, HRTF, FFT, filtering and sound occlusion. - [ ] 30 Dialogue, quests and inventory. - [*] 31 Full Motion Video✱ and integrated cinematics. - [*] 32 Editor✱, gizmos✱, properties✱, timeline✱, text✱ and data tracks. Nice to have/extend (engine dependant): - Animation pass: playlists, additive, blend/shapes, ik/bones, animgraph/controllers. // 6) anims, I (playlist: ~~forward/backwards/loop/rewind)~~, II (~~blend~~/shapes), III (ik/bone), IV (graph/controller) // ~~blend anims~~, animtracks+animevents, additive anims, // fwk_data: quantization: ~~half, quant, microfloat~~. // anim; ~~keyframes[] { frame+delay,frame+delay,... }, anim duration, anim flip,~~ // anim tracks / anim events - Audio pass: 3D audio, HRTF, FFT, filtering and sound occlusion. - Design pass: Dialogue, quests and inventory. - Design pass: Input gestures and combos. - Design pass: Integrated cinematics QTE. - Design pass: Scripting, bindings and game modules. - Design pass: Scripting: DLL (module->plugin/sys), Lua, Luajit, Teal and TypeScript. - FX pass: Particles, emitters, trails and paths. - Tools pass: Asset journaling. // expose uniforms as model_uniform(); // Pipeline: Extend asset pipeline (shaders, bindings, xml). Asset options. // cook: slang: hlsl2glsl (XShaderCompiler), hlsl2spirv (dxc), spirv2many (spirv-cross), glsl2many (sokol-shdc) // cook: tlfx22json - Render pass: Frustum culling. - Render pass: FX: particles and emitters (TLFX2), kawaii physics, clothes, breakables. - Render pass: Lighting: hard/soft shadow mapping, spotlights (VSM), omnilights (VSMCube), CSM and baked lightmaps. // lightmaps: https://blackpawn.com/texts/lightmaps/default.html // https://github.com/jpcy/xatlas // lod: https://github.com/songrun/SeamAwareDecimater // font: M/SDF https://github.com/WilliamBundy/wiggle https://github.com/Chlumsky/msdf-atlas-gen // reverse-z { // fbo attach format D16_UNORM -> D32_SFLOAT // pipeline depth compare LEQUAL -> GEQUAL // pipeline depth clear 1.0 -> 0.0 // proj matrix: float a = zfar / (zfar - znear); -> float a = -znear / (zfar - znear); // proj matrix: float b = (-znear * zfar) / (zfar - znear); -> float b = (znear * zfar) / (zfar - znear); // } Issues to fix that I keep forgetting about... render raster sprites in resolution independant way (@SushilRagoonath) window more flexibility when creating windows (@SushilRagoonath) #31 (since I dont want users to enter (w,h) resolution, maybe I should allow WINDOW_16_9, WINDOW_3_2, WINDOW_3_4, etc;) platform consider going html5 with wajic https://github.com/schellingb/wajic/issues/1 video audio buffers may exhaust. do a better mixer. video stutters shortly when fast seeking. editor gizmo crashes sometimes. editor gizmo make it better resolution independent. editor 3-gizmos 1-view. render fx_end() should flush all retained renderers (debugdraw, sprites, ...) sprite expose ortho-2d camera for sprites somehow. sprite hud sprites (resolution independent, z-index, no fx). sprite normals, lighting. profile ensure we add up different calls from matching exact section names. demo_shadertoy move logic to materials. then rename to demo_material.c pipeline showcase pipeline per-asset options? turn models 90º demo_scene two_sided option stopped working? demo_scene fuse with demo_model? demo_editor+materials instead? demo_scene bounding box should be enabled by default to showcase it. demo_pbr move all rendering logic from this demo into fwk.c, or separate module/plugin at least https 3rd_https not working in tcc_x64+win (i do think tcc_x86+win+static works, though) linux cuttlefish /lib/x86_64-linux-gnu/libm.so.6: version GLIBC_2.27 not found (required by art/tools/libcuttlefish.so.2) (reported by procedural) adaptive vsync low/inconsistent framerate on win+nvidia+fullscreen (reported by sushil) -->

Hello FWK

#include "fwk.h" // Minimal C sample
int main() {
    window_create(75.0, 0); // 75% size, no extra flags
    while( window_swap() && !input(KEY_ESC) ) { // game loop
        puts("hello FWK from C!");
    }
}
local fwk = require("fwk") -- Minimal Lua sample
fwk.window_create(75.0,0) -- 75% size, no extra flags
while fwk.window_swap() and fwk.input(fwk.KEY_ESC) == 0 do -- game loop
    print("hello FWK from Lua!")
end

Quickstart

echo win/vc       && cl hello.c
echo win/clang-cl && clang-cl hello.c
echo win/tcc      && tools\tcc hello.c -m64
echo win/mingw    && gcc   hello.c -lws2_32 -lwinmm -ldbghelp -lole32 -luser32 -lgdi32 -lcomdlg32
echo win/clang    && clang hello.c -lws2_32 -lwinmm -ldbghelp -lole32 -luser32 -lgdi32 -lcomdlg32
echo linux        && cc  hello.c -lm -ldl -lpthread -lX11
echo linux/tcc    && tcc hello.c -lm -ldl -lpthread -lX11 -D__STDC_NO_VLA__
echo osx          && cc -ObjC hello.c -framework cocoa -framework iokit -framework coreaudio -framework audiotoolbox

Cook

Extra tips

<!-- - On windows + vc, you can use `make bindings` or `make docs` to generate everything prior to a release --> <!-- - Note: Windows: Assimp.dll may need [this package installed](https://www.microsoft.com/en-us/download/confirmation.aspx?id=30679).-->

Bindings

Credits

Artwork and demos Butch, David Lam, Dean Evans, Raijin, FMS_Cat, Goblin165cm, Nuulbee, Pixel Frog, Quaternius, Rotting Pixels, Tom Lewandowski, Rye Terrell, Rxi, Tools Aaron Barany, Andreas Mantler, Arseny Kapoulkine, Assimp authors, Bernhard Schelling, FFMPEG authors, Imagination, Krzysztof Gabis, Lee Salzman, Leon Bottou, Martín Lucas Golini, Mattias Gustavsson, Morgan McGuire, Olivier Lapicque, Konstanty Bialkowski, Polyglot Team, Randy Gaul, Rxi, Adam Harrison, Sean Barrett et al., Sepehr Taghdisian, Tildearrow, Tomas Pettersson, Tor Andersson, Wael El Oraiby, Runtime Andreas Mantler, Barerose, Camilla Löwy, Dave Rand, David Herberth, David Reid, Dominic Szablewski, Dominik Madarász, Eduard Suica, Evan Wallace, Gargaj+cce/Peisik, Guilherme Lampert, Guillaume Vareille, Haruhiko Okumura, Igor Pavlov, Ilya Muravyov, James R. McKaskill, Jon Olick, Joonas Pihlajamaa, Juliette Focault, Kristoffer Grönlund, Lee Salzman, Lee Salzman, V.Hrytsenko, D.Madarász, Libtomcrypt, Lua authors, Mattias Gustavsson, Mattias Jansson, Micha Mettke, Michael Galetzka, Morten Vassvik, Mārtiņš Možeiko, Omar Cornut, vaiorabbit, Peter Schulman, Chris Willcocks, Dmitry Hrabrov, Rabia Alhaffar, Randy Gaul, Rich Geldreich, Ross Williams, Samuli Raivio, Scott Lembcke, Sean Barrett, Sebastian Steinhauer, Stan Melax, Cloud Wu, Stefan Gustavson, Sterling Orsten, Tor Andersson, Werner Stoop, Wolfgang Draxinger,

<!-- - [Christian Collins](http://www.schristiancollins.com "for GeneralUser GS soundfont (PD)"), - [ID Software, David St-Louis](https://github.com/Daivuk/PureDOOM "for PureDOOM (Doom License)"), - [Miloslav Číž](https://codeberg.org/drummyfish/Anarch "for Anarch (CC0)"), -->

Unlicense

This software is released into the public domain. Also dual-licensed as 0-BSD or MIT (No Attribution) for those countries where public domain is a concern (sigh). Any contribution to this repository is implicitly subjected to the same release conditions aforementioned.

Links

Still looking for alternatives? amulet, aroma, astera, blendelf, bullordengine, candle, cave, chickpea, corange, cute, dos-like, ejoy2d, exengine, gunslinger, hate, island, juno, l, lgf, limbus, love, lovr, mini3d, mintaro, mio, olive.c, opensource, ouzel, pez, pixie, punity, r96, ricotech, rizz, tigr, yourgamelib

<a href="https://github.com/r-lyeh/FWK/issues"><img alt="Issues" src="https://img.shields.io/github/issues-raw/r-lyeh/FWK.svg"/></a> <a href="https://discord.gg/UpB7nahEFU"><img alt="Discord" src="https://img.shields.io/discord/270565488365535232?color=5865F2&label=chat&logo=discord&logoColor=white"/></a>