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
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 SkyTexture.hpp
21 * Interface definition for class SkyTexture, a texture class.
23 #ifndef __SKYTEXTURE_HPP__
24 #define __SKYTEXTURE_HPP__
26 // #pragma warning( disable : 4786 )
29 # include <simgear_config.h>
43 //------------------------------------------------------------------------------
46 * @brief A basic texture class.
48 * @todo <WRITE EXTENDED CLASS DESCRIPTION>
53 //! Default Constructor.
54 SkyTexture() : _iID(0), _iWidth(0), _iHeight(0) {}
56 SkyTexture(unsigned int iWidth, unsigned int iHeight, unsigned int iTextureID)
57 : _iID(iTextureID), _iWidth(iWidth), _iHeight(iHeight) {}
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; }
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; }
75 inline SKYRESULT Destroy();
80 unsigned int _iHeight;
84 //------------------------------------------------------------------------------
85 // Function : SkyTexture::Destroy
87 //------------------------------------------------------------------------------
89 * @fn SkyTexture::Destroy()
90 * @brief Destroys the OpenGL texture object represented by this SkyTexture object.
92 * Fails if the GL texture has not been created (i.e. its ID is zero).
94 inline SKYRESULT SkyTexture::Destroy()
98 FAIL_RETURN_MSG(SKYRESULT_FAIL,
99 "SkyTexture::Destroy(): Error: attempt to destroy unallocated texture.");
103 glDeleteTextures(1, &_iID);
109 #endif //__SKYTEXTURE_HPP__