diff --git a/src/Trade/PhongMaterialData.cpp b/src/Trade/PhongMaterialData.cpp index 04c3bd749..c6bb210a9 100644 --- a/src/Trade/PhongMaterialData.cpp +++ b/src/Trade/PhongMaterialData.cpp @@ -27,33 +27,33 @@ namespace Magnum { namespace Trade { Vector3& PhongMaterialData::ambientColor() { - CORRADE_ASSERT(!(_flags & Flag::AmbientTexture), "Trade::PhongMaterialData::ambientColor(): the material has ambient texture", _ambient.color); - return _ambient.color; + CORRADE_ASSERT(!(_flags & Flag::AmbientTexture), "Trade::PhongMaterialData::ambientColor(): the material has ambient texture", _ambient.color()); + return _ambient.color(); } UnsignedInt& PhongMaterialData::ambientTexture() { - CORRADE_ASSERT(_flags & Flag::AmbientTexture, "Trade::PhongMaterialData::ambientTexture(): the material doesn't have ambient texture", _ambient.texture); - return _ambient.texture; + CORRADE_ASSERT(_flags & Flag::AmbientTexture, "Trade::PhongMaterialData::ambientTexture(): the material doesn't have ambient texture", _ambient.texture()); + return _ambient.texture(); } Vector3& PhongMaterialData::diffuseColor() { - CORRADE_ASSERT(!(_flags & Flag::DiffuseTexture), "Trade::PhongMaterialData::diffuseColor(): the material has diffuse texture", _diffuse.color); - return _diffuse.color; + CORRADE_ASSERT(!(_flags & Flag::DiffuseTexture), "Trade::PhongMaterialData::diffuseColor(): the material has diffuse texture", _diffuse.color()); + return _diffuse.color(); } UnsignedInt& PhongMaterialData::diffuseTexture() { - CORRADE_ASSERT(_flags & Flag::DiffuseTexture, "Trade::PhongMaterialData::diffuseTexture(): the material doesn't have diffuse texture", _diffuse.texture); - return _diffuse.texture; + CORRADE_ASSERT(_flags & Flag::DiffuseTexture, "Trade::PhongMaterialData::diffuseTexture(): the material doesn't have diffuse texture", _diffuse.texture()); + return _diffuse.texture(); } Vector3& PhongMaterialData::specularColor() { - CORRADE_ASSERT(!(_flags & Flag::SpecularTexture), "Trade::PhongMaterialData::specularColor(): the material has specular texture", _specular.color); - return _specular.color; + CORRADE_ASSERT(!(_flags & Flag::SpecularTexture), "Trade::PhongMaterialData::specularColor(): the material has specular texture", _specular.color()); + return _specular.color(); } UnsignedInt& PhongMaterialData::specularTexture() { - CORRADE_ASSERT(_flags & Flag::SpecularTexture, "Trade::PhongMaterialData::specularTexture(): the material doesn't have specular texture", _specular.texture); - return _specular.texture; + CORRADE_ASSERT(_flags & Flag::SpecularTexture, "Trade::PhongMaterialData::specularTexture(): the material doesn't have specular texture", _specular.texture()); + return _specular.texture(); } }} diff --git a/src/Trade/PhongMaterialData.h b/src/Trade/PhongMaterialData.h index 92ef09a49..ab65bf4f9 100644 --- a/src/Trade/PhongMaterialData.h +++ b/src/Trade/PhongMaterialData.h @@ -134,12 +134,28 @@ class MAGNUM_EXPORT PhongMaterialData: public AbstractMaterialData { Float shininess() const { return _shininess; } private: + #ifndef CORRADE_GCC45_COMPATIBILITY union Source { Source() {} - Vector3 color; - UnsignedInt texture; + public: + Vector3& color() { return color; } + UnsignedInt& texture() { return texture; } + + private: + Vector3 _color; + UnsignedInt _texture; + }; + #else + class Source { + public: + Vector3& color() { return *reinterpret_cast(&data); } + UnsignedInt& texture() { return *reinterpret_cast(&data); } + + private: + char data[sizeof(Vector3)]; }; + #endif Source _ambient, _diffuse,