00001
00002
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef _TextureManager_h
00039 #define _TextureManager_h
00040
00041 #include <string>
00042 #include <map>
00043 #include <boost/signals/trackable.hpp>
00044 #include <huginapp/ImageCache.h>
00045 #include "PT/Panorama.h"
00046
00047
00048 class ViewState;
00049
00050 class TextureManager
00051 {
00052 public:
00053 TextureManager(PT::Panorama *pano, ViewState *view);
00054 virtual ~TextureManager();
00055
00056 void DrawImage(unsigned int image_number, unsigned int display_list);
00057
00058
00059 void CheckUpdate();
00060
00061 void Begin();
00062 void End();
00063
00064 void SetPhotometricCorrect(bool state);
00065
00066 bool GetPhotometricCorrect() {return photometric_correct;}
00067
00068 unsigned int GetTextureName(unsigned int image_number);
00069
00070 void BindTexture(unsigned int image_number);
00071
00072 void DisableTexture(bool maskOnly=false);
00073
00074 protected:
00075 PT::Panorama * m_pano;
00076 ViewState *view_state;
00077 float viewer_exposure;
00078
00079 void CleanTextures();
00080 class TextureInfo
00081
00082
00083
00084 : public boost::signals::trackable
00085 {
00086 public:
00087 TextureInfo(ViewState *new_view_state);
00088
00089
00090 TextureInfo(ViewState *new_view_state, unsigned int width_p, unsigned int height_p);
00091 ~TextureInfo();
00092
00093
00094
00095
00096
00097 unsigned int width, height;
00098
00099 unsigned int width_p, height_p;
00100
00101 int min_lod;
00102
00103 void DefineLevels(int min, int max,
00104 bool photometric_correct,
00105 const HuginBase::PanoramaOptions &dest_img,
00106 const HuginBase::SrcPanoImage &state);
00107 void DefineMaskTexture(const HuginBase::SrcPanoImage &srcImg);
00108 void UpdateMask(const HuginBase::SrcPanoImage &srcImg);
00109 void SetMaxLevel(int level);
00110 void Bind();
00111 void BindImageTexture();
00112 void BindMaskTexture();
00113 unsigned int GetNumber() {return num;};
00114
00115 bool GetUseAlpha() {return has_mask;};
00116 bool GetHasActiveMasks() {return has_active_masks;};
00117 private:
00118 unsigned int num;
00119 unsigned int numMask;
00120 bool has_mask;
00121 bool has_active_masks;
00122 ViewState *m_viewState;
00124 HuginBase::ImageCache::RequestPtr m_imageRequest;
00125
00126
00127 void CreateTexture();
00128 void SetParameters();
00129 };
00130
00131
00132
00133 class TextureKey
00134 {
00135 public:
00136 TextureKey();
00137 TextureKey(HuginBase::SrcPanoImage * source, bool *photometric_correct_ptr);
00138
00139
00140 std::string filename;
00141 double exposure, white_balance_red, white_balance_blue;
00142 std::vector<float> EMoR_params;
00143 std::vector<double> radial_vig_corr_coeff;
00144 hugin_utils::FDiff2D radial_vig_corr_center_shift;
00145 int vig_corr_mode;
00146 HuginBase::SrcPanoImage::ResponseType response_type;
00147 std::vector<double> radial_distortion_red;
00148 std::vector<double> radial_distortion_blue;
00149 double gamma;
00150 std::string masks;
00151
00152
00153
00154 bool *photometric_correct;
00155
00156
00157
00158 const bool operator==(const TextureKey comp) const;
00159
00160 const bool operator<(const TextureKey comp) const;
00161 private:
00162 void SetOptions(HuginBase::SrcPanoImage *source);
00163 };
00164
00165
00166 std::map<TextureKey, TextureInfo> textures;
00167
00168 unsigned int GetMaxTotalTexels();
00169
00170 unsigned int GetMaxTextureSizePower();
00171 float texel_density;
00172 bool photometric_correct;
00173 };
00174
00175 #endif
00176