开发者

OpenGL linestrip boundaries

I have a network of polylines, and I'd like to dis开发者_JS百科play all parts of the lines that are inside a certain X-Y box. I'm currently rendering the lines in OpenGL using a GL_LINE_STRIP and it works well. However, if the boundary of the X-Y box crosses through one of the lines (between vertices), is there a good way to just display the part of the line that is inside the box?

thanks,

Jeff


If your box is just a ordinary two-dimensional, axis alined rectangle you can use the glScissor function. In a nutshell it defines a 2D rectangle in screen-coordinates where all drawing takes place.

If you case is more complicated (e.g. you may have a rectangle on a plane inside a 3D scene or so..) you can first draw your rectangle into the stencil buffer and enable stencil-test for the line-rendering. That approach gives you unlimited flexibility about the shape that restricts the drawing but it may be slightly slower during rendering and takes more effort to setup.


I think Nils Pipenbrinck gave you the best two options, but I'll throw out another just for completeness: clip planes (glClipPlane()).

That said, I think glScissor() is the easiest solution if it will always be window aligned.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜