Currently, I'm trying to generate white noise using a vertex array of points to display the pixels. The size of the output is 200 by 200 pixels. However, when I run the code, black vertical lines appear in the noise. When I resize the window, it fixes the problem, but I don't understand why, as I presume my sizes for the vertex array and window are correct.
Here is the code that I'm running:
#include <SFML/Graphics.hpp>
#include <time.h>
using namespace sf;
int main(int argc, char** argv) {
srand(time(NULL));
RenderWindow window(VideoMode(200, 200), "");
VertexArray noise(Points, 200 * 200);
int value = 0;
for (int i = 0; i < 200 * 200; i++) {
noise[i].position = Vector2f(i % 200, i / 200);
value = rand() % 256;
noise[i].color = Color(value, value, value);
}
while (window.isOpen()) {
Event event;
while (window.pollEvent(event)) {
if (event.type == Event::Closed)
window.close();
}
window.draw(noise);
window.display();
}
return 0;
}
All the values regarding the size of the window are set to 200, though I still get some empty space.