Browse Source

gobj: support T_unsigned_int_24_8 in TexturePeeker

rdb 7 years ago
parent
commit
1a6d329fde
3 changed files with 23 additions and 0 deletions
  1. 18 0
      panda/src/gobj/texture.I
  2. 1 0
      panda/src/gobj/texture.h
  3. 4 0
      panda/src/gobj/texturePeeker.cxx

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

@@ -2342,6 +2342,24 @@ get_unsigned_int(const unsigned char *&p) {
   return (double)v.ui / 4294967295.0;
   return (double)v.ui / 4294967295.0;
 }
 }
 
 
+/**
+ * This is used by store() to retrieve the next consecutive component value
+ * from the indicated element of the array, which is taken to be an array of
+ * unsigned ints with the value packed in the 24 least significant bits.
+ */
+INLINE double Texture::
+get_unsigned_int_24(const unsigned char *&p) {
+  union {
+    uint32_t ui;
+    uint8_t uc[4];
+  } v;
+  v.uc[0] = (*p++);
+  v.uc[1] = (*p++);
+  v.uc[2] = (*p++);
+  v.uc[3] = (*p++);
+  return (double)(v.ui & 0xffffff) / (double)0xffffff;
+}
+
 /**
 /**
  * This is used by store() to retrieve the next consecutive component value
  * This is used by store() to retrieve the next consecutive component value
  * from the indicated element of the array, which is taken to be an array of
  * from the indicated element of the array, which is taken to be an array of

+ 1 - 0
panda/src/gobj/texture.h

@@ -858,6 +858,7 @@ private:
   INLINE static double get_unsigned_byte(const unsigned char *&p);
   INLINE static double get_unsigned_byte(const unsigned char *&p);
   INLINE static double get_unsigned_short(const unsigned char *&p);
   INLINE static double get_unsigned_short(const unsigned char *&p);
   INLINE static double get_unsigned_int(const unsigned char *&p);
   INLINE static double get_unsigned_int(const unsigned char *&p);
+  INLINE static double get_unsigned_int_24(const unsigned char *&p);
   INLINE static double get_float(const unsigned char *&p);
   INLINE static double get_float(const unsigned char *&p);
   INLINE static double get_half_float(const unsigned char *&p);
   INLINE static double get_half_float(const unsigned char *&p);
 
 

+ 4 - 0
panda/src/gobj/texturePeeker.cxx

@@ -94,6 +94,10 @@ TexturePeeker(Texture *tex, Texture::CData *cdata) {
     _get_component = Texture::get_half_float;
     _get_component = Texture::get_half_float;
     break;
     break;
 
 
+  case Texture::T_unsigned_int_24_8:
+    _get_component = Texture::get_unsigned_int_24;
+    break;
+
   default:
   default:
     // Not supported.
     // Not supported.
     _image.clear();
     _image.clear();