iDevGames Forums
? Find color value of 'pixel' in color buffer? - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: ? Find color value of 'pixel' in color buffer? (/thread-974.html)



? Find color value of 'pixel' in color buffer? - Elphaba - Jul 22, 2009 12:23 PM

Hi

I'm trying to come up with a fast way of doing pixel perfect collision detection, and I don't know if I've stumbled across one.

More importantly, I don't know if it will work on the iPhone, so I thought I'd run it past you guys, ok?

If you know the colors of two differently colored objects, and you write to the color buffer for the first object - call it 'the BACKGROUND', and then you disable writes to the color buffer, and write the other object - call it 'the AVATAR', then where the color of the BACKGROUND would have changed, if they were blended with say an 'additive blend', then at that point you know you have a collision.

Right?

So can this be done on ES 1.1 = I've been googling all afternoon and can't seem to get an answer.

Thanks


? Find color value of 'pixel' in color buffer? - Bachus - Jul 22, 2009 01:23 PM

Elphaba Wrote:If you know the colors of two differently colored objects, and you write to the color buffer for the first object - call it 'the BACKGROUND', and then you disable writes to the color buffer, and write the other object - call it 'the AVATAR', then where the color of the BACKGROUND would have changed, if they were blended with say an 'additive blend', then at that point you know you have a collision.

glReadPixels() will read back values in the color buffer that you can then test. The problem is glReadPixels() is *extremely* slow on the iPhone. If you want to test individual pixel values in that way you'd probably be better off keeping track of your own pixel array separate from OpenGL.