From 9b21db073794e90c28546626bb57e0ef98362019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 16 Sep 2019 11:08:33 +0200 Subject: [PATCH] GL: don't expose half float attributes on WebGL 1. They weren't in the docs but in the internals. That's wrong. --- src/Magnum/GL/Attribute.cpp | 12 ++++++++++++ src/Magnum/GL/Attribute.h | 6 ++++++ src/Magnum/GL/Test/AttributeTest.cpp | 18 +++++++++++++----- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/Magnum/GL/Attribute.cpp b/src/Magnum/GL/Attribute.cpp index bcce98ba2..129ed92c8 100644 --- a/src/Magnum/GL/Attribute.cpp +++ b/src/Magnum/GL/Attribute.cpp @@ -37,7 +37,9 @@ UnsignedInt FloatAttribute::size(GLint components, DataType dataType) { return components; case DataType::UnsignedShort: case DataType::Short: + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case DataType::HalfFloat: + #endif return 2*components; case DataType::UnsignedInt: case DataType::Int: @@ -88,7 +90,9 @@ UnsignedInt Attribute>::size(GLint components, DataType d return components; case DataType::UnsignedShort: case DataType::Short: + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case DataType::HalfFloat: + #endif return 2*components; case DataType::UnsignedInt: case DataType::Int: @@ -117,7 +121,9 @@ UnsignedInt Attribute>::size(GLint components, DataType d return components; case DataType::UnsignedShort: case DataType::Short: + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case DataType::HalfFloat: + #endif return 2*components; case DataType::UnsignedInt: case DataType::Int: @@ -259,7 +265,9 @@ Debug& operator<<(Debug& debug, FloatAttribute::DataType value) { _c(Short) _c(UnsignedInt) _c(Int) + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) _c(HalfFloat) + #endif _c(Float) #ifndef MAGNUM_TARGET_GLES _c(Double) @@ -314,7 +322,9 @@ Debug& operator<<(Debug& debug, Attribute>::DataType valu _c(Short) _c(UnsignedInt) _c(Int) + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) _c(HalfFloat) + #endif _c(Float) #ifndef MAGNUM_TARGET_GLES _c(Double) @@ -337,7 +347,9 @@ Debug& operator<<(Debug& debug, Attribute>::DataType valu _c(Short) _c(UnsignedInt) _c(Int) + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) _c(HalfFloat) + #endif _c(Float) #ifndef MAGNUM_TARGET_GLES _c(Double) diff --git a/src/Magnum/GL/Attribute.h b/src/Magnum/GL/Attribute.h index 1f5590d62..3d2a7f1df 100644 --- a/src/Magnum/GL/Attribute.h +++ b/src/Magnum/GL/Attribute.h @@ -607,11 +607,13 @@ struct FloatAttribute { Short = GL_SHORT, UnsignedInt = GL_UNSIGNED_INT, Int = GL_INT, + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #ifndef MAGNUM_TARGET_GLES2 HalfFloat = GL_HALF_FLOAT, #else HalfFloat = GL_HALF_FLOAT_OES, #endif + #endif Float = GL_FLOAT #ifndef MAGNUM_TARGET_GLES @@ -705,11 +707,13 @@ template<> struct Attribute>: SizedAttribute<1, 3> { Short = GL_SHORT, UnsignedInt = GL_UNSIGNED_INT, Int = GL_INT, + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #ifndef MAGNUM_TARGET_GLES2 HalfFloat = GL_HALF_FLOAT, #else HalfFloat = GL_HALF_FLOAT_OES, #endif + #endif Float = GL_FLOAT #ifndef MAGNUM_TARGET_GLES @@ -751,11 +755,13 @@ template<> struct Attribute> { Short = GL_SHORT, UnsignedInt = GL_UNSIGNED_INT, Int = GL_INT, + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #ifndef MAGNUM_TARGET_GLES2 HalfFloat = GL_HALF_FLOAT, #else HalfFloat = GL_HALF_FLOAT_OES, #endif + #endif Float = GL_FLOAT #ifndef MAGNUM_TARGET_GLES , diff --git a/src/Magnum/GL/Test/AttributeTest.cpp b/src/Magnum/GL/Test/AttributeTest.cpp index 3aeead016..fe103306b 100644 --- a/src/Magnum/GL/Test/AttributeTest.cpp +++ b/src/Magnum/GL/Test/AttributeTest.cpp @@ -276,9 +276,12 @@ void AttributeTest::attributeVector4() { #ifndef MAGNUM_TARGET_GLES Attribute a(Attribute::DataType::UnsignedInt2101010Rev); CORRADE_COMPARE(a.vectorSize(), 4); - #else + #elif !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) Attribute a(Attribute::DataType::HalfFloat); CORRADE_COMPARE(a.vectorSize(), 8); + #else + Attribute a(Attribute::DataType::Float); + CORRADE_COMPARE(a.vectorSize(), 16); #endif } @@ -424,8 +427,13 @@ void AttributeTest::debugDataTypeFloat() { typedef Attribute<3, Float> Attribute; std::ostringstream out; + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) Debug{&out} << Attribute::DataType::HalfFloat << Attribute::DataType(0xdead); CORRADE_COMPARE(out.str(), "GL::Attribute::DataType::HalfFloat GL::Attribute::DataType(0xdead)\n"); + #else + Debug{&out} << Attribute::DataType::Float << Attribute::DataType(0xdead); + CORRADE_COMPARE(out.str(), "GL::Attribute::DataType::Float GL::Attribute::DataType(0xdead)\n"); + #endif } #ifndef MAGNUM_TARGET_GLES2 @@ -452,16 +460,16 @@ void AttributeTest::debugDataTypeVector3() { typedef Attribute<3, Vector3> Attribute; std::ostringstream out; - Debug{&out} << Attribute::DataType::HalfFloat << Attribute::DataType(0xdead); - CORRADE_COMPARE(out.str(), "GL::Attribute::DataType::HalfFloat GL::Attribute::DataType(0xdead)\n"); + Debug{&out} << Attribute::DataType::Float << Attribute::DataType(0xdead); + CORRADE_COMPARE(out.str(), "GL::Attribute::DataType::Float GL::Attribute::DataType(0xdead)\n"); } void AttributeTest::debugDataTypeVector4() { typedef Attribute<3, Vector4> Attribute; std::ostringstream out; - Debug{&out} << Attribute::DataType::HalfFloat << Attribute::DataType(0xdead); - CORRADE_COMPARE(out.str(), "GL::Attribute::DataType::HalfFloat GL::Attribute::DataType(0xdead)\n"); + Debug{&out} << Attribute::DataType::Float << Attribute::DataType(0xdead); + CORRADE_COMPARE(out.str(), "GL::Attribute::DataType::Float GL::Attribute::DataType(0xdead)\n"); } }}}}