|
|
|
|
@ -47,6 +47,10 @@ class MaterialDataTest: public TestSuite::Tester {
|
|
|
|
|
void accessInvalidTextures(); |
|
|
|
|
|
|
|
|
|
void debugType(); |
|
|
|
|
void debugFlag(); |
|
|
|
|
void debugFlags(); |
|
|
|
|
void debugAlphaMode(); |
|
|
|
|
|
|
|
|
|
void debugPhongFlag(); |
|
|
|
|
void debugPhongFlags(); |
|
|
|
|
}; |
|
|
|
|
@ -65,6 +69,10 @@ MaterialDataTest::MaterialDataTest() {
|
|
|
|
|
&MaterialDataTest::accessInvalidTextures, |
|
|
|
|
|
|
|
|
|
&MaterialDataTest::debugType, |
|
|
|
|
&MaterialDataTest::debugFlag, |
|
|
|
|
&MaterialDataTest::debugFlags, |
|
|
|
|
&MaterialDataTest::debugAlphaMode, |
|
|
|
|
|
|
|
|
|
&MaterialDataTest::debugPhongFlag, |
|
|
|
|
&MaterialDataTest::debugPhongFlags}); |
|
|
|
|
} |
|
|
|
|
@ -73,14 +81,17 @@ void MaterialDataTest::constructPhong() {
|
|
|
|
|
using namespace Math::Literals; |
|
|
|
|
|
|
|
|
|
const int a{}; |
|
|
|
|
PhongMaterialData data{{}, 80.0f, &a}; |
|
|
|
|
PhongMaterialData data{{}, MaterialAlphaMode::Mask, 0.3f, 80.0f, &a}; |
|
|
|
|
data.ambientColor() = 0xccffbb_rgbf; |
|
|
|
|
data.diffuseColor() = 0xeebbff_rgbf; |
|
|
|
|
data.specularColor() = 0xacabad_rgbf; |
|
|
|
|
|
|
|
|
|
const PhongMaterialData& cdata = data; |
|
|
|
|
|
|
|
|
|
CORRADE_VERIFY(cdata.flags() == PhongMaterialData::Flags{}); |
|
|
|
|
CORRADE_COMPARE(cdata.type(), MaterialType::Phong); |
|
|
|
|
CORRADE_COMPARE(cdata.flags(), PhongMaterialData::Flags{}); |
|
|
|
|
CORRADE_COMPARE(cdata.alphaMode(), MaterialAlphaMode::Mask); |
|
|
|
|
CORRADE_COMPARE(cdata.alphaMask(), 0.3f); |
|
|
|
|
CORRADE_COMPARE(cdata.ambientColor(), 0xccffbb_rgbf); |
|
|
|
|
CORRADE_COMPARE(cdata.diffuseColor(), 0xeebbff_rgbf); |
|
|
|
|
CORRADE_COMPARE(cdata.specularColor(), 0xacabad_rgbf); |
|
|
|
|
@ -92,14 +103,17 @@ void MaterialDataTest::constructPhongAmbientTexture() {
|
|
|
|
|
using namespace Math::Literals; |
|
|
|
|
|
|
|
|
|
const int a{}; |
|
|
|
|
PhongMaterialData data{PhongMaterialData::Flag::AmbientTexture, 80.0f, &a}; |
|
|
|
|
PhongMaterialData data{PhongMaterialData::Flag::AmbientTexture, MaterialAlphaMode::Mask, 0.3f, 80.0f, &a}; |
|
|
|
|
data.ambientTexture() = 42; |
|
|
|
|
data.diffuseColor() = 0xeebbff_rgbf; |
|
|
|
|
data.specularColor() = 0xacabad_rgbf; |
|
|
|
|
|
|
|
|
|
const PhongMaterialData& cdata = data; |
|
|
|
|
|
|
|
|
|
CORRADE_VERIFY(cdata.flags() == PhongMaterialData::Flag::AmbientTexture); |
|
|
|
|
CORRADE_COMPARE(cdata.type(), MaterialType::Phong); |
|
|
|
|
CORRADE_COMPARE(cdata.flags(), PhongMaterialData::Flag::AmbientTexture); |
|
|
|
|
CORRADE_COMPARE(cdata.alphaMode(), MaterialAlphaMode::Mask); |
|
|
|
|
CORRADE_COMPARE(cdata.alphaMask(), 0.3f); |
|
|
|
|
CORRADE_COMPARE(cdata.ambientTexture(), 42); |
|
|
|
|
CORRADE_COMPARE(cdata.diffuseColor(), 0xeebbff_rgbf); |
|
|
|
|
CORRADE_COMPARE(cdata.specularColor(), 0xacabad_rgbf); |
|
|
|
|
@ -111,14 +125,17 @@ void MaterialDataTest::constructPhongDiffuseTexture() {
|
|
|
|
|
using namespace Math::Literals; |
|
|
|
|
|
|
|
|
|
const int a{}; |
|
|
|
|
PhongMaterialData data{PhongMaterialData::Flag::DiffuseTexture, 80.0f, &a}; |
|
|
|
|
PhongMaterialData data{PhongMaterialData::Flag::DiffuseTexture|PhongMaterialData::Flag::DoubleSided, MaterialAlphaMode::Opaque, 0.0f, 80.0f, &a}; |
|
|
|
|
data.ambientColor() = 0xccffbb_rgbf; |
|
|
|
|
data.diffuseTexture() = 42; |
|
|
|
|
data.specularColor() = 0xacabad_rgbf; |
|
|
|
|
|
|
|
|
|
const PhongMaterialData& cdata = data; |
|
|
|
|
|
|
|
|
|
CORRADE_VERIFY(cdata.flags() == PhongMaterialData::Flag::DiffuseTexture); |
|
|
|
|
CORRADE_COMPARE(cdata.type(), MaterialType::Phong); |
|
|
|
|
CORRADE_COMPARE(cdata.flags(), PhongMaterialData::Flag::DiffuseTexture|PhongMaterialData::Flag::DoubleSided); |
|
|
|
|
CORRADE_COMPARE(cdata.alphaMode(), MaterialAlphaMode::Opaque); |
|
|
|
|
CORRADE_COMPARE(cdata.alphaMask(), 0.0f); |
|
|
|
|
CORRADE_COMPARE(cdata.ambientColor(), 0xccffbb_rgbf); |
|
|
|
|
CORRADE_COMPARE(cdata.diffuseTexture(), 42); |
|
|
|
|
CORRADE_COMPARE(cdata.specularColor(), 0xacabad_rgbf); |
|
|
|
|
@ -130,14 +147,17 @@ void MaterialDataTest::constructPhongSpecularTexture() {
|
|
|
|
|
using namespace Math::Literals; |
|
|
|
|
|
|
|
|
|
const int a{}; |
|
|
|
|
PhongMaterialData data{PhongMaterialData::Flag::SpecularTexture, 30.0f, &a}; |
|
|
|
|
PhongMaterialData data{PhongMaterialData::Flag::SpecularTexture, MaterialAlphaMode::Blend, 1.0f, 30.0f, &a}; |
|
|
|
|
data.ambientColor() = 0xccffbb_rgbf; |
|
|
|
|
data.diffuseColor() = 0xeebbff_rgbf; |
|
|
|
|
data.specularTexture() = 42; |
|
|
|
|
|
|
|
|
|
const PhongMaterialData& cdata = data; |
|
|
|
|
|
|
|
|
|
CORRADE_VERIFY(cdata.flags() == PhongMaterialData::Flag::SpecularTexture); |
|
|
|
|
CORRADE_COMPARE(cdata.type(), MaterialType::Phong); |
|
|
|
|
CORRADE_COMPARE(cdata.flags(), PhongMaterialData::Flag::SpecularTexture); |
|
|
|
|
CORRADE_COMPARE(cdata.alphaMode(), MaterialAlphaMode::Blend); |
|
|
|
|
CORRADE_COMPARE(cdata.alphaMask(), 1.0f); |
|
|
|
|
CORRADE_COMPARE(cdata.ambientColor(), 0xccffbb_rgbf); |
|
|
|
|
CORRADE_COMPARE(cdata.diffuseColor(), 0xeebbff_rgbf); |
|
|
|
|
CORRADE_COMPARE(cdata.specularTexture(), 42); |
|
|
|
|
@ -156,14 +176,14 @@ void MaterialDataTest::constructMovePhongNoAmbientTexture() {
|
|
|
|
|
using namespace Math::Literals; |
|
|
|
|
|
|
|
|
|
const int a{}; |
|
|
|
|
PhongMaterialData data{PhongMaterialData::Flag::DiffuseTexture|PhongMaterialData::Flag::SpecularTexture, 80.0f, &a}; |
|
|
|
|
PhongMaterialData data{PhongMaterialData::Flag::DiffuseTexture|PhongMaterialData::Flag::SpecularTexture, {}, {}, 80.0f, &a}; |
|
|
|
|
data.ambientColor() = 0xccffbb_rgbf; |
|
|
|
|
data.diffuseTexture() = 42; |
|
|
|
|
data.specularTexture() = 13; |
|
|
|
|
|
|
|
|
|
PhongMaterialData b{std::move(data)}; |
|
|
|
|
|
|
|
|
|
CORRADE_VERIFY(b.flags() == (PhongMaterialData::Flag::DiffuseTexture|PhongMaterialData::Flag::SpecularTexture)); |
|
|
|
|
CORRADE_COMPARE(b.flags(), (PhongMaterialData::Flag::DiffuseTexture|PhongMaterialData::Flag::SpecularTexture)); |
|
|
|
|
CORRADE_COMPARE(b.ambientColor(), 0xccffbb_rgbf); |
|
|
|
|
CORRADE_COMPARE(b.diffuseTexture(), 42); |
|
|
|
|
CORRADE_COMPARE(b.specularTexture(), 13); |
|
|
|
|
@ -171,13 +191,13 @@ void MaterialDataTest::constructMovePhongNoAmbientTexture() {
|
|
|
|
|
CORRADE_COMPARE(b.importerState(), &a); |
|
|
|
|
|
|
|
|
|
const int c{}; |
|
|
|
|
PhongMaterialData d{PhongMaterialData::Flag::AmbientTexture, 100.0f, &c}; |
|
|
|
|
PhongMaterialData d{PhongMaterialData::Flag::AmbientTexture, {}, {}, 100.0f, &c}; |
|
|
|
|
d.ambientTexture() = 42; |
|
|
|
|
d.diffuseColor() = 0xeebbff_rgbf; |
|
|
|
|
d.specularColor() = 0xacabad_rgbf; |
|
|
|
|
d = std::move(b); |
|
|
|
|
|
|
|
|
|
CORRADE_VERIFY(d.flags() == (PhongMaterialData::Flag::DiffuseTexture|PhongMaterialData::Flag::SpecularTexture)); |
|
|
|
|
CORRADE_COMPARE(d.flags(), PhongMaterialData::Flag::DiffuseTexture|PhongMaterialData::Flag::SpecularTexture); |
|
|
|
|
CORRADE_COMPARE(d.ambientColor(), 0xccffbb_rgbf); |
|
|
|
|
CORRADE_COMPARE(d.diffuseTexture(), 42); |
|
|
|
|
CORRADE_COMPARE(d.specularTexture(), 13); |
|
|
|
|
@ -189,14 +209,14 @@ void MaterialDataTest::constructMovePhongNoDiffuseTexture() {
|
|
|
|
|
using namespace Math::Literals; |
|
|
|
|
|
|
|
|
|
const int a{}; |
|
|
|
|
PhongMaterialData data{PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::SpecularTexture, 80.0f, &a}; |
|
|
|
|
PhongMaterialData data{PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::SpecularTexture, {}, {}, 80.0f, &a}; |
|
|
|
|
data.ambientTexture() = 42; |
|
|
|
|
data.diffuseColor() = 0xeebbff_rgbf; |
|
|
|
|
data.specularTexture() = 13; |
|
|
|
|
|
|
|
|
|
PhongMaterialData b{std::move(data)}; |
|
|
|
|
|
|
|
|
|
CORRADE_VERIFY(b.flags() == (PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::SpecularTexture)); |
|
|
|
|
CORRADE_COMPARE(b.flags(), PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::SpecularTexture); |
|
|
|
|
CORRADE_COMPARE(b.ambientTexture(), 42); |
|
|
|
|
CORRADE_COMPARE(b.diffuseColor(), 0xeebbff_rgbf); |
|
|
|
|
CORRADE_COMPARE(b.specularTexture(), 13); |
|
|
|
|
@ -204,13 +224,13 @@ void MaterialDataTest::constructMovePhongNoDiffuseTexture() {
|
|
|
|
|
CORRADE_COMPARE(b.importerState(), &a); |
|
|
|
|
|
|
|
|
|
const int c{}; |
|
|
|
|
PhongMaterialData d{PhongMaterialData::Flag::DiffuseTexture, 100.0f, &c}; |
|
|
|
|
PhongMaterialData d{PhongMaterialData::Flag::DiffuseTexture, {}, {}, 100.0f, &c}; |
|
|
|
|
d.ambientColor() = 0xccffbb_rgbf; |
|
|
|
|
d.diffuseTexture() = 42; |
|
|
|
|
d.specularColor() = 0xacabad_rgbf; |
|
|
|
|
d = std::move(b); |
|
|
|
|
|
|
|
|
|
CORRADE_VERIFY(d.flags() == (PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::SpecularTexture)); |
|
|
|
|
CORRADE_COMPARE(d.flags(), PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::SpecularTexture); |
|
|
|
|
CORRADE_COMPARE(d.ambientTexture(), 42); |
|
|
|
|
CORRADE_COMPARE(d.diffuseColor(), 0xeebbff_rgbf); |
|
|
|
|
CORRADE_COMPARE(d.specularTexture(), 13); |
|
|
|
|
@ -222,14 +242,14 @@ void MaterialDataTest::constructMovePhongNoSpecularTexture() {
|
|
|
|
|
using namespace Math::Literals; |
|
|
|
|
|
|
|
|
|
const int a{}; |
|
|
|
|
PhongMaterialData data{PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::DiffuseTexture, 80.0f, &a}; |
|
|
|
|
PhongMaterialData data{PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::DiffuseTexture, {}, {}, 80.0f, &a}; |
|
|
|
|
data.ambientTexture() = 13; |
|
|
|
|
data.diffuseTexture() = 42; |
|
|
|
|
data.specularColor() = 0xacabad_rgbf; |
|
|
|
|
|
|
|
|
|
PhongMaterialData b{std::move(data)}; |
|
|
|
|
|
|
|
|
|
CORRADE_VERIFY(b.flags() == (PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::DiffuseTexture)); |
|
|
|
|
CORRADE_COMPARE(b.flags(), PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::DiffuseTexture); |
|
|
|
|
CORRADE_COMPARE(b.ambientTexture(), 13); |
|
|
|
|
CORRADE_COMPARE(b.diffuseTexture(), 42); |
|
|
|
|
CORRADE_COMPARE(b.specularColor(), 0xacabad_rgbf); |
|
|
|
|
@ -237,13 +257,13 @@ void MaterialDataTest::constructMovePhongNoSpecularTexture() {
|
|
|
|
|
CORRADE_COMPARE(b.importerState(), &a); |
|
|
|
|
|
|
|
|
|
const int c{}; |
|
|
|
|
PhongMaterialData d{PhongMaterialData::Flag::SpecularTexture, 30.0f, &c}; |
|
|
|
|
PhongMaterialData d{PhongMaterialData::Flag::SpecularTexture, {}, {}, 30.0f, &c}; |
|
|
|
|
d.ambientColor() = 0xccffbb_rgbf; |
|
|
|
|
d.diffuseColor() = 0xeebbff_rgbf; |
|
|
|
|
d.specularTexture() = 42; |
|
|
|
|
d = std::move(b); |
|
|
|
|
|
|
|
|
|
CORRADE_VERIFY(d.flags() == (PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::DiffuseTexture)); |
|
|
|
|
CORRADE_COMPARE(d.flags(), PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::DiffuseTexture); |
|
|
|
|
CORRADE_COMPARE(d.ambientTexture(), 13); |
|
|
|
|
CORRADE_COMPARE(d.diffuseTexture(), 42); |
|
|
|
|
CORRADE_COMPARE(d.specularColor(), 0xacabad_rgbf); |
|
|
|
|
@ -255,7 +275,7 @@ void MaterialDataTest::accessInvalidColors() {
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
Error redirectError{&out}; |
|
|
|
|
|
|
|
|
|
PhongMaterialData a{PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::DiffuseTexture|PhongMaterialData::Flag::SpecularTexture, 80.0f}; |
|
|
|
|
PhongMaterialData a{PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::DiffuseTexture|PhongMaterialData::Flag::SpecularTexture, {}, {}, 80.0f}; |
|
|
|
|
|
|
|
|
|
a.ambientColor(); |
|
|
|
|
a.diffuseColor(); |
|
|
|
|
@ -271,7 +291,7 @@ void MaterialDataTest::accessInvalidTextures() {
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
Error redirectError{&out}; |
|
|
|
|
|
|
|
|
|
PhongMaterialData a{PhongMaterialData::Flags{}, 80.0f}; |
|
|
|
|
PhongMaterialData a{PhongMaterialData::Flags{}, {}, {}, 80.0f}; |
|
|
|
|
|
|
|
|
|
a.ambientTexture(); |
|
|
|
|
a.diffuseTexture(); |
|
|
|
|
@ -290,6 +310,27 @@ void MaterialDataTest::debugType() {
|
|
|
|
|
CORRADE_COMPARE(out.str(), "Trade::MaterialType::Phong Trade::MaterialType(0xbe)\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MaterialDataTest::debugFlag() { |
|
|
|
|
std::ostringstream out; |
|
|
|
|
|
|
|
|
|
Debug{&out} << AbstractMaterialData::Flag::DoubleSided << AbstractMaterialData::Flag(0xf0); |
|
|
|
|
CORRADE_COMPARE(out.str(), "Trade::AbstractMaterialData::Flag::DoubleSided Trade::AbstractMaterialData::Flag(0xf0)\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MaterialDataTest::debugFlags() { |
|
|
|
|
std::ostringstream out; |
|
|
|
|
|
|
|
|
|
Debug{&out} << AbstractMaterialData::Flag::DoubleSided << AbstractMaterialData::Flags{}; |
|
|
|
|
CORRADE_COMPARE(out.str(), "Trade::AbstractMaterialData::Flag::DoubleSided Trade::AbstractMaterialData::Flags{}\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MaterialDataTest::debugAlphaMode() { |
|
|
|
|
std::ostringstream out; |
|
|
|
|
|
|
|
|
|
Debug{&out} << MaterialAlphaMode::Opaque << MaterialAlphaMode(0xee); |
|
|
|
|
CORRADE_COMPARE(out.str(), "Trade::MaterialAlphaMode::Opaque Trade::MaterialAlphaMode(0xee)\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MaterialDataTest::debugPhongFlag() { |
|
|
|
|
std::ostringstream out; |
|
|
|
|
|
|
|
|
|
|