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;
|
return gl_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
void load_stb() {
|
void load_stb() {
|
||||||
int channels;
|
int channels;
|
||||||
@ -221,6 +224,7 @@ void switch_camera();
|
|||||||
void switch_theme();
|
void switch_theme();
|
||||||
void change_texture(int direction);
|
void change_texture(int direction);
|
||||||
void close_texture();
|
void close_texture();
|
||||||
|
void reload_texture();
|
||||||
|
|
||||||
void on_key(GLFWwindow*, int key, int, int action, int mods) {
|
void on_key(GLFWwindow*, int key, int, int action, int mods) {
|
||||||
if (action != GLFW_PRESS) return;
|
if (action != GLFW_PRESS) return;
|
||||||
@ -242,6 +246,9 @@ void on_key(GLFWwindow*, int key, int, int action, int mods) {
|
|||||||
case GLFW_KEY_DELETE:
|
case GLFW_KEY_DELETE:
|
||||||
close_texture();
|
close_texture();
|
||||||
return;
|
return;
|
||||||
|
case GLFW_KEY_F5:
|
||||||
|
reload_texture();
|
||||||
|
return;
|
||||||
case GLFW_KEY_TAB:
|
case GLFW_KEY_TAB:
|
||||||
switch_camera();
|
switch_camera();
|
||||||
return;
|
return;
|
||||||
@ -297,6 +304,24 @@ void close_texture() {
|
|||||||
selection -= 1;
|
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