Browse Source

Trade: rename MaterialData::*CoordinateSet() to *TextureCoordinates().

Better since it has the same prefix as other texture-related attributes,
such as *TextureMatrix(). Not using *TextureCoordinateSet() because
that's overly long, *TextureSet() is OTOH confusing (and especially so
if we'd introduce *TextureLayer()).
pull/459/head
Vladimír Vondruš 6 years ago
parent
commit
6811198532
  1. 10
      doc/changelog.dox
  2. 42
      src/Magnum/Trade/PhongMaterialData.cpp
  3. 103
      src/Magnum/Trade/PhongMaterialData.h
  4. 64
      src/Magnum/Trade/Test/MaterialDataTest.cpp

10
doc/changelog.dox

@ -111,6 +111,16 @@ See also:
coordinates), @ref MeshTools::compile() should be using only the first set coordinates), @ref MeshTools::compile() should be using only the first set
but it wasn't. but it wasn't.
@subsection changelog-latest-deprecated Deprecated APIs
- @cpp Trade::PhongMaterialData::ambientCoordinateSet() @ce,
@cpp diffuseCoordinateSet() @ce, @cpp specularCoordinateSet() @ce and
@cpp normalCoordinateSet() @ce are deprecated in favor of more consistently
named @ref Trade::PhongMaterialData::ambientTextureCoordinates(),
@ref Trade::PhongMaterialData::diffuseTextureCoordinates() "diffuseTextureCoordinates()",
@ref Trade::PhongMaterialData::specularTextureCoordinates() "specularTextureCoordinates()"
and @ref Trade::PhongMaterialData::normalTextureCoordinates() "normalTextureCoordinates()"
@subsection changelog-latest-compatibility Potential compatibility breakages, removed APIs @subsection changelog-latest-compatibility Potential compatibility breakages, removed APIs
- Removed remaining APIs deprecated in version 2018.10, in particular: - Removed remaining APIs deprecated in version 2018.10, in particular:

42
src/Magnum/Trade/PhongMaterialData.cpp

@ -32,29 +32,29 @@ namespace Magnum { namespace Trade {
using namespace Math::Literals; using namespace Math::Literals;
PhongMaterialData::PhongMaterialData(const Flags flags, const Color4& ambientColor, const UnsignedInt ambientTexture, const UnsignedInt ambientCoordinateSet, const Color4& diffuseColor, const UnsignedInt diffuseTexture, const UnsignedInt diffuseCoordinateSet, const Color4& specularColor, const UnsignedInt specularTexture, const UnsignedInt specularCoordinateSet, const UnsignedInt normalTexture, const UnsignedInt normalCoordinateSet, const Matrix3& textureMatrix, const MaterialAlphaMode alphaMode, const Float alphaMask, const Float shininess, const void* const importerState) noexcept: AbstractMaterialData{MaterialType::Phong, AbstractMaterialData::Flag(UnsignedShort(flags)), alphaMode, alphaMask, importerState}, _ambientColor{ambientColor}, _diffuseColor{diffuseColor}, _specularColor{specularColor}, _shininess{shininess} { PhongMaterialData::PhongMaterialData(const Flags flags, const Color4& ambientColor, const UnsignedInt ambientTexture, const UnsignedInt ambientTextureCoordinates, const Color4& diffuseColor, const UnsignedInt diffuseTexture, const UnsignedInt diffuseTextureCoordinates, const Color4& specularColor, const UnsignedInt specularTexture, const UnsignedInt specularTextureCoordinates, const UnsignedInt normalTexture, const UnsignedInt normalTextureCoordinates, const Matrix3& textureMatrix, const MaterialAlphaMode alphaMode, const Float alphaMask, const Float shininess, const void* const importerState) noexcept: AbstractMaterialData{MaterialType::Phong, AbstractMaterialData::Flag(UnsignedShort(flags)), alphaMode, alphaMask, importerState}, _ambientColor{ambientColor}, _diffuseColor{diffuseColor}, _specularColor{specularColor}, _shininess{shininess} {
CORRADE_ASSERT(!(flags & Flag::TextureTransformation) || (flags & (Flag::AmbientTexture|Flag::DiffuseTexture|Flag::SpecularTexture|Flag::NormalTexture)), CORRADE_ASSERT(!(flags & Flag::TextureTransformation) || (flags & (Flag::AmbientTexture|Flag::DiffuseTexture|Flag::SpecularTexture|Flag::NormalTexture)),
"Trade::PhongMaterialData: texture transformation enabled but the material has no textures", ); "Trade::PhongMaterialData: texture transformation enabled but the material has no textures", );
CORRADE_ASSERT((flags & Flag::TextureTransformation) || textureMatrix == Matrix3{}, CORRADE_ASSERT((flags & Flag::TextureTransformation) || textureMatrix == Matrix3{},
"PhongMaterialData::PhongMaterialData: non-default texture matrix requires Flag::TextureTransformation to be enabled", ); "PhongMaterialData::PhongMaterialData: non-default texture matrix requires Flag::TextureTransformation to be enabled", );
CORRADE_ASSERT((flags & Flag::TextureCoordinateSets) || (ambientCoordinateSet == 0 && diffuseCoordinateSet == 0 && specularCoordinateSet == 0 && normalCoordinateSet == 0), CORRADE_ASSERT((flags & Flag::TextureCoordinates) || (ambientTextureCoordinates == 0 && diffuseTextureCoordinates == 0 && specularTextureCoordinates == 0 && normalTextureCoordinates == 0),
"PhongMaterialData::PhongMaterialData: non-zero texture coordinate sets require Flag::TextureCoordinateSets to be enabled", ); "PhongMaterialData::PhongMaterialData: non-zero texture coordinate sets require Flag::TextureCoordinates to be enabled", );
if(flags & Flag::AmbientTexture) { if(flags & Flag::AmbientTexture) {
_ambientTexture = ambientTexture; _ambientTexture = ambientTexture;
_ambientCoordinateSet = ambientCoordinateSet; _ambientTextureCoordinates = ambientTextureCoordinates;
} }
if(flags & Flag::DiffuseTexture) { if(flags & Flag::DiffuseTexture) {
_diffuseTexture = diffuseTexture; _diffuseTexture = diffuseTexture;
_diffuseCoordinateSet = diffuseCoordinateSet; _diffuseTextureCoordinates = diffuseTextureCoordinates;
} }
if(flags & Flag::SpecularTexture) { if(flags & Flag::SpecularTexture) {
_specularTexture = specularTexture; _specularTexture = specularTexture;
_specularCoordinateSet = specularCoordinateSet; _specularTextureCoordinates = specularTextureCoordinates;
} }
if(flags & Flag::NormalTexture) { if(flags & Flag::NormalTexture) {
_normalTexture = normalTexture; _normalTexture = normalTexture;
_normalCoordinateSet = normalCoordinateSet; _normalTextureCoordinates = normalTextureCoordinates;
} }
if(flags & Flag::TextureTransformation) if(flags & Flag::TextureTransformation)
_textureMatrix = textureMatrix; _textureMatrix = textureMatrix;
@ -76,9 +76,9 @@ UnsignedInt PhongMaterialData::ambientTexture() const {
} }
UnsignedInt PhongMaterialData::ambientCoordinateSet() const { UnsignedInt PhongMaterialData::ambientTextureCoordinates() const {
CORRADE_ASSERT(flags() & Flag::AmbientTexture, "Trade::PhongMaterialData::ambientCoordinateSet(): the material doesn't have an ambient texture", {}); CORRADE_ASSERT(flags() & Flag::AmbientTexture, "Trade::PhongMaterialData::ambientTextureCoordinates(): the material doesn't have an ambient texture", {});
return _ambientCoordinateSet; return _ambientTextureCoordinates;
} }
UnsignedInt PhongMaterialData::diffuseTexture() const { UnsignedInt PhongMaterialData::diffuseTexture() const {
@ -87,9 +87,9 @@ UnsignedInt PhongMaterialData::diffuseTexture() const {
} }
UnsignedInt PhongMaterialData::diffuseCoordinateSet() const { UnsignedInt PhongMaterialData::diffuseTextureCoordinates() const {
CORRADE_ASSERT(flags() & Flag::DiffuseTexture, "Trade::PhongMaterialData::diffuseCoordinateSet(): the material doesn't have a diffuse texture", {}); CORRADE_ASSERT(flags() & Flag::DiffuseTexture, "Trade::PhongMaterialData::diffuseTextureCoordinates(): the material doesn't have a diffuse texture", {});
return _diffuseCoordinateSet; return _diffuseTextureCoordinates;
} }
UnsignedInt PhongMaterialData::specularTexture() const { UnsignedInt PhongMaterialData::specularTexture() const {
@ -98,9 +98,9 @@ UnsignedInt PhongMaterialData::specularTexture() const {
} }
UnsignedInt PhongMaterialData::specularCoordinateSet() const { UnsignedInt PhongMaterialData::specularTextureCoordinates() const {
CORRADE_ASSERT(flags() & Flag::SpecularTexture, "Trade::PhongMaterialData::specularCoordinateSet(): the material doesn't have a specular texture", {}); CORRADE_ASSERT(flags() & Flag::SpecularTexture, "Trade::PhongMaterialData::specularTextureCoordinates(): the material doesn't have a specular texture", {});
return _specularCoordinateSet; return _specularTextureCoordinates;
} }
UnsignedInt PhongMaterialData::normalTexture() const { UnsignedInt PhongMaterialData::normalTexture() const {
@ -108,9 +108,9 @@ UnsignedInt PhongMaterialData::normalTexture() const {
return _normalTexture; return _normalTexture;
} }
UnsignedInt PhongMaterialData::normalCoordinateSet() const { UnsignedInt PhongMaterialData::normalTextureCoordinates() const {
CORRADE_ASSERT(flags() & Flag::NormalTexture, "Trade::PhongMaterialData::normalCoordinateSet(): the material doesn't have a normal texture", {}); CORRADE_ASSERT(flags() & Flag::NormalTexture, "Trade::PhongMaterialData::normalTextureCoordinates(): the material doesn't have a normal texture", {});
return _normalCoordinateSet; return _normalTextureCoordinates;
} }
Debug& operator<<(Debug& debug, const PhongMaterialData::Flag value) { Debug& operator<<(Debug& debug, const PhongMaterialData::Flag value) {
@ -125,7 +125,7 @@ Debug& operator<<(Debug& debug, const PhongMaterialData::Flag value) {
_c(SpecularTexture) _c(SpecularTexture)
_c(NormalTexture) _c(NormalTexture)
_c(TextureTransformation) _c(TextureTransformation)
_c(TextureCoordinateSets) _c(TextureCoordinates)
#undef _c #undef _c
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
@ -141,7 +141,7 @@ Debug& operator<<(Debug& debug, const PhongMaterialData::Flags value) {
PhongMaterialData::Flag::SpecularTexture, PhongMaterialData::Flag::SpecularTexture,
PhongMaterialData::Flag::NormalTexture, PhongMaterialData::Flag::NormalTexture,
PhongMaterialData::Flag::TextureTransformation, PhongMaterialData::Flag::TextureTransformation,
PhongMaterialData::Flag::TextureCoordinateSets}); PhongMaterialData::Flag::TextureCoordinates});
} }
}} }}

103
src/Magnum/Trade/PhongMaterialData.h

@ -77,9 +77,18 @@ class MAGNUM_TRADE_EXPORT PhongMaterialData: public AbstractMaterialData {
/** /**
* The material uses non-default texture coordinate sets * The material uses non-default texture coordinate sets
* @m_since{2020,06} * @m_since_latest
*/
TextureCoordinates = 1 << 6,
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* The material uses non-default texture coordinate sets
* @m_deprecated_since_latest Use @ref Flag::TextureCoordinates
* instead.
*/ */
TextureCoordinateSets = 1 << 6 TextureCoordinateSets CORRADE_DEPRECATED_ENUM("use Flag::TextureCoordinates instead") = TextureCoordinates
#endif
}; };
/** /**
@ -121,7 +130,7 @@ class MAGNUM_TRADE_EXPORT PhongMaterialData: public AbstractMaterialData {
* @param importerState Importer-specific state * @param importerState Importer-specific state
* @m_since{2020,06} * @m_since{2020,06}
* *
* All `*CoordinateSet` accessors are implicitly zero with this * All `*TextureCoordinates()` accessors are implicitly zero with this
* constructor. If @p textureMatrix is not default-constructed, expects * constructor. If @p textureMatrix is not default-constructed, expects
* @ref Flag::TextureTransformation to be enabled as well. * @ref Flag::TextureTransformation to be enabled as well.
*/ */
@ -136,26 +145,26 @@ class MAGNUM_TRADE_EXPORT PhongMaterialData: public AbstractMaterialData {
* default value for a textured material. * default value for a textured material.
* @param ambientTexture Ambient texture ID. Ignored if @p flags * @param ambientTexture Ambient texture ID. Ignored if @p flags
* doesn't have @ref Flag::AmbientTexture. * doesn't have @ref Flag::AmbientTexture.
* @param ambientCoordinateSet Ambient texture coordinate set. Ignored * @param ambientTextureCoordinates Ambient texture coordinate set.
* if @p flags doesn't have @ref Flag::AmbientTexture * Ignored if @p flags doesn't have @ref Flag::AmbientTexture
* @param diffuseColor Diffuse color. Use * @param diffuseColor Diffuse color. Use
* @cpp 0xffffffff_rgbaf @ce for a default value for both a * @cpp 0xffffffff_rgbaf @ce for a default value for both a
* non-textured and a textured material. * non-textured and a textured material.
* @param diffuseTexture Diffuse texture ID. Ignored if @p flags * @param diffuseTexture Diffuse texture ID. Ignored if @p flags
* doesn't have @ref Flag::DiffuseTexture. * doesn't have @ref Flag::DiffuseTexture.
* @param diffuseCoordinateSet Diffuse texture coordinate set. Ignored * @param diffuseTextureCoordinates Diffuse texture coordinate set.
* if @p flags doesn't have @ref Flag::DiffuseTexture * Ignored if @p flags doesn't have @ref Flag::DiffuseTexture
* @param specularColor Specular color. Use * @param specularColor Specular color. Use
* @cpp 0xffffffff_rgbaf @ce for a default value for both a * @cpp 0xffffffff_rgbaf @ce for a default value for both a
* non-textured and a textured material. * non-textured and a textured material.
* @param specularTexture Specular texture ID. Ignored if * @param specularTexture Specular texture ID. Ignored if
* @p flags doesn't have @ref Flag::SpecularTexture. * @p flags doesn't have @ref Flag::SpecularTexture.
* @param specularCoordinateSet Specular texture coordinate set. * @param specularTextureCoordinates Specular texture coordinate set.
* Ignored if @p flags doesn't have @ref Flag::SpecularTexture. * Ignored if @p flags doesn't have @ref Flag::SpecularTexture.
* @param normalTexture Normal texture ID. Ignored if @p flags * @param normalTexture Normal texture ID. Ignored if @p flags
* doesn't have @ref Flag::NormalTexture. * doesn't have @ref Flag::NormalTexture.
* @param normalCoordinateSet Normal texture coordinate set. Ignored * @param normalTextureCoordinates Normal texture coordinate set.
* if @p flags doesn't have @ref Flag::NormalTexture. * Ignored if @p flags doesn't have @ref Flag::NormalTexture.
* @param textureMatrix Texture coordinate transformation * @param textureMatrix Texture coordinate transformation
* @param alphaMode Alpha mode. Use * @param alphaMode Alpha mode. Use
* @ref MaterialAlphaMode::Opaque for a default value. * @ref MaterialAlphaMode::Opaque for a default value.
@ -168,10 +177,10 @@ class MAGNUM_TRADE_EXPORT PhongMaterialData: public AbstractMaterialData {
* *
* If @p textureMatrix is not default-constructed, expects * If @p textureMatrix is not default-constructed, expects
* @ref Flag::TextureTransformation to be enabled as well. If any * @ref Flag::TextureTransformation to be enabled as well. If any
* `*CoordinateSet` is non-zero, expects @ref Flag::TextureCoordinateSets * `*Coordinates` parameter is non-zero, expects
* to be enabled as well. * @ref Flag::TextureCoordinates to be enabled as well.
*/ */
explicit PhongMaterialData(Flags flags, const Color4& ambientColor, UnsignedInt ambientTexture, UnsignedInt ambientCoordinateSet, const Color4& diffuseColor, UnsignedInt diffuseTexture, UnsignedInt diffuseCoordinateSet, const Color4& specularColor, UnsignedInt specularTexture, UnsignedInt specularCoordinateSet, UnsignedInt normalTexture, UnsignedInt normalCoordinateSet, const Matrix3& textureMatrix, MaterialAlphaMode alphaMode, Float alphaMask, Float shininess, const void* importerState = nullptr) noexcept; explicit PhongMaterialData(Flags flags, const Color4& ambientColor, UnsignedInt ambientTexture, UnsignedInt ambientTextureCoordinates, const Color4& diffuseColor, UnsignedInt diffuseTexture, UnsignedInt diffuseTextureCoordinates, const Color4& specularColor, UnsignedInt specularTexture, UnsignedInt specularTextureCoordinates, UnsignedInt normalTexture, UnsignedInt normalTextureCoordinates, const Matrix3& textureMatrix, MaterialAlphaMode alphaMode, Float alphaMask, Float shininess, const void* importerState = nullptr) noexcept;
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
/** /**
@ -223,12 +232,23 @@ class MAGNUM_TRADE_EXPORT PhongMaterialData: public AbstractMaterialData {
/** /**
* @brief Ambient texture coordinate set * @brief Ambient texture coordinate set
* @m_since{2020,06} * @m_since_latest
* *
* Available only if the material has @ref Flag::AmbientTexture. * Available only if the material has @ref Flag::AmbientTexture.
* @see @ref flags(), @ref AbstractImporter::texture() * @see @ref flags(), @ref AbstractImporter::texture()
*/ */
UnsignedInt ambientCoordinateSet() const; UnsignedInt ambientTextureCoordinates() const;
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @brief @copybrief ambientTextureCoordinates()
* @m_deprecated_since_latest Use @ref ambientTextureCoordinates()
* instead.
*/
CORRADE_DEPRECATED("use ambientTextureCoordinates() instead") UnsignedInt ambientCoordinateSet() const {
return ambientTextureCoordinates();
}
#endif
/** /**
* @brief Diffuse color * @brief Diffuse color
@ -250,12 +270,23 @@ class MAGNUM_TRADE_EXPORT PhongMaterialData: public AbstractMaterialData {
/** /**
* @brief Diffuse texture coordinate set * @brief Diffuse texture coordinate set
* @m_since{2020,06} * @m_since_latest
* *
* Available only if the material has @ref Flag::DiffuseTexture. * Available only if the material has @ref Flag::DiffuseTexture.
* @see @ref flags(), @ref AbstractImporter::texture() * @see @ref flags(), @ref AbstractImporter::texture()
*/ */
UnsignedInt diffuseCoordinateSet() const; UnsignedInt diffuseTextureCoordinates() const;
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @brief @copybrief diffuseTextureCoordinates()
* @m_deprecated_since_latest Use @ref diffuseTextureCoordinates()
* instead.
*/
CORRADE_DEPRECATED("use diffuseTextureCoordinates() instead") UnsignedInt diffuseCoordinateSet() const {
return diffuseTextureCoordinates();
}
#endif
/** /**
* @brief Specular color * @brief Specular color
@ -277,12 +308,23 @@ class MAGNUM_TRADE_EXPORT PhongMaterialData: public AbstractMaterialData {
/** /**
* @brief Specular texture coordinate set * @brief Specular texture coordinate set
* @m_since{2020,06} * @m_since_latest
* *
* Available only if the material has @ref Flag::SpecularTexture. * Available only if the material has @ref Flag::SpecularTexture.
* @see @ref flags(), @ref AbstractImporter::texture() * @see @ref flags(), @ref AbstractImporter::texture()
*/ */
UnsignedInt specularCoordinateSet() const; UnsignedInt specularTextureCoordinates() const;
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @brief @copybrief specularTextureCoordinates()
* @m_deprecated_since_latest Use @ref specularTextureCoordinates()
* instead.
*/
CORRADE_DEPRECATED("use specularTextureCoordinates() instead") UnsignedInt specularCoordinateSet() const {
return specularTextureCoordinates();
}
#endif
/** /**
* @brief Normal texture ID * @brief Normal texture ID
@ -295,12 +337,23 @@ class MAGNUM_TRADE_EXPORT PhongMaterialData: public AbstractMaterialData {
/** /**
* @brief Normal texture coordinate set * @brief Normal texture coordinate set
* @m_since{2020,06} * @m_since_latest
* *
* Available only if the material has @ref Flag::NormalTexture. * Available only if the material has @ref Flag::NormalTexture.
* @see @ref flags(), @ref AbstractImporter::texture() * @see @ref flags(), @ref AbstractImporter::texture()
*/ */
UnsignedInt normalCoordinateSet() const; UnsignedInt normalTextureCoordinates() const;
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @brief @copybrief normalTextureCoordinates()
* @m_deprecated_since_latest Use @ref normalTextureCoordinates()
* instead.
*/
CORRADE_DEPRECATED("use normalTextureCoordinates() instead") UnsignedInt normalCoordinateSet() const {
return normalTextureCoordinates();
}
#endif
/** /**
* @brief Texture coordinate transformation matrix * @brief Texture coordinate transformation matrix
@ -320,15 +373,15 @@ class MAGNUM_TRADE_EXPORT PhongMaterialData: public AbstractMaterialData {
and thus better noticeable */ and thus better noticeable */
Color4 _ambientColor; Color4 _ambientColor;
UnsignedInt _ambientTexture{~UnsignedInt{}}; UnsignedInt _ambientTexture{~UnsignedInt{}};
UnsignedInt _ambientCoordinateSet; UnsignedInt _ambientTextureCoordinates;
Color4 _diffuseColor; Color4 _diffuseColor;
UnsignedInt _diffuseTexture{~UnsignedInt{}}; UnsignedInt _diffuseTexture{~UnsignedInt{}};
UnsignedInt _diffuseCoordinateSet; UnsignedInt _diffuseTextureCoordinates;
Color4 _specularColor; Color4 _specularColor;
UnsignedInt _specularTexture{~UnsignedInt{}}; UnsignedInt _specularTexture{~UnsignedInt{}};
UnsignedInt _specularCoordinateSet; UnsignedInt _specularTextureCoordinates;
UnsignedInt _normalTexture{~UnsignedInt{}}; UnsignedInt _normalTexture{~UnsignedInt{}};
UnsignedInt _normalCoordinateSet; UnsignedInt _normalTextureCoordinates;
Matrix3 _textureMatrix; Matrix3 _textureMatrix;
Float _shininess; Float _shininess;
}; };

64
src/Magnum/Trade/Test/MaterialDataTest.cpp

@ -38,10 +38,10 @@ class MaterialDataTest: public TestSuite::Tester {
void constructPhong(); void constructPhong();
void constructPhongTextured(); void constructPhongTextured();
void constructPhongTexturedTextureTransform(); void constructPhongTexturedTextureTransform();
void constructPhongTexturedCoordinateSets(); void constructPhongTexturedCoordinates();
void constructPhongTextureTransformNoTextures(); void constructPhongTextureTransformNoTextures();
void constructPhongNoTextureTransformationFlag(); void constructPhongNoTextureTransformationFlag();
void constructPhongNoTextureCoordinateSetsFlag(); void constructPhongNoTextureCoordinatesFlag();
void constructCopy(); void constructCopy();
void constructMovePhong(); void constructMovePhong();
@ -60,10 +60,10 @@ MaterialDataTest::MaterialDataTest() {
addTests({&MaterialDataTest::constructPhong, addTests({&MaterialDataTest::constructPhong,
&MaterialDataTest::constructPhongTextured, &MaterialDataTest::constructPhongTextured,
&MaterialDataTest::constructPhongTexturedTextureTransform, &MaterialDataTest::constructPhongTexturedTextureTransform,
&MaterialDataTest::constructPhongTexturedCoordinateSets, &MaterialDataTest::constructPhongTexturedCoordinates,
&MaterialDataTest::constructPhongTextureTransformNoTextures, &MaterialDataTest::constructPhongTextureTransformNoTextures,
&MaterialDataTest::constructPhongNoTextureTransformationFlag, &MaterialDataTest::constructPhongNoTextureTransformationFlag,
&MaterialDataTest::constructPhongNoTextureCoordinateSetsFlag, &MaterialDataTest::constructPhongNoTextureCoordinatesFlag,
&MaterialDataTest::constructCopy, &MaterialDataTest::constructCopy,
&MaterialDataTest::constructMovePhong, &MaterialDataTest::constructMovePhong,
@ -115,11 +115,11 @@ void MaterialDataTest::constructPhongTextured() {
CORRADE_COMPARE(data.flags(), PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::SpecularTexture); CORRADE_COMPARE(data.flags(), PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::SpecularTexture);
CORRADE_COMPARE(data.ambientColor(), 0x111111_rgbf); CORRADE_COMPARE(data.ambientColor(), 0x111111_rgbf);
CORRADE_COMPARE(data.ambientTexture(), 42); CORRADE_COMPARE(data.ambientTexture(), 42);
CORRADE_COMPARE(data.ambientCoordinateSet(), 0); CORRADE_COMPARE(data.ambientTextureCoordinates(), 0);
CORRADE_COMPARE(data.diffuseColor(), 0xeebbff_rgbf); CORRADE_COMPARE(data.diffuseColor(), 0xeebbff_rgbf);
CORRADE_COMPARE(data.specularColor(), 0xacabad_rgbf); CORRADE_COMPARE(data.specularColor(), 0xacabad_rgbf);
CORRADE_COMPARE(data.specularTexture(), 17); CORRADE_COMPARE(data.specularTexture(), 17);
CORRADE_COMPARE(data.specularCoordinateSet(), 0); CORRADE_COMPARE(data.specularTextureCoordinates(), 0);
CORRADE_COMPARE(data.textureMatrix(), Matrix3{}); CORRADE_COMPARE(data.textureMatrix(), Matrix3{});
CORRADE_COMPARE(data.alphaMode(), MaterialAlphaMode::Blend); CORRADE_COMPARE(data.alphaMode(), MaterialAlphaMode::Blend);
CORRADE_COMPARE(data.alphaMask(), 0.37f); CORRADE_COMPARE(data.alphaMask(), 0.37f);
@ -153,12 +153,12 @@ void MaterialDataTest::constructPhongTexturedTextureTransform() {
CORRADE_COMPARE(data.importerState(), &a); CORRADE_COMPARE(data.importerState(), &a);
} }
void MaterialDataTest::constructPhongTexturedCoordinateSets() { void MaterialDataTest::constructPhongTexturedCoordinates() {
using namespace Math::Literals; using namespace Math::Literals;
const int a{}; const int a{};
PhongMaterialData data{ PhongMaterialData data{
PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::SpecularTexture|PhongMaterialData::Flag::TextureCoordinateSets, PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::SpecularTexture|PhongMaterialData::Flag::TextureCoordinates,
0x111111_rgbf, 42, 3, 0x111111_rgbf, 42, 3,
0xeebbff_rgbf, {}, 0, 0xeebbff_rgbf, {}, 0,
0xacabad_rgbf, 17, 1, 0xacabad_rgbf, 17, 1,
@ -166,14 +166,14 @@ void MaterialDataTest::constructPhongTexturedCoordinateSets() {
MaterialAlphaMode::Blend, 0.37f, 96.0f, &a}; MaterialAlphaMode::Blend, 0.37f, 96.0f, &a};
CORRADE_COMPARE(data.type(), MaterialType::Phong); CORRADE_COMPARE(data.type(), MaterialType::Phong);
CORRADE_COMPARE(data.flags(), PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::SpecularTexture|PhongMaterialData::Flag::TextureCoordinateSets); CORRADE_COMPARE(data.flags(), PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::SpecularTexture|PhongMaterialData::Flag::TextureCoordinates);
CORRADE_COMPARE(data.ambientColor(), 0x111111_rgbf); CORRADE_COMPARE(data.ambientColor(), 0x111111_rgbf);
CORRADE_COMPARE(data.ambientTexture(), 42); CORRADE_COMPARE(data.ambientTexture(), 42);
CORRADE_COMPARE(data.ambientCoordinateSet(), 3); CORRADE_COMPARE(data.ambientTextureCoordinates(), 3);
CORRADE_COMPARE(data.diffuseColor(), 0xeebbff_rgbf); CORRADE_COMPARE(data.diffuseColor(), 0xeebbff_rgbf);
CORRADE_COMPARE(data.specularColor(), 0xacabad_rgbf); CORRADE_COMPARE(data.specularColor(), 0xacabad_rgbf);
CORRADE_COMPARE(data.specularTexture(), 17); CORRADE_COMPARE(data.specularTexture(), 17);
CORRADE_COMPARE(data.specularCoordinateSet(), 1); CORRADE_COMPARE(data.specularTextureCoordinates(), 1);
CORRADE_COMPARE(data.textureMatrix(), Matrix3{}); CORRADE_COMPARE(data.textureMatrix(), Matrix3{});
CORRADE_COMPARE(data.alphaMode(), MaterialAlphaMode::Blend); CORRADE_COMPARE(data.alphaMode(), MaterialAlphaMode::Blend);
CORRADE_COMPARE(data.alphaMask(), 0.37f); CORRADE_COMPARE(data.alphaMask(), 0.37f);
@ -215,7 +215,7 @@ void MaterialDataTest::constructPhongNoTextureTransformationFlag() {
"PhongMaterialData::PhongMaterialData: non-default texture matrix requires Flag::TextureTransformation to be enabled\n"); "PhongMaterialData::PhongMaterialData: non-default texture matrix requires Flag::TextureTransformation to be enabled\n");
} }
void MaterialDataTest::constructPhongNoTextureCoordinateSetsFlag() { void MaterialDataTest::constructPhongNoTextureCoordinatesFlag() {
#ifdef CORRADE_NO_ASSERT #ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif #endif
@ -228,7 +228,7 @@ void MaterialDataTest::constructPhongNoTextureCoordinateSetsFlag() {
{}, {}, 3, {}, 4, {}, {}, {}, 3, {}, 4, {},
{}, 0.5f, 80.0f}; {}, 0.5f, 80.0f};
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
"PhongMaterialData::PhongMaterialData: non-zero texture coordinate sets require Flag::TextureCoordinateSets to be enabled\n"); "PhongMaterialData::PhongMaterialData: non-zero texture coordinate sets require Flag::TextureCoordinates to be enabled\n");
} }
void MaterialDataTest::constructCopy() { void MaterialDataTest::constructCopy() {
@ -243,7 +243,7 @@ void MaterialDataTest::constructMovePhong() {
const int a{}; const int a{};
PhongMaterialData data{ PhongMaterialData data{
PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::DiffuseTexture|PhongMaterialData::Flag::SpecularTexture|PhongMaterialData::Flag::NormalTexture|PhongMaterialData::Flag::TextureTransformation|PhongMaterialData::Flag::TextureCoordinateSets, PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::DiffuseTexture|PhongMaterialData::Flag::SpecularTexture|PhongMaterialData::Flag::NormalTexture|PhongMaterialData::Flag::TextureTransformation|PhongMaterialData::Flag::TextureCoordinates,
0x111111_rgbf, 1, 0, 0x111111_rgbf, 1, 0,
0xeebbff_rgbf, 42, 1, 0xeebbff_rgbf, 42, 1,
0xacabad_rgbf, 24, 2, 17, 3, 0xacabad_rgbf, 24, 2, 17, 3,
@ -252,18 +252,18 @@ void MaterialDataTest::constructMovePhong() {
PhongMaterialData b{std::move(data)}; PhongMaterialData b{std::move(data)};
CORRADE_COMPARE(b.type(), MaterialType::Phong); CORRADE_COMPARE(b.type(), MaterialType::Phong);
CORRADE_COMPARE(b.flags(), PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::DiffuseTexture|PhongMaterialData::Flag::SpecularTexture|PhongMaterialData::Flag::NormalTexture|PhongMaterialData::Flag::TextureTransformation|PhongMaterialData::Flag::TextureCoordinateSets); CORRADE_COMPARE(b.flags(), PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::DiffuseTexture|PhongMaterialData::Flag::SpecularTexture|PhongMaterialData::Flag::NormalTexture|PhongMaterialData::Flag::TextureTransformation|PhongMaterialData::Flag::TextureCoordinates);
CORRADE_COMPARE(b.ambientColor(), 0x111111_rgbf); CORRADE_COMPARE(b.ambientColor(), 0x111111_rgbf);
CORRADE_COMPARE(b.ambientTexture(), 1); CORRADE_COMPARE(b.ambientTexture(), 1);
CORRADE_COMPARE(b.ambientCoordinateSet(), 0); CORRADE_COMPARE(b.ambientTextureCoordinates(), 0);
CORRADE_COMPARE(b.diffuseColor(), 0xeebbff_rgbf); CORRADE_COMPARE(b.diffuseColor(), 0xeebbff_rgbf);
CORRADE_COMPARE(b.diffuseTexture(), 42); CORRADE_COMPARE(b.diffuseTexture(), 42);
CORRADE_COMPARE(b.diffuseCoordinateSet(), 1); CORRADE_COMPARE(b.diffuseTextureCoordinates(), 1);
CORRADE_COMPARE(b.specularColor(), 0xacabad_rgbf); CORRADE_COMPARE(b.specularColor(), 0xacabad_rgbf);
CORRADE_COMPARE(b.specularTexture(), 24); CORRADE_COMPARE(b.specularTexture(), 24);
CORRADE_COMPARE(b.specularCoordinateSet(), 2); CORRADE_COMPARE(b.specularTextureCoordinates(), 2);
CORRADE_COMPARE(b.normalTexture(), 17); CORRADE_COMPARE(b.normalTexture(), 17);
CORRADE_COMPARE(b.normalCoordinateSet(), 3); CORRADE_COMPARE(b.normalTextureCoordinates(), 3);
CORRADE_COMPARE(b.textureMatrix(), Matrix3::rotation(90.0_degf)); CORRADE_COMPARE(b.textureMatrix(), Matrix3::rotation(90.0_degf));
CORRADE_COMPARE(b.alphaMode(), MaterialAlphaMode::Blend); CORRADE_COMPARE(b.alphaMode(), MaterialAlphaMode::Blend);
CORRADE_COMPARE(b.alphaMask(), 0.55f); CORRADE_COMPARE(b.alphaMask(), 0.55f);
@ -279,18 +279,18 @@ void MaterialDataTest::constructMovePhong() {
d = std::move(b); d = std::move(b);
CORRADE_COMPARE(d.type(), MaterialType::Phong); CORRADE_COMPARE(d.type(), MaterialType::Phong);
CORRADE_COMPARE(d.flags(), PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::DiffuseTexture|PhongMaterialData::Flag::SpecularTexture|PhongMaterialData::Flag::NormalTexture|PhongMaterialData::Flag::TextureTransformation|PhongMaterialData::Flag::TextureCoordinateSets); CORRADE_COMPARE(d.flags(), PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::DiffuseTexture|PhongMaterialData::Flag::SpecularTexture|PhongMaterialData::Flag::NormalTexture|PhongMaterialData::Flag::TextureTransformation|PhongMaterialData::Flag::TextureCoordinates);
CORRADE_COMPARE(d.ambientColor(), 0x111111_rgbf); CORRADE_COMPARE(d.ambientColor(), 0x111111_rgbf);
CORRADE_COMPARE(d.ambientTexture(), 1); CORRADE_COMPARE(d.ambientTexture(), 1);
CORRADE_COMPARE(d.ambientCoordinateSet(), 0); CORRADE_COMPARE(d.ambientTextureCoordinates(), 0);
CORRADE_COMPARE(d.diffuseColor(), 0xeebbff_rgbf); CORRADE_COMPARE(d.diffuseColor(), 0xeebbff_rgbf);
CORRADE_COMPARE(d.diffuseTexture(), 42); CORRADE_COMPARE(d.diffuseTexture(), 42);
CORRADE_COMPARE(d.diffuseCoordinateSet(), 1); CORRADE_COMPARE(d.diffuseTextureCoordinates(), 1);
CORRADE_COMPARE(d.specularColor(), 0xacabad_rgbf); CORRADE_COMPARE(d.specularColor(), 0xacabad_rgbf);
CORRADE_COMPARE(d.specularTexture(), 24); CORRADE_COMPARE(d.specularTexture(), 24);
CORRADE_COMPARE(d.specularCoordinateSet(), 2); CORRADE_COMPARE(d.specularTextureCoordinates(), 2);
CORRADE_COMPARE(d.normalTexture(), 17); CORRADE_COMPARE(d.normalTexture(), 17);
CORRADE_COMPARE(d.normalCoordinateSet(), 3); CORRADE_COMPARE(d.normalTextureCoordinates(), 3);
CORRADE_COMPARE(d.textureMatrix(), Matrix3::rotation(90.0_degf)); CORRADE_COMPARE(d.textureMatrix(), Matrix3::rotation(90.0_degf));
CORRADE_COMPARE(d.alphaMode(), MaterialAlphaMode::Blend); CORRADE_COMPARE(d.alphaMode(), MaterialAlphaMode::Blend);
CORRADE_COMPARE(d.alphaMask(), 0.55f); CORRADE_COMPARE(d.alphaMask(), 0.55f);
@ -315,22 +315,22 @@ void MaterialDataTest::accessInvalidTextures() {
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
a.ambientTexture(); a.ambientTexture();
a.ambientCoordinateSet(); a.ambientTextureCoordinates();
a.diffuseTexture(); a.diffuseTexture();
a.diffuseCoordinateSet(); a.diffuseTextureCoordinates();
a.specularTexture(); a.specularTexture();
a.specularCoordinateSet(); a.specularTextureCoordinates();
a.normalTexture(); a.normalTexture();
a.normalCoordinateSet(); a.normalTextureCoordinates();
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
"Trade::PhongMaterialData::ambientTexture(): the material doesn't have an ambient texture\n" "Trade::PhongMaterialData::ambientTexture(): the material doesn't have an ambient texture\n"
"Trade::PhongMaterialData::ambientCoordinateSet(): the material doesn't have an ambient texture\n" "Trade::PhongMaterialData::ambientTextureCoordinates(): the material doesn't have an ambient texture\n"
"Trade::PhongMaterialData::diffuseTexture(): the material doesn't have a diffuse texture\n" "Trade::PhongMaterialData::diffuseTexture(): the material doesn't have a diffuse texture\n"
"Trade::PhongMaterialData::diffuseCoordinateSet(): the material doesn't have a diffuse texture\n" "Trade::PhongMaterialData::diffuseTextureCoordinates(): the material doesn't have a diffuse texture\n"
"Trade::PhongMaterialData::specularTexture(): the material doesn't have a specular texture\n" "Trade::PhongMaterialData::specularTexture(): the material doesn't have a specular texture\n"
"Trade::PhongMaterialData::specularCoordinateSet(): the material doesn't have a specular texture\n" "Trade::PhongMaterialData::specularTextureCoordinates(): the material doesn't have a specular texture\n"
"Trade::PhongMaterialData::normalTexture(): the material doesn't have a normal texture\n" "Trade::PhongMaterialData::normalTexture(): the material doesn't have a normal texture\n"
"Trade::PhongMaterialData::normalCoordinateSet(): the material doesn't have a normal texture\n"); "Trade::PhongMaterialData::normalTextureCoordinates(): the material doesn't have a normal texture\n");
} }
void MaterialDataTest::debugType() { void MaterialDataTest::debugType() {

Loading…
Cancel
Save