Jelajahi Sumber

more multi-window support

David Rose 24 tahun lalu
induk
melakukan
e3d04fd248

+ 1 - 1
direct/src/gui/DirectWaitBar.py

@@ -77,7 +77,7 @@ class DirectWaitBar(DirectFrame):
     def update(self, value):
         self['value'] = value
         # finally update the window
-        base.win.update()
+        base.win.renderAndUpdate()
 
     def finish(self):
         # Fill the bar in N frames

+ 12 - 1
direct/src/showbase/ShowBase.py

@@ -75,6 +75,8 @@ class ShowBase:
         # stores a CollisionTraverser pointer here, we'll traverse it
         # in the igloop task.
         self.cTrav = 0
+        # Ditto for an AppTraverser.
+        self.appTrav = 0
 
         # base.win is the main, or only window; base.winList is a list of
         # *all* windows.  Similarly with base.pipeList and base.camList.
@@ -513,10 +515,19 @@ class ShowBase:
         # CollisionTraverser set.
         if self.cTrav:
             self.cTrav.traverse(self.render)
+        if self.appTrav:
+            self.appTrav.traverse(self.render.getTopNode())
+            
         # Finally, render the frame.
         for win in self.winList:
-            win.update()
+            win.renderAndUpdate()
+
+        # The clock needs to be ticked once per frame.
         globalClock.tick()
+
+        # Lerp stuff needs this event, and it must be generated in
+        # C++, not in Python.
+        throwNewFrame()
         return Task.cont
 
     def restart(self):

+ 8 - 37
direct/src/showbase/showBase.cxx

@@ -60,38 +60,6 @@ get_particle_path() {
 std::string chan_config = "single";
 std::string window_title = "Panda3D";
 
-void render_frame(GraphicsPipe *pipe) {
-  int num_windows = pipe->get_num_windows();
-  for (int w = 0; w < num_windows; w++) {
-    GraphicsWindow *win = pipe->get_window(w);
-    win->get_gsg()->render_frame();
-  }
-  // clock tick moved to igloop in ShowBase.py because
-  // clock must tick while app is iconified and draw
-  // callback is not being called by panda gsg
-
-  //  ClockObject::get_global_clock()->tick();
-  throw_event("NewFrame");
-}
-
-class WindowCallback : public GraphicsWindow::Callback {
-public:
-  WindowCallback(GraphicsPipe *pipe, Node *render_top) :
-    _pipe(pipe),
-    _render_top(render_top),
-    _app_traverser(RenderRelation::get_class_type()) { }
-  virtual ~WindowCallback() { }
-
-  virtual void draw(bool) {
-    _app_traverser.traverse(_render_top);
-    render_frame(_pipe);
-  }
-
-  PT(GraphicsPipe) _pipe;
-  PT(Node) _render_top;
-  AppTraverser _app_traverser;
-};
-
 
 PT(GraphicsPipe) make_graphics_pipe() {
   PT(GraphicsPipe) main_pipe;
@@ -142,14 +110,17 @@ ChanConfig make_graphics_window(GraphicsPipe *pipe, NodeRelation *render_arc) {
   main_win = chan_config.get_win();
   assert(main_win != (GraphicsWindow*)0L);
 
-  WindowCallback *wcb = new WindowCallback(pipe, render_top);
-
-  // Set draw callback.  Currently there is no reason to use the idle callback.
-  main_win->set_draw_callback(wcb);
-
   return chan_config;
 }
 
+// Throw the "NewFrame" event in the C++ world.  Some of the lerp code
+// depends on receiving this.
+void 
+throw_new_frame() {
+  throw_event("NewFrame");
+}
+
+
 // Create a scene graph, associated with the indicated window, that
 // can contain 2-d geometry and will be rendered on top of the
 // existing 3-d window.  Returns the top node of the scene graph.

+ 1 - 0
direct/src/showbase/showBase.h

@@ -47,6 +47,7 @@ EXPCL_DIRECT ChanConfig
   make_graphics_window(GraphicsPipe *pipe,
                        NodeRelation *render_arc);
 
+EXPCL_DIRECT void throw_new_frame();
 EXPCL_DIRECT NodePath setup_panda_2d(GraphicsWindow *win, const string &name);
 EXPCL_DIRECT void add_render_layer(GraphicsWindow *win, Node *render_top,
                                    Camera *camera);