Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Limiting the draw area of each widget to a specific area

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2012
    Location
    Belgium
    Posts
    4

    Limit the draw area of each widget to a specific area

    Hi,

    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.

    Thanks,

    A
    Last edited by _Apollo_; 04-17-2013 at 06:57 AM.

  2. #2
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    381
    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

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2012
    Location
    Belgium
    Posts
    4
    Thanks that did the trick.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •