SFML community forums

Help => Graphics => Topic started by: SFMLNewGuy on March 31, 2021, 02:32:02 pm

Title: Vertex Array shapes
Post by: SFMLNewGuy on March 31, 2021, 02:32:02 pm
Hello,

As of right now, I'm using Rectangles as a Tile Map as textures aren't of importance right now. It was a simple transparent fillColor, 1.f outline, sf::White outline color. So I'm trying to use VertexArray without textures (sf::Quad). Everything was fine until I realized I don't think colors work like that now.

So would I add an extra 4 lines over the current square to create an outline? Perhaps, just draw the same quad coordinates as lines? I'm just making sure there isn't an easier way.

Thanks
Title: Re: Vertex Array shapes
Post by: SFMLNewGuy on March 31, 2021, 02:41:38 pm
So I just took the same sf::VertexArray container and after trying it as Quad, changed the colors and drew it as a sf::LineStrip.

It sort of worked? Except I have lines running diagonally through the rectangles as well. I tried all the various sf::Lines types just to make sure. I'm sure this is an easy fix?
Title: Re: Vertex Array shapes
Post by: eXpl0it3r on March 31, 2021, 03:06:24 pm
I think you forgot to mention what you're trying to achieve. Can you describe what you expect to get in the end?
Title: Re: Vertex Array shapes
Post by: Hapax on April 02, 2021, 10:35:32 pm
Looks like you're trying to draw rectangular outlines using LineStrip....

The diagonals sound like you're connecting two opposite points. Remember that with a line strip every point is connected to the previous one so if you're creating a 'grid' of lines, remember that each vertex much not be diagonal from the previous one.

Chances are, your quad is created (by the sounds of it) by vertices in a zig-zig "Z" shape. Try creating them in order around the rectangle.
If you find that connecting ones are creating diagonals, you may need to add extra vertices in order to trace around the grid to get to the next position instead of just going straight there.