From 41b0776995e66daacc30277781d5a24e2b01b44f Mon Sep 17 00:00:00 2001 From: Porteries Tristan Date: Sat, 9 Sep 2017 23:13:36 +0200 Subject: [PATCH] UPBGE: Allow creating custom filter without shader source. Previously the user was obligated to specify a fragment source when calling filter.addFilter for custom filter. But if the user want to use a custom shader it was impossible to not failed the first compilation and then call setSourceList. To avoid an useless compilation failure, the function addFilter allow creating a custom shader without receiving any fragment source. This produces a empty filter unused in rendering while the user doesn't called setSourceList. --- .../rst/bge_types/bge.types.KX_2DFilterManager.rst | 2 +- source/gameengine/Rasterizer/RAS_2DFilter.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/python_api/rst/bge_types/bge.types.KX_2DFilterManager.rst b/doc/python_api/rst/bge_types/bge.types.KX_2DFilterManager.rst index d6204b5ed558..7de348c64cdb 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_2DFilterManager.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_2DFilterManager.rst @@ -30,7 +30,7 @@ base class --- :class:`PyObjectPlus` :type type: integer :arg fragmentProgram: The filter shader fragment program. - Specified only if :data:`type` is :data:`bge.logic.RAS_2DFILTER_CUSTOMFILTER`. (optional) + Used only if :data:`type` is :data:`bge.logic.RAS_2DFILTER_CUSTOMFILTER`, if empty or not specified the filter is created without shader, waiting call to :data:`BL_Shader.setSourceList`. (optional) :type fragmentProgram: string :return: The 2D Filter. :rtype: :class:`KX_2DFilter` diff --git a/source/gameengine/Rasterizer/RAS_2DFilter.cpp b/source/gameengine/Rasterizer/RAS_2DFilter.cpp index fa66af0e0217..9e41fa58957e 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilter.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilter.cpp @@ -58,10 +58,12 @@ RAS_2DFilter::RAS_2DFilter(RAS_2DFilterData& data) m_predefinedUniforms[i] = -1; } - m_progs[VERTEX_PROGRAM] = std::string(datatoc_RAS_VertexShader2DFilter_glsl); - m_progs[FRAGMENT_PROGRAM] = data.shaderText; + if (!data.shaderText.empty()) { + m_progs[VERTEX_PROGRAM] = std::string(datatoc_RAS_VertexShader2DFilter_glsl); + m_progs[FRAGMENT_PROGRAM] = data.shaderText; - LinkProgram(); + LinkProgram(); + } } RAS_2DFilter::~RAS_2DFilter()