Skip to content

Commit

Permalink
textures: Free all textures on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
joel16 committed Aug 2, 2022
1 parent 11c72a3 commit c5e4ddb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
5 changes: 0 additions & 5 deletions source/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions source/textures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand All @@ -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]);
}
}

0 comments on commit c5e4ddb

Please sign in to comment.