Okay, so my game is crashing on some computers and I don’t know the reason for it…
Crashes seem to be related to OpenTK/Graphics/Textures and System.TypeInitializationException.
Here’s first error, it might have some typos because I wrote it by hand
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often indication that other memory is corrupt.
at OpenTK.Graphics.OpenGL.GL.GetTexImage[T4](TextureTarget target, Int32 level, PixelFormat format, PixelType type, T4[] pixels)
at Microsoft.Xna.Framework.Graphics.Texture2D.PlatformGetData[t](Int32 level, Int32 arraySlice, Nullable 1 rect, T[] data, Int32 startIndex, Int32 elementCount)
at Microsoft.Xna.Framework.Graphics.Texture2D.GetData[T](Int32 level, Int32 arraySlice, Nullable 1 rect, T[] data, Int32 startIndex, Int32 elementCount)
at Microsoft.Xna.Framework.Graphics.Texture2D.GetData[T](T[] data)
at MyGame.ContentHandler.RecolorTextureAsWhite(Texture2D sourceTexture) in
(filename + line number + jumps through the code here)
…and here’s the function, sourceTexture is not null or default(Texture2D), its checked before calling this function
public Texture2D RecolorTextureAsWhite(Texture2D sourceTexture)
{
Texture2D recoloredTexture = new Texture2D(sourceTexture.GraphicsDevice, sourceTexture.Width, sourceTexture.Height);
Color[] data = new Color[sourceTexture.Width * sourceTexture.Height];
sourceTexture.GetData(data);
for (int i = 0; i < data.Length; i++)
{
if (data[i].A > 100)
{
data[i] = Color.White;
}
else
{
data[i] = Color.Transparent;
}
}
recoloredTexture.SetData(data);
return recoloredTexture;
}
Another mysterious error:
Unhandled Exception: System.TypeInitializationException: The type initializer for 'MyGame.Objects.ExplosionEffect' threw an exception. ---> System.InvalidOperationException: This image format is not supported ---> System.OutOfMemoryException: Out of memory.