From c01ca6d6c9dfa8f48378c951f232176675d47ba0 Mon Sep 17 00:00:00 2001 From: XProger Date: Tue, 8 Jan 2019 08:18:02 +0300 Subject: [PATCH] fix memory leak in UI; #15 nx clear screen right after context initialization --- src/platform/nx/main.cpp | 31 ++++++++++++++++++------------- src/ui.h | 3 +++ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/platform/nx/main.cpp b/src/platform/nx/main.cpp index b610f67..7223529 100644 --- a/src/platform/nx/main.cpp +++ b/src/platform/nx/main.cpp @@ -95,6 +95,20 @@ EGLSurface surface; EGLContext context; NWindow *window; +void configureResolution() { + if (appletGetOperationMode() == AppletOperationMode_Docked) { + Core::width = 1920; + Core::height = 1080; + } + else { + Core::width = 1280; + Core::height = 720; + } + + int offset = 1080 - Core::height; + nwindowSetCrop(window, 0, offset, Core::width, Core::height + offset); +} + bool eglInit() { display = eglGetDisplay(EGL_DEFAULT_DISPLAY); if (display == EGL_NO_DISPLAY) @@ -144,6 +158,10 @@ bool eglInit() { if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) return false; + configureResolution(); + glClear(GL_COLOR_BUFFER_BIT); + eglSwapBuffers(display, surface); + return true; } @@ -155,19 +173,6 @@ void eglFree() { eglReleaseThread(); } -void configureResolution() { - if (appletGetOperationMode() == AppletOperationMode_Docked) { - Core::width = 1920; - Core::height = 1080; - } else { - Core::width = 1280; - Core::height = 720; - } - - int offset = 1080 - Core::height; - nwindowSetCrop(window, 0, offset, Core::width, Core::height + offset); -} - // Input bool osJoyReady(int index) { return index == 0; diff --git a/src/ui.h b/src/ui.h index 2d24cfe..b5842dd 100644 --- a/src/ui.h +++ b/src/ui.h @@ -507,6 +507,9 @@ namespace UI { } void deinit() { + for (int i = 0; i < pickups.length; i++) { + delete pickups[i].animation; + } pickups.clear(); }