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 )
30 //------------------------------------------------------------------------------
33 * @brief A basic texture class.
35 * @todo <WRITE EXTENDED CLASS DESCRIPTION>
40 //! Default Constructor.
41 SkyTexture() : _iID(0), _iWidth(0), _iHeight(0) {}
43 SkyTexture(unsigned int iWidth, unsigned int iHeight, unsigned int iTextureID)
44 : _iID(iTextureID), _iWidth(iWidth), _iHeight(iHeight) {}
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; }
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; }
62 inline SKYRESULT Destroy();
67 unsigned int _iHeight;
71 //------------------------------------------------------------------------------
72 // Function : SkyTexture::Destroy
74 //------------------------------------------------------------------------------
76 * @fn SkyTexture::Destroy()
77 * @brief Destroys the OpenGL texture object represented by this SkyTexture object.
79 * Fails if the GL texture has not been created (i.e. its ID is zero).
81 inline SKYRESULT SkyTexture::Destroy()
85 FAIL_RETURN_MSG(SKYRESULT_FAIL,
86 "SkyTexture::Destroy(): Error: attempt to destroy unallocated texture.");
90 glDeleteTextures(1, &_iID);
96 #endif //__SKYTEXTURE_HPP__