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] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.
  3 
  4 #ifndef tools_sg_zb_manager
  5 #define tools_sg_zb_manager
  6 
  7 #include "render_manager"
  8 
  9 #ifdef TOOLS_MEM
 10 #include "../mem"
 11 #endif
 12 
 13 #include <map>
 14 
 15 namespace tools {
 16 namespace sg {
 17 
 18 class zb_manager : public virtual render_manager {
 19   typedef render_manager parent;
 20 public:
 21   TOOLS_SCLASS(tools::sg::zb_manager)
 22   virtual void* cast(const std::string& a_class) const {
 23     if(void* p = cmp_cast<zb_manager>(this,a_class)) {return p;}
 24     else return 0;
 25   }
 26 public:
 27   virtual bool begin_render(int,int,unsigned int,unsigned int,float,float,float,float,bool = true) {return true;}
 28   virtual void end_render() {}
 29 
 30   virtual unsigned int create_texture(const img_byte& a_img,bool /*a_NEAREST*/) {
 31     m_gen_id++; //never return 0.
 32     m_gstos[m_gen_id] = a_img;
 33     return m_gen_id;
 34   }
 35 
 36   virtual unsigned int create_gsto_from_data(size_t,const float*) {return 0;}
 37 
 38   virtual bool is_gsto_id_valid(unsigned int a_id) const {
 39     gstos_t::const_iterator it = m_gstos.find(a_id);
 40     if(it==m_gstos.end()) return false;
 41     return true;
 42   }
 43   virtual void delete_gsto(unsigned int a_id) {
 44     gstos_t::iterator it = m_gstos.find(a_id);
 45     if(it!=m_gstos.end()) m_gstos.erase(it);
 46   }
 47 
 48   //
 49   virtual gsto_mode get_gsto_mode() const {return gsto_memory;}
 50   virtual void set_gsto_mode(gsto_mode) {}
 51   virtual void available_gsto_modes(std::vector<std::string>& a_v) {a_v.clear();}
 52   virtual void available_not_memory_gsto_mode(std::string& a_s) const {a_s.clear();}
 53   virtual size_t used_texture_memory() const {return 0;}
 54   virtual size_t gstos_size() const {return 0;}
 55 public:
 56   zb_manager():m_gen_id(0){
 57 #ifdef TOOLS_MEM
 58     mem::increment(s_class().c_str());
 59 #endif
 60   }
 61   virtual ~zb_manager(){
 62     m_gstos.clear();
 63 #ifdef TOOLS_MEM
 64     mem::decrement(s_class().c_str());
 65 #endif
 66   }
 67 public:
 68   zb_manager(const zb_manager& a_from)
 69   :parent(a_from)
 70   ,m_gen_id(0)
 71   ,m_gstos()
 72   {
 73 #ifdef TOOLS_MEM
 74     mem::increment(s_class().c_str());
 75 #endif
 76   }
 77   zb_manager& operator=(const zb_manager& a_from){
 78     if(&a_from==this) return *this;
 79     m_gen_id = 0;
 80     m_gstos.clear();
 81     return *this;
 82   }
 83 public:
 84   bool find(unsigned int a_id,img_byte& a_img) {
 85     gstos_t::iterator it = m_gstos.find(a_id);
 86     if(it==m_gstos.end()) return false;
 87     a_img = (*it).second;
 88     return true;
 89   }
 90   //void cleanup() {}
 91   void delete_gstos() {m_gstos.clear();}
 92 protected:
 93   unsigned int m_gen_id;
 94   typedef std::map<unsigned int,img_byte> gstos_t;
 95   gstos_t m_gstos; //only textures for the moment.
 96 };
 97 
 98 }}
 99 
100 #endif