Results 1 to 3 of 3

Thread: Nested Clipping

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2008

    Nested Clipping

    I'm try create a windowing system using OpenGL. I have a series of nested frames that represent windows. Each has its own local transformation so that if you move the parent frame, all children frames move as well. Each frame also has a width and height. I would like to clip what is drawn in the child frames by each of the parent frames.

    Is there an easy way to do this?

    I was looking at clipping planes. I could use 4 clipping planes to clip to the child to the parent frame, but this would not clip a child to its grandparent frame.

    I'm not sure how to proceed.

  2. #2
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001

    Re: Nested Clipping

    glScissor may help you. Or stencil buffer.

  3. #3
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Watford, UK

    Re: Nested Clipping

    Maintain a stack of clipping rectangles and draw-offset points.

    Code :
    extern RECT ClipRect;
    extern POINT DrawOffs;
    bool xEnterClip(x,y,wid,hei){
       RECT clip1 = {x,y,x+wid,y+hei};
       ClipRect = IntersectRect(ClipRect,clip1);
       if(Rectangle_Area(ClipRect)==0)return false;
       return true;
    void xLeaveClip(){

    I personally find it better to not use scissors, just my own rectangle-clipping code - scissors weren't present in some widely-used cards, and there are less than 200 quads per window to draw.

    Also, you can use the z-buffer for different windows, that will overlap. (add a preliminary stage that only draws to z).

Similar Threads

  1. Nested loop issue
    By Theodor Mader in forum OpenGL: GLSL
    Replies: 0
    Last Post: 08-16-2012, 03:56 AM
  2. Nested Timer Queries
    By skynet in forum OpenGL: General
    Replies: 9
    Last Post: 08-24-2011, 08:51 AM
  3. Nested Asset
    By Rasson in forum COLLADA
    Replies: 5
    Last Post: 11-10-2010, 04:16 AM
  4. nested FBO render to texture? RT1(RT2(), RT2())?
    By Zarniwoop in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 07-04-2010, 02:08 PM
  5. Nested FBO's slowdown
    By eldritch in forum OpenGL: Advanced Coding
    Replies: 9
    Last Post: 01-18-2007, 03:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean