Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Complicated hit buffer question

15 views
Skip to first unread message

Bint

unread,
Jul 21, 2012, 2:52:12 PM7/21/12
to
Hello,

I have an iphone app which uses OpenGL ES 1.x. I detect hits on objects
by drawing vertex buffer objects into an offscreen hit buffer, where each
object's color is a different number. Then I read the buffer location to
tell which object was hit.

I am adding the ability to have various 'layers' of objects, and each layer
has its own hit vertex buffer object with object 'colors' ranging from 1 to
the number of objects.

This works fine as long as I only detect hits on one layer at a time, but
there are occasions when I want to draw all the layers together and detect a
hit. In that case, I would have an object with color '1' on each layer, and
I wouldn't be able to tell which was the chosen object.

I'm wondering if there is a way to do this without re-rendering all these
vertext buffer objects. I was thinking maybe there was some way that I
could tell opengl to add a value to every color it drew. Is that possible?

So then say layer 1 has 100 objects, I would draw it normally. Then I would
draw layer two with a color offset of 100, where that value would be added
to every pixel. Is there anything like that available?

I imagine not, because the color are probably treated by their rgb channels
anyway,so that addition wouldn't work. Any other suggestions of a way to do
it without reconstructing my vbo's?

Thanks
B

bob smith

unread,
Jul 30, 2012, 7:45:56 PM7/30/12
to
Yes, there is something like that. It's called GL_BLEND. You would do something like this:

glEnable(GL_BLEND);

glBlendFunc(GL_ONE, GL_ONE);

When you pass GL_ONE and GL_ONE to the blend function, I think it tells OpenGL to add the source color to the destination color.
0 new messages