Panda3D
 All Classes Functions Variables Enumerations
textureProperties.h
00001 // Filename: textureProperties.h
00002 // Created by:  drose (28Nov00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef TEXTUREPROPERTIES_H
00016 #define TEXTUREPROPERTIES_H
00017 
00018 #include "pandatoolbase.h"
00019 
00020 #include "eggTexture.h"
00021 #include "typedWritable.h"
00022 
00023 class PNMFileType;
00024 class FactoryParams;
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //       Class : TextureProperties
00028 // Description : This is the set of characteristics of a texture that,
00029 //               if different from another texture, prevent the two
00030 //               textures from sharing a PaletteImage.  It includes
00031 //               properties such as mipmapping, number of channels,
00032 //               etc.
00033 ////////////////////////////////////////////////////////////////////
00034 class TextureProperties : public TypedWritable {
00035 public:
00036   TextureProperties();
00037   TextureProperties(const TextureProperties &copy);
00038   void operator = (const TextureProperties &copy);
00039 
00040   void clear_basic();
00041 
00042   bool has_num_channels() const;
00043   int get_num_channels() const;
00044   void set_num_channels(int num_channels);
00045   void force_grayscale();
00046   void force_nonalpha();
00047   bool uses_alpha() const;
00048 
00049   string get_string() const;
00050   void update_properties(const TextureProperties &other);
00051   void fully_define();
00052 
00053   void update_egg_tex(EggTexture *egg_tex) const;
00054   bool egg_properties_match(const TextureProperties &other) const;
00055 
00056   bool operator < (const TextureProperties &other) const;
00057   bool operator == (const TextureProperties &other) const;
00058   bool operator != (const TextureProperties &other) const;
00059 
00060   EggTexture::Format _format;
00061   bool _force_format;  // true when format has been explicitly specified
00062   bool _generic_format; // true if 'generic' keyword, meaning rgba8 -> rgba.
00063   bool _keep_format;   // true if 'keep-format' keyword.
00064   EggTexture::FilterType _minfilter, _magfilter;
00065   EggTexture::QualityLevel _quality_level;
00066   int _anisotropic_degree;
00067   PNMFileType *_color_type;
00068   PNMFileType *_alpha_type;
00069 
00070 private:
00071   static string get_format_string(EggTexture::Format format);
00072   static string get_filter_string(EggTexture::FilterType filter_type);
00073   static string get_anisotropic_degree_string(int aniso_degree);
00074   static string get_quality_level_string(EggTexture::QualityLevel quality_level);
00075   static string get_type_string(PNMFileType *color_type,
00076                                 PNMFileType *alpha_type);
00077 
00078   static EggTexture::Format union_format(EggTexture::Format a,
00079                                          EggTexture::Format b);
00080 
00081   static EggTexture::FilterType union_filter(EggTexture::FilterType a,
00082                                              EggTexture::FilterType b);
00083   static EggTexture::QualityLevel union_quality_level(EggTexture::QualityLevel a,
00084                                                       EggTexture::QualityLevel b);
00085 
00086   bool _got_num_channels;
00087   int _num_channels;
00088   int _effective_num_channels;
00089 
00090   // The TypedWritable interface follows.
00091 public:
00092   static void register_with_read_factory();
00093   virtual void write_datagram(BamWriter *writer, Datagram &datagram);
00094   virtual int complete_pointers(TypedWritable **p_list,
00095                                 BamReader *manager);
00096 
00097 protected:
00098   static TypedWritable *make_TextureProperties(const FactoryParams &params);
00099 
00100 public:
00101   void fillin(DatagramIterator &scan, BamReader *manager);
00102 
00103 public:
00104   static TypeHandle get_class_type() {
00105     return _type_handle;
00106   }
00107   static void init_type() {
00108     TypedWritable::init_type();
00109     register_type(_type_handle, "TextureProperties",
00110                   TypedWritable::get_class_type());
00111   }
00112   virtual TypeHandle get_type() const {
00113     return get_class_type();
00114   }
00115 
00116 private:
00117   static TypeHandle _type_handle;
00118 };
00119 
00120 #endif
00121 
 All Classes Functions Variables Enumerations