Add method to check if texture IDs and vertex buffer IDs are valid.

This commit is contained in:
UnknownShadow200 2015-05-16 07:36:55 +10:00
parent 1b2013f689
commit 345df89a45
2 changed files with 12 additions and 0 deletions

View File

@ -40,6 +40,8 @@ namespace ClassicalSharp.GraphicsAPI {
DeleteTexture( ref texture.ID );
}
public abstract bool IsValidTexture( int texId );
/// <summary> Whether fog is currently enabled. </summary>
public abstract bool Fog { set; }
@ -123,6 +125,8 @@ namespace ClassicalSharp.GraphicsAPI {
public abstract IndexedVbInfo InitIndexedVb<T>( T[] vertices, ushort[] indices, DrawMode mode,
int verticesCount, int indicesCount ) where T : struct;
public abstract bool IsValidVb( int vb );
public abstract void DeleteVb( int id );
public abstract void DeleteIndexedVb( IndexedVbInfo id );

View File

@ -165,6 +165,10 @@ namespace ClassicalSharp.GraphicsAPI {
texId = -1;
}
public override bool IsValidTexture( int texId ) {
return GL.IsTexture( texId );
}
public override bool Texturing {
set { ToggleCap( EnableCap.Texture2D, value ); }
}
@ -371,6 +375,10 @@ namespace ClassicalSharp.GraphicsAPI {
GL.Arb.DeleteBuffers( 2, ref id.Vb );
}
public override bool IsValidVb( int vb ) {
return useVbos ? GL.Arb.IsBuffer( vb ) : GL.IsList( vb );
}
public override void DrawVbPos3fTex2f( DrawMode mode, int id, int verticesCount ) {
BeginVbBatch( VertexFormat.VertexPos3fTex2f );
DrawVbBatch( mode, id, verticesCount );