]> git.mxchange.org Git - simgear.git/blob - simgear/scene/sky/clouds3d/SkyTexture.hpp
Clouds3D crashes because there is no Light
[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 #ifdef HAVE_CONFIG_H
29 #  include <simgear_config.h>
30 #endif
31
32 #ifdef HAVE_WINDOWS_H
33 #  include <windows.h>
34 #endif
35
36 #include <GL/gl.h>
37
38 #define __glext_h_
39 #define __GLEXT_H_
40 #define __glext_h_
41 #define __GLEXT_H_
42
43 //------------------------------------------------------------------------------
44 /**
45  * @class SkyTexture
46  * @brief A basic texture class.
47  * 
48  * @todo <WRITE EXTENDED CLASS DESCRIPTION>
49  */
50 class SkyTexture
51 {
52 public:
53   //! Default Constructor.
54   SkyTexture() : _iID(0), _iWidth(0), _iHeight(0) {}
55   //! Constructor.
56   SkyTexture(unsigned int iWidth, unsigned int iHeight, unsigned int iTextureID)
57     : _iID(iTextureID), _iWidth(iWidth), _iHeight(iHeight) {}
58   //! Destructor.
59   ~SkyTexture() {}
60
61   //! Sets the texture width in texels.
62   void              SetWidth(unsigned int iWidth)   { _iWidth  = iWidth;      }
63   //! Sets the texture height in texels.
64   void              SetHeight(unsigned int iHeight) { _iHeight = iHeight;     }
65   //! Sets the texture ID as created by OpenGL.
66   void              SetID(unsigned int iTextureID)  { _iID     = iTextureID;  }
67                     
68   //! Returns the texture width in texels.
69   unsigned int      GetWidth() const                { return _iWidth;         }
70   //! Returns the texture height in texels.
71   unsigned int      GetHeight() const               { return _iHeight;        }
72   //! Returns the texture ID as created by OpenGL.
73   unsigned int      GetID() const                   { return _iID;            }
74
75   inline SKYRESULT  Destroy();
76
77 protected:
78   unsigned int _iID;
79   unsigned int _iWidth;
80   unsigned int _iHeight;
81 };
82
83
84 //------------------------------------------------------------------------------
85 // Function               : SkyTexture::Destroy
86 // Description      : 
87 //------------------------------------------------------------------------------
88 /**
89  * @fn SkyTexture::Destroy()
90  * @brief Destroys the OpenGL texture object represented by this SkyTexture object.
91  * 
92  * Fails if the GL texture has not been created (i.e. its ID is zero).
93  */ 
94 inline SKYRESULT SkyTexture::Destroy()
95 {
96   if (0 == _iID)
97   {
98     FAIL_RETURN_MSG(SKYRESULT_FAIL, 
99                     "SkyTexture::Destroy(): Error: attempt to destroy unallocated texture.");
100   }
101   else
102   {
103     glDeleteTextures(1, &_iID);
104     _iID = 0;
105   }
106   return SKYRESULT_OK;
107 }
108
109 #endif //__SKYTEXTURE_HPP__