summaryrefslogtreecommitdiffstats
path: root/src/graphics/core/texture.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics/core/texture.h')
-rw-r--r--src/graphics/core/texture.h36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/graphics/core/texture.h b/src/graphics/core/texture.h
index 8d6b082..8abe86a 100644
--- a/src/graphics/core/texture.h
+++ b/src/graphics/core/texture.h
@@ -14,11 +14,14 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// texture.h
+/**
+ * \file graphics/core/texture.h
+ * \brief Texture struct and related enums
+ */
#pragma once
-#include "math/intsize.h"
+#include "math/intpoint.h"
namespace Gfx {
@@ -189,34 +192,43 @@ struct TextureStageParams
Also contains some additional data. */
struct Texture
{
- //! Whether the texture (ID) is valid
- bool valid;
- //! ID of the texture in graphics engine
+ //! ID of the texture in graphics engine; 0 = invalid texture
unsigned int id;
//! Size of texture
- Math::IntSize size;
+ Math::IntPoint size;
//! Whether the texture has alpha channel
bool alpha;
Texture()
{
- valid = false;
id = 0;
alpha = false;
}
+ //! Returns whether the texture is valid (ID != 0)
+ bool Valid() const
+ {
+ return id != 0;
+ }
+
+ //! Sets the ID to invalid value (0)
+ void SetInvalid()
+ {
+ id = 0;
+ }
+
//! Comparator for use in texture maps and sets
inline bool operator<(const Gfx::Texture &other) const
{
// Invalid textures are always "less than" every other texture
- if ( (!valid) && (!other.valid) )
+ if ( (! Valid()) && (! other.Valid()) )
return false;
- if (!valid)
+ if (! Valid())
return true;
- if (!other.valid)
+ if (! other.Valid())
return false;
return id < other.id;
@@ -225,9 +237,9 @@ struct Texture
//! Comparator
inline bool operator==(const Gfx::Texture &other) const
{
- if (valid != other.valid)
+ if (Valid() != other.Valid())
return false;
- if ( (!valid) && (!other.valid) )
+ if ( (! Valid()) && (! other.Valid()) )
return true;
return id == other.id;