gfx_cpu.h
Level two access to a live CPU frame, with no platform types.
#include "isolenui/gfx/gfx_cpu.h". The guide starts at The CPU backend.
CPU frames
Explained in The CPU backend.
gfx_cpu_framegfx_cpu_frame_ofgfx_cpu_flushgfx_cpu_damagegfx_cpu_bandsgfx_cpu_targetExample
meter.cpp
#include "isolenui/app/app.h"
#include "isolenui/gfx/gfx_cpu.h"
// a meter painted straight into the cpu target over the tree
static void view(isolen_frame* f, void* user)
{
const float level = *static_cast<float*>(user);
ui::ctx* u = f->ui;
ui_box(u, ui::col().grow().pad(24.0f))
{
ui::text(u, "cpu level two", ui::body(u));
}
// the tree is recorded, then rasterised so these pixels land on top
isolen_flush_ui(f->app);
gfx_cpu_frame cf;
if (!gfx_cpu_frame_of(&f->native, &cf) || !gfx_cpu_flush(&f->native)) {
return;
}
const uint32_t h = 8u;
const uint32_t y0 = cf.height - h;
const uint32_t w = uint32_t(float(cf.width) * level);
for (uint32_t y = y0; y < cf.height; ++y) {
uint32_t* row = cf.pixels + size_t(y) * cf.stride;
for (uint32_t x = 0; x < w; ++x) {
// bgra8, read as one word it is 0xaarrggbb
row[x] = 0xff38c172u;
}
}
// the rows written, so their bands are presented
gfx_cpu_damage(&f->native, y0, h);
}
int main(int argc, char** argv)
{
static float level = 0.6f;
isolen_app_desc d = isolen_app_defaults();
d.title = "meter";
d.backend = gfx_backend_cpu;
d.view = view;
d.user = &level;
return isolen_run(&d, argc, argv);
}