From eb66de657bcd16f490a0dd331324a9bafdb98cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 19 Feb 2014 20:22:39 +0100 Subject: [PATCH] MSVC 2013 compatibility: fix memory corruption. The quality of this compiler just reached a new low. Getting memory corruption just because I didn't include the header which isn't needed by any other compiler?! What?! --- src/Magnum/Implementation/FramebufferState.h | 6 ++++++ src/Magnum/Implementation/ShaderProgramState.h | 6 ++++++ src/Magnum/Implementation/TextureState.h | 10 ++++++++++ 3 files changed, 22 insertions(+) diff --git a/src/Magnum/Implementation/FramebufferState.h b/src/Magnum/Implementation/FramebufferState.h index 0239d1d8c..29c6a9ceb 100644 --- a/src/Magnum/Implementation/FramebufferState.h +++ b/src/Magnum/Implementation/FramebufferState.h @@ -34,6 +34,12 @@ #include "Magnum/RenderbufferFormat.h" #endif +/* We did't get memory corruption like in e.g. TextureState here, but include + the header just to be sure */ +#ifndef CORRADE_MSVC2013_COMPATIBILITY +#include "Magnum/Renderbuffer.h" +#endif + namespace Magnum { namespace Implementation { struct FramebufferState { diff --git a/src/Magnum/Implementation/ShaderProgramState.h b/src/Magnum/Implementation/ShaderProgramState.h index d2113052e..5964742ee 100644 --- a/src/Magnum/Implementation/ShaderProgramState.h +++ b/src/Magnum/Implementation/ShaderProgramState.h @@ -31,6 +31,12 @@ #include "Magnum/Magnum.h" #include "Magnum/OpenGL.h" +/* Otherwise we get a pretty nice memory corruption without any warning or + error whatsoever (!) */ +#ifdef CORRADE_MSVC2013_COMPATIBILITY +#include "Magnum/AbstractShaderProgram.h" +#endif + namespace Magnum { namespace Implementation { struct ShaderProgramState { diff --git a/src/Magnum/Implementation/TextureState.h b/src/Magnum/Implementation/TextureState.h index 6ba092be9..8b0c79628 100644 --- a/src/Magnum/Implementation/TextureState.h +++ b/src/Magnum/Implementation/TextureState.h @@ -39,6 +39,16 @@ #include "Magnum/TextureFormat.h" #endif +/* Otherwise we get a pretty nice memory corruption only with a warning about + architecture-dependent alignment of `setBufferImplementation` variable */ +#ifdef CORRADE_MSVC2013_COMPATIBILITY +#ifndef MAGNUM_TARGET_GLES +#include "Magnum/BufferTexture.h" +#else +#include "Magnum/AbstractTexture.h" +#endif +#endif + namespace Magnum { namespace Implementation { struct TextureState {