mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 02:25:32 -04:00
Don't bind to buffer 0 since we always use vertex buffers.
This commit is contained in:
parent
5d1fbbb578
commit
d6bbf39432
@ -140,10 +140,8 @@ namespace ClassicalSharp {
|
|||||||
} else {
|
} else {
|
||||||
SplitText( value );
|
SplitText( value );
|
||||||
}
|
}
|
||||||
lastSplitText = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static string lastSplitText;
|
|
||||||
static void SplitText( string value ) {
|
static void SplitText( string value ) {
|
||||||
int code = 0xF;
|
int code = 0xF;
|
||||||
for( int i = 0; i < value.Length; i++ ) {
|
for( int i = 0; i < value.Length; i++ ) {
|
||||||
|
@ -270,9 +270,6 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
device.DrawPrimitives( modeMappings[(int)mode], startVertex, NumPrimitives( verticesCount, mode ) );
|
device.DrawPrimitives( modeMappings[(int)mode], startVertex, NumPrimitives( verticesCount, mode ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void EndVbBatch() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void BeginIndexedVbBatch() {
|
public override void BeginIndexedVbBatch() {
|
||||||
device.VertexFormat = formatMapping[(int)VertexFormat.Pos3fTex2fCol4b];
|
device.VertexFormat = formatMapping[(int)VertexFormat.Pos3fTex2fCol4b];
|
||||||
batchStride = VertexPos3fTex2fCol4b.Size;
|
batchStride = VertexPos3fTex2fCol4b.Size;
|
||||||
|
@ -126,8 +126,6 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
|
|
||||||
public abstract void DrawVbBatch( DrawMode mode, int id, int startVertex, int verticesCount );
|
public abstract void DrawVbBatch( DrawMode mode, int id, int startVertex, int verticesCount );
|
||||||
|
|
||||||
public abstract void EndVbBatch();
|
|
||||||
|
|
||||||
public abstract void BeginIndexedVbBatch();
|
public abstract void BeginIndexedVbBatch();
|
||||||
|
|
||||||
public abstract void DrawIndexedVbBatch( DrawMode mode, int vb, int ib, int indicesCount,
|
public abstract void DrawIndexedVbBatch( DrawMode mode, int vb, int ib, int indicesCount,
|
||||||
|
@ -29,9 +29,9 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
}
|
}
|
||||||
base.InitDynamicBuffers();
|
base.InitDynamicBuffers();
|
||||||
|
|
||||||
drawBatchFuncCol4b = DrawVbPos3fCol4b;
|
setupBatchFuncCol4b = SetupVbPos3fCol4b;
|
||||||
drawBatchFuncTex2f = DrawVbPos3fTex2f;
|
setupBatchFuncTex2f = SetupVbPos3fTex2f;
|
||||||
drawBatchFuncTex2fCol4b = DrawVbPos3fTex2fCol4b;
|
setupBatchFuncTex2fCol4b = SetupVbPos3fTex2fCol4b;
|
||||||
Gl.glEnableClientState( ArrayCap.VertexArray );
|
Gl.glEnableClientState( ArrayCap.VertexArray );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,10 +185,8 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
|
|
||||||
#region Vertex buffers
|
#region Vertex buffers
|
||||||
|
|
||||||
Action<DrawMode, int, int, int> drawBatchFunc;
|
Action setupBatchFunc;
|
||||||
Action<DrawMode, int, int, int> drawBatchFuncTex2f;
|
Action setupBatchFuncTex2f, setupBatchFuncCol4b, setupBatchFuncTex2fCol4b;
|
||||||
Action<DrawMode, int, int, int> drawBatchFuncCol4b;
|
|
||||||
Action<DrawMode, int, int, int> drawBatchFuncTex2fCol4b;
|
|
||||||
|
|
||||||
public unsafe override int CreateDynamicVb( VertexFormat format, int maxVertices ) {
|
public unsafe override int CreateDynamicVb( VertexFormat format, int maxVertices ) {
|
||||||
int id = 0;
|
int id = 0;
|
||||||
@ -196,7 +194,6 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
int sizeInBytes = maxVertices * strideSizes[(int)format];
|
int sizeInBytes = maxVertices * strideSizes[(int)format];
|
||||||
Gl.glBindBufferARB( BufferTarget.ArrayBuffer, id );
|
Gl.glBindBufferARB( BufferTarget.ArrayBuffer, id );
|
||||||
Gl.glBufferDataARB( BufferTarget.ArrayBuffer, new IntPtr( sizeInBytes ), IntPtr.Zero, BufferUsageHint.DynamicDraw );
|
Gl.glBufferDataARB( BufferTarget.ArrayBuffer, new IntPtr( sizeInBytes ), IntPtr.Zero, BufferUsageHint.DynamicDraw );
|
||||||
Gl.glBindBufferARB( BufferTarget.ArrayBuffer, 0 );
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +205,6 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
GCHandle handle = GCHandle.Alloc( vertices, GCHandleType.Pinned );
|
GCHandle handle = GCHandle.Alloc( vertices, GCHandleType.Pinned );
|
||||||
Gl.glBufferDataARB( BufferTarget.ArrayBuffer, new IntPtr( sizeInBytes ), handle.AddrOfPinnedObject(), BufferUsageHint.StaticDraw );
|
Gl.glBufferDataARB( BufferTarget.ArrayBuffer, new IntPtr( sizeInBytes ), handle.AddrOfPinnedObject(), BufferUsageHint.StaticDraw );
|
||||||
handle.Free();
|
handle.Free();
|
||||||
Gl.glBindBufferARB( BufferTarget.ArrayBuffer, 0 );
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,20 +216,19 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
fixed( ushort* ptr = indices ) {
|
fixed( ushort* ptr = indices ) {
|
||||||
Gl.glBufferDataARB( BufferTarget.ElementArrayBuffer, new IntPtr( sizeInBytes ), (IntPtr)ptr, BufferUsageHint.StaticDraw );
|
Gl.glBufferDataARB( BufferTarget.ElementArrayBuffer, new IntPtr( sizeInBytes ), (IntPtr)ptr, BufferUsageHint.StaticDraw );
|
||||||
}
|
}
|
||||||
Gl.glBindBufferARB( BufferTarget.ElementArrayBuffer, 0 );
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawDynamicVb<T>( DrawMode mode, int vb, T[] vertices, VertexFormat format, int count ) {
|
public override void DrawDynamicVb<T>( DrawMode mode, int id, T[] vertices, VertexFormat format, int count ) {
|
||||||
int sizeInBytes = count * strideSizes[(int)format];
|
int sizeInBytes = count * strideSizes[(int)format];
|
||||||
Gl.glBindBufferARB( BufferTarget.ArrayBuffer, vb );
|
Gl.glBindBufferARB( BufferTarget.ArrayBuffer, id );
|
||||||
GCHandle handle = GCHandle.Alloc( vertices, GCHandleType.Pinned );
|
GCHandle handle = GCHandle.Alloc( vertices, GCHandleType.Pinned );
|
||||||
Gl.glBufferSubDataARB( BufferTarget.ArrayBuffer, IntPtr.Zero, new IntPtr( sizeInBytes ), handle.AddrOfPinnedObject() );
|
Gl.glBufferSubDataARB( BufferTarget.ArrayBuffer, IntPtr.Zero, new IntPtr( sizeInBytes ), handle.AddrOfPinnedObject() );
|
||||||
handle.Free();
|
handle.Free();
|
||||||
|
|
||||||
BeginVbBatch( format );
|
BeginVbBatch( format );
|
||||||
DrawVbBatch( mode, vb, 0, count );
|
setupBatchFunc();
|
||||||
EndVbBatch();
|
Gl.glDrawArrays( modeMappings[(int)mode], 0, count );
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe override void DeleteDynamicVb( int id ) {
|
public unsafe override void DeleteDynamicVb( int id ) {
|
||||||
@ -261,8 +256,9 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
|
|
||||||
public override void DrawVb( DrawMode mode, VertexFormat format, int id, int startVertex, int verticesCount ) {
|
public override void DrawVb( DrawMode mode, VertexFormat format, int id, int startVertex, int verticesCount ) {
|
||||||
BeginVbBatch( format );
|
BeginVbBatch( format );
|
||||||
DrawVbBatch( mode, id, startVertex, verticesCount );
|
Gl.glBindBufferARB( BufferTarget.ArrayBuffer, id );
|
||||||
EndVbBatch();
|
setupBatchFunc();
|
||||||
|
Gl.glDrawArrays( modeMappings[(int)mode], startVertex, verticesCount );
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexFormat batchFormat = (VertexFormat)999;
|
VertexFormat batchFormat = (VertexFormat)999;
|
||||||
@ -282,13 +278,13 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
if( format == VertexFormat.Pos3fTex2fCol4b ) {
|
if( format == VertexFormat.Pos3fTex2fCol4b ) {
|
||||||
Gl.glEnableClientState( ArrayCap.ColorArray );
|
Gl.glEnableClientState( ArrayCap.ColorArray );
|
||||||
Gl.glEnableClientState( ArrayCap.TextureCoordArray );
|
Gl.glEnableClientState( ArrayCap.TextureCoordArray );
|
||||||
drawBatchFunc = drawBatchFuncTex2fCol4b;
|
setupBatchFunc = setupBatchFuncTex2fCol4b;
|
||||||
} else if( format == VertexFormat.Pos3fTex2f ) {
|
} else if( format == VertexFormat.Pos3fTex2f ) {
|
||||||
Gl.glEnableClientState( ArrayCap.TextureCoordArray );
|
Gl.glEnableClientState( ArrayCap.TextureCoordArray );
|
||||||
drawBatchFunc = drawBatchFuncTex2f;
|
setupBatchFunc = setupBatchFuncTex2f;
|
||||||
} else if( format == VertexFormat.Pos3fCol4b ) {
|
} else if( format == VertexFormat.Pos3fCol4b ) {
|
||||||
Gl.glEnableClientState( ArrayCap.ColorArray );
|
Gl.glEnableClientState( ArrayCap.ColorArray );
|
||||||
drawBatchFunc = drawBatchFuncCol4b;
|
setupBatchFunc = setupBatchFuncCol4b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +293,9 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawVbBatch( DrawMode mode, int id, int startVertex, int verticesCount ) {
|
public override void DrawVbBatch( DrawMode mode, int id, int startVertex, int verticesCount ) {
|
||||||
drawBatchFunc( mode, id, startVertex, verticesCount );
|
Gl.glBindBufferARB( BufferTarget.ArrayBuffer, id );
|
||||||
|
setupBatchFunc();
|
||||||
|
Gl.glDrawArrays( modeMappings[(int)mode], startVertex, verticesCount );
|
||||||
}
|
}
|
||||||
|
|
||||||
const DrawElementsType indexType = DrawElementsType.UnsignedShort;
|
const DrawElementsType indexType = DrawElementsType.UnsignedShort;
|
||||||
@ -313,35 +311,24 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
Gl.glDrawElements( modeMappings[(int)mode], indicesCount, indexType, new IntPtr( startIndex * 2 ) );
|
Gl.glDrawElements( modeMappings[(int)mode], indicesCount, indexType, new IntPtr( startIndex * 2 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void EndVbBatch() {
|
|
||||||
Gl.glBindBufferARB( BufferTarget.ArrayBuffer, 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void EndIndexedVbBatch() {
|
public override void EndIndexedVbBatch() {
|
||||||
Gl.glBindBufferARB( BufferTarget.ArrayBuffer, 0 );
|
|
||||||
Gl.glBindBufferARB( BufferTarget.ElementArrayBuffer, 0 );
|
Gl.glBindBufferARB( BufferTarget.ElementArrayBuffer, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawVbPos3fTex2f( DrawMode mode, int id, int offset, int verticesCount ) {
|
void SetupVbPos3fTex2f() {
|
||||||
Gl.glBindBufferARB( BufferTarget.ArrayBuffer, id );
|
|
||||||
Gl.glVertexPointer( 3, PointerType.Float, 20, new IntPtr( 0 ) );
|
Gl.glVertexPointer( 3, PointerType.Float, 20, new IntPtr( 0 ) );
|
||||||
Gl.glTexCoordPointer( 2, PointerType.Float, 20, new IntPtr( 12 ) );
|
Gl.glTexCoordPointer( 2, PointerType.Float, 20, new IntPtr( 12 ) );
|
||||||
Gl.glDrawArrays( modeMappings[(int)mode], offset, verticesCount );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawVbPos3fCol4b( DrawMode mode, int id, int offset, int verticesCount ) {
|
void SetupVbPos3fCol4b() {
|
||||||
Gl.glBindBufferARB( BufferTarget.ArrayBuffer, id );
|
|
||||||
Gl.glVertexPointer( 3, PointerType.Float, 16, new IntPtr( 0 ) );
|
Gl.glVertexPointer( 3, PointerType.Float, 16, new IntPtr( 0 ) );
|
||||||
Gl.glColorPointer( 4, PointerType.UnsignedByte, 16, new IntPtr( 12 ) );
|
Gl.glColorPointer( 4, PointerType.UnsignedByte, 16, new IntPtr( 12 ) );
|
||||||
Gl.glDrawArrays( modeMappings[(int)mode], offset, verticesCount );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawVbPos3fTex2fCol4b( DrawMode mode, int id, int offset, int verticesCount ) {
|
void SetupVbPos3fTex2fCol4b() {
|
||||||
Gl.glBindBufferARB( BufferTarget.ArrayBuffer, id );
|
|
||||||
Gl.glVertexPointer( 3, PointerType.Float, 24, new IntPtr( 0 ) );
|
Gl.glVertexPointer( 3, PointerType.Float, 24, new IntPtr( 0 ) );
|
||||||
Gl.glColorPointer( 4, PointerType.UnsignedByte, 24, new IntPtr( 12 ) );
|
Gl.glColorPointer( 4, PointerType.UnsignedByte, 24, new IntPtr( 12 ) );
|
||||||
Gl.glTexCoordPointer( 2, PointerType.Float, 24, new IntPtr( 16 ) );
|
Gl.glTexCoordPointer( 2, PointerType.Float, 24, new IntPtr( 16 ) );
|
||||||
Gl.glDrawArrays( modeMappings[(int)mode], offset, verticesCount );
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -51,7 +51,6 @@ namespace ClassicalSharp.Selections {
|
|||||||
box.Render( delta );
|
box.Render( delta );
|
||||||
}
|
}
|
||||||
Graphics.AlphaBlending = false;
|
Graphics.AlphaBlending = false;
|
||||||
Graphics.EndVbBatch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user