diff --git a/GraphicsAPI/IGraphicsApi.cs b/GraphicsAPI/IGraphicsApi.cs
index 42866445e..5c16567cb 100644
--- a/GraphicsAPI/IGraphicsApi.cs
+++ b/GraphicsAPI/IGraphicsApi.cs
@@ -40,6 +40,8 @@ namespace ClassicalSharp.GraphicsAPI {
DeleteTexture( ref texture.ID );
}
+ public abstract bool IsValidTexture( int texId );
+
/// Whether fog is currently enabled.
public abstract bool Fog { set; }
@@ -123,6 +125,8 @@ namespace ClassicalSharp.GraphicsAPI {
public abstract IndexedVbInfo InitIndexedVb( 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 );
diff --git a/GraphicsAPI/OpenGLApi.cs b/GraphicsAPI/OpenGLApi.cs
index f694f394e..c75334573 100644
--- a/GraphicsAPI/OpenGLApi.cs
+++ b/GraphicsAPI/OpenGLApi.cs
@@ -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 );