#include <GL/glew.h>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <random>
#include <vector>
int main()
{
sf::Window window(sf::VideoMode(800, 600), "OpenGL", sf::Style::Default, sf::ContextSettings(32));
window.setVerticalSyncEnabled(true);
glewExperimental = GL_TRUE;
glewInit();
// Vertices Array Initialization
int nbVertices = 1000;
std::vector<float> vertices;
for (auto i(0); i < nbVertices*2; ++i)
vertices.push_back(.0f);
bool running = true;
while (running)
{
// Events Capture
sf::Event windowEvent;
while (window.pollEvent(windowEvent))
if(windowEvent.type == sf::Event::Closed)
running = false;
// Update Vertices Array
auto const seed = std::time(nullptr);
std::default_random_engine engin { seed };
std::mt19937_64 gen { engin() };
std::uniform_real_distribution<float> disp { -1.0f, 1.0f };
for (auto i(0); i < nbVertices*2; ++i)
vertices[i] = disp(gen);
// Clean the screen
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Define an array of generic vertex attribute data
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, &vertices[0]);
glEnableVertexAttribArray(0);
// Drawing in the back-buffer
glDrawArrays(GL_POINTS, 0, nbVertices);
glDisableVertexAttribArray(0);
// Switch Buffer
window.display();
}
return 0;
}