TDME2 1.9.121
PostProcessingShaderDesaturationImplementation.cpp
Go to the documentation of this file.
2
3#include <string>
4
5#include <tdme/tdme.h>
10
11using std::string;
12
17
18bool PostProcessingShaderDesaturationImplementation::isSupported(Renderer* renderer) {
19 return renderer->getShaderVersion() == "gl3";
20}
21
23{
24}
25
27{
28 auto shaderVersion = renderer->getShaderVersion();
29
30 // fragment shader
33 "shader/" + shaderVersion + "/postprocessing",
34 "desaturation_fragmentshader.frag",
35 Engine::is4K() == true?"#define HAVE_4K":""
36 );
37 if (fragmentShaderId == 0) return;
38
39 // vertex shader
42 "shader/" + shaderVersion + "/postprocessing",
43 "desaturation_vertexshader.vert"
44 );
45 if (vertexShaderId == 0) return;
46
47 // create, attach and link program
51
52 //
54
55 //
56 if (initialized == false) return;
57
58 // uniforms
60
61 // register shader
63 Engine::ShaderType::SHADERTYPE_POSTPROCESSING,
64 "desaturation",
65 {{ "intensity", ShaderParameter(0.0f) }}
66 );
67}
68
70 if (uniformIntensity != -1) renderer->setProgramUniformFloat(contextIdx, uniformIntensity, engine->getShaderParameter("desaturation", "intensity").getFloatValue());
71}
72
Engine main class.
Definition: Engine.h:122
static void registerShader(ShaderType type, const string &shaderId, const map< string, ShaderParameter > &parameterDefaults={})
Register shader.
Definition: Engine.cpp:2122
const ShaderParameter getShaderParameter(const string &shaderId, const string &parameterName)
Returns shader parameter for given shader id and parameter name, if the value does not exist,...
Definition: Engine.h:792
static bool is4K()
Definition: Engine.h:594
Shader parameter model class.
virtual int32_t loadShader(int32_t type, const string &pathName, const string &fileName, const string &definitions=string(), const string &functions=string())=0
Loads a shader.
virtual int32_t createProgram(int type)=0
Creates a shader program.
virtual void attachShaderToProgram(int32_t programId, int32_t shaderId)=0
Attaches a shader to a program.
virtual int32_t getProgramUniformLocation(int32_t programId, const string &name)=0
Returns location of given uniform variable.
virtual void setProgramUniformFloat(int contextIdx, int32_t uniformId, float value)=0
Set up a float uniform value.