? Find color value of 'pixel' in color buffer?

Member
Posts: 48
Joined: 2009.05
Post: #1
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
Quote this message in a reply
Member
Posts: 269
Joined: 2005.04
Post: #2
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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL Pixel Buffer Object setup issue dotbianry 2 3,247 Jan 6, 2013 11:03 AM
Last Post: dotbianry
  Problem with the graphics color on a videogame for iphone femmedragon 6 4,861 Dec 16, 2012 07:37 PM
Last Post: SethWillits
  How do I do Color Picking? dockode 2 5,167 Sep 24, 2011 08:02 PM
Last Post: dockode
  iPhone OpenGL color bug agreendev 8 7,347 Aug 12, 2010 08:20 PM
Last Post: AnotherJake
  [CoreGraphics] Image manipulation - pixel by pixel g00se 5 10,155 Jul 28, 2010 08:27 AM
Last Post: ThemsAllTook