[libavg-devel] Div Node Rotations Patch
Nick Hebner
hebnern at gmail.com
Sun Aug 19 23:48:10 CEST 2007
On 8/19/07, Ulrich von Zadow <uzadow at libavg.de> wrote:
>
> Nick Hebner schrieb:
> >
> > On 8/18/07, *Nick Hebner* <hebnern at gmail.com <mailto:hebnern at gmail.com>>
> > wrote:
> >
> > Attached is a patch moving rotations into Node. This fixed the clip
> > lanes problem clipping members of the div, but somehow introduced a
> > bug where items outside of the div are being clipped (the 'Click
> > Here to Rotate' text in my script for instance). I am nos sure why
> > this is occurring, and will continue to look into it. If you have
> > any ideas, let me know.
> >
> >
> > Ok, I think I figured out the problem. The way that pushClipRect was
> > written, it only applied the clip rect in ogl if it was for a div node.
> > This was leaving the old clip planes around, and clipping the next
> > element that was rendered. I removed the bClip bool from pushClipRect,
> > so they are always applied. Let me know if there are any other issues
> > with this patch.
>
> Looking at the code again, I think the bool parameter worked and was
> there for a reason... but there's other things. If you run make check,
> you'll see several failing tests :-(. The test code is in
> src/test/Test.py. The images that changed are in src/test/resultimages.
> It seems that rotations are applied twice now.
Ah yeah, I guess I can take the rotation stuff out of the
DisplayEngine::blt* functions since it is happening elsewhere now.
Also, now that I look at it more closely, I see something else: The
> current clip rectangles are calculated as intersections of clip
> rectangles up the node hierarchy and then the resulting rectangle is
> used for the opengl clipping planes - have a look at
> Node::getVisibleRect(). This will break if there are rotations in between.
>
> I am not sure how to solve this cleanly. Without rotations, there is
> always just a clipping rectangle. With rotations, there is an arbitrary
> convex clipping polygon - the intersection of several, possibly rotated
> rectangles. And opengl allows only 6 clipping planes to be set :-(. (If
> I'm not being clear, draw a few <divs> rotated differently on paper - if
> the clipping rectangles intersect, the resulting region isn't a
> rectangle anymore.)
>
> One possible way would be to make <div> nodes non-clipping and add a
> <clip> node that adds a clipping rectangle. Only one <clip> node could
> be active at a time...
>
> Or draw the clipping region into the stencil buffer and use that to clip
> - actually, I'm beginning to like that the best.
Any better ideas?
That sounds like the best route to me too - it would seem that this is a
perfect job for the stencil buffer. I am not extraordinarily familiar with
the gl api in general, but some quick research on the stencil buffer gave me
the following idea. Does this look feasible to you?
int m_clipLevel;
pushClipRect()
glStencilFunc(GL_NEVER, 0, 0);
glStencilOp(GL_INC, GL_INC, GL_INC);
m_clipLevel++;
// Draw clip rectangle into stencil buffer
// Only allow pixels on the current clip level through
glStencilFunc(GL_EQUAL, m_clipLevel, 0xFFFFFFFF);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
popClipRect()
glStencilFunc(GL_NEVER, 0, 0);
glStencilOp(GL_DEC, GL_DEC, GL_DEC);
m_clipLevel--;
// Draw clip rectangle into stencil buffer
glStencilFunc(GL_EQUAL, m_clipLevel, 0xFFFFFFFF);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
Regards,
>
> Uli
>
> --
>
> Ulrich von Zadow | +49-172-7872715 | cocacoder at jabber.berlin.ccc.de
>
>
Nick Hebner
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.datenhain.de/pipermail/libavg-devel/attachments/20070819/9177c84a/attachment.html
More information about the libavg-devel
mailing list