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)
31 #include "SkyUtil.hpp"
32 #include "SkySingleton.hpp"
37 class SkyDynamicTextureManager;
39 //! Dynamic Texture Manager Singleton declaration.
40 /*! The DynamicTextureManager must be created by calling DynamicTextureManager::Instantiate(). */
41 typedef SkySingleton<SkyDynamicTextureManager> DynamicTextureManager;
43 //------------------------------------------------------------------------------
45 * @class SkyDynamicTextureManager
46 * @brief A repository that allows check-out and check-in from a pool of dynamic textures.
48 * When an object needs a dynamic texture, it checks it out using CheckOutTexture(), passing
49 * the resolution of the texture it needs. When the object is done with the texture, it
50 * calls CheckInTexture(). New dynamic textures can be allocated by calling CreateDynamicTexture,
51 * but these textures will be unmanaged.
53 class SkyDynamicTextureManager
56 SkyTexture* CheckOutTexture(unsigned int iWidth, unsigned int iHeight);
57 void CheckInTexture(SkyTexture* pTexture);
59 SkyTexture* CreateDynamicTexture(unsigned int iWidth, unsigned int iHeight);
62 SkyDynamicTextureManager(); // these are protected because it is a singleton.
63 ~SkyDynamicTextureManager();
65 protected: // datatypes
66 typedef multimap<unsigned int, SkyTexture*> TextureSubset;
67 typedef multimap<unsigned int, TextureSubset*> TextureSet;
70 TextureSet _availableTexturePool;
71 TextureSubset _checkedOutTexturePool;
73 unsigned int _iAvailableSizeCounts[11][11];
75 unsigned int _iNumTextureBytesUsed;
76 unsigned int _iNumTextureBytesCheckedOut;
77 unsigned int _iNumTextureBytesCheckedIn;
80 #endif //__SKYDYNAMICTEXTUREMANAGER_HPP__