From 086c6b54165788b7d6e5179bbf44f7028dead4bc Mon Sep 17 00:00:00 2001 From: LuisAntonRebollo Date: Thu, 17 Apr 2014 20:29:44 +0200 Subject: [PATCH] Add GFXShader::init with support for ordered vector of sampler names for shader. --- Engine/source/gfx/gfxShader.cpp | 13 +++++++++++++ Engine/source/gfx/gfxShader.h | 17 +++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Engine/source/gfx/gfxShader.cpp b/Engine/source/gfx/gfxShader.cpp index 0bbcb4942..5e81d8a10 100644 --- a/Engine/source/gfx/gfxShader.cpp +++ b/Engine/source/gfx/gfxShader.cpp @@ -45,16 +45,29 @@ GFXShader::~GFXShader() Torque::FS::RemoveChangeNotification( mPixelFile, this, &GFXShader::_onFileChanged ); } +#ifndef TORQUE_OPENGL bool GFXShader::init( const Torque::Path &vertFile, const Torque::Path &pixFile, F32 pixVersion, const Vector ¯os ) +{ + Vector samplerNames; + return init( vertFile, pixFile, pixVersion, macros, samplerNames ); +} +#endif + +bool GFXShader::init( const Torque::Path &vertFile, + const Torque::Path &pixFile, + F32 pixVersion, + const Vector ¯os, + const Vector &samplerNames) { // Store the inputs for use in reloading. mVertexFile = vertFile; mPixelFile = pixFile; mPixVersion = pixVersion; mMacros = macros; + mSamplerNamesOrdered = samplerNames; // Before we compile the shader make sure the // conditioner features have been updated. diff --git a/Engine/source/gfx/gfxShader.h b/Engine/source/gfx/gfxShader.h index 8c77a5448..4b2c10f46 100644 --- a/Engine/source/gfx/gfxShader.h +++ b/Engine/source/gfx/gfxShader.h @@ -237,6 +237,13 @@ protected: /// The macros to be passed to the shader. Vector mMacros; + /// Ordered SamplerNames + /// We need to store a list of sampler for allow OpenGL to + /// assign correct location for each sampler. + /// GLSL 150 not allow explicit uniform location. + /// Only used on OpenGL + Vector mSamplerNamesOrdered; + /// The pixel version this is compiled for. F32 mPixVersion; @@ -292,10 +299,20 @@ public: virtual ~GFXShader(); /// + /// Deprecated. Remove on T3D 4.0 +#ifndef TORQUE_OPENGL bool init( const Torque::Path &vertFile, const Torque::Path &pixFile, F32 pixVersion, const Vector ¯os ); +#endif + + /// + bool init( const Torque::Path &vertFile, + const Torque::Path &pixFile, + F32 pixVersion, + const Vector ¯os, + const Vector &samplerNames); /// Reloads the shader from disk. bool reload();