<br><br><div><span class="gmail_quote">On 8/19/07, <b class="gmail_sendername">Ulrich von Zadow</b> <<a href="mailto:uzadow@libavg.de">uzadow@libavg.de</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Nick Hebner schrieb:<br>><br>> On 8/18/07, *Nick Hebner* <<a href="mailto:hebnern@gmail.com">hebnern@gmail.com</a> <mailto:<a href="mailto:hebnern@gmail.com">hebnern@gmail.com</a>>><br>> wrote:<br>>
<br>> Attached is a patch moving rotations into Node. This fixed the clip<br>> lanes problem clipping members of the div, but somehow introduced a<br>> bug where items outside of the div are being clipped (the 'Click
<br>> Here to Rotate' text in my script for instance). I am nos sure why<br>> this is occurring, and will continue to look into it. If you have<br>> any ideas, let me know.<br>><br>><br>> Ok, I think I figured out the problem. The way that pushClipRect was
<br>> written, it only applied the clip rect in ogl if it was for a div node.<br>> This was leaving the old clip planes around, and clipping the next<br>> element that was rendered. I removed the bClip bool from pushClipRect,
<br>> so they are always applied. Let me know if there are any other issues<br>> with this patch.<br><br>Looking at the code again, I think the bool parameter worked and was<br>there for a reason... but there's other things. If you run make check,
<br>you'll see several failing tests :-(. The test code is in<br>src/test/Test.py. The images that changed are in src/test/resultimages.<br>It seems that rotations are applied twice now.</blockquote><div><br>Ah yeah, I guess I can take the rotation stuff out of the DisplayEngine::blt* functions since it is happening elsewhere now.
<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Also, now that I look at it more closely, I see something else: The<br>current clip rectangles are calculated as intersections of clip
<br>rectangles up the node hierarchy and then the resulting rectangle is<br>used for the opengl clipping planes - have a look at<br>Node::getVisibleRect(). This will break if there are rotations in between.<br><br>I am not sure how to solve this cleanly. Without rotations, there is
<br>always just a clipping rectangle. With rotations, there is an arbitrary<br>convex clipping polygon - the intersection of several, possibly rotated<br>rectangles. And opengl allows only 6 clipping planes to be set :-(. (If
<br>I'm not being clear, draw a few <divs> rotated differently on paper - if<br>the clipping rectangles intersect, the resulting region isn't a<br>rectangle anymore.)<br><br>One possible way would be to make <div> nodes non-clipping and add a
<br><clip> node that adds a clipping rectangle. Only one <clip> node could<br>be active at a time...<br><br>Or draw the clipping region into the stencil buffer and use that to clip<br>- actually, I'm beginning to like that the best.
</blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Any better ideas?</blockquote><div><br>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?
<br><br>int m_clipLevel;<br><br>pushClipRect()<br> glStencilFunc(GL_NEVER, 0, 0);<br> glStencilOp(GL_INC, GL_INC, GL_INC);<br><br> m_clipLevel++;<br> // Draw clip rectangle into stencil buffer<br><br> // Only allow pixels on the current clip level through
<br> glStencilFunc(GL_EQUAL, m_clipLevel, 0xFFFFFFFF);<br>
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);<br><br>popClipRect()<br>
glStencilFunc(GL_NEVER, 0, 0);<br>
glStencilOp(GL_DEC, GL_DEC, GL_DEC);<br>
<br> m_clipLevel--;<br>
// Draw clip rectangle into stencil buffer<br>
<br>
glStencilFunc(GL_EQUAL, m_clipLevel, 0xFFFFFFFF);<br>
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Regards,<br><br> Uli<br><br>--<br>
<br>Ulrich von Zadow | +49-172-7872715 | <a href="mailto:cocacoder@jabber.berlin.ccc.de">cocacoder@jabber.berlin.ccc.de</a><br><br></blockquote></div><br>Nick Hebner<br>