From 66e76be76dd159bd12077608dff0f333724fddee Mon Sep 17 00:00:00 2001 From: Deve Date: Wed, 6 Jul 2016 06:37:22 +0200 Subject: [PATCH] Don't use hardcoded path for irrlicht shaders --- lib/irrlicht/include/SIrrCreationParameters.h | 8 +++++++ .../source/Irrlicht/COGLES2Driver.cpp | 21 ++++++++++++------- lib/irrlicht/source/Irrlicht/COGLES2Driver.h | 2 ++ src/graphics/irr_driver.cpp | 2 ++ src/io/file_manager.hpp | 5 +++++ 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/lib/irrlicht/include/SIrrCreationParameters.h b/lib/irrlicht/include/SIrrCreationParameters.h index bd64b39c8..8e0397fec 100644 --- a/lib/irrlicht/include/SIrrCreationParameters.h +++ b/lib/irrlicht/include/SIrrCreationParameters.h @@ -9,6 +9,7 @@ #include "EDeviceTypes.h" #include "dimension2d.h" #include "ILogger.h" +#include "irrString.h" namespace irr { @@ -48,6 +49,7 @@ namespace irr DriverMultithreaded(false), UsePerformanceTimer(true), ForceLegacyDevice(false), + ShadersPath(""), SDK_version_do_not_use(IRRLICHT_SDK_VERSION) { } @@ -81,6 +83,7 @@ namespace irr DisplayAdapter = other.DisplayAdapter; UsePerformanceTimer = other.UsePerformanceTimer; ForceLegacyDevice = other.ForceLegacyDevice; + ShadersPath = other.ShadersPath; PrivateData = other.PrivateData; return *this; } @@ -296,6 +299,11 @@ namespace irr /** opengl 3 context is available. */ bool ForceLegacyDevice; + + //! Specifies custom path for shaders directory. + /** Allows to overwrite IRR_OGLES2_SHADER_PATH constant + */ + core::stringc ShadersPath; //! Don't use or change this parameter. /** Always set it to IRRLICHT_SDK_VERSION, which is done by default. diff --git a/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp b/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp index cb5ec5b15..e49c275f5 100644 --- a/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp +++ b/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp @@ -54,6 +54,7 @@ namespace video , ViewRenderbuffer(0) , ViewDepthRenderbuffer(0) #endif + , Params(params) { #ifdef _DEBUG setDebugName("COGLES2Driver"); @@ -435,12 +436,16 @@ namespace video // Load shaders from files (in future shaders will be merged with source code). // Fixed pipeline. + + core::stringc shaders_path = IRR_OGLES2_SHADER_PATH; + if (Params.ShadersPath.size() > 0) + shaders_path = Params.ShadersPath; - core::stringc FPVSPath = IRR_OGLES2_SHADER_PATH; + core::stringc FPVSPath = shaders_path; FPVSPath += "COGLES2FixedPipeline.vsh"; os::Printer::log(FPVSPath.c_str()); - core::stringc FPFSPath = IRR_OGLES2_SHADER_PATH; + core::stringc FPFSPath = shaders_path; FPFSPath += "COGLES2FixedPipeline.fsh"; io::IReadFile* FPVSFile = FileSystem->createAndOpenFile(FPVSPath); @@ -479,10 +484,10 @@ namespace video // Normal Mapping. - core::stringc NMVSPath = IRR_OGLES2_SHADER_PATH; + core::stringc NMVSPath = shaders_path; NMVSPath += "COGLES2NormalMap.vsh"; - core::stringc NMFSPath = IRR_OGLES2_SHADER_PATH; + core::stringc NMFSPath = shaders_path; NMFSPath += "COGLES2NormalMap.fsh"; io::IReadFile* NMVSFile = FileSystem->createAndOpenFile(NMVSPath); @@ -521,10 +526,10 @@ namespace video // Parallax Mapping. - core::stringc PMVSPath = IRR_OGLES2_SHADER_PATH; + core::stringc PMVSPath = shaders_path; PMVSPath += "COGLES2ParallaxMap.vsh"; - core::stringc PMFSPath = IRR_OGLES2_SHADER_PATH; + core::stringc PMFSPath = shaders_path; PMFSPath += "COGLES2ParallaxMap.fsh"; io::IReadFile* PMVSFile = FileSystem->createAndOpenFile(FPVSPath); @@ -593,10 +598,10 @@ namespace video // Create 2D material renderer. - core::stringc R2DVSPath = IRR_OGLES2_SHADER_PATH; + core::stringc R2DVSPath = shaders_path; R2DVSPath += "COGLES2Renderer2D.vsh"; - core::stringc R2DFSPath = IRR_OGLES2_SHADER_PATH; + core::stringc R2DFSPath = shaders_path; R2DFSPath += "COGLES2Renderer2D.fsh"; io::IReadFile* R2DVSFile = FileSystem->createAndOpenFile(R2DVSPath); diff --git a/lib/irrlicht/source/Irrlicht/COGLES2Driver.h b/lib/irrlicht/source/Irrlicht/COGLES2Driver.h index fd86619ab..9b6287680 100644 --- a/lib/irrlicht/source/Irrlicht/COGLES2Driver.h +++ b/lib/irrlicht/source/Irrlicht/COGLES2Driver.h @@ -478,6 +478,8 @@ namespace video void* EglSurface; void* EglContext; #endif + + SIrrlichtCreationParameters Params; }; //! This bridge between Irlicht pseudo OpenGL calls diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index eb4915b8c..b68dcc329 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -474,6 +474,8 @@ void IrrDriver::initDevice() core::dimension2du(UserConfigParams::m_width, UserConfigParams::m_height); params.HandleSRGB = true; + params.ShadersPath = (file_manager->getShadersDir() + + "irrlicht/").c_str(); /* switch ((int)UserConfigParams::m_antialiasing) diff --git a/src/io/file_manager.hpp b/src/io/file_manager.hpp index 003507f9c..d09821c5e 100644 --- a/src/io/file_manager.hpp +++ b/src/io/file_manager.hpp @@ -180,6 +180,11 @@ public: return getAsset(SHADER, name); } // getShader + + std::string getShadersDir() const + { + return m_subdir_name[SHADER]; + } }; // FileManager extern FileManager* file_manager;