TDME2 1.9.121
LightingShaderBaseImplementation.h
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4
5#include <tdme/tdme.h>
11#include <tdme/engine/Engine.h>
12#include <tdme/math/fwd-tdme.h>
13#include <tdme/math/Matrix4x4.h>
14
15using std::array;
16
22
23/**
24 * Lighting shader implementation
25 * @author Andreas Drewke
26 * @version $Id$
27 */
29{
30protected:
31 int32_t programId { -1 };
32 int32_t fragmentShaderId { -1 };
33 int32_t vertexShaderId { -1 };
45 int32_t uniformCameraMatrix { -1 };
46 int32_t uniformCameraPosition { -1 };
47 int32_t uniformMVPMatrix { -1 };
48 int32_t uniformMVMatrix { -1 };
49 int32_t uniformNormalMatrix { -1 };
50 int32_t uniformModelMatrix { -1 };
51 int32_t uniformTextureMatrix { -1 };
52 int32_t uniformEffectColorMul { -1 };
53 int32_t uniformEffectColorAdd { -1 };
54 int32_t uniformMaterialAmbient { -1 };
55 int32_t uniformMaterialDiffuse { -1 };
61 int32_t uniformTime { -1 };
66 array<int32_t, Engine::LIGHTS_MAX> uniformLightEnabled;
67 array<int32_t, Engine::LIGHTS_MAX> uniformLightAmbient;
68 array<int32_t, Engine::LIGHTS_MAX> uniformLightDiffuse;
69 array<int32_t, Engine::LIGHTS_MAX> uniformLightSpecular;
70 array<int32_t, Engine::LIGHTS_MAX> uniformLightPosition;
71 array<int32_t, Engine::LIGHTS_MAX> uniformLightSpotDirection;
72 array<int32_t, Engine::LIGHTS_MAX> uniformLightSpotExponent;
73 array<int32_t, Engine::LIGHTS_MAX> uniformLightSpotCosCutoff;
74 array<int32_t, Engine::LIGHTS_MAX> uniformLightConstantAttenuation;
75 array<int32_t, Engine::LIGHTS_MAX> uniformLightLinearAttenuation;
76 array<int32_t, Engine::LIGHTS_MAX> uniformLightQuadraticAttenuation;
77 array<int32_t, Engine::LIGHTS_MAX> uniformLightRadius;
78 array<float, 4> defaultSceneColor {{ 0.0f, 0.0f, 0.0f, 0.0f }};
79 bool initialized { false };
80 Renderer* renderer { nullptr };
81public:
82 /**
83 * Public constructor
84 * @param renderer renderer
85 */
87
88 // overridden methods
89 virtual bool isInitialized() override;
90 virtual void initialize() override;
91 virtual void useProgram(Engine* engine, int contextIdx) override;
92 virtual void unUseProgram(int contextIdx) override;
93 virtual void updateEffect(Renderer* renderer, int contextIdx) override;
94 virtual void updateMaterial(Renderer* renderer, int contextIdx) override;
95 virtual void updateLight(Renderer* renderer, int contextIdx, int32_t lightId) override;
96 virtual void updateMatrices(Renderer* renderer, int contextIdx) override;
97 virtual void updateTextureMatrix(Renderer* renderer, int contextIdx) override;
98 virtual void bindTexture(Renderer* renderer, int contextIdx, int32_t textureId) override;
99 virtual void updateShaderParameters(Renderer* renderer, int contextIdx) override = 0;
100
101};
Engine main class.
Definition: Engine.h:122
virtual void updateLight(Renderer *renderer, int contextIdx, int32_t lightId) override
Update light to program.
virtual void updateTextureMatrix(Renderer *renderer, int contextIdx) override
Update texture matrix to program.
virtual void updateMaterial(Renderer *renderer, int contextIdx) override
Update material to program.
virtual void updateMatrices(Renderer *renderer, int contextIdx) override
Update matrices to program.
virtual void bindTexture(Renderer *renderer, int contextIdx, int32_t textureId) override
Bind texture.
virtual void updateEffect(Renderer *renderer, int contextIdx) override
Update effect to program.
virtual void unUseProgram(int contextIdx) override
Unuse lighting program.
virtual void useProgram(Engine *engine, int contextIdx) override
Use lighting program.
virtual void updateShaderParameters(Renderer *renderer, int contextIdx) override=0
Update shader parameters.
4x4 3D Matrix class
Definition: Matrix4x4.h:24