gfx_list.h
The backend neutral draw list. Every frame is recorded here in logical units, and a backend only copies it into its own buffers.
#include "isolenui/gfx/gfx_list.h". The guide starts at The draw list.
Rounded clips
Explained in The draw list.
gfx_maskgfx_list_maskgfx_mask_ongfx_mask_pxgfx_art::maskgfx_run::maskgfx_list::maskPolylines
Explained in The draw list.
gfx_polyline_fillGFX_CURVE_JOIN_STARTGFX_CURVE_JOIN_ENDGFX_CURVE_SPLIT_ENDGFX_CURVE_ROUND_STARTGFX_CURVE_ROUND_ENDGFX_CURVE_STYLEGFX_CURVE_ANGLE_MASKGFX_CURVE_ANGLE_STEPSGFX_CURVE_START_SHIFTGFX_CURVE_END_SHIFTGFX_CURVE_JOINT_FARgfx_curve_dirTurned glyphs
Explained in The draw list.
GFX_GLYPH_TURNEDGFX_GLYPH_TURN_STEPSgfx_glyph_turngfx_glyph_turnedgfx_glyph_anglegfx_glyph_rangegfx_glyph_boxgfx_glyph_scale_rangeRecords
Explained in The draw list.
gfx_rectgfx_glyphgfx_curvegfx_image_quadgfx_svg_paintgfx_art_kindgfx_art_imagegfx_art_svggfx_artgfx_rungfx_listgfx_quadgfx_paintGFX_CURVE_ROUND_CAPGFX_CURVE_GLOW_ONLYRecording
Explained in The draw list.
gfx_list_begingfx_list_clipgfx_list_unclipgfx_list_layergfx_list_shinegfx_fillgfx_roundgfx_outlinegfx_shadowgfx_shadow_rectgfx_gradientgfx_glassgfx_blobgfx_shapegfx_glyphsgfx_glyphs_tailgfx_glyphs_placedgfx_curvesgfx_polylinegfx_image_drawgfx_svg_drawCapacities and sinks
Explained in The draw list.
GFX_LAYERSGFX_RUN_LIMITGFX_ART_LIMITgfx_list_capsgfx_list_caps_defaultgfx_list_sinkgfx_list_initgfx_list_freegfx_list_sink_setgfx_list_flushgfx_list_emptyHandles
Explained in Assets and handles.
gfx_imagegfx_svggfx_fontGFX_NONEExample
gfx_list_recorder.cpp
#include "isolenui/gfx/gfx_list.h"
#include <math.h>
// red is the low byte and alpha the high byte, see the colors page
constexpr uint32_t abgr(uint32_t r, uint32_t g, uint32_t b, uint32_t a = 255u)
{
return r | (g << 8) | (b << 16) | (a << 24);
}
// the struct is small and the records live on the heap, init frees what the
// list held first, so the list must start zeroed
static gfx_list g_list;
// caps are where each record kind starts, past them the list flushes through a
// sink if it has one and grows otherwise
static bool open_list(void)
{
gfx_list_caps caps = gfx_list_caps_default();
caps.glyphs = 8192u;
return gfx_list_init(&g_list, &caps);
}
static void close_list(void)
{
gfx_list_free(&g_list);
}
static void record_hud(gfx_image logo, gfx_svg icon, float w, float h, float time)
{
gfx_list_begin(&g_list, w, h, time);
// layer zero first, a full bleed background
gfx_list_layer(&g_list, 0u);
gfx_fill(&g_list, 0.0f, 0.0f, w, h, abgr(0x0a, 0x0a, 0x0a));
// clip to a card, then a glass fill and an outline inside it
gfx_list_clip(&g_list, 24.0f, 24.0f, 320.0f, 120.0f);
gfx_glass(&g_list, 24.0f, 24.0f, 320.0f, 120.0f, 12.0f, 0.5f,
abgr(0x8a, 0x64, 0xe5, 0x60));
gfx_outline(&g_list, 24.0f, 24.0f, 320.0f, 120.0f, 12.0f, 1.0f,
abgr(0xff, 0xff, 0xff, 0x30));
gfx_list_unclip(&g_list);
// a glowing trace, curves are their own record kind with round caps
float xy[64];
for (uint32_t i = 0; i < 32; ++i) {
const float t = float(i) / 31.0f;
xy[i * 2 + 0] = 24.0f + t * 320.0f;
xy[i * 2 + 1] = 200.0f + 24.0f * sinf(t * 6.28f + time);
}
gfx_polyline(&g_list, xy, 32u, 1.5f, 6.0f, abgr(0x6d, 0x98, 0xcc),
GFX_CURVE_ROUND_CAP);
// layer one on top, the art assets
gfx_list_layer(&g_list, 1u);
const gfx_image_quad quad = gfx_quad(48.0f, 48.0f, 96.0f, 32.0f);
gfx_image_draw(&g_list, logo, &quad);
gfx_svg_paint paint = gfx_paint();
paint.supersample = true;
gfx_svg_draw(&g_list, icon, 300.0f, 40.0f, 24.0f, 24.0f, &paint);
}