Introduce Renderer.WorldBufferSnapshot().
This commit is contained in:
@@ -46,7 +46,6 @@ namespace OpenRA.Graphics
|
||||
readonly List<IRenderable> renderablesBuffer = new();
|
||||
readonly IRenderer[] renderers;
|
||||
readonly IRenderPostProcessPass[] postProcessPasses;
|
||||
readonly ITexture postProcessTexture;
|
||||
|
||||
internal WorldRenderer(ModData modData, World world)
|
||||
{
|
||||
@@ -75,8 +74,6 @@ namespace OpenRA.Graphics
|
||||
debugVis = Exts.Lazy(() => world.WorldActor.TraitOrDefault<DebugVisualizations>());
|
||||
|
||||
postProcessPasses = world.WorldActor.TraitsImplementing<IRenderPostProcessPass>().ToArray();
|
||||
if (postProcessPasses.Length > 0)
|
||||
postProcessTexture = Game.Renderer.Context.CreateTexture();
|
||||
}
|
||||
|
||||
public void BeginFrame()
|
||||
@@ -323,18 +320,13 @@ namespace OpenRA.Graphics
|
||||
|
||||
void ApplyPostProcessing(PostProcessPassType type)
|
||||
{
|
||||
var size = Game.Renderer.WorldFrameBufferSize;
|
||||
var rect = new Rectangle(0, 0, size.Width, size.Height);
|
||||
foreach (var pass in postProcessPasses)
|
||||
{
|
||||
if (pass.Type != type || !pass.Enabled)
|
||||
continue;
|
||||
|
||||
// Make a copy of the world texture to avoid reading and writing on the same buffer
|
||||
Game.Renderer.Flush();
|
||||
postProcessTexture.SetDataFromReadBuffer(rect);
|
||||
Game.Renderer.Flush();
|
||||
pass.Draw(this, postProcessTexture);
|
||||
pass.Draw(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user