tutorialsthe c abi
2. your first window
describe a window, create it, show it, run it
three steps, describe the window you want, create it, then run it until it closes. swap the
all good line and the return 0 under it for this
// what we want, built up one setter at a time, anything we dont set keeps its default
gui_desc_t* desc = NULL;
gui_desc_create(&desc);
gui_desc_set_title(desc, "my window");
gui_desc_set_size(desc, 640, 480);
gui_desc_set_kind(desc, gui_kind_chromed);
gui_desc_set_present(desc, gui_present_opaque);
gui_desc_set_on_top(desc, 0);
// the window itself, the desc is only read here so it goes straight after
gui_host_t* host = NULL;
int32_t err = gui_host_create(desc, &host);
gui_desc_destroy(desc);
if (err != gui_ok)
{
printf("no window, %s\n", gui_err_text(err));
return 1;
}
// put it on screen, then sit in the loop til it closes
gui_host_show(host, 1);
gui_host_run(host);
// frees everything we made, the window included
gui_shutdown();
return 0;every call has the same shape, and it is worth knowing before the next page
| it returns a status | gui_ok is 0, anything else is an error and gui_err_text says which |
| values come back through a pointer | so &host and &desc, never a return value |
kind | gui_kind_chromed is a normal app window you can resize, gui_kind_popup is a bare box |
present | how the pixels get to the screen, gui_present_opaque is the plain one |
a chromed window has to be
opaque, the default islayeredandgui_host_createrefuses that pair, so leave that line out and you get an error back instead of a window
compile and run it, same commands as page 1
you should see an empty window that you can resize
there are no close buttons yet, the lib leaves the title bar to you and we have not made one. quit with alt+f4