The error I get is "An unhandled exception of type 'OpenTK.Graphics.GraphicsContextException' occurred in OpenTK.dll
Additional information: Failed to make context 131072 current. Error: 0"
I've searched around and I can't find what's causing it and I'm not sure on where to start if I wanted to fix it myself. The code that I believe is causing it is:
public static Texture2D GetRectangle(int width, int height, Color colour, bool fill)
{
Color[] _rectangleData = new Color[width * height];
Color _fillColour;
if (fill)
{
_fillColour = colour;
}
else
{
_fillColour = Color.Transparent;
}
//create top
for (int x = 0; x < width; x++)
{
_rectangleData[x] = colour;
}
//create sides
for (int y = 1; y < height - 1; y++)
{
_rectangleData[y * width] = colour;
for (int x = 1; x < width - 1; x++)
{
_rectangleData[y * width + x] = _fillColour;
}
_rectangleData[y * width + (width - 1)] = colour;
}
//create bottom
for (int x = 0; x < width; x++)
{
_rectangleData[width * (height - 1) + x] = colour;
}
Texture2D texture = TextureManager.newTexture2D(width, height);
texture.SetData(_rectangleData);
return texture;
}
Which I call once to make a square which I can use to draw a grid. It is static as it's part of the class I use to handle textures so I'm not passing the graphicsDevice around the whole project. Once I disable this method from being run the error doesn't appear. If it is enabled, it will run for a few seconds before crashing, sometimes the window will turn black. I have already checked to see if it was maybe being looped by something which caused it to overload something, but it is only ever called upon once.
I am using Empty Keys which is a GUI library for Monogame based off WPF, although this doesn't seem to be causing any issues. I am open to changes made in order to draw a square, although I would like to know what's causing this issue so if it comes up in the future I can deal with it.