Просмотр исходного кода

pview: add shift+r keyboard bind to reload all textures (#1678)

John C. Allwein 1 год назад
Родитель
Сommit
e3f580763a
1 измененных файлов с 12 добавлено и 0 удалено
  1. 12 0
      panda/src/testbed/pview.cxx

+ 12 - 0
panda/src/testbed/pview.cxx

@@ -164,6 +164,17 @@ event_0(const Event *event, void *) {
   card_np.set_texture(buffer->get_texture());
 }
 
+void
+event_R(const Event *event, void *) {
+  // shift-R(eload): reload all textures
+  TextureCollection collection = TexturePool::get_global_ptr()->find_all_textures("*");
+  for (int i = 0; i < collection.size(); ++i)
+  {
+    nout << "Reloading texture " << collection[i]->get_filename() << std::endl;
+    collection[i]->reload();
+  }
+}
+
 void
 usage() {
   cerr <<
@@ -513,6 +524,7 @@ main(int argc, char **argv) {
     framework.define_key("shift-f", "flatten hierarchy", event_F, nullptr);
     framework.define_key("alt-enter", "toggle between window/fullscreen", event_Enter, nullptr);
     framework.define_key("2", "split the window", event_2, nullptr);
+    framework.define_key("shift-r", "reload textures", event_R, nullptr);
     if (pview_test_hack) {
       framework.define_key("0", "run quick hacky test", event_0, nullptr);
     }