v4k/README.md

12 KiB

V·4·K

Envision, Prototype, Perfect

Features

  • Pipeline: configurable and integrated asset pipeline.
  • Embedded: single-file header, all dependencies included.
  • Compiler: MSVC, MINGW64, TCC, GCC, clang, clang-cl and emscripten.
  • Linkage: Both static linkage and dynamic .dll/.so/.dylib support.
  • Platform: Windows, Linux and OSX. Partial HTML5/Web support.
  • DS: hash, sort, array/vector, map, set.
  • Math: rand, noise, ease, vec2/3/4, mat33/34/44, quat.
  • Geometry: ray, line, plane, aabb, sphere, capsule, triangle, poly and frustum.
  • Window: windowed, soft/hard fullscreen, msaa, icon, cursor handling.
  • Input: keyboard, mouse and gamepads.
  • Script: Lua scripting, Luajit bindings.
  • Network: downloads (HTTPS) and sockets (TCP/UDP).
  • Network: Game sync module
  • AI: Swarm/Boids.
  • UI: button, list, slider, toggle, checkbox, editbox, dialog, color, image, menu, window, notify...
  • Font: TTF, OTF and TTC. Basic syntax highlighter. Glyph ranges. Atlasing.
  • Localization/I18N: XLSX and INI. Unicode.
  • Image: JPG, PNG, BMP, PSD, PIC, PNM, ICO.
  • Texture: KTX/2, PVR, DDS, ASTC, BASIS, HDR, TGA.
  • Texel: Depth, R, RG, RGB, RGBA, BC1/2/3/4/5/6/7, PVRI/II, ETC1/2, ASTC.
  • Audio: WAV/FLAC, OGG/MP1/MP3, FUR, MOD/XM/S3M/IT, SFXR and MID+SF2/SF3.
  • Video: MP4, MPG, OGV, MKV, WMV and AVI. Also, MP4 recording with MPEG-1 fallback.
  • Model: IQM/E, GLTF/2, GLB, FBX, OBJ, DAE, BLEND, MD3/5, MS3D, SMD, X, 3DS, BVH, DXF, LWO.
  • Render: PBR (metallic-roughness) workflow.
  • Render: Cubemaps, panoramas and spherical harmonics. Rayleigh/Mie scattering.
  • Render: Post-effects (SSAO,FXAA1/3,CRT,Contrast,Grain,Outline,Vignette...).
  • Render: 3D Anims, skeletal anims, hardware skinning and instanced rendering.
  • Render: 3D Debugdraw, batching and vectorial font.
  • Render: 2D Sprites, spritesheets, AA zooming and batching.
  • Render: 2D Tilemaps and tilesets: TMX, TSX.
  • Render: Compute shaders and SSBO support.
  • Render: Geometry shaders.
  • Compression: DEFLATE, LZMA, LZ4, ULZ, BALZ, BCM, CRUSH, LZW3, LZSS and PPP.
  • Virtual filesystem: ZIP, PAK, TAR and DIR.
  • Level data: JSON, JSON5, SJSON, XML, INI.
  • Disk cache.
  • Scene handling.
  • Profiler, stats and leaks finder.
  • Documentation (wip).

Hello V4K

#include "v4k.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 V4K from C!");
    }
}
local v4k = require("v4k") -- Minimal Lua sample
v4k.window_create(75.0,0) -- 75% size, no extra flags
while v4k.window_swap() and v4k.input(v4k.KEY_ESC) == 0 do -- game loop
    print("hello V4K from Lua!")
end

Quickstart

  • Double-click MAKE.bat to quick start.
  • MAKE.bat all to build everything.
  • MAKE.bat proj to generate solutions/makefiles.
  • MAKE.bat help for a bunch of options.
  • MAKE.bat hello.c to build a single executable.
  • Alternatively,
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 audiotoolbox

Cook

  • Assets need to be cooked before being consumed in your application. The tools/ folder contains all the related binaries to perform any asset processing plus the cookbook to do so.
  • Your game will cook all your assets as long as the tools/ folder is next to your executable. Alternatively, cook them all just by invoking supplied tools/cook standalone binary.
  • In both cases, assets will be cooked and packed into .zipfiles next to your executable, then mounted before entering game loop. These .zipfiles plus your executable are the only required files when releasing your game.

Extra tips

  • Any ico/png file named after the executable name will be automatically used as app icon.
  • Similar to the ico/png case above, the cooked .zipfiles can be named after the main executable as well.
  • Dropped files into game window will be imported & saved into import/ folder.
  • Update the gamepad controller database by upgrading the gamecontrollerdb.txt file.
  • Depending on your IDE, you might need to browse to engine/split/ sources when debugging FWK.
  • Cook assets on demand, as opposed to cook all existing assets on depot, by using --cook-on-demand flag.
  • Linux/OSX users can optionally install wine and use the Windows tools instead (by using --cook-wine flag).
  • Disable automatic cooking by using --cook-jobs=0 flag (not recommended).
  • Generate a project solution by dropping engine/v4k.h, v4k.c and v4k files into it.
  • Auto-generated Luajit and Python bindings can be found in the engine/bind/ folder.

Credits

Original Big big thanks to r-lyeh for the amazing FWK base!

Artwork Dean Evans, Raijin for the Map song (c), FMS_Cat for nicest VHS/VCR shader around (MIT), Goblin165cm for witch 3D model (CC BY 4.0), Nuulbee for kgirls01 3D model (CC BY-NC-ND 4.0), Quaternius for the lovely 3D robots (CC0), Rotting Pixels for castle-tileset (CC0), Tom Lewandowski for his MIDI recordings (c), Rye Terrell for nicest rayleigh/mie scattering shader around (CC0), Tools Aaron Barany for cuttlefish (APACHE2), Arseny Kapoulkine for pugixml (MIT), Assimp authors for assimp (BSD3), Bernhard Schelling for tml.h (Zlib) and tsf.h (MIT), Christian Collins for GeneralUser GS soundfont (PD), FFMPEG authors for ffmpeg (LGPL21), Imagination for pvrtextoolcli (ITL), Krzysztof Gabis for split.py/join.py (MIT), Lee Salzman for iqm.cpp (PD), Martín Lucas Golini for emscripten-fs.html (CC0), Mattias Gustavsson for mid.h (PD), Michael Schmoock for lcpp (MIT), Morgan McGuire for markdeep (BSD2), Olivier Lapicque, Konstanty Bialkowski for libmodplug (PD), Polyglot Team for polyglot gamedev (CC0), Tildearrow for Furnace (GPL2), Tomas Pettersson for sfxr (PD), Tor Andersson for assiqe.c (BSD), Runtime Andreas Mantler for their math library (PD), Barerose for swrap (CC0) and math library (CC0), Camilla Löwy for glfw3 (Zlib), Dave Rand for ppp (PD), David Herberth for glad generated code (PD), David Reid for miniaudio (PD), Dominic Szablewski for pl_mpeg (MIT), Dominik Madarász for json5 parser (PD), Eduard Suica for tlse (PD), Evan Wallace for their math library (CC0), Gargaj+cce/Peisik for Foxotron/PBR shaders (UNLICENSE), Guilherme Lampert for their math library (PD), Guillaume Vareille for tinyfiledialogs (ZLIB), Haruhiko Okumura for lzss (PD), Igor Pavlov for LZMA (PD), Ilya Muravyov for bcm, balz, crush, ulz, lz4x (PD), Jon Olick for jo_mp1 and jo_mpeg (PD), Joonas Pihlajamaa for JUnzip library (PD), Juliette Focault for the generated MD header (ZLIB), Kristoffer Grönlund for their math library (CC0), Lee Salzman for IQM spec & player (PD), Lee Salzman, V.Hrytsenko, D.Madarász for enet (MIT), Libtomcrypt for libtomcrypt (Unlicense), Lua authors for Lua language (MIT), Mattias Gustavsson for thread.h and https.h (PD), Micha Mettke for their math library (PD), Micha Mettke, Chris Willcocks, Dmitry Hrabrov for nuklear (PD), Michael Galetzka for swarmz (UNLICENSE), Morten Vassvik for mv_easy_font (Unlicense), Mārtiņš Možeiko for A* pathfinding (PD), Omar Cornut, vaiorabbit for tables of unicode ranges (MIT-0), Rabia Alhaffar for ice_batt.h (PD), Rich Geldreich for miniz (PD), Ross Williams for lzrw3a (PD), Samuli Raivio for bq_websocket (PD), Sean Barrett for stb_image, stb_image_write, stb_sprintf, stb_truetype and stb_vorbis (PD), Sebastian Steinhauer for sts_mixer (PD), Stan Melax, Cloud Wu for polychop C algorithm (PD), Stefan Gustavson for simplex noise (PD), Sterling Orsten for their math library (UNLICENSE), Tor Andersson for xml.c (PD), Wolfgang Draxinger for their math library (WTFPL2),

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.