Limit the draw area of each widget to a specific area
I have a problem and I don't know how I can fix it.
Ok, what I 'm trying to do is to draw a widget (like a rectangle).
The widget has in its structure an X,Y coordinate pair that defines a reference point for the rectangle, a width and a height.
These are the items I use to draw the rectangle.
Now, in this structure there is a second width and height that defines the area that the rectangle may use.
If the rectangle width/height is larger than the area width/height, then the the drawn rectangle is limited to the area width/height.
The draw of the widget has to be clipped on the area boundaries.
For now I solved it by using glScissor to limit the area where the widget can be drawn.
An other option of the widget is that I can rotate the rectangle.
Now when I rotate the rectangle, the drawn rectangle is rotated but I cannot rotate the scissor box.
This results in the rectangle is drawn completely out of the scissor area and nothing is drawn.
I can not reposition the scissor box because it is always an X, Y oriented box and not on a given angle.
Does somebody knows how this can be done.
I have to use OpenGL 1.0 and I can not use all the functions available.
Actually I use OpenGL 1.0 SC.
Last edited by _Apollo_; 04-17-2013 at 06:57 AM.
If the clipping region needs to rotate with the rectangle, you could use the stencil buffer. A quick description + example can be found here: http://en.wikibooks.org/wiki/OpenGL_...Stencil_buffer
If you still want to use scissor test, you could either create a much larger clipping rect centered on the rotation point, or grow/shrink the clipping rect using an approach like this: http://stackoverflow.com/questions/6...picture-inside
Thanks that did the trick.