Browse Source

GL: don't expose half float attributes on WebGL 1.

They weren't in the docs but in the internals. That's wrong.
findsdl-include-root
Vladimír Vondruš 7 years ago
parent
commit
9b21db0737
  1. 12
      src/Magnum/GL/Attribute.cpp
  2. 6
      src/Magnum/GL/Attribute.h
  3. 18
      src/Magnum/GL/Test/AttributeTest.cpp

12
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<Math::Vector<3, Float>>::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<Math::Vector<4, Float>>::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<Math::Vector<3, Float>>::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<Math::Vector<4, Float>>::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)

6
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<Math::Vector<3, Float>>: 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<Math::Vector<4, Float>> {
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
,

18
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");
}
}}}}

Loading…
Cancel
Save