mirror of
git://windcorp.ru/ProgressiaTexturePreviewer.git
synced 2025-04-21 06:30:45 +03:00
Added texture reload feature
This commit is contained in:
parent
00e110acb7
commit
4373c6aeb8
25
main.cpp
25
main.cpp
@ -71,6 +71,9 @@ public:
|
||||
return gl_id;
|
||||
}
|
||||
|
||||
const std::string& getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
void load_stb() {
|
||||
int channels;
|
||||
@ -221,6 +224,7 @@ void switch_camera();
|
||||
void switch_theme();
|
||||
void change_texture(int direction);
|
||||
void close_texture();
|
||||
void reload_texture();
|
||||
|
||||
void on_key(GLFWwindow*, int key, int, int action, int mods) {
|
||||
if (action != GLFW_PRESS) return;
|
||||
@ -242,6 +246,9 @@ void on_key(GLFWwindow*, int key, int, int action, int mods) {
|
||||
case GLFW_KEY_DELETE:
|
||||
close_texture();
|
||||
return;
|
||||
case GLFW_KEY_F5:
|
||||
reload_texture();
|
||||
return;
|
||||
case GLFW_KEY_TAB:
|
||||
switch_camera();
|
||||
return;
|
||||
@ -297,6 +304,24 @@ void close_texture() {
|
||||
selection -= 1;
|
||||
}
|
||||
|
||||
void reload_texture() {
|
||||
if (LOADED_TEXTURES.empty()) return;
|
||||
|
||||
auto it = LOADED_TEXTURES.begin() + selection;
|
||||
std::string name = (*it)->getName();
|
||||
|
||||
LOADED_TEXTURES.erase(it);
|
||||
|
||||
load_texture(name);
|
||||
|
||||
for (size_t i = 0; i < LOADED_TEXTURES.size(); ++i) {
|
||||
if (LOADED_TEXTURES[i]->getName() == name) {
|
||||
selection = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user