#define IMPORT_CORE #include #include #include #include "../Tests.h" #include "core/Window.h" static int ticks = 200; static Button closeButton = 0; static Button testButton = 0; static bool isRunning(void*) { return !shouldWindowClose() && ticks > 0 && !isButtonDown(closeButton); } static void tick(void*) { ticks -= ticks > 0; printf("TPS: %.3f\nFPS: %.3f\n", (double)getWindowTicksPerSecond(), (double)getWindowFramesPerSecond()); printf("%12s | Down: %d | DownTime: %3d | Released: %d\n", getButtonName(closeButton), isButtonDown(closeButton), getButtonDownTime(closeButton), wasButtonReleased(closeButton)); printf("%12s | Down: %d | DownTime: %3d | Released: %d\n", getButtonName(testButton), isButtonDown(testButton), getButtonDownTime(testButton), wasButtonReleased(testButton)); Vector2 mouse = getLastMousePosition(); printf("Mouse: %.2f %.2f\n", (double)mouse.data[0], (double)mouse.data[1]); } static void render(void*, float) { } void testWindow(void) { WindowOptions options = {{{800, 480}}, false, "Test"}; if(openWindow(&options)) { return; } closeButton = addButton("Close Button"); bindKeyToButton(closeButton, GLFW_KEY_Q); testButton = addButton("Test Button"); bindKeyToButton(testButton, GLFW_KEY_T); showWindow(); setWindowRunHandler(isRunning, nullptr); setWindowTickHandler(tick, nullptr); setWindowRenderHandler(render, nullptr); setWindowNanosPerTick(50000000); runWindow(); closeWindow(); }