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

Author Topic: erase method in VertexArray  (Read 2930 times)

0 Members and 1 Guest are viewing this topic.

Chiller

  • Newbie
  • *
  • Posts: 4
    • View Profile
erase method in VertexArray
« on: December 12, 2012, 10:10:31 am »
I found the VertexArray to be a pretty useful class. However, it lacks a way to delete individual vertices in the middle of the array, short of performing a full copy. Since I built my own SFML libs, I've edited an erase() method in, but I see no reason it shouldn't have been there in the first place. (It could be solved via inheritance, except it's not possible to inherit from most SFML classes in any useful way because member data is predominantly private).

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
AW: erase method in VertexArray
« Reply #1 on: December 12, 2012, 10:15:41 am »
sf::VertexArray is only a light wrapper for std::vector<sf::Vertex> and there's no reason to implement everything std::vector provides, thus if you want some special function you better just use a vector directly, but keep in mind that erase() isn't the lightest operation on a vector. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Chiller

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: erase method in VertexArray
« Reply #2 on: December 12, 2012, 10:22:18 am »
Yeah you're right, it's pretty simple (just looked at the full code, I thought it would be a bit more complex). Still, it does more things than a naked vector. I guess it doesn't really matter.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: erase method in VertexArray
« Reply #3 on: December 13, 2012, 04:19:05 am »
Only thing it does that vector doesn't is draw.
http://en.sfml-dev.org/forums/index.php?topic=9169.msg62009#msg62009
Back to C++ gamedev with SFML in May 2023