2
\$\begingroup\$

I'm currently using the Farseer tools to create a body from a Texture2D. However, my texture is a spritesheet and I need to get the uint array containing the colors from a portion of the full Texture2D.

Let's say may texture is 200x200 big and I need to get the colors in the Rectangle(20, 20, 40, 40). I know that there is a GetData() overload and I'd imagine I have to call it like this:

        uint[] subData = new uint[40 * 40];
        polygonTexture.GetData(0, new Rectangle(20, 20, 40, 40), subData, 0, 40*40);

However, I always get a System.NotImplementedException, probably due to MonoGame. Is there another easy way to do this? Or do I have to create a Subtexture and then get the Colors from that subtexture?

\$\endgroup\$
  • 2
    \$\begingroup\$ Ah, System.NotImplementedException. The classiest way of saying "couldn't be bothered". \$\endgroup\$ – Anko Apr 15 '13 at 21:01
  • 1
    \$\begingroup\$ The best way would be to implement the missing functionality in MonoGame so the next person to try this won't get a NotImplementedException. Be bothered ;) \$\endgroup\$ – craftworkgames Apr 15 '13 at 23:55
  • \$\begingroup\$ This doesn't sound too bad, actually, although I don't really know much about DirectX/OpenGL, but I'll look into it. \$\endgroup\$ – brdigi Apr 16 '13 at 19:38
2
\$\begingroup\$

I noticed this question has been around for a while unanswered so I thought I'd put some information here for future reference. It's not a complete answer, but it might help the next person.

Is seems there are a number of open issues with lots of discussion around this issue and why it's difficult to implement.

https://github.com/mono/MonoGame/issues/1405

https://github.com/mono/MonoGame/issues/644

https://github.com/mono/MonoGame/pull/1789

The primary issue is that OpenGL ES 2.0 does not support retrieving data from textures. However, it looks like there have been plenty of attempts to solve it and it may be solved now for some platforms. Not sure.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.