Problem with ReadPixels
Monkey Targets Forums/XNA/Problem with ReadPixels
| ||
I draw my screen, then run this: '(w=512 h=512) Local buf:=New Int[w*2*h] ReadPixels buf,0,0,w,h,w,w*2 But I always get this error, and only in XNA (not GLFW, iOS or Android): Monkey Runtime Error : The rectangle is too large or too small for this resource. Parameter name: rect Does anyone have any ideas why this might only be happening in the XNA target? |
| ||
OK, I found the problem, and it's only on XNA. If the CreateImage is larger than the DeviceWidth/DeviceHeight on XNA, then ReadPixels breaks. I had it at 512x512, but when I changed it to 480x320 (my Width/Height) then it worked. I've yet to see if this change has any affect on other platforms yet. |
| ||
How would you read from outside the current buffer? Makes sense, no? |
| ||
What I need to draw will draw off screen, and there are no errors if I draw off screen. So I didn't think there would be a problem with drawing what I always draw, then reading all the pixels. Plus it worked fine in GLFW, Android, iOS, and Flash as it was. So I didn't see any reason why it wouldn't work in XNA, which is the problem. Monkey is supposed to be code-once and work on all targets, which isn't true in this case, so that doesn't make sense to me. ReadPixels needs to be fixed so that it works the same with all targets. |
| ||
I'm very surprised you are getting any pixels offscreen on other targets. |
| ||
It may not be getting the pixels off-screen, but it's allowing the code to work and not cause errors. |