فهرست منبع

add get_window()

David Rose 21 سال پیش
والد
کامیت
f36cc707b1
2فایلهای تغییر یافته به همراه33 افزوده شده و 2 حذف شده
  1. 30 2
      panda/src/display/graphicsEngine.cxx
  2. 3 0
      panda/src/display/graphicsEngine.h

+ 30 - 2
panda/src/display/graphicsEngine.cxx

@@ -413,14 +413,42 @@ reset_all_windows(bool swapchain) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsEngine::is_empty
 //     Function: GraphicsEngine::is_empty
 //       Access: Published
 //       Access: Published
-//  Description: Returns true if there are no windows managed by the
-//               engine, false if there is at least one.
+//  Description: Returns true if there are no windows or buffers
+//               managed by the engine, false if there is at least
+//               one.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 bool GraphicsEngine::
 bool GraphicsEngine::
 is_empty() const {
 is_empty() const {
   return _windows.empty();
   return _windows.empty();
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsEngine::get_num_windows
+//       Access: Published
+//  Description: Returns the number of windows (or buffers) managed by
+//               the engine.
+////////////////////////////////////////////////////////////////////
+int GraphicsEngine::
+get_num_windows() const {
+  return _windows.size();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsEngine::get_window
+//       Access: Published
+//  Description: Returns the nth window or buffers managed by the
+//               engine, in sorted order.
+////////////////////////////////////////////////////////////////////
+GraphicsOutput *GraphicsEngine::
+get_window(int n) const {
+  nassertr(n >= 0 && n < (int)_windows.size(), NULL);
+
+  if (!_windows_sorted) {
+    ((GraphicsEngine *)this)->do_resort_windows();
+  }
+  return _windows[n];
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsEngine::render_frame
 //     Function: GraphicsEngine::render_frame
 //       Access: Published
 //       Access: Published

+ 3 - 0
panda/src/display/graphicsEngine.h

@@ -88,7 +88,10 @@ PUBLISHED:
   bool remove_window(GraphicsOutput *window);
   bool remove_window(GraphicsOutput *window);
   void remove_all_windows();
   void remove_all_windows();
   void reset_all_windows(bool swapchain);
   void reset_all_windows(bool swapchain);
+
   bool is_empty() const;
   bool is_empty() const;
+  int get_num_windows() const;
+  GraphicsOutput *get_window(int n) const;
 
 
   void render_frame();
   void render_frame();
   void open_windows();
   void open_windows();