[nostalgia/core] Add focusWindow, cleanup GLFW leak into Userland, change shutdown to stop main loop
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <nostalgia/core/config.hpp>
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/core/input.hpp>
|
||||
#include <nostalgia/core/userland/gfx.hpp>
|
||||
|
||||
#include "core.hpp"
|
||||
|
||||
@@ -19,11 +20,10 @@ namespace nostalgia::core {
|
||||
void draw(Context *ctx) noexcept;
|
||||
|
||||
static void handleKeyPress(Context *ctx, int key) {
|
||||
const auto id = ctx->windowerData<GlfwImplData>();
|
||||
switch (key) {
|
||||
case GLFW_KEY_ESCAPE:
|
||||
case GLFW_KEY_Q:
|
||||
glfwSetWindowShouldClose(id->window, true);
|
||||
shutdown(ctx);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -66,6 +66,11 @@ ox::Error run(Context *ctx) noexcept {
|
||||
draw(ctx);
|
||||
glfwSwapBuffers(id->window);
|
||||
}
|
||||
// destroy GLFW window
|
||||
oxReturnError(renderer::shutdown(ctx));
|
||||
glfwDestroyWindow(id->window);
|
||||
ctx->setWindowerData(nullptr);
|
||||
delete id;
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
@@ -85,4 +90,10 @@ bool buttonDown(Key) noexcept {
|
||||
return false;
|
||||
}
|
||||
|
||||
void shutdown(Context *ctx) noexcept {
|
||||
const auto id = ctx->windowerData<GlfwImplData>();
|
||||
glfwSetWindowShouldClose(id->window, true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user