@Mauru wrote:
Hi there - first of all I am new here so excuse me if this is the wrong place to ask or if i sound incoherent or overly confused
![]()
I am trying to extract the Color[] data of a 512x512 texture on a Windows OpenGL Project and am running into an "IndexOutOfRange" - Exception.
My GetData call (not called every draw call, dont worry
) :
Rectangle extractRegion = new Rectangle(x, y, width, height); Color[] rawData = new Color[width * height]; texture.GetData<Color>(0, extractRegion, rawData, 0, width * height);
The relevant code from Texture2D.OpenGL.cs { Line 284 }
var temp = new T[this.width * this.height]; GL.GetTexImage(TextureTarget.Texture2D, level, this.glFormat, this.glType, temp); int z = 0, w = 0; for (int y = rect.Value.Y; y < rect.Value.Y + rect.Value.Height; ++y) { for (int x = rect.Value.X; x < rect.Value.X + rect.Value.Width; ++x) { data[z * rect.Value.Width + w] = temp[(y * width) + x]; ++w; } ++z; w = 0; }
My guess is this might be related to this old issue : https://github.com/MonoGame/MonoGame/issues/2958
It seems this might be due to the texture size (since smaller textures work fine) or rather the max index/length of the array...
Am I missing something incredibly obvious?
Posts: 6
Participants: 2