How do I check whether a pixel is filled or not on a canvas in OpenGL?

263 Views Asked by At

I am trying to detect whether a particular pixel is filled or not in OpenGL in order to implement the flood fill algorithm. So, I searched and found the glreadpixel function but I don't get how I can use this function and whether or not it can solve my problem.

2

There are 2 best solutions below

0
On BEST ANSWER

The proper way is probably not to read back pixels. Instead, you should do all manipulations in a bitmap that you manage on your own. Then you request OpenGL to show this bitmap.

0
On

OpenGL is not a image manipulation library. It's a drawing API and it should not be used for tasks like this. Reading back image data is very expensive in OpenGL and should be avoided.