build/api-examples/Window.cpp¶
Complete program from the Window API reference. Save it at the path shown above and use the build command in the reference page.
Source files · Download Window.cpp
#include "gaspardos.hpp"
#include <cstdio>
#include <cstring>
int main()
{
gaspardos::Window window;
GO64_WindowOptions options = {};
options.width = 1000;
options.height = 700;
std::strcpy(options.title, "Example");
if (window.create(options) < 0)
return 1;
for (unsigned i = 0; i < 10000 && !window.ready(); ++i)
{
GO64_Event event = {};
int64_t result = window.event(event);
if (result < 0 && result != -11)
return 1;
if (result == 0 && (event.type == GO64_ERROR || event.type == 15))
return 1;
GO64_yield();
}
if (!window.ready())
return 1;
GO64_Drawing drawing = {};
drawing.width = 200;
drawing.height = 100;
if (window.fill(drawing) < 0)
return 1;
return window.close() == 0 ? 0 : 1;
}