Added gallery.

This commit is contained in:
2017-05-21 12:21:39 -04:00
parent 6b98770b0e
commit e69e030b20
16 changed files with 24 additions and 10 deletions

View File

@@ -1,5 +1,4 @@
#ifdef _USE_CPP11_RANDOM
#warning "Using C++11 random number generators."
#ifdef USE_CPP11_RANDOM
#include <random>
#include <chrono>
#include <functional>
@@ -13,7 +12,7 @@
#include "sampling.hpp"
#ifdef _USE_CPP11_RANDOM
#ifdef USE_CPP11_RANDOM
using std::uniform_real_distribution;
using std::mt19937;
using std::bind;
@@ -29,7 +28,7 @@ const float PDF = (1.0f / (2.0f * pi<float>()));
static bool seeded = false;
#ifdef _USE_CPP11_RANDOM
#ifdef USE_CPP11_RANDOM
static uniform_real_distribution<float> dist(0, 1);
static mt19937 engine;
static auto generator = bind(dist, engine);
@@ -37,14 +36,14 @@ static auto generator = bind(dist, engine);
float random01() {
if (!seeded) {
#ifdef _USE_CPP11_RANDOM
#ifdef USE_CPP11_RANDOM
engine.seed(std::chrono::system_clock::now().time_since_epoch().count());
#else
srand(time(NULL));
#endif
seeded = true;
}
#ifdef _USE_CPP11_RANDOM
#ifdef USE_CPP11_RANDOM
return generator();
#else
return static_cast<float>(rand()) / RAND_MAX;