I want to place text in window. The text shall automatically shift to another location if the given location is occupied (having other text printed already).
My steps of detecting whether an area is available for print are:
- Convert text’s obj cooridnates into window coordinates;
- Calculate the size of the rectagnel that holds the text in window;
- Read all pixels of the rectangle (glReadPixels);
- Compare each pixel’s color with background color;
- If all pixels hold bg color, pint; otherwise, select another rectangle and repeat 1/2/3/4.
Yet, I can only obtain correct pixel info occasionally.
Could you corrrect the steps if necessary, or suggest a better method of smartly placing text?