diff --git a/OpenRA.Game/Graphics/HardwarePalette.cs b/OpenRA.Game/Graphics/HardwarePalette.cs index 98f486e2cf..f3acab51d0 100644 --- a/OpenRA.Game/Graphics/HardwarePalette.cs +++ b/OpenRA.Game/Graphics/HardwarePalette.cs @@ -78,9 +78,9 @@ namespace OpenRA.Graphics data[j,i] = c[i]; } - // Doesn't work + // TODO: Doesn't work (why?) texture.SetData(data); - Game.Renderer.PaletteTexture = texture; + Game.Renderer.SetPalette(texture); } } } diff --git a/OpenRA.Game/Graphics/LineRenderer.cs b/OpenRA.Game/Graphics/LineRenderer.cs index 63baa7cde5..96776cc684 100644 --- a/OpenRA.Game/Graphics/LineRenderer.cs +++ b/OpenRA.Game/Graphics/LineRenderer.cs @@ -78,7 +78,7 @@ namespace OpenRA.Graphics DrawLine(new float2(r.Left, y), new float2(r.Right, y), color, color); } - public void SetShaderParams(ITexture palette, Size screen, float zoom, float2 scroll) + public void SetViewportParams(Size screen, float zoom, float2 scroll) { shader.SetVec("Scroll", (int)scroll.X, (int)scroll.Y); shader.SetVec("r1", zoom*2f/screen.Width, -zoom*2f/screen.Height); diff --git a/OpenRA.Game/Graphics/QuadRenderer.cs b/OpenRA.Game/Graphics/QuadRenderer.cs index 83ecf2886c..05140a5ac6 100644 --- a/OpenRA.Game/Graphics/QuadRenderer.cs +++ b/OpenRA.Game/Graphics/QuadRenderer.cs @@ -57,7 +57,7 @@ namespace OpenRA.Graphics nv += 4; } - public void SetShaderParams(ITexture palette, Size screen, float zoom, float2 scroll) + public void SetViewportParams(Size screen, float zoom, float2 scroll) { shader.SetVec("Scroll", (int)scroll.X, (int)scroll.Y); shader.SetVec("r1", zoom*2f/screen.Width, -zoom*2f/screen.Height); diff --git a/OpenRA.Game/Graphics/Renderer.cs b/OpenRA.Game/Graphics/Renderer.cs index 443ad08844..8c1bbd0ea0 100644 --- a/OpenRA.Game/Graphics/Renderer.cs +++ b/OpenRA.Game/Graphics/Renderer.cs @@ -34,8 +34,6 @@ namespace OpenRA.Graphics public SpriteRenderer RgbaSpriteRenderer { get; private set; } public SpriteRenderer SpriteRenderer { get; private set; } - public ITexture PaletteTexture; - Queue> tempBuffers = new Queue>(); public Dictionary Fonts; @@ -67,12 +65,19 @@ namespace OpenRA.Graphics public void BeginFrame(float2 scroll, float zoom) { device.Clear(); - WorldSpriteRenderer.SetShaderParams(PaletteTexture, Resolution, zoom, scroll); - WorldLineRenderer.SetShaderParams(PaletteTexture, Resolution, zoom, scroll); - WorldQuadRenderer.SetShaderParams(PaletteTexture, Resolution, zoom, scroll); - SpriteRenderer.SetShaderParams(PaletteTexture, Resolution, 1f, float2.Zero); - LineRenderer.SetShaderParams(PaletteTexture, Resolution, 1f, float2.Zero); - RgbaSpriteRenderer.SetShaderParams(PaletteTexture, Resolution, 1f, float2.Zero); + WorldSpriteRenderer.SetViewportParams(Resolution, zoom, scroll); + SpriteRenderer.SetViewportParams(Resolution, 1f, float2.Zero); + RgbaSpriteRenderer.SetViewportParams(Resolution, 1f, float2.Zero); + WorldLineRenderer.SetViewportParams(Resolution, zoom, scroll); + WorldQuadRenderer.SetViewportParams(Resolution, zoom, scroll); + LineRenderer.SetViewportParams(Resolution, 1f, float2.Zero); + } + + public void SetPalette(ITexture paletteTexture) + { + RgbaSpriteRenderer.SetPalette(paletteTexture); + SpriteRenderer.SetPalette(paletteTexture); + WorldSpriteRenderer.SetPalette(paletteTexture); } public void EndFrame(IInputHandler inputHandler) diff --git a/OpenRA.Game/Graphics/SpriteRenderer.cs b/OpenRA.Game/Graphics/SpriteRenderer.cs index 5140c2a99a..c73485213f 100644 --- a/OpenRA.Game/Graphics/SpriteRenderer.cs +++ b/OpenRA.Game/Graphics/SpriteRenderer.cs @@ -87,9 +87,13 @@ namespace OpenRA.Graphics shader.Render(() => renderer.DrawBatch(buffer, start, length, type)); } - public void SetShaderParams(ITexture palette, Size screen, float zoom, float2 scroll) + public void SetPalette(ITexture palette) { shader.SetTexture("Palette", palette); + } + + public void SetViewportParams(Size screen, float zoom, float2 scroll) + { shader.SetVec("Scroll", (int)scroll.X, (int)scroll.Y); shader.SetVec("r1", zoom*2f/screen.Width, -zoom*2f/screen.Height); shader.SetVec("r2", -1, 1);