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

Author Topic: sf::VertexArray concerns and issues (ideas) regarding implementation  (Read 1852 times)

0 Members and 1 Guest are viewing this topic.

BaneTrapper

  • Full Member
  • ***
  • Posts: 213
  • Do you even see this, i dont need it.
    • View Profile
    • Email
Hello.
2d top down 4sidescroller(i don't know how to describe going up and down) game.
I will jump strait to the point because am having trouble getting this true.
What i am making is unit, that is linked with VertexArray.
My goal is not to use sf::Sprite and to get great performance, therefore i was thinking of code going like this.
class Unit : BehaviorInhertiance
{
public:
//Witch vertices is this unit in VertexArray
int StartingVertice;//Position in vertex array that the sprite starts
};
 

The issue starts when i look what is gonna happen in the game.
I am gonna have units die, units get spawned(created).
That means removing or adding elements or keeping track or elements that are free and when adding new unit populate the free elements instead of adding new ones, the issues with this aproach is that i am thinking about boss battles and at some times i will need to create about 50 units that are gonna be just dummy units. But they need position and textures.
Resizing the array will probably be ok if i dont use references, but using int and storing vertex position is kinda not the thing id like to do.
So any suggestions you would like to pass, what should i so considering the design i am wanting.
« Last Edit: August 16, 2013, 08:25:45 pm by Laurent »
BaneTrapperDev@hotmail.com Programing, Coding
Projects: Not in development(unfinished/playable):
http://en.sfml-dev.org/forums/index.php?topic=11073.msg76266#msg76266
UP and in Development: The Wanderer - Lost in time
http://en.sfml-dev.org/forums/index.php?topic=14563.0

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: sf::VertexArray concerns and issues (ideas) regarding implementation
« Reply #1 on: August 16, 2013, 08:27:21 pm »
This is not the intended usage for sf::VertexArray. Sprites should be ok for that, especially if you don't have a lot of them (< 100).
Laurent Gomila - SFML developer

BaneTrapper

  • Full Member
  • ***
  • Posts: 213
  • Do you even see this, i dont need it.
    • View Profile
    • Email
Re: sf::VertexArray concerns and issues (ideas) regarding implementation
« Reply #2 on: August 17, 2013, 07:27:49 pm »
Well that is the reason i made this post.
Estimated amount of sprites is about 50 at long term period with about + 100 being temporary.
The amount of them being shown at screen will vary to 25-30 at times.
I will also need to draw text for each unit 2 times therefore i want to make the drawing allot faster so i can get some complex AI for the units.
If i made for each unit sf::VertexArray of 4 sf::PrimitiveType::Quads instead of sf::Sprite would that be better regarding performance?
BaneTrapperDev@hotmail.com Programing, Coding
Projects: Not in development(unfinished/playable):
http://en.sfml-dev.org/forums/index.php?topic=11073.msg76266#msg76266
UP and in Development: The Wanderer - Lost in time
http://en.sfml-dev.org/forums/index.php?topic=14563.0

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: sf::VertexArray concerns and issues (ideas) regarding implementation
« Reply #3 on: August 17, 2013, 07:34:57 pm »
Quote
If i made for each unit sf::VertexArray of 4 sf::PrimitiveType::Quads instead of sf::Sprite would that be better regarding performance?
It's the same, sf::Sprite uses 4 sf::Vertex internally.
Laurent Gomila - SFML developer

BaneTrapper

  • Full Member
  • ***
  • Posts: 213
  • Do you even see this, i dont need it.
    • View Profile
    • Email
Re: sf::VertexArray concerns and issues (ideas) regarding implementation
« Reply #4 on: August 17, 2013, 07:39:05 pm »
It's the same, sf::Sprite uses 4 sf::Vertex internally.
But using sf::Vertex i will only apply "transformation" so i can move it around.
If i use sprite, scaling etc... is also applied therefore slower?
BaneTrapperDev@hotmail.com Programing, Coding
Projects: Not in development(unfinished/playable):
http://en.sfml-dev.org/forums/index.php?topic=11073.msg76266#msg76266
UP and in Development: The Wanderer - Lost in time
http://en.sfml-dev.org/forums/index.php?topic=14563.0

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: sf::VertexArray concerns and issues (ideas) regarding implementation
« Reply #5 on: August 17, 2013, 07:52:36 pm »
I'm pretty sure the reason using a big VertexArray on a tilemap *can* be faster than tons of different sprites is because it means fewer draw() calls, and as Laurent said even that isn't very significant unless the number of sprites is in the hundreds.  I don't think the speed of 2D vertex transformations is ever a limiting factor.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: sf::VertexArray concerns and issues (ideas) regarding implementation
« Reply #6 on: August 17, 2013, 08:35:42 pm »
Everything is transformed, even things that have no position/rotation/scale (in this case it's an identity matrix).
Laurent Gomila - SFML developer