Index: build/premake/premake5.lua =================================================================== --- build/premake/premake5.lua +++ build/premake/premake5.lua @@ -730,7 +730,8 @@ "graphics/scripting", "renderer", "renderer/scripting", - "third_party/mikktspace" + "third_party/mikktspace", + "third_party/ogre3d" } extern_libs = { "opengl", @@ -745,6 +746,7 @@ source_dirs = { + "third_party/ogre3d", "tools/atlas/GameInterface", "tools/atlas/GameInterface/Handlers" } Index: source/ps/PreprocessorWrapper.h =================================================================== --- source/ps/PreprocessorWrapper.h +++ source/ps/PreprocessorWrapper.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -18,7 +18,7 @@ #ifndef INCLUDED_PREPROCESSORWRAPPER #define INCLUDED_PREPROCESSORWRAPPER -#include "ps/Preprocessor.h" +#include "third_party/ogre3d/OgreGLSLPreprocessor.h" #include "ps/CStr.h" class CShaderDefines; @@ -37,8 +37,14 @@ CStr Preprocess(const CStr& input); + static void PyrogenesisShaderError(void* UNUSED(iData), int iLine, const char *iError, + const char *iToken, size_t iTokenLen); + private: CPreprocessor m_Preprocessor; }; +CPreprocessor::ErrorHandler = CPreprocessorWrapper::PyrogenesisShaderError; + + #endif // INCLUDED_PREPROCESSORWRAPPER Index: source/ps/PreprocessorWrapper.cpp =================================================================== --- source/ps/PreprocessorWrapper.cpp +++ source/ps/PreprocessorWrapper.cpp @@ -22,6 +22,17 @@ #include "graphics/ShaderDefines.h" #include "ps/CLogger.h" + +void CPreprocessorWrapper::PyrogenesisShaderError(void* UNUSED(iData), int iLine, const char *iError, + const char *iToken, size_t iTokenLen) +{ + if (iToken) + LOGERROR("Preprocessor error: line %d: %s: '%s'\n", + iLine, iError, std::string (iToken, iTokenLen)); + else + LOGERROR("Preprocessor error: line %d: %s\n", iLine, iError); +} + void CPreprocessorWrapper::AddDefine(const char* name, const char* value) { m_Preprocessor.Define(name, value); Index: source/ps/tests/test_Preprocessor.h =================================================================== --- source/ps/tests/test_Preprocessor.h +++ source/ps/tests/test_Preprocessor.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -17,7 +17,7 @@ #include "lib/self_test.h" -#include "ps/Preprocessor.h" +#include "third_party/ogre3d/OgreGLSLPreprocessor.h" class TestPreprocessor : public CxxTest::TestSuite { Index: source/third_party/ogre3d/OgreGLSLPreprocessor.cpp =================================================================== --- source/third_party/ogre3d/OgreGLSLPreprocessor.cpp +++ source/third_party/ogre3d/OgreGLSLPreprocessor.cpp @@ -34,9 +34,7 @@ #include "precompiled.h" -#include "Preprocessor.h" - -#include "ps/CLogger.h" +#include "OgreGLSLPreprocessor.h" // Limit max number of macro arguments to this #define MAX_MACRO_ARGS 16 @@ -227,14 +225,15 @@ //---------------------------------------------------------------------------// static void DefaultError (void *iData, int iLine, const char *iError, - const char *iToken, size_t iTokenLen) + const char *iToken, size_t iTokenLen) { (void)iData; + char line [1000]; if (iToken) - LOGERROR("Preprocessor error: line %d: %s: '%s'\n", - iLine, iError, std::string (iToken, iTokenLen)); + snprintf (line, sizeof (line), "line %d: %s: `%.*s'\n", + iLine, iError, int (iTokenLen), iToken); else - LOGERROR("Preprocessor error: line %d: %s\n", iLine, iError); + snprintf (line, sizeof (line), "line %d: %s\n", iLine, iError); } //---------------------------------------------------------------------------//