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

Author Topic: Is it possible to reduce the size of a VertexBuffer?  (Read 1763 times)

0 Members and 1 Guest are viewing this topic.

shujidev

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Is it possible to reduce the size of a VertexBuffer?
« on: June 16, 2020, 05:34:41 am »
I was trying to draw a buffer after removing the last vertex and I couldn't see any changes, only after this I noticed it was possible to modify a part of the vertexbuffer but apparently the buffer is not getting smaller, so is something like a resize possible somehow?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Is it possible to reduce the size of a VertexBuffer?
« Reply #1 on: June 16, 2020, 08:37:54 am »
You'll have to call create on the VertexBuffer with a different size.
See also the example in the documentation: https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1VertexBuffer.php#details
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Is it possible to reduce the size of a VertexBuffer?
« Reply #2 on: June 16, 2020, 11:18:58 am »
Note that there's an overload of the draw function that takes the range of vertices to draw from a VertexBuffer. That allows you to change what's drawn without touching the vertex buffer; remember that they are stored in VRAM and that modifying them is an expensive operation (data goes back and forth between system RAM and VRAM, the graphics pipeline may be flushed, etc).
Laurent Gomila - SFML developer