Dispose of graphics resources deterministically.
Textures, FrameBuffers and VertexBuffers allocated by the Sdl2 Renderer were only being released via finalizers. This could lead to OpenGL out of memory errors since resources may not be cleaned up in a timely manner. To avoid this, IDisposable has been implemented and transitively applied to classes that use these resources. As a side-effect some static state is no longer static, particularly in Renderer, in order to facilitate this change and just for nicer design in general. Also dispose some bitmaps.
This commit is contained in:
committed by
RoosterDragon
parent
38b579a081
commit
f0f02dff5c
@@ -63,7 +63,7 @@ namespace OpenRA
|
||||
void ReleaseWindowMouseFocus();
|
||||
}
|
||||
|
||||
public interface IVertexBuffer<T>
|
||||
public interface IVertexBuffer<T> : IDisposable
|
||||
{
|
||||
void Bind();
|
||||
void SetData(T[] vertices, int length);
|
||||
@@ -80,7 +80,8 @@ namespace OpenRA
|
||||
}
|
||||
|
||||
public enum TextureScaleFilter { Nearest, Linear }
|
||||
public interface ITexture
|
||||
|
||||
public interface ITexture : IDisposable
|
||||
{
|
||||
void SetData(Bitmap bitmap);
|
||||
void SetData(uint[,] colors);
|
||||
@@ -90,7 +91,7 @@ namespace OpenRA
|
||||
TextureScaleFilter ScaleFilter { get; set; }
|
||||
}
|
||||
|
||||
public interface IFrameBuffer
|
||||
public interface IFrameBuffer : IDisposable
|
||||
{
|
||||
void Bind();
|
||||
void Unbind();
|
||||
|
||||
Reference in New Issue
Block a user