diff --git a/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs b/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs index 95ebb25387..572c1d1c76 100755 --- a/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs +++ b/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs @@ -57,7 +57,7 @@ namespace OpenRA.FileFormats.Graphics public interface IIndexBuffer { void Bind(); - void SetData( ushort[] indices, int length ); + void SetData( uint[] indices, int length ); } public interface IShader diff --git a/OpenRA.Game/Graphics/LineRenderer.cs b/OpenRA.Game/Graphics/LineRenderer.cs index e461538d23..d0b14b1167 100644 --- a/OpenRA.Game/Graphics/LineRenderer.cs +++ b/OpenRA.Game/Graphics/LineRenderer.cs @@ -18,7 +18,7 @@ namespace OpenRA.Graphics Renderer renderer; Vertex[] vertices = new Vertex[ Renderer.TempBufferSize ]; - ushort[] indices = new ushort[ Renderer.TempBufferSize ]; + uint[] indices = new uint[ Renderer.TempBufferSize ]; int nv = 0, ni = 0; public LineRenderer( Renderer renderer ) diff --git a/OpenRA.Game/Graphics/SpriteRenderer.cs b/OpenRA.Game/Graphics/SpriteRenderer.cs index cdbe35f5b3..035a802c20 100644 --- a/OpenRA.Game/Graphics/SpriteRenderer.cs +++ b/OpenRA.Game/Graphics/SpriteRenderer.cs @@ -18,7 +18,7 @@ namespace OpenRA.Graphics IShader shader; Vertex[] vertices = new Vertex[Renderer.TempBufferSize]; - ushort[] indices = new ushort[Renderer.TempBufferSize]; + uint[] indices = new uint[Renderer.TempBufferSize]; Sheet currentSheet = null; int nv = 0, ni = 0; diff --git a/OpenRA.Game/Graphics/TerrainRenderer.cs b/OpenRA.Game/Graphics/TerrainRenderer.cs index b4505b2291..1907a4cca5 100644 --- a/OpenRA.Game/Graphics/TerrainRenderer.cs +++ b/OpenRA.Game/Graphics/TerrainRenderer.cs @@ -35,7 +35,7 @@ namespace OpenRA.Graphics x => Game.modData.SheetBuilder.Add(world.TileSet.GetBytes(x), tileSize)); Vertex[] vertices = new Vertex[4 * map.Bounds.Height * map.Bounds.Width]; - ushort[] indices = new ushort[6 * map.Bounds.Height * map.Bounds.Width]; + uint[] indices = new uint[6 * map.Bounds.Height * map.Bounds.Width]; terrainSheet = tileMapping[map.MapTiles.Value[map.Bounds.Left, map.Bounds.Top]].sheet; diff --git a/OpenRA.Game/Graphics/Util.cs b/OpenRA.Game/Graphics/Util.cs index c3aad0901b..ead333b2ff 100644 --- a/OpenRA.Game/Graphics/Util.cs +++ b/OpenRA.Game/Graphics/Util.cs @@ -44,7 +44,7 @@ namespace OpenRA.Graphics static float[] channelSelect = { 0.75f, 0.25f, -0.25f, -0.75f }; - public static void FastCreateQuad(Vertex[] vertices, ushort[] indices, float2 o, Sprite r, int palette, int nv, int ni, float2 size) + public static void FastCreateQuad(Vertex[] vertices, uint[] indices, float2 o, Sprite r, int palette, int nv, int ni, float2 size) { var attrib = new float2(palette / (float)HardwarePalette.MaxPalettes, channelSelect[(int)r.channel]); @@ -55,12 +55,12 @@ namespace OpenRA.Graphics vertices[nv + 2] = new Vertex(new float2(o.X, o.Y + size.Y), r.FastMapTextureCoords(2), attrib); vertices[nv + 3] = new Vertex(new float2(o.X + size.X, o.Y + size.Y), - r.FastMapTextureCoords(3), attrib); - - indices[ni] = (ushort)(nv); - indices[ni + 1] = indices[ni + 3] = (ushort)(nv + 1); - indices[ni + 2] = indices[ni + 5] = (ushort)(nv + 2); - indices[ni + 4] = (ushort)(nv + 3); + r.FastMapTextureCoords(3), attrib); + + indices[ni] = (uint)(nv); + indices[ni + 1] = indices[ni + 3] = (uint)(nv + 1); + indices[ni + 2] = indices[ni + 5] = (uint)(nv + 2); + indices[ni + 4] = (uint)(nv + 3); } static readonly int[] channelMasks = { 2, 1, 0, 3 }; // yes, our channel order is nuts. diff --git a/OpenRA.Renderer.Cg/IndexBuffer.cs b/OpenRA.Renderer.Cg/IndexBuffer.cs index ceb2111389..ddf37aa276 100644 --- a/OpenRA.Renderer.Cg/IndexBuffer.cs +++ b/OpenRA.Renderer.Cg/IndexBuffer.cs @@ -10,7 +10,9 @@ using System; using OpenRA.FileFormats.Graphics; -using Tao.OpenGl; +using Tao.OpenGl; + +using ElemType = System.UInt32; namespace OpenRA.Renderer.Cg { @@ -24,18 +26,18 @@ namespace OpenRA.Renderer.Cg GraphicsDevice.CheckGlError(); Bind(); Gl.glBufferData(Gl.GL_ELEMENT_ARRAY_BUFFER, - new IntPtr(2 * size), - new ushort[ size ], + new IntPtr(sizeof(ElemType) * size), + new ElemType[ size ], Gl.GL_DYNAMIC_DRAW); GraphicsDevice.CheckGlError(); } - public void SetData(ushort[] data, int length) + public void SetData(ElemType[] data, int length) { Bind(); Gl.glBufferSubData(Gl.GL_ELEMENT_ARRAY_BUFFER, IntPtr.Zero, - new IntPtr(2 * length), + new IntPtr(sizeof(ElemType) * length), data); GraphicsDevice.CheckGlError(); } diff --git a/OpenRA.Renderer.Gl/GraphicsDevice.cs b/OpenRA.Renderer.Gl/GraphicsDevice.cs index 2dae7ae3b8..e66589cc65 100755 --- a/OpenRA.Renderer.Gl/GraphicsDevice.cs +++ b/OpenRA.Renderer.Gl/GraphicsDevice.cs @@ -273,14 +273,14 @@ namespace OpenRA.Renderer.Glsl public void DrawIndexedPrimitives( PrimitiveType pt, Range vertices, Range indices ) { Gl.glDrawElements( ModeFromPrimitiveType( pt ), indices.End - indices.Start, - Gl.GL_UNSIGNED_SHORT, new IntPtr( indices.Start * 2 ) ); + Gl.GL_UNSIGNED_INT, new IntPtr( indices.Start * 4 ) ); CheckGlError(); } public void DrawIndexedPrimitives( PrimitiveType pt, int numVerts, int numPrimitives ) { - Gl.glDrawElements( ModeFromPrimitiveType( pt ), numPrimitives * IndicesPerPrimitive( pt ), - Gl.GL_UNSIGNED_SHORT, IntPtr.Zero ); + Gl.glDrawElements( ModeFromPrimitiveType( pt ), numPrimitives * IndicesPerPrimitive( pt ), + Gl.GL_UNSIGNED_INT, IntPtr.Zero); CheckGlError(); } diff --git a/OpenRA.Renderer.Gl/IndexBuffer.cs b/OpenRA.Renderer.Gl/IndexBuffer.cs index dfe49fa5cb..aba056f9ee 100644 --- a/OpenRA.Renderer.Gl/IndexBuffer.cs +++ b/OpenRA.Renderer.Gl/IndexBuffer.cs @@ -12,6 +12,8 @@ using System; using OpenRA.FileFormats.Graphics; using Tao.OpenGl; +using ElemType = System.UInt32; + namespace OpenRA.Renderer.Glsl { public class IndexBuffer : IIndexBuffer, IDisposable @@ -24,18 +26,18 @@ namespace OpenRA.Renderer.Glsl GraphicsDevice.CheckGlError(); Bind(); Gl.glBufferData(Gl.GL_ELEMENT_ARRAY_BUFFER, - new IntPtr(2 * size), - new ushort[ size ], + new IntPtr(sizeof(ElemType) * size), + new ElemType[ size ], Gl.GL_DYNAMIC_DRAW); GraphicsDevice.CheckGlError(); - } - - public void SetData(ushort[] data, int length) + } + + public void SetData(ElemType[] data, int length) { Bind(); Gl.glBufferSubData(Gl.GL_ELEMENT_ARRAY_BUFFER, - IntPtr.Zero, - new IntPtr(2 * length), + IntPtr.Zero, + new IntPtr(sizeof(ElemType) * length), data); GraphicsDevice.CheckGlError(); } diff --git a/OpenRA.Renderer.Null/NullGraphicsDevice.cs b/OpenRA.Renderer.Null/NullGraphicsDevice.cs index 3665ef9739..ef4dedc6d1 100644 --- a/OpenRA.Renderer.Null/NullGraphicsDevice.cs +++ b/OpenRA.Renderer.Null/NullGraphicsDevice.cs @@ -54,7 +54,7 @@ namespace OpenRA.Renderer.Null public class NullIndexBuffer : IIndexBuffer { public void Bind() {} - public void SetData(ushort[] indices, int length) {} + public void SetData(uint[] indices, int length) {} } public class NullShader : IShader