Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Vertex Array shapes  (Read 4394 times)

0 Members and 1 Guest are viewing this topic.

SFMLNewGuy

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Vertex Array shapes
« 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

SFMLNewGuy

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Vertex Array shapes
« Reply #1 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?
« Last Edit: March 31, 2021, 03:04:24 pm by SFMLNewGuy »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Vertex Array shapes
« Reply #2 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?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Vertex Array shapes
« Reply #3 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.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*