2
0
Эх сурвалжийг харах

fix render order of offscreen buffers

David Rose 18 жил өмнө
parent
commit
5393b55fac

+ 52 - 0
panda/src/display/graphicsOutput.I

@@ -376,6 +376,58 @@ get_sort() const {
   return _sort;
   return _sort;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsOutput::set_child_sort
+//       Access: Published
+//  Description: Specifies the sort value of future offscreen buffers
+//               created by make_texture_sort().
+//
+//               The purpose of this method is to allow the user to
+//               limit the sort value chosen for a buffer created via
+//               make_texture_buffer().  Normally, this buffer will be
+//               assigned a value of get_sort() - 1, so that it
+//               will be rendered before this window is rendered; but
+//               sometimes this isn't sufficiently early, especially
+//               if other buffers also have a view into the same
+//               scene.
+//
+//               If you specify a value here, then new buffers created
+//               via make_texture_buffer() will be given that sort
+//               value instead of get_sort() - 1.
+////////////////////////////////////////////////////////////////////
+INLINE void GraphicsOutput::
+set_child_sort(int child_sort) {
+  _child_sort = child_sort;
+  _got_child_sort = true;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsOutput::clear_child_sort
+//       Access: Published
+//  Description: Resets the sort value of future offscreen buffers
+//               created by make_texture_sort() to the default value.
+//               See set_child_sort().
+////////////////////////////////////////////////////////////////////
+INLINE void GraphicsOutput::
+clear_child_sort() {
+  _got_child_sort = false;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsOutput::get_child_sort
+//       Access: Published
+//  Description: Returns the sort value of future offscreen buffers
+//               created by make_texture_sort(). See set_child_sort().
+////////////////////////////////////////////////////////////////////
+INLINE int GraphicsOutput::
+get_child_sort() const {
+  if (_got_child_sort) {
+    return _child_sort;
+  } else {
+    return get_sort() - 1;
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsOutput::trigger_copy
 //     Function: GraphicsOutput::trigger_copy
 //       Access: Published
 //       Access: Published

+ 3 - 1
panda/src/display/graphicsOutput.cxx

@@ -102,6 +102,8 @@ GraphicsOutput(GraphicsPipe *pipe,
   _cube_map_index = -1;
   _cube_map_index = -1;
   _cube_map_dr = NULL;
   _cube_map_dr = NULL;
   _sort = 0;
   _sort = 0;
+  _child_sort = 0;
+  _got_child_sort = false;
   _internal_sort_index = 0;
   _internal_sort_index = 0;
   _active = true;
   _active = true;
   _one_shot = false;
   _one_shot = false;
@@ -733,7 +735,7 @@ make_texture_buffer(const string &name, int x_size, int y_size,
   
   
   GraphicsOutput *buffer = get_gsg()->get_engine()->
   GraphicsOutput *buffer = get_gsg()->get_engine()->
     make_output(get_gsg()->get_pipe(),
     make_output(get_gsg()->get_pipe(),
-                name, get_sort()-1,
+                name, get_child_sort(),
                 props, WindowProperties::size(x_size, y_size),
                 props, WindowProperties::size(x_size, y_size),
                 GraphicsPipe::BF_refuse_window,
                 GraphicsPipe::BF_refuse_window,
                 get_gsg(), get_host());
                 get_gsg(), get_host());

+ 6 - 0
panda/src/display/graphicsOutput.h

@@ -158,6 +158,10 @@ PUBLISHED:
   void set_sort(int sort);
   void set_sort(int sort);
   INLINE int get_sort() const;
   INLINE int get_sort() const;
 
 
+  INLINE void set_child_sort(int child_sort);
+  INLINE void clear_child_sort();
+  INLINE int get_child_sort() const;
+
   INLINE void trigger_copy();
   INLINE void trigger_copy();
   
   
   INLINE DisplayRegion *make_display_region();
   INLINE DisplayRegion *make_display_region();
@@ -279,6 +283,8 @@ private:
   void do_determine_display_regions();
   void do_determine_display_regions();
   
   
   int _sort;
   int _sort;
+  int _child_sort;
+  bool _got_child_sort;
   unsigned int _internal_sort_index;
   unsigned int _internal_sort_index;
 
 
 protected:
 protected: