]> git.mxchange.org Git - simgear.git/blob - simgear/scene/sky/clouds3d/SkyDynamicTextureManager.hpp
Clouds3D crashes because there is no Light
[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 #ifdef HAVE_CONFIG_H
30 #  include <simgear_config.h>
31 #endif
32
33 #ifdef HAVE_WINDOWS_H
34 #  include <windows.h>
35 #endif
36
37 #include <map>
38
39 #include <GL/gl.h>
40
41 #include "SkyUtil.hpp"
42 #include "SkySingleton.hpp"
43
44 using namespace std;
45
46 class SkyTexture;
47 class SkyDynamicTextureManager;
48
49 //! Dynamic Texture Manager Singleton declaration.
50 /*! The DynamicTextureManager must be created by calling DynamicTextureManager::Instantiate(). */
51 typedef SkySingleton<SkyDynamicTextureManager> DynamicTextureManager;
52
53 //------------------------------------------------------------------------------
54 /**
55  * @class SkyDynamicTextureManager
56  * @brief A repository that allows check-out and check-in from a pool of dynamic textures.
57  * 
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.
62  */
63 class SkyDynamicTextureManager
64 {
65 public:
66   SkyTexture* CheckOutTexture(unsigned int iWidth, unsigned int iHeight);
67   void        CheckInTexture(SkyTexture* pTexture);
68
69   SkyTexture* CreateDynamicTexture(unsigned int iWidth, unsigned int iHeight);
70   
71 protected: // methods
72   SkyDynamicTextureManager(); // these are protected because it is a singleton.
73   ~SkyDynamicTextureManager();
74
75 protected: // datatypes
76   typedef multimap<unsigned int, SkyTexture*>    TextureSubset;
77   typedef multimap<unsigned int, TextureSubset*> TextureSet;
78   
79 protected: // data
80   TextureSet      _availableTexturePool;
81   TextureSubset   _checkedOutTexturePool;
82
83   unsigned int    _iAvailableSizeCounts[11][11];
84
85   unsigned int    _iNumTextureBytesUsed;
86   unsigned int    _iNumTextureBytesCheckedOut;
87   unsigned int    _iNumTextureBytesCheckedIn;
88 };
89
90 #endif //__SKYDYNAMICTEXTUREMANAGER_HPP__