Skip to content

Commit

Permalink
UPBGE: Allow creating custom filter without shader source.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
panzergame committed Sep 9, 2017
1 parent 6926baf commit 41b0776
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
8 changes: 5 additions & 3 deletions source/gameengine/Rasterizer/RAS_2DFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 41b0776

Please sign in to comment.