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

Author Topic: Can't copy VertexArrays with slice notation?  (Read 8986 times)

0 Members and 1 Guest are viewing this topic.

C with a C

  • Newbie
  • *
  • Posts: 21
    • View Profile
Can't copy VertexArrays with slice notation?
« on: July 25, 2017, 11:11:07 pm »
I tried making a copy of a vertex array using the slice notation...
textLayer = extraTextBuffer[:]

... and this is what happens:
#  File "graphics.pyx", line 1587, in sfml.graphics.VertexArray.__getitem__ (src/sfml\graphics.cpp:26182)
#  TypeError: an integer is required

I'm confused as to why this happens. (EDIT: Probably because VertexArrays are not python Lists! I realized later.)

I want to copy the array by value, and I can copy it by iterating through it, but that's quite a slow process (because the array is BIG). My goal was to check if using slice notation was significantly faster or not.

Basically my idea here is to have a vertex array with default values (colors and tex_coords), and simply use it to "clear" the one I'm using every frame. I'm doing this to test how it might affect performance. Iterating through a vertexarray and reseting all the vertices is also a rather slow process. Perhaps even slower than copying vertices from another array.

Simply copying like
array1 = array2
seems to copy them by reference, as it would a python list.
« Last Edit: July 26, 2017, 10:37:08 pm by C with a C »