fix leaky textures & vbos

This commit is contained in:
Chris Forbes
2011-05-05 19:16:45 +12:00
parent 75588b050e
commit a52d7fb496
4 changed files with 14 additions and 25 deletions

View File

@@ -40,6 +40,9 @@ namespace OpenRA.Renderer.Glsl
SetData(bitmap);
}
void FinalizeInner() { UpdateMemoryUsage(0); Gl.glDeleteTextures(1, ref texture); }
~Texture() { Game.RunAfterTick(FinalizeInner); }
void PrepareTexture()
{
GraphicsDevice.CheckGlError();

View File

@@ -15,7 +15,7 @@ using Tao.OpenGl;
namespace OpenRA.Renderer.Glsl
{
public class VertexBuffer<T> : IVertexBuffer<T>, IDisposable
public class VertexBuffer<T> : IVertexBuffer<T>
where T : struct
{
int buffer;
@@ -52,16 +52,7 @@ namespace OpenRA.Renderer.Glsl
GraphicsDevice.CheckGlError();
}
bool disposed;
public void Dispose()
{
if (disposed) return;
GC.SuppressFinalize(this);
Gl.glDeleteBuffers(1, ref buffer);
GraphicsDevice.CheckGlError();
disposed = true;
}
//~VertexBuffer() { Dispose(); }
void FinalizeInner() { Gl.glDeleteBuffers( 1, ref buffer ); }
~VertexBuffer() { Game.RunAfterTick( FinalizeInner ); }
}
}