diff --git a/GraphicsAPI/IGraphicsApi.cs b/GraphicsAPI/IGraphicsApi.cs index d2a987bd4..6116d6194 100644 --- a/GraphicsAPI/IGraphicsApi.cs +++ b/GraphicsAPI/IGraphicsApi.cs @@ -122,11 +122,11 @@ namespace ClassicalSharp.GraphicsAPI { public abstract void DeleteIb( int ib ); - public abstract void DrawVb( DrawMode mode, VertexFormat format, int id, int verticesCount ); + public abstract void DrawVb( DrawMode mode, VertexFormat format, int id, int offset, int verticesCount ); public abstract void BeginVbBatch( VertexFormat format ); - public abstract void DrawVbBatch( DrawMode mode, int id, int verticesCount ); + public abstract void DrawVbBatch( DrawMode mode, int id, int offset, int verticesCount ); public abstract void EndVbBatch(); diff --git a/GraphicsAPI/OpenGLApi.cs b/GraphicsAPI/OpenGLApi.cs index 6b4064ab5..23f12f201 100644 --- a/GraphicsAPI/OpenGLApi.cs +++ b/GraphicsAPI/OpenGLApi.cs @@ -190,10 +190,10 @@ namespace ClassicalSharp.GraphicsAPI { #if TRACK_RESOURCES Dictionary vbs = new Dictionary(); #endif - Action drawBatchFunc; - Action drawBatchFuncTex2f; - Action drawBatchFuncCol4b; - Action drawBatchFuncTex2fCol4b; + Action drawBatchFunc; + Action drawBatchFuncTex2f; + Action drawBatchFuncCol4b; + Action drawBatchFuncTex2fCol4b; public override int CreateDynamicVb( VertexFormat format, int maxVertices ) { @@ -235,7 +235,7 @@ namespace ClassicalSharp.GraphicsAPI { GL.Arb.BufferSubData( BufferTargetArb.ArrayBuffer, IntPtr.Zero, new IntPtr( sizeInBytes ), vertices ); BeginVbBatch( format ); - DrawVbBatch( mode, vb, count ); + DrawVbBatch( mode, vb, 0, count ); EndVbBatch(); } @@ -265,9 +265,9 @@ namespace ClassicalSharp.GraphicsAPI { return GL.Arb.IsBuffer( ib ); } - public override void DrawVb( DrawMode mode, VertexFormat format, int id, int verticesCount ) { + public override void DrawVb( DrawMode mode, VertexFormat format, int id, int offset, int verticesCount ) { BeginVbBatch( format ); - DrawVbBatch( mode, id, verticesCount ); + DrawVbBatch( mode, id, offset, verticesCount ); EndVbBatch(); } @@ -288,8 +288,8 @@ namespace ClassicalSharp.GraphicsAPI { EnableClientState( VertexFormat.Pos3fTex2fCol4b ); } - public override void DrawVbBatch( DrawMode mode, int id, int verticesCount ) { - drawBatchFunc( mode, id, verticesCount ); + public override void DrawVbBatch( DrawMode mode, int id, int offset, int verticesCount ) { + drawBatchFunc( mode, id, offset, verticesCount ); } public override void DrawIndexedVbBatch( DrawMode mode, int vb, int ib, int indicesCount ) { @@ -312,26 +312,26 @@ namespace ClassicalSharp.GraphicsAPI { GL.Arb.BindBuffer( BufferTargetArb.ElementArrayBuffer, 0 ); } - void DrawVbPos3fTex2fFast( DrawMode mode, int id, int verticesCount ) { + void DrawVbPos3fTex2fFast( DrawMode mode, int id, int offset, int verticesCount ) { GL.Arb.BindBuffer( BufferTargetArb.ArrayBuffer, id ); GL.VertexPointer( 3, VertexPointerType.Float, 20, new IntPtr( 0 ) ); GL.TexCoordPointer( 2, TexCoordPointerType.Float, 20, new IntPtr( 12 ) ); - GL.DrawArrays( modeMappings[(int)mode], 0, verticesCount ); + GL.DrawArrays( modeMappings[(int)mode], offset, verticesCount ); } - void DrawVbPos3fCol4bFast( DrawMode mode, int id, int verticesCount ) { + void DrawVbPos3fCol4bFast( DrawMode mode, int id, int offset, int verticesCount ) { GL.Arb.BindBuffer( BufferTargetArb.ArrayBuffer, id ); GL.VertexPointer( 3, VertexPointerType.Float, 16, new IntPtr( 0 ) ); GL.ColorPointer( 4, ColorPointerType.UnsignedByte, 16, new IntPtr( 12 ) ); - GL.DrawArrays( modeMappings[(int)mode], 0, verticesCount ); + GL.DrawArrays( modeMappings[(int)mode], offset, verticesCount ); } - void DrawVbPos3fTex2fCol4bFast( DrawMode mode, int id, int verticesCount ) { + void DrawVbPos3fTex2fCol4bFast( DrawMode mode, int id, int offset, int verticesCount ) { GL.Arb.BindBuffer( BufferTargetArb.ArrayBuffer, id ); GL.VertexPointer( 3, VertexPointerType.Float, 24, new IntPtr( 0 ) ); GL.TexCoordPointer( 2, TexCoordPointerType.Float, 24, new IntPtr( 12 ) ); GL.ColorPointer( 4, ColorPointerType.UnsignedByte, 24, new IntPtr( 20 ) ); - GL.DrawArrays( modeMappings[(int)mode], 0, verticesCount ); + GL.DrawArrays( modeMappings[(int)mode], offset, verticesCount ); } static void EnableClientState( VertexFormat format ) { diff --git a/Model/ModelPart.cs b/Model/ModelPart.cs index 73f74ef8a..9ac03108f 100644 --- a/Model/ModelPart.cs +++ b/Model/ModelPart.cs @@ -16,7 +16,7 @@ namespace ClassicalSharp { } public void Render() { - Graphics.DrawVb( DrawMode.Triangles, VertexFormat.Pos3fTex2fCol4b, VbId, Count ); + Graphics.DrawVb( DrawMode.Triangles, VertexFormat.Pos3fTex2fCol4b, VbId, 0, Count ); } public void Dispose() { diff --git a/Rendering/MapEnvRenderer.cs b/Rendering/MapEnvRenderer.cs index 28ea18f82..bb17d6134 100644 --- a/Rendering/MapEnvRenderer.cs +++ b/Rendering/MapEnvRenderer.cs @@ -45,7 +45,7 @@ namespace ClassicalSharp { Graphics.Texturing = true; Graphics.Bind2DTexture( sideTexId ); - Graphics.DrawVb( DrawMode.Triangles, VertexFormat.Pos3fTex2fCol4b, sidesVboId, sidesVertices ); + Graphics.DrawVb( DrawMode.Triangles, VertexFormat.Pos3fTex2fCol4b, sidesVboId, 0, sidesVertices ); Graphics.Texturing = false; } @@ -55,7 +55,7 @@ namespace ClassicalSharp { Graphics.Texturing = true; Graphics.AlphaBlending = true; Graphics.Bind2DTexture( edgeTexId ); - Graphics.DrawVb( DrawMode.Triangles, VertexFormat.Pos3fTex2fCol4b, edgesVboId, edgesVertices ); + Graphics.DrawVb( DrawMode.Triangles, VertexFormat.Pos3fTex2fCol4b, edgesVboId, 0, edgesVertices ); Graphics.AlphaBlending = false; Graphics.Texturing = false; } diff --git a/Rendering/StandardEnvRenderer.cs b/Rendering/StandardEnvRenderer.cs index b17c5a245..8689c0043 100644 --- a/Rendering/StandardEnvRenderer.cs +++ b/Rendering/StandardEnvRenderer.cs @@ -29,7 +29,7 @@ namespace ClassicalSharp.Renderers { Vector3 pos = Window.LocalPlayer.EyePosition; if( pos.Y < Map.Height + skyOffset ) { - Graphics.DrawVb( DrawMode.Triangles, VertexFormat.Pos3fCol4b, skyVbo, skyVertices ); + Graphics.DrawVb( DrawMode.Triangles, VertexFormat.Pos3fCol4b, skyVbo, 0, skyVertices ); } RenderClouds( deltaTime ); ResetFog(); @@ -97,7 +97,7 @@ namespace ClassicalSharp.Renderers { Graphics.AlphaTest = true; Graphics.Texturing = true; Graphics.Bind2DTexture( cloudTexture ); - Graphics.DrawVb( DrawMode.Triangles, VertexFormat.Pos3fTex2fCol4b, cloudsVbo, cloudsVertices ); + Graphics.DrawVb( DrawMode.Triangles, VertexFormat.Pos3fTex2fCol4b, cloudsVbo, 0, cloudsVertices ); Graphics.AlphaTest = false; Graphics.Texturing = false; diff --git a/Selections/SelectionBox.cs b/Selections/SelectionBox.cs index 56f668ff9..ccc983f9b 100644 --- a/Selections/SelectionBox.cs +++ b/Selections/SelectionBox.cs @@ -27,9 +27,9 @@ namespace ClassicalSharp.Selections { public void Render( double delta ) { Graphics.DepthWrite = false; - Graphics.DrawVbBatch( DrawMode.Triangles, VboId, VerticesCount ); + Graphics.DrawVbBatch( DrawMode.Triangles, VboId, 0, VerticesCount ); Graphics.DepthWrite = true; - Graphics.DrawVbBatch( DrawMode.Lines, LineVboId, LineVerticesCount ); + Graphics.DrawVbBatch( DrawMode.Lines, LineVboId, 0, LineVerticesCount ); } public SelectionBox( Vector3I start, Vector3I end, FastColour col, IGraphicsApi graphics ) { diff --git a/Utils/Utils.cs b/Utils/Utils.cs index 3d0f2419e..24279e2cb 100644 --- a/Utils/Utils.cs +++ b/Utils/Utils.cs @@ -6,10 +6,11 @@ using OpenTK; namespace ClassicalSharp { // NOTE: These delegates should be removed when using versions later than NET 2.0. - // ################################################################ - public delegate void Action( T1 arg1, T2 arg2 ); + // ################################################################ public delegate void Action(); + public delegate void Action( T1 arg1, T2 arg2 ); public delegate void Action( T1 arg1, T2 arg2, T3 arg3 ); + public delegate void Action( T1 arg1, T2 arg2, T3 arg3, T4 arg4 ); public delegate TResult Func(); public delegate TResult Func( T1 arg1 ); public delegate TResult Func( T1 arg1, T2 arg2 );