tutorialsthe c abi
3. your first pixels
put a panel in the window and it draws itself
the abi has no paint function. instead you put controls in the window and each one draws itself. the plainest one is a panel, a filled rect, so that is our brush
add this between gui_host_create and gui_host_show, under the error check
// the root, the one control the window draws, a panel the colour of the background
gui_control_t* root = NULL;
gui_panel_create(0xFF202830, 0.0f, &root);
// one orange box, 40 in from the top left, 120 wide and 80 tall
gui_control_t* box = NULL;
gui_panel_create(0xFFE06040, 0.0f, &box);
gui_control_set_bounds(box, 40, 40, 120, 80);
// the box goes in the root, then the root goes in the window
gui_control_add(root, box);
gui_host_set_root(host, root);| the root | sized to the window for you, so it has no bounds of its own to set |
| bounds | x, y, w, h, from the top left of the window, x goes right and y goes down |
| the units | logical px, so a 2x screen draws it the same size, just sharper |
| the colour | 0xAARRGGBB, alpha first |
forget the
FFup front and nothing draws.0x00E06040is an alpha of 0, i.e. fully see through, and it is the easiest mistake on this page
later adds draw on top, and a child always draws over its parent, which is why the box shows over the root
you should see a dark blue window with an orange box in the top left