Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
new: TTF support, S3M/IT support, revisit MOD/XM/FLAC,
Browse files Browse the repository at this point in the history
new: font_face(), font_scales(), font_color(), font atlases, font ranges, --debug-font-atlas,
new: camera_enable(), --with-camera-smooth
new: .glb models, RELEASE/OPTIMIZE/O_FLAG directives, sort_u64(),
new: VIDEO_RGB, VIDEO_NO_AUDIO, video_textures(),
new: sponza model, shaderball model for upcoming materials demo,
fix: reduce font atlas occupancy, simplify each_array(), bugfix array_unique(), each_set(), each_set_ptr(),
del: MOD/XM/FLAC decoders,
ren: sprite_update() > sprite_flush(), viewport_color() > viewport_color3(), --cook-jobs=N > --with-jobs=N
  • Loading branch information
r-lyeh committed Oct 16, 2021
1 parent 5bb919c commit dddb5cd
Show file tree
Hide file tree
Showing 81 changed files with 168,493 additions and 9,897 deletions.
28 changes: 28 additions & 0 deletions MAKE.bat
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ if [ "$(uname)" != "Darwin" ]; then
echo demo_script && cc -o demo_script demo_script.c fwk.o -lm -ldl -lpthread -w -g &
echo demo_socket && cc -o demo_socket demo_socket.c fwk.o -lm -ldl -lpthread -w -g &
echo demo_easing && cc -o demo_easing demo_easing.c fwk.o -lm -ldl -lpthread -w -g &
echo demo_font && cc -o demo_font demo_font.c fwk.o -lm -ldl -lpthread -w -g &
echo demo_material && cc -o demo_material demo_material.c fwk.o -lm -ldl -lpthread -w -g &
fi

if [ "$(uname)" = "Darwin" ]; then
Expand Down Expand Up @@ -81,6 +83,8 @@ if [ "$(uname)" = "Darwin" ]; then
echo demo_script && cc -o demo_script demo_script.c fwk.o -framework cocoa -framework iokit -w -g &
echo demo_socket && cc -o demo_socket demo_socket.c fwk.o -framework cocoa -framework iokit -w -g &
echo demo_easing && cc -o demo_easing demo_easing.c fwk.o -framework cocoa -framework iokit -w -g &
echo demo_font && cc -o demo_font demo_font.c fwk.o -framework cocoa -framework iokit -w -g &
echo demo_material && cc -o demo_material demo_material.c fwk.o -framework cocoa -framework iokit -w -g &
fi

exit
Expand Down Expand Up @@ -150,6 +154,16 @@ if "%1"=="docs" (
rem copy demos to root folder. local changes are preserved
echo n | copy /-y art\demos\*.c 1> nul 2> nul

rem check memory api calls
if "%1"=="checkmem" (
findstr /NC:"realloc(" fwk.c
findstr /NC:"malloc(" fwk.c
findstr /NC:"free(" fwk.c
findstr /NC:"calloc(" fwk.c
findstr /NC:"strdup(" fwk.c
exit /b
)

rem dll publish
if "%1"=="dll" (
rem cl fwk.c /LD /DAPI=EXPORT && rem 6.6MiB
Expand All @@ -161,6 +175,8 @@ if "%1"=="dll" (

rem tidy environment
if "%1"=="tidy" (
move /y demo_*.png art\demos
move /y demo_*.c art\demos
del .temp*.*
del *.zip
del *.mem
Expand All @@ -174,12 +190,18 @@ if "%1"=="tidy" (
del *.png
del *.def
rem del *.dll
del 3rd_*.*
del fwk_*.*
del demo_*.*
rd /q /s .vs
del tcc.bat
exit /b
)

if exist "fwk_*" (
call art\tools\join
)

if "%Platform%"=="x64" (
rem pipeline
rem cl art/tools/ass2iqe.c /Feart/tools/ass2iqe.exe /nologo /openmp /O2 /Oy /MT /DNDEBUG /DFINAL assimp.lib
Expand Down Expand Up @@ -215,6 +237,8 @@ if "%Platform%"=="x64" (
cl demo_script.c /nologo /openmp /Zi fwk.obj %*
cl demo_socket.c /nologo /openmp /Zi fwk.obj %*
cl demo_easing.c /nologo /openmp /Zi fwk.obj %*
cl demo_font.c /nologo /openmp /Zi fwk.obj %*
cl demo_material.c /nologo /openmp /Zi fwk.obj %*

) else if "%Platform%"=="mingw64" (
rem pipeline
Expand All @@ -238,6 +262,8 @@ if "%Platform%"=="x64" (
echo demo_script && gcc -o demo_script demo_script.c fwk.o -lws2_32 -lgdi32 -lwinmm -ldbghelp -std=c99 -w -g
echo demo_socket && gcc -o demo_socket demo_socket.c fwk.o -lws2_32 -lgdi32 -lwinmm -ldbghelp -std=c99 -w -g
echo demo_easing && gcc -o demo_easing demo_easing.c fwk.o -lws2_32 -lgdi32 -lwinmm -ldbghelp -std=c99 -w -g
echo demo_font && gcc -o demo_font demo_font.c fwk.o -lws2_32 -lgdi32 -lwinmm -ldbghelp -std=c99 -w -g
echo demo_material && gcc -o demo_material demo_material.c fwk.o -lws2_32 -lgdi32 -lwinmm -ldbghelp -std=c99 -w -g

) else (
rem pipeline
Expand All @@ -261,6 +287,8 @@ if "%Platform%"=="x64" (
echo demo_script && tcc demo_script.c fwk.o %*
echo demo_socket && tcc demo_socket.c fwk.o %*
echo demo_easing && tcc demo_easing.c fwk.o %*
echo demo_font && tcc demo_font.c fwk.o %*
echo demo_material && tcc demo_material.c fwk.o %*
)

rem PAUSE only if double-clicked from Windows
Expand Down
53 changes: 30 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,55 @@
- [x] ~~Royaltie fee~~. Free and unlicensed.

## Features ᕦ(ᐛ)ᕤ
- [x] Pipeline: configurable and integrated [asset pipeline](fwk.ini).
- [x] Embedded: single-file, all dependencies included.
- [x] Compiler: MSVC, MINGW64, TCC, GCC and clang.
- [x] Platform: Windows, Linux and OSX.
- [x] DS: hash, sort, array/vector, map, set.
- [x] Math: rand, noise, ease, vec2/3/4, mat33/34/44, quat.
- [x] Geometry: ray, line, plane, aabb, sphere, capsule, triangle, poly and frustum.
- [x] Window: windowed, soft/hard fullscreen, msaa, icon, cursor handling.
- [x] Input: keyboard, mouse and gamepads.
- [x] Script: Lua scripting, Luajit bindings.
- [x] Network: downloads (HTTPS) and sockets (TCP/UDP).
- [x] UI: color3/4, button, list, slider, toggle, checkbox, editbox, dialog, image, menus.
- [x] Math: rand, noise, ease, vec2/3/4, mat33/34/44, quat.
- [x] Geometry: ray, line, plane, aabb, sphere, capsule, triangle, poly and frustum.
- [x] Image: JPG, PNG, TGA, BMP, PSD, HDR, PIC and PNM. KTX/2, PVR, DDS, ASTC.
- [x] Texture: Depth, R, RG, RGB, RGBA, BC1/2/3/4/5/6/7, PVRI/II, ETC1/2, ASTC.
- [x] Audio: WAV, MOD, XM, FLAC, OGG, MP1, MP3, SFXR and MID.
- [x] Font: TTF and TTC. Basic syntax highlighter. Unicode ranges, atlasing, I18N.
- [x] Image: JPG, PNG, TGA, BMP, PSD, PIC, PNM, ICO.
- [x] Texture: KTX/2, PVR, DDS, ASTC, BASIS, HDR.
- [x] Texel: Depth, R, RG, RGB, RGBA, BC1/2/3/4/5/6/7, PVRI/II, ETC1/2, ASTC.
- [x] Audio: WAV/FLAC, OGG/MP1/MP3, MOD/XM/S3M/IT, SFXR and MID.
- [x] Video: MP4, MPG, OGV, MKV, WMV and AVI.
- [x] Model: IQM/E, GLTF/2, FBX, OBJ, DAE, BLEND, MD3/5, MS3D, SMD, X, 3DS, BVH, DXF, LWO.
- [x] Model: IQM/E, GLTF/2, GLB, FBX, OBJ, DAE, BLEND, MD3/5, MS3D, SMD, X, 3DS, BVH, DXF, LWO.
- [x] Render: 2D Sprites, spritesheets and batching.
- [x] Render: 3D Anims, skeletal anims and hardware skinning.
- [x] Render: 3D Debugdraw, batching and vectorial font.
- [x] Render: Cubemaps, panoramas and spherical harmonics. Rayleigh/Mie scattering.
- [x] Render: Post-effects (SSAO,FXAA1/3,CRT,Contrast,Grain,Outline,Vignette...).
- [x] Compression: DEFLATE, LZMA, LZ4, ULZ, BALZ, BCM, CRUSH, LZW3, LZSS and PPP.
- [x] Virtual filesystem: ZIP, PAK, TAR and DIR.
- [x] Level data: JSON, JSON5, SJSON, XML.
- [x] Disk cache.
- [x] Scene handling.
- [x] [Configurable](fwk.ini) and integrated asset pipeline.
- [x] Profiler, stats and leaks finder.
- [x] Level data: JSON, JSON5, SJSON, XML.
- [x] [Documentation (wip)](https://bit.ly/f-w-k).

## Roadmap ᕕ(ᐛ)ᕗ (in order of arrival; ✱: partial support)
- [ ] Network: NAT traversal. Socketless API, message API and pub/sub wrappers (enet/websocket).
- [ ] Render: Materials (colors✱, textures✱, matcaps✱, videos✱, shadertoys✱). Shadertoys as post-fx✱. <!--materials as postfx, as they have an update() method -->
- [ ] Render: Hard/soft shadow mapping and baked lightmaps.
- [ ] Render: Flags (billboards✱, un/lit, cast shadows on/off, skybox/mie).
- [ ] Scene: toggles on/off (billboards✱, materials, un/lit, cast shadows, wireframe, skybox/mie, collide, physics).
- [ ] Scene: node singleton display, node console, node labels, node outlines.
- [ ] Math: quat2, bezier, catmull.
- [ ] Level editor: gizmos✱, scene tree, property editor, load/save, undo/redo, copy/paste.
- [ ] Editor: gizmos✱, scene tree, property editor, load/save, undo/redo, copy/paste.
<!-- editor = tree of nodes. levels and objects are nodes, and widgets are also nodes -->
<!-- you can perform actions on nodes, with or without descendants, top-bottom or bottom-top -->
<!-- operations include load/save, reset, undo/redo, play/render vis on/off/alpha logic on/off/other ddraw on/off log on/off, etc -->
- [ ] Level objects: volumes✱, triggers, platforms, streaming.
- [ ] Script: DLL✱ (module->plugin/sys), Lua✱, Luajit✱, Teal✱ and TypeScript.
- [ ] Script: Refl/meta binding tool (during cook stage).
- [ ] Pipeline: Extend: shaders, bindings, textures. Per-platform✱, per-type✱, per-asset options.
- [ ] Pipeline: GIF, PKM.
- [ ] Pipeline: Atlassing (sprite/lightmaps). Fit packing (fonts/sprites).
- [ ] Pipeline: Extend: shaders, bindings. Per-platform✱, per-type✱, per-asset options. GIF, PKM.
- [ ] Pipeline: Extend atlas (sprite/lightmaps). Fit packing (sprites).
- [ ] Font: text layout and shaping, underlining, soft/hard shadows, outlines.
- [ ] Maybe: Tiled maps and 2D spines.
- [ ] Maybe: Animation pass.
- [ ] Maybe: AI/Logic pass.
Expand All @@ -78,7 +85,7 @@
// [x] system: debugger, callstack, exec, time/date.
// [ ] fwk_input: cursor, mouse clip, mouse wrap,
// [ ] sprites: pixel perfect zooming (demo+wheel)
// [ ] zip0 seek-vfs optimization. zip_append_file is suboptimal, optimize that and avoid allocs as much as possible.
// [ ] zip0 seek-vfs optimization. zip_append_file is suboptimal, and requires tons of contiguous memory for giant files.
// [ ] expose uniforms as ui options, also model_uniform();
-->

Expand All @@ -99,12 +106,8 @@
//[ ] Render: Materials (textures, matcaps, videos, shadertoys).
// material: fixed color, texture or script that returns color
// animated textures (shadertoys, videos)
//[ ] Pipeline: Extend configurable asset pipeline (shaders, bindings, xml, textures). Asset options.
// extending asset pipeline
// cook: img2png (spot, stbi), tex2pvr (spot, soil2)
//[ ] Pipeline: Extend asset pipeline (shaders, bindings, xml). Asset options.
// cook: hlsl2glsl (XShaderCompiler), hlsl2spirv (dxc), spirv2many (spirv-cross), glsl2many (sokol-shdc)
// cook: ogg2wav, mp32wav, mp22wav, flac2wav
// cook: xml2json, mp2json
// cook: tiled2json, spine2json, tlfx22json
// 6) anims, I (playlist: forward/backwards/loop/rewind), II (blend/shapes), III (ik/bone), IV (graph/controller)
// blend anims, animtracks+animevents, draw skeleton, additive anims,
Expand Down Expand Up @@ -201,6 +204,7 @@ Any contribution to this repository is implicitly subjected to the same release
## Gallery
<p align="center">
<img src="art/demos/demo_script.png" width="204px" title="Script.">
<img src="art/demos/demo_font.png" width="204px" title="Fonts.">
<img src="art/demos/demo_collide.png" width="204px" title="Collision.">
<img src="art/demos/demo_model.png" width="204px" title="Model.">
<img src="art/demos/demo_scene.png" width="204px" title="Scene.">
Expand All @@ -220,15 +224,17 @@ Any contribution to this repository is implicitly subjected to the same release
- [wwwtyro](https://github.com/wwwtyro/glsl-atmosphere), for nicest rayleigh/mie scattering shader around (CC0).

## Credits (Tools)
- [Aaron Barany](https://github.com/akb825/Cuttlefish), for cuttefish (APACHE2).
- [Aaron Barany](https://github.com/akb825/Cuttlefish), for cuttlefish (APACHE2).
- [Assimp authors](https://github.com/assimp/assimp), for assimp (BSD3).
- [Bernhard Schelling](https://github.com/schellingb/TinySoundFont), for tml.h (Zlib) and tsf.h (MIT).
- [ffmpeg authors](https://www.ffmpeg.org/), for ffmpeg (LGPL21).
- [Imagination](https://developer.imaginationtech.com/pvrtextool/), for pvrtextoocli (ITL).
- [Imagination](https://developer.imaginationtech.com/pvrtextool/), for pvrtextoolcli (ITL).
- [Krzysztof Gabis](https://github.com/kgabis/ape), for split.py/join.py (MIT).
- [Lee Salzman](https://github.com/lsalzman/iqm/tree/5882b8c32fa622eba3861a621bb715d693573420/demo), for iqm.cpp (PD).
- [Mattias Gustavsson](https://github.com/mattiasgustavsson/libs), for mid.h (PD).
- [Michael Schmoock](http://github.com/willsteel/lcpp), for lcpp (MIT).
- [Morgan McGuire](https://casual-effects.com/markdeep/), for markdeep (BSD2).
- [Tomas Pettersson](http://www.drpetter.se/), for sfxr (PD).
- [Tor Andersson](https://github.com/ccxvii/asstools), for assiqe.c (BSD).

## Credits (Runtime)
Expand All @@ -245,20 +251,20 @@ Any contribution to this repository is implicitly subjected to the same release
- [Ilya Muravyov](https://github.com/encode84) for bcm, balz, crush, ulz, lz4x (PD).
- [Jon Olick](https://www.jonolick.com/), for jo_mp1 and jo_mpeg (PD).
- [Joonas Pihlajamaa](https://github.com/jokkebk/JUnzip), for JUnzip library (PD).
- [Joshua Reisenauer](https://github.com/kd7tck), for jar_mod and jar_xm (PD).
- [Lee Salzman](https://github.com/lsalzman/iqm/tree/5882b8c32fa622eba3861a621bb715d693573420/demo), for IQM spec & player (PD).
- [Lee Salzman, V.Hrytsenko and D.Madarász](https://github.com/zpl-c/enet/), for enet (MIT).
- [Libtomcrypt](https://github.com/libtom/libtomcrypt), for libtomcrypt (Unlicense).
- [Lua authors](https://www.lua.org/), for Lua language (MIT).
- [Mattias Gustavsson](https://github.com/mattiasgustavsson/libs), for thread.h and https.h (PD).
- [Micha Mettke](https://github.com/vurtun/nuklear), for nuklear (PD).
- [Omar Cornut, vaiorabbit](https://github.com/ocornut/imgui/pull/3627), for tables of unicode ranges (MIT-0).
- [Rich Geldreich](https://github.com/richgel999/miniz), for miniz (PD).
- [Ross Williams](http://ross.net/compression/lzrw3a.html) for lzrw3a (PD).
- [Samuli Raivio](https://github.com/bqqbarbhg/bq_websocket), for bq_websocket (PD).
- [Sean Barrett](https://github.com/nothings), for stb_image, stb_image_write and stb_vorbis (PD).
- [Sebastian Steinhauer](https://github.com/kieselsteini), for sts_mixer (PD).
- [Stefan Gustavson](https://github.com/stegu/perlin-noise), for simplex noise (PD).
- [Tomas Pettersson](http://www.drpetter.se/), for sfxr (PD).
- [Vassvik](https://github.com/vassvik/mv_easy_font), for mv_easy_font (Unlicense).
- Special thanks to [@ands](https://github.com/ands) (PD), [@barerose](https://github.com/barerose) (CC0), [@datenwolf](https://github.com/datenwolf) (WTFPL2), [@evanw](https://github.com/evanw) (CC0), [@glampert](https://github.com/glampert) (PD), [@krig](https://github.com/krig) (CC0), [@sgorsten](https://github.com/sgorsten) (Unlicense) and [@vurtun](https://github.com/vurtun) (PD) for their math libraries.

## Links
Expand All @@ -276,6 +282,7 @@ Still looking for alternatives?
[chickpea](https://github.com/ivansafrin/chickpea),
[corange](https://github.com/orangeduck/Corange),
[cute](https://github.com/RandyGaul/cute_framework),
[dos-like](https://github.com/mattiasgustavsson/dos-like),
[ejoy2d](https://github.com/ejoy/ejoy2d),
[exengine](https://github.com/exezin/exengine),
[gunslinger](https://github.com/MrFrenik/gunslinger),
Expand Down
2 changes: 1 addition & 1 deletion art/demos/demo_collide.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int main(void) {
mat44 projview; multiply44x2(projview, cam.proj, cam.view);

// rendering
viewport_color(vec3(0.15,0.15,0.15));
viewport_color3(vec3(0.15,0.15,0.15));
viewport_clear(true, true);
viewport_clip(vec2(0,0), vec2(window_width(), window_height()));

Expand Down
110 changes: 110 additions & 0 deletions art/demos/demo_font.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#include "fwk.h"

int main() {
window_create(0.75, WINDOW_MSAA8);

// style: our aliases
#define FONT_REGULAR FONT_FACE1
#define FONT_ITALIC FONT_FACE2
#define FONT_BOLD FONT_FACE3
#define FONT_JAPANESE FONT_FACE4
#define FONT_MONOSPACE FONT_FACE5

#define FONT_GRAY FONT_COLOR2
#define FONT_ORANGE FONT_COLOR3
#define FONT_LIME FONT_COLOR4
#define FONT_GREEN FONT_COLOR5
#define FONT_CYAN FONT_COLOR6

#define FONT_LARGEST FONT_H1
#define FONT_LARGE FONT_H2
#define FONT_MEDIUM FONT_H3
#define FONT_NORMAL FONT_H4
#define FONT_SMALL FONT_H5
#define FONT_TINY FONT_H6

// style: atlas size, unicode ranges and font faces (up to 6 faces)
font_face(FONT_REGULAR, "Carlito-Regular.ttf", 48.f, FONT_EU|FONT_AR|FONT_RU|FONT_2048);
font_face(FONT_ITALIC, "Carlito-Italic.ttf", 48.f, FONT_EU|FONT_AR|FONT_RU|FONT_2048);
font_face(FONT_BOLD, "Carlito-Bold.ttf", 48.f, FONT_EU|FONT_AR|FONT_RU|FONT_2048);
font_face(FONT_JAPANESE, "mplus-1p-medium.ttf", 48.f, FONT_JP|FONT_2048); // CJK|FONT_2048|FONT_OVERSAMPLE_Y);
font_face(FONT_MONOSPACE, "Inconsolata-Regular.ttf", 24.f, FONT_EU|FONT_512);

// style: colors (up to 10 colors)
font_color(FONT_GRAY, RGB4(100,100,100,255));
font_color(FONT_ORANGE, RGB4(255,192,0,255));
font_color(FONT_LIME, RGB4(192,255,0,255));
font_color(FONT_GREEN, RGB4(0,255,192,255));
font_color(FONT_CYAN, RGB4(0,192,255,255));

// prepare color highlighting for following code snippet
const char *source =
FONT_MONOSPACE FONT_LARGEST
"int main(int argc, char **argv) {\n"
" for( int i = 0; i < 10; ++i)\n"
" puts(\"hello world\");\n"
" return 0;\n"
"}\n";
const void *colors = font_colorize(source, "void,int,char", "if,else,for,do,while,return,switch,case,break,default,");

// demo loop
while( window_swap() && !input(KEY_ESC) ) {
ddraw_grid(0);

// initial spacing
font_goto(0, 50);

// print a code snippet with syntax highlighting
font_highlight(source, colors);

// print a few strings with markup codes
font_print(
FONT_REGULAR
FONT_LARGEST FONT_GRAY "The quick "
FONT_LARGE FONT_LIME "brown "
FONT_MEDIUM FONT_GRAY "fox "
FONT_NORMAL "jumps over "
FONT_SMALL "the lazy "
FONT_TINY "dog.\n");

font_print(
FONT_REGULAR FONT_LARGE FONT_CYAN
"Now is the time for all " FONT_ITALIC "good men " FONT_REGULAR "to come to the aid of " FONT_BOLD "the party.\n");

font_print(
FONT_ITALIC FONT_LARGE FONT_GREEN
"Ég get etið gler án þess að meiða mig!\n");

font_print(
FONT_BOLD FONT_LARGE FONT_ORANGE
"Эх, чужак! Общий съём цен шляп (юфть)—вдрызг!.\n");

font_print(
FONT_JAPANESE
"私はガラスを食べられます。それは私を傷つけません。\n");

font_print( "This text ");
font_print( "should be concatenated, ");
font_print( "as there are no linefeeds.\n" );

// i18n: pangrams.txt file, line browser
static int counter;
static array(char*) lines; do_once lines = strsplit( vfs_read("pangrams.txt"), "\r\n" );
counter += (counter += input_down(KEY_RIGHT)-input_down(KEY_LEFT)) < 0 ? array_count(lines) : 0;
font_print( stringf("<< %s >>\n", lines[counter % array_count(lines)]) );

// this does not work yet. you cant chain alignments yet...
//font_print(FONT_TOP "Top" FONT_MIDDLE "Middle" FONT_BASELINE "Baseline" FONT_BOTTOM "Bottom\n");
//font_print(FONT_LEFT "Left" FONT_CENTER "Center" FONT_RIGHT "Right\n");

// ... alignment must be the first tag in a string for now. this is a temporary hack.
font_print(FONT_LEFT "left");
font_print(FONT_CENTER "center");
font_print(FONT_RIGHT "right");

font_print(FONT_TOP FONT_CENTER "top\n");
font_print(FONT_MIDDLE FONT_RIGHT "middle\n");
font_print(FONT_BASELINE FONT_RIGHT "baseline\n");
font_print(FONT_BOTTOM FONT_CENTER "bottom\n");
}
}
Binary file added art/demos/demo_font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit dddb5cd

Please sign in to comment.