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

Author Topic: Drawing a subset of a vertex array?  (Read 173 times)

0 Members and 1 Guest are viewing this topic.

smurf

  • Newbie
  • *
  • Posts: 36
    • View Profile
Drawing a subset of a vertex array?
« on: November 19, 2024, 04:40:51 pm »
I have a particle system where sparks burn out over time.
Instead of creating a brand new VertexArray every frame with the burnt-out particles removed, I wanted to re-use the same VertexArray and just shift things around so that the burnt-out ones are on the end, and then not draw them by passing a count parameter to the Draw function. The idea is by not creating a new VertexArray every frame this should be much more performant.

But it seems the window.Draw function does not quite give me the overload I need.

renderWindow.Draw(vertexArray, 0, vertexCount, vertexArray.PrimitiveType);

This is invalid code because the first parameter needs to be an array of vertices instead of a vertexArray  ::)

but the VertexArray class does not expose its internal array of vertices. So any way I can do this?

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: Drawing a subset of a vertex array?
« Reply #1 on: November 20, 2024, 10:52:17 am »
You can use the [] operator of VertexArray

window.draw(&vertices[offset], count, sf::Triangles);
 

smurf

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: Drawing a subset of a vertex array?
« Reply #2 on: November 20, 2024, 03:04:29 pm »
Thanks!

But I'm using SFML.Net and it doesn't seem to have that in C# :(

 

anything