Browse Source

Seamless cube map sampling in OpenGL

rdb 11 years ago
parent
commit
df30721f79

+ 12 - 1
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -571,7 +571,7 @@ reset() {
     _supports_depth_stencil =
     _supports_depth_stencil =
       has_extension("GL_EXT_packed_depth_stencil") || has_extension("GL_OES_packed_depth_stencil");
       has_extension("GL_EXT_packed_depth_stencil") || has_extension("GL_OES_packed_depth_stencil");
   }
   }
-  
+ 
   _supports_3d_texture = false;
   _supports_3d_texture = false;
 
 
   if (is_at_least_gl_version(1, 2)) {
   if (is_at_least_gl_version(1, 2)) {
@@ -634,12 +634,19 @@ reset() {
   }
   }
 #endif
 #endif
 
 
+  _cube_map_seamless = false;
 #ifdef OPENGLES_2
 #ifdef OPENGLES_2
   _supports_cube_map = true;
   _supports_cube_map = true;
 #else
 #else
   _supports_cube_map =
   _supports_cube_map =
     has_extension("GL_ARB_texture_cube_map") || is_at_least_gl_version(1, 3) ||
     has_extension("GL_ARB_texture_cube_map") || is_at_least_gl_version(1, 3) ||
     has_extension("GL_OES_texture_cube_map");
     has_extension("GL_OES_texture_cube_map");
+
+  if (_supports_cube_map && gl_cube_map_seamless) {
+    if (is_at_least_gl_version(3, 2) || has_extension("GL_ARB_seamless_cube_map")) {
+      _cube_map_seamless = true;
+    }
+  }
 #endif
 #endif
 
 
   _supports_compressed_texture = false;
   _supports_compressed_texture = false;
@@ -2214,6 +2221,10 @@ begin_frame(Thread *current_thread) {
   }
   }
 #endif  // NDEBUG
 #endif  // NDEBUG
 
 
+  if (_cube_map_seamless) {
+    glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
+  }
+
   report_my_gl_errors();
   report_my_gl_errors();
   return true;
   return true;
 }
 }

+ 1 - 0
panda/src/glstuff/glGraphicsStateGuardian_src.h

@@ -579,6 +579,7 @@ public:
   PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC _glCompressedTexSubImage3D;
   PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC _glCompressedTexSubImage3D;
   PFNGLGETCOMPRESSEDTEXIMAGEPROC _glGetCompressedTexImage;
   PFNGLGETCOMPRESSEDTEXIMAGEPROC _glGetCompressedTexImage;
 
 
+  bool _cube_map_seamless;
   bool _supports_bgr;
   bool _supports_bgr;
   bool _supports_rescale_normal;
   bool _supports_rescale_normal;
 
 

+ 13 - 5
panda/src/glstuff/glmisc_src.cxx

@@ -141,11 +141,11 @@ ConfigVariableBool gl_finish
             "This variable is enabled only if PStats is compiled in."));
             "This variable is enabled only if PStats is compiled in."));
 
 
 ConfigVariableBool gl_force_depth_stencil
 ConfigVariableBool gl_force_depth_stencil
-  ("gl-force-depth-stencil", false, 
+  ("gl-force-depth-stencil", false,
    PRC_DESC("Temporary hack variable 7x00 vs 8x00 nVidia bug.  See glGraphicsStateGuardian_src.cxx."));
    PRC_DESC("Temporary hack variable 7x00 vs 8x00 nVidia bug.  See glGraphicsStateGuardian_src.cxx."));
 
 
 ConfigVariableBool gl_matrix_palette
 ConfigVariableBool gl_matrix_palette
-  ("gl-matrix-palette", false, 
+  ("gl-matrix-palette", false,
    PRC_DESC("Temporary hack variable protecting untested code.  See glGraphicsStateGuardian_src.cxx."));
    PRC_DESC("Temporary hack variable protecting untested code.  See glGraphicsStateGuardian_src.cxx."));
 
 
 ConfigVariableBool gl_force_no_error
 ConfigVariableBool gl_force_no_error
@@ -153,17 +153,26 @@ ConfigVariableBool gl_force_no_error
    PRC_DESC("Avoid reporting OpenGL errors, for a small performance benefit."));
    PRC_DESC("Avoid reporting OpenGL errors, for a small performance benefit."));
 
 
 ConfigVariableBool gl_force_no_flush
 ConfigVariableBool gl_force_no_flush
-  ("gl-force-no-flush", false, 
+  ("gl-force-no-flush", false,
    PRC_DESC("Avoid calling glFlush(), for a potential performance benefit.  This may be a little dangerous."));
    PRC_DESC("Avoid calling glFlush(), for a potential performance benefit.  This may be a little dangerous."));
 
 
 ConfigVariableBool gl_separate_specular_color
 ConfigVariableBool gl_separate_specular_color
-  ("gl-separate-specular-color", true, 
+  ("gl-separate-specular-color", true,
    PRC_DESC("When separate specular mode is on, the specular component "
    PRC_DESC("When separate specular mode is on, the specular component "
             "will be written to the secondary instead of the primary "
             "will be written to the secondary instead of the primary "
             "color, which is added after the texturing stage.  In other "
             "color, which is added after the texturing stage.  In other "
             "words, the specular highlight will be unmodulated by the "
             "words, the specular highlight will be unmodulated by the "
             "color of the texture."));
             "color of the texture."));
 
 
+ConfigVariableBool gl_cube_map_seamless
+  ("gl-cube-map-seamless", true,
+   PRC_DESC("This configures Panda to try and enable seamless cube map "
+            "sampling when supported.  This will help to remove seams "
+            "that show up at cube map edges, especially at lower "
+            "resolutions.  On by default; disable if you suspect that "
+            "this is causing problems or if you simply don't need the "
+            "functionality."));
+
 extern ConfigVariableBool gl_parallel_arrays;
 extern ConfigVariableBool gl_parallel_arrays;
 
 
 void CLP(init_classes)() {
 void CLP(init_classes)() {
@@ -189,4 +198,3 @@ void CLP(init_classes)() {
   // since we won't know those until we create a graphics context (and
   // since we won't know those until we create a graphics context (and
   // the answer may be different for different contexts).
   // the answer may be different for different contexts).
 }
 }
-

+ 1 - 0
panda/src/glstuff/glmisc_src.h

@@ -62,6 +62,7 @@ extern ConfigVariableBool gl_matrix_palette;
 extern ConfigVariableBool gl_force_no_error;
 extern ConfigVariableBool gl_force_no_error;
 extern ConfigVariableBool gl_force_no_flush;
 extern ConfigVariableBool gl_force_no_flush;
 extern ConfigVariableBool gl_separate_specular_color;
 extern ConfigVariableBool gl_separate_specular_color;
+extern ConfigVariableBool gl_cube_map_seamless;
 
 
 extern EXPCL_GL void CLP(init_classes)();
 extern EXPCL_GL void CLP(init_classes)();