#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/VertexArray.hpp>
#include <SFML/Graphics/Texture.hpp>
#include <SFML/System/Clock.hpp>
#include <SFML/Window/Event.hpp>
int main(){
sf::Vector2i s(640,360);
sf::RenderWindow window(sf::VideoMode(s.x, s.y),"TheEvent");
sf::VertexArray graph; graph.setPrimitiveType(sf::LinesStrip);
for (int x = 0; x < s.x; ++x) graph.append(sf::Vertex());
sf::Texture texture; texture.create(16,16);
sf::Clock clock; int frame = 0;
while (true){
sf::Event e; while (window.pollEvent(e));
window.clear();
++frame; clock.restart();
for (int i = 0; i < s.x*s.y/256;++i){
sf::Uint8 buffer[1024];
for (int i = 0; i < 1024; i++)
buffer[i] = rand()%256;
texture.update(buffer); // <<----randomly super slow
}
graph[frame%s.x].position = sf::Vector2f(frame%s.x,
s.y-s.y*clock.getElapsedTime().asMicroseconds()/33333);
window.draw(graph);
window.display();
}
return 0;
}