mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 02:56:09 -04:00
Make OpenGL VBO drawing simpler.
This commit is contained in:
parent
1eaab6fcdd
commit
138420c538
@ -126,13 +126,6 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
|
|
||||||
public abstract void DeleteVb( int id );
|
public abstract void DeleteVb( int id );
|
||||||
|
|
||||||
public virtual void DrawVb( DrawMode mode, int id, int verticesCount, VertexFormat format ) {
|
|
||||||
if( format == VertexFormat.VertexPos3f ) DrawVbPos3f( mode, id, verticesCount );
|
|
||||||
else if( format == VertexFormat.VertexPos3fTex2f ) DrawVbPos3fTex2f( mode, id, verticesCount );
|
|
||||||
else if( format == VertexFormat.VertexPos3fCol4b ) DrawVbPos3fCol4b( mode, id, verticesCount );
|
|
||||||
else if( format == VertexFormat.VertexPos3fTex2fCol4b ) DrawVbPos3fTex2fCol4b( mode, id, verticesCount );
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void DrawVbPos3f( DrawMode mode, int id, int verticesCount );
|
public abstract void DrawVbPos3f( DrawMode mode, int id, int verticesCount );
|
||||||
|
|
||||||
public abstract void DrawVbPos3fTex2f( DrawMode mode, int id, int verticesCount );
|
public abstract void DrawVbPos3fTex2f( DrawMode mode, int id, int verticesCount );
|
||||||
|
@ -352,75 +352,27 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawVbPos3f( DrawMode mode, int id, int verticesCount ) {
|
public override void DrawVbPos3f( DrawMode mode, int id, int verticesCount ) {
|
||||||
if( !useVbos ) {
|
BeginVbBatch( VertexFormat.VertexPos3f );
|
||||||
GL.CallList( id );
|
DrawVbBatch( mode, id, verticesCount );
|
||||||
return;
|
EndVbBatch();
|
||||||
}
|
|
||||||
GL.EnableClientState( ArrayCap.VertexArray );
|
|
||||||
|
|
||||||
GL.Arb.BindBuffer( BufferTargetArb.ArrayBuffer, id );
|
|
||||||
GL.VertexPointer( 3, VertexPointerType.Float, 12, new IntPtr( 0 ) );
|
|
||||||
GL.DrawArrays( modeMappings[(int)mode], 0, verticesCount );
|
|
||||||
|
|
||||||
GL.Arb.BindBuffer( BufferTargetArb.ArrayBuffer, 0 );
|
|
||||||
GL.DisableClientState( ArrayCap.VertexArray );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawVbPos3fTex2f( DrawMode mode, int id, int verticesCount ) {
|
public override void DrawVbPos3fTex2f( DrawMode mode, int id, int verticesCount ) {
|
||||||
if( !useVbos ) {
|
BeginVbBatch( VertexFormat.VertexPos3fTex2f );
|
||||||
GL.CallList( id );
|
DrawVbBatch( mode, id, verticesCount );
|
||||||
return;
|
EndVbBatch();
|
||||||
}
|
|
||||||
GL.EnableClientState( ArrayCap.VertexArray );
|
|
||||||
GL.EnableClientState( ArrayCap.TextureCoordArray );
|
|
||||||
|
|
||||||
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.Arb.BindBuffer( BufferTargetArb.ArrayBuffer, 0 );
|
|
||||||
GL.DisableClientState( ArrayCap.VertexArray );
|
|
||||||
GL.DisableClientState( ArrayCap.TextureCoordArray );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawVbPos3fCol4b( DrawMode mode, int id, int verticesCount ) {
|
public override void DrawVbPos3fCol4b( DrawMode mode, int id, int verticesCount ) {
|
||||||
if( !useVbos ) {
|
BeginVbBatch( VertexFormat.VertexPos3fCol4b );
|
||||||
GL.CallList( id );
|
DrawVbBatch( mode, id, verticesCount );
|
||||||
return;
|
EndVbBatch();
|
||||||
}
|
|
||||||
GL.EnableClientState( ArrayCap.VertexArray );
|
|
||||||
GL.EnableClientState( ArrayCap.ColorArray );
|
|
||||||
|
|
||||||
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.Arb.BindBuffer( BufferTargetArb.ArrayBuffer, 0 );
|
|
||||||
GL.DisableClientState( ArrayCap.VertexArray );
|
|
||||||
GL.DisableClientState( ArrayCap.ColorArray );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawVbPos3fTex2fCol4b( DrawMode mode, int id, int verticesCount ) {
|
public override void DrawVbPos3fTex2fCol4b( DrawMode mode, int id, int verticesCount ) {
|
||||||
if( !useVbos ) {
|
BeginVbBatch( VertexFormat.VertexPos3fTex2fCol4b );
|
||||||
GL.CallList( id );
|
DrawVbBatch( mode, id, verticesCount );
|
||||||
return;
|
EndVbBatch();
|
||||||
}
|
|
||||||
GL.EnableClientState( ArrayCap.VertexArray );
|
|
||||||
GL.EnableClientState( ArrayCap.TextureCoordArray );
|
|
||||||
GL.EnableClientState( ArrayCap.ColorArray );
|
|
||||||
|
|
||||||
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.Arb.BindBuffer( BufferTargetArb.ArrayBuffer, 0 );
|
|
||||||
GL.DisableClientState( ArrayCap.VertexArray );
|
|
||||||
GL.DisableClientState( ArrayCap.TextureCoordArray );
|
|
||||||
GL.DisableClientState( ArrayCap.ColorArray );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexFormat batchFormat;
|
VertexFormat batchFormat;
|
||||||
@ -462,6 +414,7 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
GL.DisableClientState( ArrayCap.ColorArray );
|
GL.DisableClientState( ArrayCap.ColorArray );
|
||||||
GL.DisableClientState( ArrayCap.TextureCoordArray );
|
GL.DisableClientState( ArrayCap.TextureCoordArray );
|
||||||
}
|
}
|
||||||
|
GL.Arb.BindBuffer( BufferTargetArb.ArrayBuffer, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawVbPos3fFast( DrawMode mode, int id, int verticesCount ) {
|
void DrawVbPos3fFast( DrawMode mode, int id, int verticesCount ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user