2021-11-12 12:22:18 +01:00
|
|
|
/* Copyright (C) 2021 Wildfire Games.
|
2013-09-21 10:24:45 +02:00
|
|
|
* This file is part of 0 A.D.
|
|
|
|
*
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
#include "JSInterface_Renderer.h"
|
2018-04-27 18:48:44 +02:00
|
|
|
|
2018-08-05 23:50:00 +02:00
|
|
|
#include "graphics/TextureManager.h"
|
2019-08-04 10:28:30 +02:00
|
|
|
#include "renderer/RenderingOptions.h"
|
2013-09-21 10:24:45 +02:00
|
|
|
#include "renderer/Renderer.h"
|
2021-03-02 21:01:14 +01:00
|
|
|
#include "scriptinterface/FunctionWrapper.h"
|
2013-09-21 10:24:45 +02:00
|
|
|
|
2021-03-02 21:01:14 +01:00
|
|
|
namespace JSI_Renderer
|
|
|
|
{
|
2019-08-04 10:28:30 +02:00
|
|
|
#define IMPLEMENT_BOOLEAN_SCRIPT_SETTING(NAME) \
|
2021-03-02 21:01:14 +01:00
|
|
|
bool Get##NAME##Enabled() \
|
2013-09-21 10:24:45 +02:00
|
|
|
{ \
|
2021-03-02 21:01:14 +01:00
|
|
|
return g_RenderingOptions.Get##NAME(); \
|
2013-09-21 10:24:45 +02:00
|
|
|
} \
|
|
|
|
\
|
2021-03-02 21:01:14 +01:00
|
|
|
void Set##NAME##Enabled(bool enabled) \
|
2013-09-21 10:24:45 +02:00
|
|
|
{ \
|
2019-08-04 10:28:30 +02:00
|
|
|
g_RenderingOptions.Set##NAME(enabled); \
|
2013-09-21 10:24:45 +02:00
|
|
|
}
|
|
|
|
|
2019-08-04 10:28:30 +02:00
|
|
|
IMPLEMENT_BOOLEAN_SCRIPT_SETTING(DisplayFrustum);
|
2020-01-15 00:51:29 +01:00
|
|
|
IMPLEMENT_BOOLEAN_SCRIPT_SETTING(DisplayShadowsFrustum);
|
2013-09-21 10:24:45 +02:00
|
|
|
|
|
|
|
#undef IMPLEMENT_BOOLEAN_SCRIPT_SETTING
|
|
|
|
|
2021-03-02 21:01:14 +01:00
|
|
|
std::string GetRenderPath()
|
2013-09-21 10:24:45 +02:00
|
|
|
{
|
2019-08-04 10:28:30 +02:00
|
|
|
return RenderPathEnum::ToString(g_RenderingOptions.GetRenderPath());
|
2013-09-21 10:24:45 +02:00
|
|
|
}
|
|
|
|
|
2021-11-12 12:22:18 +01:00
|
|
|
std::string GetRenderDebugMode()
|
|
|
|
{
|
|
|
|
return RenderDebugModeEnum::ToString(g_RenderingOptions.GetRenderDebugMode()).c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetRenderDebugMode(const std::string& mode)
|
|
|
|
{
|
|
|
|
g_RenderingOptions.SetRenderDebugMode(RenderDebugModeEnum::FromString(mode));
|
|
|
|
}
|
|
|
|
|
2021-03-02 21:01:14 +01:00
|
|
|
bool TextureExists(const std::wstring& filename)
|
2018-08-05 23:50:00 +02:00
|
|
|
{
|
|
|
|
return g_Renderer.GetTextureManager().TextureExists(filename);
|
|
|
|
}
|
2013-09-21 10:24:45 +02:00
|
|
|
|
|
|
|
#define REGISTER_BOOLEAN_SCRIPT_SETTING(NAME) \
|
2021-03-02 21:01:14 +01:00
|
|
|
ScriptFunction::Register<&Get##NAME##Enabled>(rq, "Renderer_Get" #NAME "Enabled"); \
|
|
|
|
ScriptFunction::Register<&Set##NAME##Enabled>(rq, "Renderer_Set" #NAME "Enabled");
|
2013-09-21 10:24:45 +02:00
|
|
|
|
2021-03-02 21:01:14 +01:00
|
|
|
void RegisterScriptFunctions(const ScriptRequest& rq)
|
2013-09-21 10:24:45 +02:00
|
|
|
{
|
2021-03-02 21:01:14 +01:00
|
|
|
ScriptFunction::Register<&GetRenderPath>(rq, "Renderer_GetRenderPath");
|
|
|
|
ScriptFunction::Register<&TextureExists>(rq, "TextureExists");
|
2021-11-12 12:22:18 +01:00
|
|
|
ScriptFunction::Register<&GetRenderDebugMode>(rq, "Renderer_GetRenderDebugMode");
|
|
|
|
ScriptFunction::Register<&SetRenderDebugMode>(rq, "Renderer_SetRenderDebugMode");
|
2014-05-26 15:42:32 +02:00
|
|
|
REGISTER_BOOLEAN_SCRIPT_SETTING(DisplayFrustum);
|
2020-01-15 00:51:29 +01:00
|
|
|
REGISTER_BOOLEAN_SCRIPT_SETTING(DisplayShadowsFrustum);
|
2013-09-21 10:24:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef REGISTER_BOOLEAN_SCRIPT_SETTING
|
2021-03-02 21:01:14 +01:00
|
|
|
}
|