Report all OpenGL errors
This commit is contained in:
@@ -13,6 +13,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using SDL2;
|
using SDL2;
|
||||||
@@ -750,15 +751,20 @@ namespace OpenRA.Platforms.Default
|
|||||||
if (type == GL_NO_ERROR)
|
if (type == GL_NO_ERROR)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string errorText;
|
var errors = new List<int>();
|
||||||
errorText = ErrorToText.TryGetValue(type, out errorText) ? errorText : type.ToStringInvariant("X");
|
do
|
||||||
var error = $"GL Error: {errorText}\n{new StackTrace()}";
|
{
|
||||||
|
errors.Add(type);
|
||||||
|
type = glGetError();
|
||||||
|
}
|
||||||
|
while (type != GL_NO_ERROR);
|
||||||
|
|
||||||
WriteGraphicsLog(error);
|
var stringErrors = string.Join(',', errors.Select(error => ErrorToText.TryGetValue(error, out var errorText) ? errorText : error.ToStringInvariant("X")));
|
||||||
|
WriteGraphicsLog($"GL Errors: {stringErrors}\n{new StackTrace()}");
|
||||||
|
|
||||||
const string exceptionMessage = "OpenGL Error: See graphics.log for details.";
|
const string exceptionMessage = "OpenGL Error: See graphics.log for details.";
|
||||||
|
|
||||||
if (type == GL_OUT_OF_MEMORY)
|
if (errors.Contains(GL_OUT_OF_MEMORY))
|
||||||
throw new OutOfMemoryException(exceptionMessage);
|
throw new OutOfMemoryException(exceptionMessage);
|
||||||
|
|
||||||
throw new InvalidOperationException(exceptionMessage);
|
throw new InvalidOperationException(exceptionMessage);
|
||||||
|
|||||||
Reference in New Issue
Block a user