diff options
author | Piotr Dziwinski <piotrdz@gmail.com> | 2012-08-12 19:28:22 +0200 |
---|---|---|
committer | Piotr Dziwinski <piotrdz@gmail.com> | 2012-08-12 19:28:22 +0200 |
commit | 45a5e1e865ec02892054080e1fc0b7e7c463e9d3 (patch) | |
tree | 7cbeeb13b077c677f170595e53fab48e8699cae7 /src/graphics/core | |
parent | b4b74c30e9aa93ae736db73df5cb0c5d508ec6ed (diff) | |
download | colobot-45a5e1e865ec02892054080e1fc0b7e7c463e9d3.tar.gz colobot-45a5e1e865ec02892054080e1fc0b7e7c463e9d3.tar.bz2 colobot-45a5e1e865ec02892054080e1fc0b7e7c463e9d3.zip |
Object handling in CEngine
- finished rewriting CEngine object, shadow, etc. handling
- refactored texture code
- added new log levels
Diffstat (limited to 'src/graphics/core')
-rw-r--r-- | src/graphics/core/material.h | 10 | ||||
-rw-r--r-- | src/graphics/core/texture.h | 27 |
2 files changed, 28 insertions, 9 deletions
diff --git a/src/graphics/core/material.h b/src/graphics/core/material.h index eb73c50..156ff36 100644 --- a/src/graphics/core/material.h +++ b/src/graphics/core/material.h @@ -45,6 +45,16 @@ struct Material Gfx::Color ambient; //! Specular color Gfx::Color specular; + + bool operator==(const Gfx::Material &mat) const + { + return diffuse == mat.diffuse && ambient == mat.ambient && specular == mat.specular; + } + + bool operator!=(const Gfx::Material &mat) const + { + return ! operator==(mat); + } }; }; // namespace Gfx diff --git a/src/graphics/core/texture.h b/src/graphics/core/texture.h index c36b6c6..8abe86a 100644 --- a/src/graphics/core/texture.h +++ b/src/graphics/core/texture.h @@ -192,9 +192,7 @@ 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::IntPoint size; @@ -203,23 +201,34 @@ struct Texture 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; @@ -228,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; |