Update StarRenderingLuaBindings.cpp
This commit is contained in:
parent
1a0bf768f0
commit
f7dc97965d
@ -1,6 +1,8 @@
|
|||||||
#include "StarRenderingLuaBindings.hpp"
|
#include "StarRenderingLuaBindings.hpp"
|
||||||
|
#include "StarJsonExtra.hpp"
|
||||||
#include "StarLuaConverters.hpp"
|
#include "StarLuaConverters.hpp"
|
||||||
#include "StarClientApplication.hpp"
|
#include "StarClientApplication.hpp"
|
||||||
|
#include "StarRenderer.hpp"
|
||||||
|
|
||||||
namespace Star {
|
namespace Star {
|
||||||
|
|
||||||
@ -11,8 +13,30 @@ LuaCallbacks LuaBindings::makeRenderingCallbacks(ClientApplication* app) {
|
|||||||
callbacks.registerCallbackWithSignature<void, String, bool, Maybe<bool>>("setPostProcessGroupEnabled", bind(mem_fn(&ClientApplication::setPostProcessGroupEnabled), app, _1, _2, _3));
|
callbacks.registerCallbackWithSignature<void, String, bool, Maybe<bool>>("setPostProcessGroupEnabled", bind(mem_fn(&ClientApplication::setPostProcessGroupEnabled), app, _1, _2, _3));
|
||||||
callbacks.registerCallbackWithSignature<bool, String>("postProcessGroupEnabled", bind(mem_fn(&ClientApplication::postProcessGroupEnabled), app, _1));
|
callbacks.registerCallbackWithSignature<bool, String>("postProcessGroupEnabled", bind(mem_fn(&ClientApplication::postProcessGroupEnabled), app, _1));
|
||||||
|
|
||||||
|
|
||||||
// not entirely necessary (root.assetJson can achieve the same purpose) but may as well
|
// not entirely necessary (root.assetJson can achieve the same purpose) but may as well
|
||||||
callbacks.registerCallbackWithSignature<Json>("postProcessGroups", bind(mem_fn(&ClientApplication::postProcessGroups), app));
|
callbacks.registerCallbackWithSignature<Json>("postProcessGroups", bind(mem_fn(&ClientApplication::postProcessGroups), app));
|
||||||
|
|
||||||
|
// typedef Variant<float, int, Vec2F, Vec3F, Vec4F, bool> RenderEffectParameter;
|
||||||
|
// feel free to change this if there's a better way to do this
|
||||||
|
// specifically checks if the effect parameter is an int since Lua prefers converting the values to floats
|
||||||
|
callbacks.registerCallback("setEffectParameter", [app](String const& effectName, String const& effectParameter, RenderEffectParameter const& value) {
|
||||||
|
auto renderer = app->renderer();
|
||||||
|
auto mtype = renderer->getEffectScriptableParameterType(effectName, effectParameter);
|
||||||
|
if (mtype) {
|
||||||
|
auto type = mtype.value();
|
||||||
|
if (type == 1 && value.is<float>()) {
|
||||||
|
renderer->setEffectScriptableParameter(effectName, effectParameter, (int)value.get<float>());
|
||||||
|
} else {
|
||||||
|
renderer->setEffectScriptableParameter(effectName, effectParameter, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
callbacks.registerCallback("getEffectParameter", [app](String const& effectName, String const& effectParameter) {
|
||||||
|
auto renderer = app->renderer();
|
||||||
|
return renderer->getEffectScriptableParameter(effectName, effectParameter);
|
||||||
|
});
|
||||||
|
|
||||||
return callbacks;
|
return callbacks;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user