Browse Source

rats, unintended commit

David Rose 15 years ago
parent
commit
1764ae7a7a
2 changed files with 20 additions and 43 deletions
  1. 2 16
      panda/src/testbed/Sources.pp
  2. 18 27
      panda/src/testbed/pview.cxx

+ 2 - 16
panda/src/testbed/Sources.pp

@@ -7,10 +7,10 @@
     framework putil collide pgraph chan text \
     pnmimage pnmimagetypes pnmtext event effects gobj display \
     mathutil putil express dgraph device tform \
-    linmath pstatclient panda pandaspeedtree
+    linmath pstatclient panda
 
 #begin bin_target
-  #define TARGET pview1
+  #define TARGET pview
 
   #define SOURCES \
     pview.cxx
@@ -38,17 +38,3 @@
   #define TARGET test_map
   #define SOURCES test_map.cxx
 #end test_bin_target
-
-#begin test_bin_target
-  #define USE_PACKAGES gl
-  #define LOCAL_LIBS
-  #define TARGET gm
-  #define SOURCES gm.cxx
-#end test_bin_target
-
-#begin test_bin_target
-  #define USE_PACKAGES gl
-  #define LOCAL_LIBS
-  #define TARGET om
-  #define SOURCES om.cxx
-#end test_bin_target

+ 18 - 27
panda/src/testbed/pview.cxx

@@ -22,8 +22,6 @@
 #include "partGroup.h"
 #include "cardMaker.h"
 #include "bamCache.h"
-#include "speedTreeNode.h"
-#include "randomizer.h"
 
 // By including checkPandaVersion.h, we guarantee that runtime
 // attempts to run pview will fail if it inadvertently links with the
@@ -149,34 +147,27 @@ event_0(const Event *event, void *) {
   WindowFramework *wf;
   DCAST_INTO_V(wf, param.get_ptr());
 
-  PT(SpeedTreeNode) st = new SpeedTreeNode("st");
-  Filename dirname("/c/Users/drose/Desktop/SpeedTree/SpeedTree SDK v5.1.1 Full/Bin/Forests/Huangshan");
-  vector_string basenames;
-  dirname.scan_directory(basenames);
+  // Create a new offscreen buffer.
+  GraphicsOutput *win = wf->get_graphics_output();
+  PT(GraphicsOutput) buffer = win->make_texture_buffer("tex", 256, 256);
+  cerr << buffer->get_type() << "\n";
 
-  vector_string srts;
-  for (size_t bi = 0; bi < basenames.size(); ++bi) {
-    if (Filename(basenames[bi]).get_extension() == "srt") {
-      srts.push_back(basenames[bi]);
-    }
-  }
-  nassertv(!srts.empty());
-  
-  Randomizer random;
-  for (int xi = 0; xi < 20; ++xi) {
-    for (int yi = 0; yi < 20; ++yi) {
-      int ri = random.random_int(srts.size());
-      Filename filename(dirname, srts[ri]);
-      NodePath tree1 = wf->load_model(NodePath(), filename);
-      tree1.set_pos(xi * 50, yi * 50, 0);
-      st->add_instances(tree1);
-    }
-  }
+  // Set the offscreen buffer to render the same scene as the main camera.
+  DisplayRegion *dr = buffer->make_display_region();
+  dr->set_camera(NodePath(wf->get_camera(0)));
 
-  NodePath stnp = framework.get_models().attach_new_node(st);
+  // Make the clear color on the buffer be yellow, so it's obviously
+  // different from the main scene's background color.
+  buffer->set_clear_color(Colorf(1, 1, 0, 0));
 
-  NodePath axis = wf->load_model(framework.get_models(), "zup-axis.bam");
-  wf->center_trackball(axis);
+  // Apply the offscreen buffer's texture to a card in the main
+  // window.
+  CardMaker cm("card");
+  cm.set_frame(0, 1, 0, 1);
+  NodePath card_np(cm.generate());
+  
+  card_np.reparent_to(wf->get_render_2d());
+  card_np.set_texture(buffer->get_texture());
 }
 
 void