[nostalgia/core/glfw] Cleanup up main loop is running check to use GLFW
This commit is contained in:
parent
43c67eacaa
commit
2be31cca5c
@ -23,7 +23,7 @@ static void handleKeyPress(Context *ctx, int key) {
|
||||
switch (key) {
|
||||
case GLFW_KEY_ESCAPE:
|
||||
case GLFW_KEY_Q:
|
||||
id->running = false;
|
||||
glfwSetWindowShouldClose(id->window, true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -50,13 +50,7 @@ ox::Error init(Context *ctx) noexcept {
|
||||
|
||||
ox::Error run(Context *ctx) noexcept {
|
||||
const auto id = ctx->windowerData<GlfwImplData>();
|
||||
id->running = true;
|
||||
// try adaptive vsync
|
||||
//if (SDL_GL_SetSwapInterval(config::SdlVsyncOption) < 0) {
|
||||
// oxTrace("nostalgia::core::sdl", "Could not enable adaptive vsync, falling back on vsync");
|
||||
// SDL_GL_SetSwapInterval(1); // fallback on normal vsync
|
||||
//}
|
||||
while (id->running && !glfwWindowShouldClose(id->window)) {
|
||||
while (!glfwWindowShouldClose(id->window)) {
|
||||
glfwPollEvents();
|
||||
const auto ticks = ticksMs(ctx);
|
||||
if (id->wakeupTime <= ticks && id->eventHandler) {
|
||||
|
@ -15,7 +15,6 @@ namespace nostalgia::core {
|
||||
struct GlfwImplData {
|
||||
struct GLFWwindow *window = nullptr;
|
||||
int64_t startTime = 0;
|
||||
bool running = false;
|
||||
event_handler eventHandler = nullptr;
|
||||
uint64_t wakeupTime = 0;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user