File 0001-Fix-ODR-violation-for-ShaderModelRendererInternals.patch of Package 0ad
From d5ac9cf91b3e7e6c48c7baf961ebf78fad446a21 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Mon, 3 Aug 2020 11:00:17 +0200
Subject: [PATCH] Fix ODR violation for ShaderModelRendererInternals
ShaderModelRendererInternals is defined twice, once by ModelRenderer.cpp
and once by HWLightingModelRenderer.cpp. Having both in the global
namespace is a violation of the C++ One-Definition-Rule.
Move both definitions into their "parent" classes.
---
source/renderer/HWLightingModelRenderer.cpp | 2 +-
source/renderer/HWLightingModelRenderer.h | 3 +--
source/renderer/ModelRenderer.cpp | 2 +-
source/renderer/ModelRenderer.h | 4 +---
4 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/source/renderer/HWLightingModelRenderer.cpp b/source/renderer/HWLightingModelRenderer.cpp
index 97cb45c..66c83b0 100644
--- a/source/renderer/HWLightingModelRenderer.cpp
+++ b/source/renderer/HWLightingModelRenderer.cpp
@@ -96,7 +96,7 @@ struct ShaderModel : public CModelRData
};
-struct ShaderModelRendererInternals
+struct ShaderModelVertexRenderer::ShaderModelRendererInternals
{
bool cpuLighting;
diff --git a/source/renderer/HWLightingModelRenderer.h b/source/renderer/HWLightingModelRenderer.h
index cd89f45..0b99c5d 100644
--- a/source/renderer/HWLightingModelRenderer.h
+++ b/source/renderer/HWLightingModelRenderer.h
@@ -25,8 +25,6 @@
#include "renderer/ModelVertexRenderer.h"
-struct ShaderModelRendererInternals;
-
/**
* Render animated models using a ShaderRenderModifier.
* This computes and binds per-vertex data; the modifier is responsible
@@ -48,6 +46,7 @@ public:
void RenderModel(const CShaderProgramPtr& shader, int streamflags, CModel* model, CModelRData* data);
protected:
+ struct ShaderModelRendererInternals;
ShaderModelRendererInternals* m;
};
diff --git a/source/renderer/ModelRenderer.cpp b/source/renderer/ModelRenderer.cpp
index 49a86e4..037ce6b 100644
--- a/source/renderer/ModelRenderer.cpp
+++ b/source/renderer/ModelRenderer.cpp
@@ -203,7 +203,7 @@ void ModelRenderer::BuildIndices(
* Separated into the source file to increase implementation hiding (and to
* avoid some causes of recompiles).
*/
-struct ShaderModelRendererInternals
+struct ShaderModelRenderer::ShaderModelRendererInternals
{
ShaderModelRendererInternals(ShaderModelRenderer* r) : m_Renderer(r) { }
diff --git a/source/renderer/ModelRenderer.h b/source/renderer/ModelRenderer.h
index eff1b63..a3c7ecd 100644
--- a/source/renderer/ModelRenderer.h
+++ b/source/renderer/ModelRenderer.h
@@ -245,9 +245,6 @@ public:
static void GenTangents(const CModelDefPtr& mdef, std::vector<float>& newVertices, bool gpuSkinning);
};
-
-struct ShaderModelRendererInternals;
-
/**
* Implementation of ModelRenderer that loads the appropriate shaders for
* rendering each model, and that batches by shader (and by mesh and texture).
@@ -270,6 +267,7 @@ public:
virtual void Render(const RenderModifierPtr& modifier, const CShaderDefines& context, int cullGroup, int flags);
private:
+ struct ShaderModelRendererInternals;
ShaderModelRendererInternals* m;
};
--
2.27.0