Browse Source

Parasite buffer inversion fix

Josh Yelon 19 years ago
parent
commit
84550f0527

+ 2 - 0
panda/src/display/parasiteBuffer.cxx

@@ -57,6 +57,8 @@ ParasiteBuffer(GraphicsOutput *host, const string &name,
   _default_display_region->compute_pixels(_x_size, _y_size);
   _default_display_region->compute_pixels(_x_size, _y_size);
   _is_valid = true;
   _is_valid = true;
   
   
+  set_inverted(host->get_gsg()->get_copy_texture_inverted());
+  
   nassertv(_x_size <= host->get_x_size() && _y_size <= host->get_y_size());
   nassertv(_x_size <= host->get_x_size() && _y_size <= host->get_y_size());
 }
 }
 
 

+ 3 - 0
panda/src/gobj/texture.I

@@ -1009,6 +1009,7 @@ INLINE void Texture::
 set_x_size(int x_size) {
 set_x_size(int x_size) {
   if (_x_size != x_size) {
   if (_x_size != x_size) {
     _x_size = x_size;
     _x_size = x_size;
+    ++_modified;
     clear_ram_image();
     clear_ram_image();
   }
   }
 }
 }
@@ -1025,6 +1026,7 @@ set_y_size(int y_size) {
   if (_y_size != y_size) {
   if (_y_size != y_size) {
     nassertv(_texture_type != Texture::TT_1d_texture || y_size == 1);
     nassertv(_texture_type != Texture::TT_1d_texture || y_size == 1);
     _y_size = y_size;
     _y_size = y_size;
+    ++_modified;
     clear_ram_image();
     clear_ram_image();
   }
   }
 }
 }
@@ -1043,6 +1045,7 @@ set_z_size(int z_size) {
              (_texture_type == Texture::TT_cube_map && z_size == 6) ||
              (_texture_type == Texture::TT_cube_map && z_size == 6) ||
              (z_size == 1));
              (z_size == 1));
     _z_size = z_size;
     _z_size = z_size;
+    ++_modified;
     clear_ram_image();
     clear_ram_image();
   }
   }
 }
 }

+ 23 - 0
panda/src/wgldisplay/wglGraphicsPipe.cxx

@@ -25,6 +25,9 @@
 typedef enum {Software, MCD, ICD} OGLDriverType;
 typedef enum {Software, MCD, ICD} OGLDriverType;
 
 
 TypeHandle wglGraphicsPipe::_type_handle;
 TypeHandle wglGraphicsPipe::_type_handle;
+bool    wglGraphicsPipe::_current_valid;
+HDC     wglGraphicsPipe::_current_hdc;
+HGLRC   wglGraphicsPipe::_current_hglrc;
   
   
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: wglGraphicsPipe::Constructor
 //     Function: wglGraphicsPipe::Constructor
@@ -33,6 +36,7 @@ TypeHandle wglGraphicsPipe::_type_handle;
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 wglGraphicsPipe::
 wglGraphicsPipe::
 wglGraphicsPipe() {
 wglGraphicsPipe() {
+  _current_valid = false;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -44,6 +48,25 @@ wglGraphicsPipe::
 ~wglGraphicsPipe() {
 ~wglGraphicsPipe() {
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: wglGraphicsPipe::wgl_make_current
+//       Access: Private, Static
+//  Description: a thin wrapper around wglMakeCurrent to avoid
+//               unnecessary switches.
+////////////////////////////////////////////////////////////////////
+void wglGraphicsPipe::
+wgl_make_current(HDC hdc, HGLRC hglrc) {
+  if ((_current_valid) &&
+      (_current_hdc == hdc) &&
+      (_current_hglrc == hglrc)) {
+    return;
+  }
+  _current_valid = true;
+  _current_hdc = hdc;
+  _current_hglrc = hglrc;
+  wglMakeCurrent(hdc, hglrc);
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: wglGraphicsPipe::get_interface_name
 //     Function: wglGraphicsPipe::get_interface_name
 //       Access: Published, Virtual
 //       Access: Published, Virtual

+ 6 - 0
panda/src/wgldisplay/wglGraphicsPipe.h

@@ -74,6 +74,12 @@ private:
                                       HDC window_dc, int pfnum);
                                       HDC window_dc, int pfnum);
   static string format_pfd_flags(DWORD pfd_flags);
   static string format_pfd_flags(DWORD pfd_flags);
 
 
+  static bool  _current_valid;
+  static HDC   _current_hdc;
+  static HGLRC _current_hglrc;
+
+  static void wgl_make_current(HDC hdc, HGLRC hglrc);
+
 public:
 public:
   static TypeHandle get_class_type() {
   static TypeHandle get_class_type() {
     return _type_handle;
     return _type_handle;