Improve out-of-memory logging with more details.

Also ensure that when OpenGL gives an out-of-memory error, we throw an OutOfMemoryException so the improved logging is triggered here too.
This commit is contained in:
RoosterDragon
2016-09-11 16:59:54 +01:00
parent af0249f2ae
commit 696d783a67
2 changed files with 40 additions and 21 deletions

View File

@@ -48,6 +48,7 @@ namespace OpenRA.Platforms.Default
// Errors
public const int GL_NO_ERROR = 0;
public const int GL_OUT_OF_MEMORY = 0x505;
// BeginMode
public const int GL_POINTS = 0;
@@ -489,9 +490,14 @@ namespace OpenRA.Platforms.Default
var n = glGetError();
if (n != GL_NO_ERROR)
{
var error = "GL Error: {0}\n{1}".F(n, new StackTrace());
var errorText = n == GL_OUT_OF_MEMORY ? "Out Of Memory" : n.ToString();
var error = "GL Error: {0}\n{1}".F(errorText, new StackTrace());
WriteGraphicsLog(error);
throw new InvalidOperationException("OpenGL Error: See graphics.log for details.");
const string ExceptionMessage = "OpenGL Error: See graphics.log for details.";
if (n == GL_OUT_OF_MEMORY)
throw new OutOfMemoryException(ExceptionMessage);
else
throw new InvalidOperationException(ExceptionMessage);
}
}