tags:

views:

373

answers:

4

Hi all,
I've got the mouseclick handler correctly set up. I have a drawing with some shapes. Is there any way for me to fill the surrounding part of a point until it hits a polygon boundary. Something like Microsoft Paint's "fill" command.

Thanks!

A: 

Using opengl? I seriously doubt that ... What you can do ist to detect the shape selected by the mouse click and draw this shape in a different color.

MartinStettner
How do I detect the shape?
Michael
+4  A: 

Consider using OpenGL selection capabilities with glSelectBuffer.
Refer to this chapter of the red book for explanation.

Amro
+1  A: 

What you're looking for is called a Flood Fill and it's a per-pixel algorithm; which means you're going to want to look at either Frame buffer objects with shaders or use the (very slow) glDrawPixels.

Ron Warholic
+2  A: 

The advice to use glSelectBuffer is pretty good. Once you've read that chapter, however, look for the "Now that you know" chapter, and look for a section named "Object Selection Using the Back Buffer" -- it's a lot simpler, and usually entirely adequate.

Jerry Coffin