tutorialsc++
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 your
whole main.cpp for this
//
// my first window
//
#include "host/host.h"
#include "host/pump.h"
int main()
{
// what we want, anything we dont set keeps its default
gui::host_desc_t desc;
desc.title = "my window";
desc.size = { 640, 480 };
desc.kind = gui::host_kind_t::chromed;
desc.present = gui::present_kind_t::opaque;
desc.always_on_top = false;
// the window itself, create hands back false if the os said no
gui::host_t host;
if (!host.create(desc))
return 1;
// put it on screen, then sit in the loop til it closes
host.show(true);
gui::run(host);
return 0;
}kind | chromed is a normal app window you can resize, popup is a bare box with no frame |
present | how the pixels get to the screen, opaque is the plain one |
run | keeps the window alive and answering until it closes, then returns |
a chromed window has to be
opaque, the default islayeredandcreaterefuses that pair, so leave that line out andcreatereturns false
compile and run it, same command as page 1
you should see an empty dark grey window that you can resize
there are no close buttons yet, the lib leaves the title bar to you and we have not drawn one. quit with cmd+q on mac or alt+f4 on windows