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

Author Topic: Can't modify vertex in vertexarray  (Read 2362 times)

0 Members and 1 Guest are viewing this topic.

kpulv

  • Newbie
  • *
  • Posts: 18
    • View Profile
Can't modify vertex in vertexarray
« on: November 06, 2013, 01:20:58 am »
I've been working on trying to get batched rendering working for my framework using SFML, but it seems that in dotnet I am unable to edit a vertex after it's in the array.  I'm attempting to draw a large number of sprites that are dynamic with the vertex array, and rebuilding the array during each update to take into account the changes ends up being very costly (5000 quads is when my update loop takes more than 17ms meaning the framerate is no longer a smooth 60)

Is there something I'm missing on how I should be trying to organize this logic?  If I cant modify the vertex after it's in the vertex array, what is the best option for updating the vertices aside from rebuilding the entire array each time?

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Can't modify vertex in vertexarray
« Reply #1 on: November 06, 2013, 02:45:51 am »
C# structs strike again  ::)

http://en.sfml-dev.org/forums/index.php?topic=12162.msg84530#msg84530

I have a few more posts regarding this if you want to find them. Basically in C# you can't modify values on returned structs since its only a copy.
« Last Edit: November 06, 2013, 02:48:46 am by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

kpulv

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Can't modify vertex in vertexarray
« Reply #2 on: November 06, 2013, 05:16:10 am »
Hm, bummer.  If there's so much dislike of structs when it comes to this kind of stuff, why did SFML end up using them in so many places for the dotnet version?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Can't modify vertex in vertexarray
« Reply #3 on: November 06, 2013, 07:35:11 am »
Structures are allocated on the stack and can be transfered directly to/from the C runtime. Classes instances are always allocated dynamically on the heap and must be serialized explicitely.

So they are used for small structures where as few overhead as possible is required.

Don't blame me if C# sucks :P
Laurent Gomila - SFML developer