Expose Graphics.Renderer setting; Refactor Renderer.Null.

This commit is contained in:
Paul Chote
2010-11-11 23:53:29 +13:00
parent 233e9326f0
commit ccf66cde2f
11 changed files with 43 additions and 92 deletions

View File

@@ -12,6 +12,7 @@ using System.Drawing;
using System.IO;
using OpenRA.FileFormats.Graphics;
using OpenRA.Graphics;
using System;
[assembly: Renderer(typeof(OpenRA.Renderer.Null.NullGraphicsDevice))]
@@ -23,6 +24,7 @@ namespace OpenRA.Renderer.Null
public NullGraphicsDevice(int width, int height, WindowMode window, bool vsync)
{
Console.WriteLine("Using Null renderer");
WindowSize = new Size(width, height);
}
@@ -46,4 +48,31 @@ namespace OpenRA.Renderer.Null
public ITexture CreateTexture(Bitmap bitmap) { return new NullTexture(); }
public IShader CreateShader(string name) { return new NullShader(); }
}
public class NullIndexBuffer : IIndexBuffer
{
public void Bind() {}
public void SetData(ushort[] indices, int length) {}
}
public class NullShader : IShader
{
public void SetValue(string name, float x, float y) { }
public void SetValue(string param, ITexture texture) { }
public void Commit() { }
public void Render(Action a) { }
}
public class NullTexture : ITexture
{
public void SetData(Bitmap bitmap) { }
public void SetData(uint[,] colors) { }
public void SetData(byte[] colors, int width, int height) { }
}
class NullVertexBuffer<T> : IVertexBuffer<T>
{
public void Bind() { }
public void SetData(T[] vertices, int length) { }
}
}

View File

@@ -1,20 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see LICENSE.
*/
#endregion
using OpenRA.FileFormats.Graphics;
namespace OpenRA.Renderer.Null
{
public class NullIndexBuffer : IIndexBuffer
{
public void Bind() {}
public void SetData(ushort[] indices, int length) {}
}
}

View File

@@ -1,23 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see LICENSE.
*/
#endregion
using System;
using OpenRA.FileFormats.Graphics;
namespace OpenRA.Renderer.Null
{
public class NullShader : IShader
{
public void SetValue(string name, float x, float y) { }
public void SetValue(string param, ITexture texture) { }
public void Commit() { }
public void Render(Action a) { }
}
}

View File

@@ -1,22 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see LICENSE.
*/
#endregion
using System.Drawing;
using OpenRA.FileFormats.Graphics;
namespace OpenRA.Renderer.Null
{
public class NullTexture : ITexture
{
public void SetData(Bitmap bitmap) { }
public void SetData(uint[,] colors) { }
public void SetData(byte[] colors, int width, int height) { }
}
}

View File

@@ -1,20 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see LICENSE.
*/
#endregion
using OpenRA.FileFormats.Graphics;
namespace OpenRA.Renderer.Null
{
class NullVertexBuffer<T> : IVertexBuffer<T>
{
public void Bind() { }
public void SetData(T[] vertices, int length) { }
}
}

View File

@@ -48,10 +48,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="NullGraphicsDevice.cs" />
<Compile Include="NullIndexBuffer.cs" />
<Compile Include="NullShader.cs" />
<Compile Include="NullTexture.cs" />
<Compile Include="NullVertexBuffer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>