Don't use hardcoded path for irrlicht shaders

This commit is contained in:
Deve 2016-07-06 06:37:22 +02:00
parent 20e72b2e9d
commit 66e76be76d
5 changed files with 30 additions and 8 deletions

View File

@ -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.

View File

@ -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);

View File

@ -478,6 +478,8 @@ namespace video
void* EglSurface;
void* EglContext;
#endif
SIrrlichtCreationParameters Params;
};
//! This bridge between Irlicht pseudo OpenGL calls

View File

@ -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)

View File

@ -180,6 +180,11 @@ public:
return getAsset(SHADER, name);
} // getShader
std::string getShadersDir() const
{
return m_subdir_name[SHADER];
}
}; // FileManager
extern FileManager* file_manager;