]> git.mxchange.org Git - simgear.git/blob - simgear/scene/sky/clouds3d/SkyTexture.hpp
Tweak lib name.
[simgear.git] / simgear / scene / sky / clouds3d / SkyTexture.hpp
1 //------------------------------------------------------------------------------
2 // File : SkyTexture.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 SkyTexture.hpp
20  * 
21  * Interface definition for class SkyTexture, a texture class.
22  */
23 #ifndef __SKYTEXTURE_HPP__
24 #define __SKYTEXTURE_HPP__
25
26 #pragma warning( disable : 4786 )
27
28 #include <GL/glut.h>
29
30 //------------------------------------------------------------------------------
31 /**
32  * @class SkyTexture
33  * @brief A basic texture class.
34  * 
35  * @todo <WRITE EXTENDED CLASS DESCRIPTION>
36  */
37 class SkyTexture
38 {
39 public:
40   //! Default Constructor.
41   SkyTexture() : _iID(0), _iWidth(0), _iHeight(0) {}
42   //! Constructor.
43   SkyTexture(unsigned int iWidth, unsigned int iHeight, unsigned int iTextureID)
44     : _iID(iTextureID), _iWidth(iWidth), _iHeight(iHeight) {}
45   //! Destructor.
46   ~SkyTexture() {}
47
48   //! Sets the texture width in texels.
49   void              SetWidth(unsigned int iWidth)   { _iWidth  = iWidth;      }
50   //! Sets the texture height in texels.
51   void              SetHeight(unsigned int iHeight) { _iHeight = iHeight;     }
52   //! Sets the texture ID as created by OpenGL.
53   void              SetID(unsigned int iTextureID)  { _iID     = iTextureID;  }
54                     
55   //! Returns the texture width in texels.
56   unsigned int      GetWidth() const                { return _iWidth;         }
57   //! Returns the texture height in texels.
58   unsigned int      GetHeight() const               { return _iHeight;        }
59   //! Returns the texture ID as created by OpenGL.
60   unsigned int      GetID() const                   { return _iID;            }
61
62   inline SKYRESULT  Destroy();
63
64 protected:
65   unsigned int _iID;
66   unsigned int _iWidth;
67   unsigned int _iHeight;
68 };
69
70
71 //------------------------------------------------------------------------------
72 // Function               : SkyTexture::Destroy
73 // Description      : 
74 //------------------------------------------------------------------------------
75 /**
76  * @fn SkyTexture::Destroy()
77  * @brief Destroys the OpenGL texture object represented by this SkyTexture object.
78  * 
79  * Fails if the GL texture has not been created (i.e. its ID is zero).
80  */ 
81 inline SKYRESULT SkyTexture::Destroy()
82 {
83   if (0 == _iID)
84   {
85     FAIL_RETURN_MSG(SKYRESULT_FAIL, 
86                     "SkyTexture::Destroy(): Error: attempt to destroy unallocated texture.");
87   }
88   else
89   {
90     glDeleteTextures(1, &_iID);
91     _iID = 0;
92   }
93   return SKYRESULT_OK;
94 }
95
96 #endif //__SKYTEXTURE_HPP__