From 44c0b2f2bf913354e62d25b1acc81d8db37372cc Mon Sep 17 00:00:00 2001 From: Michael Oborne Date: Fri, 18 Aug 2023 12:34:54 +1000 Subject: [PATCH] HUD: add dispose to cleanup opengl textures - traced via GL Intercept --- ExtLibs/Controls/HUD.cs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/ExtLibs/Controls/HUD.cs b/ExtLibs/Controls/HUD.cs index dc4dc6369a..79a8aceea4 100644 --- a/ExtLibs/Controls/HUD.cs +++ b/ExtLibs/Controls/HUD.cs @@ -274,6 +274,30 @@ public HUD() graphicsObjectGDIP = new GdiGraphics(Graphics.FromImage(objBitmap)); } + protected override void Dispose(bool disposing) + { + log.Info("HUD Dispose"); + + if (opengl) + { + foreach (character texid in _texture) + { + if (texid != null && texid.gltextureid != 0) + GL.DeleteTexture(texid.gltextureid); + } + + this._texture = new character[_texture.Length]; + + foreach (character texid in charDict.Values) + { + if (texid.gltextureid != 0) + GL.DeleteTexture(texid.gltextureid); + } + } + + base.Dispose(disposing); + } + private float _roll = 0; private float _navroll = 0; private float _pitch = 0; @@ -1782,8 +1806,6 @@ public void FillRectangle(Brush brushh, RectangleF rectf) GL.Begin(PrimitiveType.TriangleFan); - GL.LineWidth(0); - if (((Type) brushh.GetType()) == typeof(LinearGradientBrush)) { LinearGradientBrush temp = (LinearGradientBrush) brushh;