From 02158cd0f9a638efbb032600b27ff69b93bcedba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 8 Nov 2012 18:58:28 +0100 Subject: [PATCH] GCC 4.5 compatibility: fixed initializer-list issues. --- src/Mesh.h | 6 +++--- src/Shaders/FlatShader.cpp | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Mesh.h b/src/Mesh.h index 78a1ee686..dc8737ab4 100644 --- a/src/Mesh.h +++ b/src/Mesh.h @@ -619,7 +619,7 @@ class MAGNUM_EXPORT Mesh { template inline void addVertexAttribute(typename std::enable_if::AttributeType, GLfloat>::value, Buffer*>::type buffer, const AbstractShaderProgram::Attribute& attribute, GLintptr offset, GLsizei stride) { for(GLuint i = 0; i != Implementation::Attribute::vectorCount(); ++i) { - attributes.push_back({ + attributes.push_back(Attribute{ buffer, location+i, Implementation::Attribute::size(attribute.dataOptions()), @@ -635,7 +635,7 @@ class MAGNUM_EXPORT Mesh { #ifndef MAGNUM_TARGET_GLES2 template inline void addVertexAttribute(typename std::enable_if::AttributeType>::value, Buffer*>::type buffer, const AbstractShaderProgram::Attribute& attribute, GLintptr offset, GLsizei stride) { - integerAttributes.push_back({ + integerAttributes.push_back(IntegerAttribute{ buffer, location, Implementation::Attribute::size(), @@ -650,7 +650,7 @@ class MAGNUM_EXPORT Mesh { #ifndef MAGNUM_TARGET_GLES template inline void addVertexAttribute(typename std::enable_if::AttributeType, GLdouble>::value, Buffer*>::type buffer, const AbstractShaderProgram::Attribute& attribute, GLintptr offset, GLsizei stride) { for(GLuint i = 0; i != Implementation::Attribute::vectorCount(); ++i) { - longAttributes.push_back({ + longAttributes.push_back(LongAttribute{ buffer, location+i, Implementation::Attribute::size(), diff --git a/src/Shaders/FlatShader.cpp b/src/Shaders/FlatShader.cpp index 78ad7a450..96e713653 100644 --- a/src/Shaders/FlatShader.cpp +++ b/src/Shaders/FlatShader.cpp @@ -39,11 +39,22 @@ namespace { template FlatShader::FlatShader() { Corrade::Utility::Resource rs("MagnumShaders"); + /* Weird bug in GCC 4.5 - cannot use initializer list here, although the + same thing works in PhongShader flawlessly*/ + #ifndef CORRADE_GCC45_COMPATIBILITY #ifndef MAGNUM_TARGET_GLES Version v = Context::current()->supportedVersion({Version::GL320, Version::GL210}); #else Version v = Context::current()->supportedVersion({Version::GLES300, Version::GLES200}); #endif + #else + #ifndef MAGNUM_TARGET_GLES + std::initializer_list vs{Version::GL320, Version::GL210}; + #else + std::initializer_list vs{Version::GLES300, Version::GLES200}; + #endif + Version v = Context::current()->supportedVersion(vs); + #endif Shader vertexShader(v, Shader::Type::Vertex); vertexShader.addSource(rs.get("compatibility.glsl"));