Hi. (Sorry for grammar I don't use english everyday)
I have big problem. I wrote a lichen array function. The problem is with performance.
When I use 2 dimension array of rectangle shape (shape size 6x6). In my function I'm checking conditions and setting color of each rectangle. Then I draw it. So the time of draw is like 20ms and the time of iteriation 100x100 and setting colors/checking conditions is under 1ms.
I have read that I should use VertexArray of points. So i did it. The draw time is under 0.1ms for 100x100 array and that is perfect but... iterating and swapping colors is over 25ms? No idea why I have the same amount of conditions etc. I just have one more field that I increment to 10000. So its O(1). Maybe the problem is with setting the array. For 100x100 I just set it like that in constructor. But I just do it once so I don't think so. (The Vertex is point and I add this point to VertexArray named vert, other two arrays are normal vectors)
int j = 0;
int pom = 0;
int pom2 = 0;
for (int i = 0; i < 10000; i++) {
odpornosc.push_back(0);
flaga.push_back(true);
if (i == 100) {
pom = i;
j++;
pom2 = 0;
}
if (pom + 100 == i) {
pom += 100;
j++;
pom2 = 0;
}
point.position = Vector2f(pom2, j);
pom2++;
point.color = Color::Green;
vert.append(point);
}
In my iteration function I use methods only like:
vert[pom].color = Color::Yellow;
Of course I use this function in loop while(window.isOpen())
It looks like that:
https://www.youtube.com/watch?v=XKkq8rPhtDk&feature=youtu.beMaybe there is possibility to make 2 dimension vertex array and still draw efficiently?