gfx_metal.h
Level two typed access to a live metal device. Only objective c++ sees it, so a plain c++ unit that includes it stays neutral.
#include "isolenui/gfx/gfx_metal.h". The guide starts at Level 2, native handles.
Metal handles
Explained in Level 2, native handles.
gfx_metal_devicegfx_metal_framegfx_metal_device_ofgfx_metal_frame_ofgfx_metal_encodergfx_metal_targetgfx_metal_formatExample
main.mm
#include "isolenui/app/app.h"
#include "isolenui/gfx/gfx_metal.h"
// level two on macos, this file is objective c++ so gfx_metal.h declares its
// types, a plain .cpp that includes the same header sees nothing at all
static void draw(isolen_frame* f, void* user)
{
(void)user;
ui::ctx* u = f->ui;
ui_box(u, ui::col().grow().pad(24.0f))
{
ui::text(u, "metal pass draws over this", ui::body(u));
}
isolen_flush_ui(f->app);
gfx_metal_frame mf = {};
if (!gfx_metal_frame_of(&f->native, &mf)) {
return;
}
// the encoder is open on the frame target, a native pass sets its own
// pipeline and draws here, slot indexes a per frame in flight ring
id<MTLRenderCommandEncoder> enc = gfx_metal_encoder(&f->native);
const MTLPixelFormat format = gfx_metal_format(&f->native);
[enc pushDebugGroup:@"native pass"];
[enc popDebugGroup];
(void)format;
(void)mf.slot;
isolen_redraw(f->app);
}
int main(int argc, char** argv)
{
isolen_app_desc d = isolen_app_defaults();
d.title = "isolen ui, level two on metal";
d.backend = gfx_backend_metal;
d.view = draw;
return isolen_run(&d, argc, argv);
}