Browse Source

Add GSG::get_supports_texture_srgb()

rdb 11 years ago
parent
commit
5f8fffccfe

+ 10 - 0
panda/src/display/graphicsStateGuardian.I

@@ -447,6 +447,16 @@ get_supports_tex_non_pow2() const {
   return _supports_tex_non_pow2;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsStateGuardian::get_supports_texture_srgb
+//       Access: Published
+//  Description: Returns true if this GSG can handle sRGB textures.
+////////////////////////////////////////////////////////////////////
+INLINE bool GraphicsStateGuardian::
+get_supports_texture_srgb() const {
+  return _supports_texture_srgb;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsStateGuardian::get_supports_compressed_texture
 //       Access: Published

+ 1 - 0
panda/src/display/graphicsStateGuardian.cxx

@@ -195,6 +195,7 @@ GraphicsStateGuardian(CoordinateSystem internal_coordinate_system,
   _supports_2d_texture_array = false;
   _supports_cube_map = false;
   _supports_tex_non_pow2 = false;
+  _supports_texture_srgb = false;
   _supports_compressed_texture = false;
   _compressed_texture_formats.clear();
   _compressed_texture_formats.set_bit(Texture::CM_off);

+ 2 - 0
panda/src/display/graphicsStateGuardian.h

@@ -127,6 +127,7 @@ PUBLISHED:
   INLINE bool get_supports_2d_texture_array() const;
   INLINE bool get_supports_cube_map() const;
   INLINE bool get_supports_tex_non_pow2() const;
+  INLINE bool get_supports_texture_srgb() const;
 
   INLINE bool get_supports_compressed_texture() const;
   virtual INLINE bool get_supports_compressed_texture_format(int compression_mode) const;
@@ -476,6 +477,7 @@ protected:
   bool _supports_2d_texture_array;
   bool _supports_cube_map;
   bool _supports_tex_non_pow2;
+  bool _supports_texture_srgb;
 
   bool _supports_compressed_texture;
   BitMask32 _compressed_texture_formats;

+ 8 - 0
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -828,6 +828,14 @@ reset() {
   }
 #endif
 
+  _supports_texture_srgb = false;
+  if (is_at_least_gl_version(2, 1) || has_extension("GL_EXT_texture_sRGB")) {
+    _supports_texture_srgb = true;
+
+  } else if (has_extension("GL_EXT_sRGB")) { // GLES case.
+    _supports_texture_srgb = true;
+  }
+
   _supports_compressed_texture = false;
 
 #ifdef OPENGLES

+ 2 - 0
panda/src/gsgbase/graphicsStateGuardianBase.h

@@ -124,6 +124,8 @@ PUBLISHED:
   virtual int get_supported_geom_rendering() const=0;
   virtual bool get_supports_shadow_filter() const=0;
 
+  virtual bool get_supports_texture_srgb() const=0;
+
 public:
   // These are some general interface functions; they're defined here
   // mainly to make it easy to call these from code in some directory