Pārlūkot izejas kodu

gobj: add F_rg, F_rg16, F_rg32, F_rgb32 to TexturePeeker

rdb 7 gadi atpakaļ
vecāks
revīzija
5cafe8552b
2 mainītis faili ar 20 papildinājumiem un 0 dzēšanām
  1. 19 0
      panda/src/gobj/texturePeeker.cxx
  2. 1 0
      panda/src/gobj/texturePeeker.h

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

@@ -140,6 +140,12 @@ TexturePeeker(Texture *tex, Texture::CData *cdata) {
     _get_texel = get_texel_la;
     break;
 
+  case Texture::F_rg16:
+  case Texture::F_rg32:
+  case Texture::F_rg:
+    _get_texel = get_texel_rg;
+    break;
+
   case Texture::F_rgb:
   case Texture::F_rgb5:
   case Texture::F_rgb8:
@@ -148,6 +154,7 @@ TexturePeeker(Texture *tex, Texture::CData *cdata) {
   case Texture::F_rgb332:
   case Texture::F_r11_g11_b10:
   case Texture::F_rgb9_e5:
+  case Texture::F_rgb32:
     _get_texel = get_texel_rgb;
     break;
 
@@ -582,6 +589,18 @@ get_texel_la(LColor &color, const unsigned char *&p, GetComponentFunc *get_compo
   color[3] = (*get_component)(p);
 }
 
+/**
+ * Gets the color of the texel at byte p, given that the texture is in format
+ * F_rg or similar.
+ */
+void TexturePeeker::
+get_texel_rg(LColor &color, const unsigned char *&p, GetComponentFunc *get_component) {
+  color[0] = (*get_component)(p);
+  color[1] = (*get_component)(p);
+  color[2] = 0.0f;
+  color[3] = 1.0f;
+}
+
 /**
  * Gets the color of the texel at byte p, given that the texture is in format
  * F_rgb or similar.

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

@@ -77,6 +77,7 @@ private:
   static void get_texel_a(LColor &color, const unsigned char *&p, GetComponentFunc *get_component);
   static void get_texel_l(LColor &color, const unsigned char *&p, GetComponentFunc *get_component);
   static void get_texel_la(LColor &color, const unsigned char *&p, GetComponentFunc *get_component);
+  static void get_texel_rg(LColor &color, const unsigned char *&p, GetComponentFunc *get_component);
   static void get_texel_rgb(LColor &color, const unsigned char *&p, GetComponentFunc *get_component);
   static void get_texel_rgba(LColor &color, const unsigned char *&p, GetComponentFunc *get_component);
   static void get_texel_srgb(LColor &color, const unsigned char *&p, GetComponentFunc *get_component);