]> git.mxchange.org Git - simgear.git/blob - simgear/scene/sky/clouds3d/SkyDynamicTextureManager.hpp
Initial revision.
[simgear.git] / simgear / scene / sky / clouds3d / SkyDynamicTextureManager.hpp
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 
12 // restrictions. 
13 //
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 
17 // implied warranty.
18 /**
19  * @file SkyDynamicTextureManager.hpp
20  * 
21  * Interface definition of a repository for check out and check in of dynamic textures.
22  */
23 #ifndef __SKYDYNAMICTEXTUREMANAGER_HPP__
24 #define __SKYDYNAMICTEXTUREMANAGER_HPP__
25   
26 // warning for truncation of template name for browse info
27 #pragma warning( disable : 4786)
28
29 #include <map>
30 #include <GL/glut.h>
31 #include "SkyUtil.hpp"
32 #include "SkySingleton.hpp"
33
34 using namespace std;
35
36 class SkyTexture;
37 class SkyDynamicTextureManager;
38
39 //! Dynamic Texture Manager Singleton declaration.
40 /*! The DynamicTextureManager must be created by calling DynamicTextureManager::Instantiate(). */
41 typedef SkySingleton<SkyDynamicTextureManager> DynamicTextureManager;
42
43 //------------------------------------------------------------------------------
44 /**
45  * @class SkyDynamicTextureManager
46  * @brief A repository that allows check-out and check-in from a pool of dynamic textures.
47  * 
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.
52  */
53 class SkyDynamicTextureManager
54 {
55 public:
56   SkyTexture* CheckOutTexture(unsigned int iWidth, unsigned int iHeight);
57   void        CheckInTexture(SkyTexture* pTexture);
58
59   SkyTexture* CreateDynamicTexture(unsigned int iWidth, unsigned int iHeight);
60   
61 protected: // methods
62   SkyDynamicTextureManager(); // these are protected because it is a singleton.
63   ~SkyDynamicTextureManager();
64
65 protected: // datatypes
66   typedef multimap<unsigned int, SkyTexture*>    TextureSubset;
67   typedef multimap<unsigned int, TextureSubset*> TextureSet;
68   
69 protected: // data
70   TextureSet      _availableTexturePool;
71   TextureSubset   _checkedOutTexturePool;
72
73   unsigned int    _iAvailableSizeCounts[11][11];
74
75   unsigned int    _iNumTextureBytesUsed;
76   unsigned int    _iNumTextureBytesCheckedOut;
77   unsigned int    _iNumTextureBytesCheckedIn;
78 };
79
80 #endif //__SKYDYNAMICTEXTUREMANAGER_HPP__