// Copyright (C) 2010, Guy Barrand. All rights reserved. // See the file tools.license for terms. #ifndef tools_sg_zb_manager #define tools_sg_zb_manager #include "render_manager" #include namespace tools { namespace sg { class zb_manager : public virtual render_manager { typedef render_manager parent; public: TOOLS_SCLASS(tools::sg::zb_manager) virtual void* cast(const std::string& a_class) const { if(void* p = cmp_cast(this,a_class)) {return p;} else return 0; } public: virtual bool begin_render(int,int,unsigned int,unsigned int,float,float,float,float,bool = true) {return true;} virtual void end_render() {} virtual unsigned int create_texture(const img_byte& a_img,bool /*a_NEAREST*/) { m_gen_id++; //never return 0. m_gstos[m_gen_id] = a_img; return m_gen_id; } virtual unsigned int create_gsto_from_data(size_t,const float*) {return 0;} virtual bool is_gsto_id_valid(unsigned int a_id) const { gstos_t::const_iterator it = m_gstos.find(a_id); if(it==m_gstos.end()) return false; return true; } virtual void delete_gsto(unsigned int a_id) { gstos_t::iterator it = m_gstos.find(a_id); if(it!=m_gstos.end()) m_gstos.erase(it); } // virtual gsto_mode get_gsto_mode() const {return gsto_memory;} virtual void set_gsto_mode(gsto_mode) {} virtual void available_gsto_modes(std::vector& a_v) {a_v.clear();} virtual void available_not_memory_gsto_mode(std::string& a_s) const {a_s.clear();} virtual size_t used_texture_memory() const {return 0;} virtual size_t gstos_size() const {return 0;} public: zb_manager():m_gen_id(0){ } virtual ~zb_manager(){ m_gstos.clear(); } public: zb_manager(const zb_manager& a_from) :parent(a_from) ,m_gen_id(0) ,m_gstos() { } zb_manager& operator=(const zb_manager& a_from){ if(&a_from==this) return *this; m_gen_id = 0; m_gstos.clear(); return *this; } public: bool find(unsigned int a_id,img_byte& a_img) { gstos_t::iterator it = m_gstos.find(a_id); if(it==m_gstos.end()) return false; a_img = (*it).second; return true; } void delete_gstos() {m_gstos.clear();} protected: unsigned int m_gen_id; typedef std::map gstos_t; gstos_t m_gstos; //only textures for the moment. }; }} #endif