Selaa lähdekoodia

more fixes to fullscreen/windowed switch

David Rose 19 vuotta sitten
vanhempi
sitoutus
d0cf3615bc

+ 28 - 0
panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx

@@ -2896,6 +2896,34 @@ do_issue_blending() {
   _d3d_device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: DXGraphicsStateGuardian8::close_gsg
+//       Access: Protected, Virtual
+//  Description: This is called by the associated GraphicsWindow when
+//               close_window() is called.  It should null out the
+//               _win pointer and possibly free any open resources
+//               associated with the GSG.
+////////////////////////////////////////////////////////////////////
+void DXGraphicsStateGuardian8::
+close_gsg() {
+  GraphicsStateGuardian::close_gsg();
+
+  // Unlike in OpenGL, in DX8 it is safe to try to explicitly release
+  // any textures here.  And it may even be a good idea.
+  if (_prepared_objects->get_ref_count() == 1) {
+    release_all_textures();
+    release_all_geoms();
+    release_all_vertex_buffers();
+    release_all_index_buffers();
+
+    // Now we need to actually delete all of the objects we just
+    // released.
+    Thread *current_thread = Thread::get_current_thread();
+    _prepared_objects->begin_frame(this, current_thread);
+    _prepared_objects->end_frame(current_thread);
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: DXGraphicsStateGuardian8::free_nondx_resources
 //       Access: Public

+ 1 - 0
panda/src/dxgsg8/dxGraphicsStateGuardian8.h

@@ -141,6 +141,7 @@ protected:
   virtual void enable_clip_plane(int plane_id, bool enable);
   virtual void bind_clip_plane(const NodePath &plane, int plane_id);
 
+  virtual void close_gsg();
   void free_nondx_resources();
   void free_d3d_device();
 

+ 28 - 0
panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx

@@ -3996,6 +3996,34 @@ bind_clip_plane(const NodePath &plane, int plane_id) {
   }
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: DXGraphicsStateGuardian9::close_gsg
+//       Access: Protected, Virtual
+//  Description: This is called by the associated GraphicsWindow when
+//               close_window() is called.  It should null out the
+//               _win pointer and possibly free any open resources
+//               associated with the GSG.
+////////////////////////////////////////////////////////////////////
+void DXGraphicsStateGuardian9::
+close_gsg() {
+  GraphicsStateGuardian::close_gsg();
+
+  // Unlike in OpenGL, in DX9 it is safe to try to explicitly release
+  // any textures here.  And it may even be a good idea.
+  if (_prepared_objects->get_ref_count() == 1) {
+    release_all_textures();
+    release_all_geoms();
+    release_all_vertex_buffers();
+    release_all_index_buffers();
+
+    // Now we need to actually delete all of the objects we just
+    // released.
+    Thread *current_thread = Thread::get_current_thread();
+    _prepared_objects->begin_frame(this, current_thread);
+    _prepared_objects->end_frame(current_thread);
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: DXGraphicsStateGuardian9::free_nondx_resources
 //       Access: Public

+ 1 - 0
panda/src/dxgsg9/dxGraphicsStateGuardian9.h

@@ -187,6 +187,7 @@ protected:
   virtual void enable_clip_plane(int plane_id, bool enable);
   virtual void bind_clip_plane(const NodePath &plane, int plane_id);
 
+  virtual void close_gsg();
   void free_nondx_resources();
   void free_d3d_device();