Add offset parameter to DrawVb/DrawVbBatch.

This commit is contained in:
UnknownShadow200 2015-06-01 06:17:09 +10:00
parent aba1ae465c
commit 2c18ebc5bb
7 changed files with 27 additions and 26 deletions

View File

@ -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();

View File

@ -190,10 +190,10 @@ namespace ClassicalSharp.GraphicsAPI {
#if TRACK_RESOURCES
Dictionary<int, string> vbs = new Dictionary<int, string>();
#endif
Action<DrawMode, int, int> drawBatchFunc;
Action<DrawMode, int, int> drawBatchFuncTex2f;
Action<DrawMode, int, int> drawBatchFuncCol4b;
Action<DrawMode, int, int> drawBatchFuncTex2fCol4b;
Action<DrawMode, int, int, int> drawBatchFunc;
Action<DrawMode, int, int, int> drawBatchFuncTex2f;
Action<DrawMode, int, int, int> drawBatchFuncCol4b;
Action<DrawMode, int, int, int> 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 ) {

View File

@ -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() {

View File

@ -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;
}

View File

@ -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;

View File

@ -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 ) {

View File

@ -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, T2>( T1 arg1, T2 arg2 );
// ################################################################
public delegate void Action();
public delegate void Action<T1, T2>( T1 arg1, T2 arg2 );
public delegate void Action<T1, T2, T3>( T1 arg1, T2 arg2, T3 arg3 );
public delegate void Action<T1, T2, T3, T4>( T1 arg1, T2 arg2, T3 arg3, T4 arg4 );
public delegate TResult Func<TResult>();
public delegate TResult Func<T1, TResult>( T1 arg1 );
public delegate TResult Func<T1, T2, TResult>( T1 arg1, T2 arg2 );