textures: Free all textures on exit

This commit is contained in:
Joel16 2022-08-01 23:37:47 -04:00
parent 11c72a3625
commit c5e4ddb4ac
2 changed files with 4 additions and 9 deletions

View File

@ -11,9 +11,6 @@
namespace ImageViewer {
void ClearTextures(void) {
for (unsigned int i = 0; i < data.textures.size(); i++)
Textures::Free(data.textures[i]);
data.textures.clear();
data.frame_count = 0;
}
@ -94,14 +91,12 @@ namespace ImageViewer {
if (key & HidNpadButton_L) {
ImageViewer::ClearTextures();
svcSleepThread(10000000);
if (!ImageViewer::HandlePrev())
data.state = WINDOW_STATE_FILEBROWSER;
}
else if (key & HidNpadButton_R) {
ImageViewer::ClearTextures();
svcSleepThread(10000000);
if (!ImageViewer::HandleNext())
data.state = WINDOW_STATE_FILEBROWSER;

View File

@ -37,6 +37,7 @@
#include "imgui_impl_switch.hpp"
#include "log.hpp"
#include "textures.hpp"
#include "windows.hpp"
#define BYTES_PER_PIXEL 4
#define MAX_IMAGE_BYTES (48 * 1024 * 1024)
@ -439,10 +440,6 @@ namespace Textures {
void Free(Tex &texture) {
glDeleteTextures(1, &texture.id);
glViewport(0, 0, static_cast<int>(ImGui::GetIO().DisplaySize.x), static_cast<int>(ImGui::GetIO().DisplaySize.y));
glClearColor(0.00f, 0.00f, 0.00f, 1.00f);
glClear(GL_COLOR_BUFFER_BIT);
GUI::SwapBuffers();
}
void Exit(void) {
@ -452,5 +449,8 @@ namespace Textures {
Textures::Free(uncheck_icon);
Textures::Free(check_icon);
Textures::Free(folder_icon);
for (unsigned int i = 0; i < data.textures.size(); i++)
Textures::Free(data.textures[i]);
}
}