mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-08 03:41:11 -04:00
lua - add ability to query the currently active shaders
This commit is contained in:
parent
50f8bc721d
commit
450f587844
@ -82,7 +82,7 @@ message(STATUS "Configuring OpenMW...")
|
|||||||
set(OPENMW_VERSION_MAJOR 0)
|
set(OPENMW_VERSION_MAJOR 0)
|
||||||
set(OPENMW_VERSION_MINOR 50)
|
set(OPENMW_VERSION_MINOR 50)
|
||||||
set(OPENMW_VERSION_RELEASE 0)
|
set(OPENMW_VERSION_RELEASE 0)
|
||||||
set(OPENMW_LUA_API_REVISION 76)
|
set(OPENMW_LUA_API_REVISION 77)
|
||||||
set(OPENMW_POSTPROCESSING_API_REVISION 2)
|
set(OPENMW_POSTPROCESSING_API_REVISION 2)
|
||||||
|
|
||||||
set(OPENMW_VERSION_COMMITHASH "")
|
set(OPENMW_VERSION_COMMITHASH "")
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "postprocessingbindings.hpp"
|
#include "postprocessingbindings.hpp"
|
||||||
|
|
||||||
|
#include "MyGUI_LanguageManager.h"
|
||||||
|
|
||||||
#include <components/lua/util.hpp>
|
#include <components/lua/util.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
@ -8,6 +10,14 @@
|
|||||||
|
|
||||||
#include "luamanagerimp.hpp"
|
#include "luamanagerimp.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
std::string getLocalizedMyGUIString(std::string_view unlocalized)
|
||||||
|
{
|
||||||
|
return MyGUI::LanguageManager::getInstance().replaceTags(std::string(unlocalized)).asUTF8();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace MWLua
|
namespace MWLua
|
||||||
{
|
{
|
||||||
struct Shader;
|
struct Shader;
|
||||||
@ -37,7 +47,7 @@ namespace MWLua
|
|||||||
if (!mShader)
|
if (!mShader)
|
||||||
return "Shader(nil)";
|
return "Shader(nil)";
|
||||||
|
|
||||||
return Misc::StringUtils::format("Shader(%s, %s)", mShader->getName(), mShader->getFileName());
|
return Misc::StringUtils::format("Shader(%s, %s)", mShader->getName(), mShader->getFileName().value());
|
||||||
}
|
}
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -139,6 +149,15 @@ namespace MWLua
|
|||||||
return MWBase::Environment::get().getWorld()->getPostProcessor()->isTechniqueEnabled(shader.mShader);
|
return MWBase::Environment::get().getWorld()->getPostProcessor()->isTechniqueEnabled(shader.mShader);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
shader["name"] = sol::readonly_property(
|
||||||
|
[](const Shader& shader) { return getLocalizedMyGUIString(shader.mShader->getName()); });
|
||||||
|
shader["author"] = sol::readonly_property(
|
||||||
|
[](const Shader& shader) { return getLocalizedMyGUIString(shader.mShader->getAuthor()); });
|
||||||
|
shader["description"] = sol::readonly_property(
|
||||||
|
[](const Shader& shader) { return getLocalizedMyGUIString(shader.mShader->getDescription()); });
|
||||||
|
shader["version"] = sol::readonly_property(
|
||||||
|
[](const Shader& shader) { return getLocalizedMyGUIString(shader.mShader->getVersion()); });
|
||||||
|
|
||||||
shader["setBool"] = getSetter<bool>(context);
|
shader["setBool"] = getSetter<bool>(context);
|
||||||
shader["setFloat"] = getSetter<float>(context);
|
shader["setFloat"] = getSetter<float>(context);
|
||||||
shader["setInt"] = getSetter<int>(context);
|
shader["setInt"] = getSetter<int>(context);
|
||||||
@ -164,6 +183,20 @@ namespace MWLua
|
|||||||
return shader;
|
return shader;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
api["getChain"] = []() {
|
||||||
|
std::vector<Shader> chain;
|
||||||
|
|
||||||
|
for (const auto& shader : MWBase::Environment::get().getWorld()->getPostProcessor()->getChain())
|
||||||
|
{
|
||||||
|
// Don't expose internal shaders to the API, they should be invisible to the user
|
||||||
|
if (shader->getInternal())
|
||||||
|
continue;
|
||||||
|
chain.emplace_back(shader);
|
||||||
|
}
|
||||||
|
|
||||||
|
return chain;
|
||||||
|
};
|
||||||
|
|
||||||
return LuaUtil::makeReadOnly(api);
|
return LuaUtil::makeReadOnly(api);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -786,6 +786,11 @@ namespace MWRender
|
|||||||
return mTemplates.back();
|
return mTemplates.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PostProcessor::TechniqueList PostProcessor::getChain()
|
||||||
|
{
|
||||||
|
return mTechniques;
|
||||||
|
}
|
||||||
|
|
||||||
void PostProcessor::loadChain()
|
void PostProcessor::loadChain()
|
||||||
{
|
{
|
||||||
mTechniques.clear();
|
mTechniques.clear();
|
||||||
|
@ -178,6 +178,8 @@ namespace MWRender
|
|||||||
|
|
||||||
std::shared_ptr<fx::Technique> loadTechnique(const std::string& name, bool loadNextFrame = false);
|
std::shared_ptr<fx::Technique> loadTechnique(const std::string& name, bool loadNextFrame = false);
|
||||||
|
|
||||||
|
TechniqueList getChain();
|
||||||
|
|
||||||
bool isEnabled() const { return mUsePostProcessing; }
|
bool isEnabled() const { return mUsePostProcessing; }
|
||||||
|
|
||||||
void disable();
|
void disable();
|
||||||
|
@ -4,6 +4,12 @@
|
|||||||
-- @module postprocessing
|
-- @module postprocessing
|
||||||
-- @usage local postprocessing = require('openmw.postprocessing')
|
-- @usage local postprocessing = require('openmw.postprocessing')
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @type Shader
|
||||||
|
-- @field #string name Name of the shader
|
||||||
|
-- @field #string description Description of the shader
|
||||||
|
-- @field #string author Author of the shader
|
||||||
|
-- @field #string version Version of the shader
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Load a shader and return its handle.
|
-- Load a shader and return its handle.
|
||||||
@ -15,6 +21,12 @@
|
|||||||
-- -- It must be enabled to see its effect.
|
-- -- It must be enabled to see its effect.
|
||||||
-- local vignetteShader = postprocessing.load('vignette')
|
-- local vignetteShader = postprocessing.load('vignette')
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Returns the ordered list of active shaders.
|
||||||
|
-- Active shaders may change between frames.
|
||||||
|
-- @function [parent=#postprocessing] getChain
|
||||||
|
-- @return #list<#Shader> list The currently active shaders, in order
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Enable the shader. Has no effect if the shader is already enabled or does
|
-- Enable the shader. Has no effect if the shader is already enabled or does
|
||||||
-- not exist. Will not apply until the next frame.
|
-- not exist. Will not apply until the next frame.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user