forked from Mirrors/openclonk
Instantiate C4ShaderCall within C4FoWDrawStrategy
This will allow us to use different shaders for different passes of the draw.directional-lights
parent
7552fd94f7
commit
96013162fa
|
@ -249,14 +249,9 @@ void C4FoW::Render(C4FoWRegion *pRegion, const C4TargetFacet *pOnScreen, C4Playe
|
|||
assert(pShader);
|
||||
if (!pShader) return;
|
||||
|
||||
C4ShaderCall Call(pShader);
|
||||
Call.Start();
|
||||
Call.SetUniformMatrix4x4(C4FoWRSU_ProjectionMatrix, projectionMatrix);
|
||||
|
||||
for (C4FoWLight *pLight = pLights; pLight; pLight = pLight->getNext())
|
||||
if (pLight->IsVisibleForPlayer(pPlr))
|
||||
pLight->Render(pRegion, pOnScreen, Call);
|
||||
pLight->Render(pRegion, pOnScreen, projectionMatrix, *pShader);
|
||||
|
||||
Call.Finish();
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -139,8 +139,12 @@ void C4FoWDrawLightTextureStrategy::Begin(const C4FoWRegion* regionPar)
|
|||
}
|
||||
}
|
||||
|
||||
void C4FoWDrawLightTextureStrategy::End(C4ShaderCall& call)
|
||||
void C4FoWDrawLightTextureStrategy::End(const StdProjectionMatrix& projectionMatrix, const C4Shader& renderShader)
|
||||
{
|
||||
C4ShaderCall call(&renderShader);
|
||||
call.Start();
|
||||
call.SetUniformMatrix4x4(C4FoWRSU_ProjectionMatrix, projectionMatrix);
|
||||
|
||||
// If we have nothing to draw (e.g. directly after initialization), abort early.
|
||||
if (vertices.empty()) return;
|
||||
|
||||
|
@ -254,7 +258,7 @@ void C4FoWDrawLightTextureStrategy::End(C4ShaderCall& call)
|
|||
|
||||
// Assume the capacity stays the same:
|
||||
vertices.resize(0);
|
||||
C4FoWDrawStrategy::End(call);
|
||||
C4FoWDrawStrategy::End(projectionMatrix, renderShader);
|
||||
}
|
||||
|
||||
void C4FoWDrawLightTextureStrategy::DrawVertex(float x, float y, bool shadow)
|
||||
|
@ -359,8 +363,12 @@ void C4FoWDrawWireframeStrategy::Begin(const C4FoWRegion* region)
|
|||
{
|
||||
}
|
||||
|
||||
void C4FoWDrawWireframeStrategy::End(C4ShaderCall& call)
|
||||
void C4FoWDrawWireframeStrategy::End(const StdProjectionMatrix& projectionMatrix, const C4Shader& renderShader)
|
||||
{
|
||||
C4ShaderCall call(&renderShader);
|
||||
call.Start();
|
||||
call.SetUniformMatrix4x4(C4FoWRSU_ProjectionMatrix, projectionMatrix);
|
||||
|
||||
// If we have nothing to draw (e.g. directly after initialization), abort early.
|
||||
if (vertices.empty()) return;
|
||||
|
||||
|
@ -421,7 +429,7 @@ void C4FoWDrawWireframeStrategy::End(C4ShaderCall& call)
|
|||
|
||||
// Assume the capacity stays the same:
|
||||
vertices.resize(0);
|
||||
C4FoWDrawStrategy::End(call);
|
||||
C4FoWDrawStrategy::End(projectionMatrix, renderShader);
|
||||
}
|
||||
|
||||
void C4FoWDrawWireframeStrategy::DrawVertex(Vertex& vtx)
|
||||
|
|
|
@ -84,7 +84,10 @@ public:
|
|||
/** Called before each rendering pass */
|
||||
virtual void Begin(const C4FoWRegion* region) = 0;
|
||||
/** Called after each rendering pass */
|
||||
virtual void End(C4ShaderCall& call) { triangulator.Reset(); }
|
||||
/* TODO: shaders should be created in drawstrategy, but: make sure
|
||||
* there is only one shader per class
|
||||
* (static? but then when to clean up?). */
|
||||
virtual void End(const StdProjectionMatrix&, const C4Shader& renderShader) { triangulator.Reset(); }
|
||||
|
||||
virtual void DrawLightVertex(float x, float y) { triangulator.AddVertex(); }
|
||||
virtual void DrawDarkVertex(float x, float y) { triangulator.AddVertex(); }
|
||||
|
@ -124,7 +127,7 @@ public:
|
|||
virtual void DrawLightVertex(float x, float y);
|
||||
virtual void DrawDarkVertex(float x, float y);
|
||||
virtual void Begin(const C4FoWRegion* region);
|
||||
virtual void End(C4ShaderCall& call);
|
||||
virtual void End(const StdProjectionMatrix&, const C4Shader& renderShader);
|
||||
|
||||
private:
|
||||
void DrawVertex(float x, float y, bool shadeLight);
|
||||
|
@ -161,7 +164,7 @@ public:
|
|||
virtual void DrawLightVertex(float x, float y);
|
||||
virtual void DrawDarkVertex(float x, float y);
|
||||
virtual void Begin(const C4FoWRegion* region);
|
||||
virtual void End(C4ShaderCall& call);
|
||||
virtual void End(const StdProjectionMatrix&, const C4Shader& renderShader);
|
||||
|
||||
private:
|
||||
struct Vertex {
|
||||
|
|
|
@ -119,7 +119,7 @@ void C4FoWLight::Update(C4Rect Rec)
|
|||
sections[i]->Update(Rec);
|
||||
}
|
||||
|
||||
void C4FoWLight::Render(C4FoWRegion *region, const C4TargetFacet *onScreen, C4ShaderCall& call)
|
||||
void C4FoWLight::Render(C4FoWRegion *region, const C4TargetFacet *onScreen, const StdProjectionMatrix& projectionMatrix, const C4Shader& renderShader)
|
||||
{
|
||||
TriangleList triangles;
|
||||
|
||||
|
@ -157,7 +157,7 @@ void C4FoWLight::Render(C4FoWRegion *region, const C4TargetFacet *onScreen, C4Sh
|
|||
DrawFade(strategy.get(), triangles);
|
||||
DrawIntermediateFadeTriangles(strategy.get(), triangles);
|
||||
|
||||
strategy->End(call);
|
||||
strategy->End(projectionMatrix, renderShader);
|
||||
}
|
||||
|
||||
void C4FoWLight::CalculateFanMaxed(TriangleList &triangles) const
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
/** Update all light beams within the given rectangle for this light */
|
||||
void Update(C4Rect r);
|
||||
/** Render this light*/
|
||||
void Render(class C4FoWRegion *pRegion, const C4TargetFacet *pOnScreen, C4ShaderCall& call);
|
||||
void Render(class C4FoWRegion *pRegion, const C4TargetFacet *pOnScreen, const StdProjectionMatrix& projectionMatrix, const C4Shader& renderShader);
|
||||
|
||||
bool IsVisibleForPlayer(C4Player *player) const; // check if attached to an object that is not hostile to the given player
|
||||
|
||||
|
|
Loading…
Reference in New Issue