Rogue line being drawn to window

后端 未结 2 1043
走了就别回头了
走了就别回头了 2021-01-21 01:47

I am making a graphing program in C++ using the SFML library. So far I have been able to draw a function to the screen. I have run into two problems along the way. The first is

2条回答
  •  不知归路
    2021-01-21 02:35

    Those artifacts are due to the way sf::PrimitiveType::LinesStrip works (or more specific lines strips in general).

    In your second example, visualizing y = -tan(x), you're jumping from positive infinity to negative infinity, which is the line you're seeing. You can't get rid of this, unless you're using a different primitive type or splitting your rendering into multiple draw calls.

    Imagine a line strip as one long thread you're pinning with pushpins (representing your vertices). There's no (safe) way to go from positive infinity to negative infinity without those artifacts. Of course you could move outside the visible area, but then again that's really specific to this one function.

提交回复
热议问题