1 //------------------------------------------------------------------------------
2 // File : SkyDynamicTextureManager.hpp
3 //------------------------------------------------------------------------------
4 // SkyWorks : Copyright 2002 Mark J. Harris and
5 // The University of North Carolina at Chapel Hill
6 //------------------------------------------------------------------------------
7 // Permission to use, copy, modify, distribute and sell this software and its
8 // documentation for any purpose is hereby granted without fee, provided that
9 // the above copyright notice appear in all copies and that both that copyright
10 // notice and this permission notice appear in supporting documentation.
11 // Binaries may be compiled with this software without any royalties or
14 // The author(s) and The University of North Carolina at Chapel Hill make no
15 // representations about the suitability of this software for any purpose.
16 // It is provided "as is" without express or
19 * @file SkyDynamicTextureManager.hpp
21 * Interface definition of a repository for check out and check in of dynamic textures.
23 #ifndef __SKYDYNAMICTEXTUREMANAGER_HPP__
24 #define __SKYDYNAMICTEXTUREMANAGER_HPP__
26 // warning for truncation of template name for browse info
27 #pragma warning( disable : 4786)
30 # include <simgear_config.h>
41 #include "SkyUtil.hpp"
42 #include "SkySingleton.hpp"
47 class SkyDynamicTextureManager;
49 //! Dynamic Texture Manager Singleton declaration.
50 /*! The DynamicTextureManager must be created by calling DynamicTextureManager::Instantiate(). */
51 typedef SkySingleton<SkyDynamicTextureManager> DynamicTextureManager;
53 //------------------------------------------------------------------------------
55 * @class SkyDynamicTextureManager
56 * @brief A repository that allows check-out and check-in from a pool of dynamic textures.
58 * When an object needs a dynamic texture, it checks it out using CheckOutTexture(), passing
59 * the resolution of the texture it needs. When the object is done with the texture, it
60 * calls CheckInTexture(). New dynamic textures can be allocated by calling CreateDynamicTexture,
61 * but these textures will be unmanaged.
63 class SkyDynamicTextureManager
66 SkyTexture* CheckOutTexture(unsigned int iWidth, unsigned int iHeight);
67 void CheckInTexture(SkyTexture* pTexture);
69 SkyTexture* CreateDynamicTexture(unsigned int iWidth, unsigned int iHeight);
72 SkyDynamicTextureManager(); // these are protected because it is a singleton.
73 ~SkyDynamicTextureManager();
75 protected: // datatypes
76 typedef multimap<unsigned int, SkyTexture*> TextureSubset;
77 typedef multimap<unsigned int, TextureSubset*> TextureSet;
80 TextureSet _availableTexturePool;
81 TextureSubset _checkedOutTexturePool;
83 unsigned int _iAvailableSizeCounts[11][11];
85 unsigned int _iNumTextureBytesUsed;
86 unsigned int _iNumTextureBytesCheckedOut;
87 unsigned int _iNumTextureBytesCheckedIn;
90 #endif //__SKYDYNAMICTEXTUREMANAGER_HPP__