diff --git a/panda/src/gobj/texture.I b/panda/src/gobj/texture.I index c766c5b82d..4abb480348 100644 --- a/panda/src/gobj/texture.I +++ b/panda/src/gobj/texture.I @@ -2342,6 +2342,24 @@ get_unsigned_int(const unsigned char *&p) { 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 * from the indicated element of the array, which is taken to be an array of diff --git a/panda/src/gobj/texture.h b/panda/src/gobj/texture.h index 852f618c81..7cb5f305fb 100644 --- a/panda/src/gobj/texture.h +++ b/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_short(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_half_float(const unsigned char *&p); diff --git a/panda/src/gobj/texturePeeker.cxx b/panda/src/gobj/texturePeeker.cxx index ef007d91dd..7bb17ab87a 100644 --- a/panda/src/gobj/texturePeeker.cxx +++ b/panda/src/gobj/texturePeeker.cxx @@ -94,6 +94,10 @@ TexturePeeker(Texture *tex, Texture::CData *cdata) { _get_component = Texture::get_half_float; break; + case Texture::T_unsigned_int_24_8: + _get_component = Texture::get_unsigned_int_24; + break; + default: // Not supported. _image.clear();