00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 // Copyright (C) 2010 Daniele Giannetti 00015 // 00016 // This file is part of VR3Lib. 00017 // The VR3Lib is free software, but is distributed in the static precompiled 00018 // version as it is NOT open source. The VR3Lib may be used in any virtual 00019 // reality application free of charge, but it must be clearly stated that this 00020 // library is used in the application EULA and distribution license 00021 // (for both free and proprietary applications). 00023 00024 #ifndef __VR3TEXTUREMANAGER_H__ 00025 #define __VR3TEXTUREMANAGER_H__ 00026 00027 // STL map class 00028 #include <map> 00029 // STL map utility file 00030 #include <VR3Map.h> 00031 00033 00049 class VR3TextureManager { 00051 struct MapElement { 00053 VR3Texture* texture; 00055 int count; 00056 }; 00057 00059 // file name type 00060 static std::map<std::string, std::map<GLenum,MapElement> , VR3Map::Less> ms_textures; 00061 00063 VR3TextureManager(); 00064 00065 //----------------------- Texture Loading Functions -------------------------// 00066 00068 00074 static void Load2D(const char* file_name, GLuint& tex); 00075 00077 00115 static void LoadCubeMap(const char* file_name, GLuint& tex); 00116 00117 public: 00118 00120 00131 static void LoadTexture( const char* file_name, VR3Texture* texture, 00132 GLenum tex_type = VR3TEX_2D ); 00133 00135 00136 //--------------------- Texture Management Functions ------------------------// 00137 00139 00140 00141 private: 00142 00144 00153 static void CreateTexture(VR3Texture* texture); 00154 00155 public: 00156 00158 00168 static VR3Texture* FindTexture(const char* file_name, GLenum tex_type); 00169 00171 00179 static void DeleteReference(VR3Texture* texture); 00180 00182 00190 static void AddReference(VR3Texture* texture); 00191 00193 }; 00194 00195 #endif