summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/angle/samples/angle/sample_util/random_utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/angle/samples/angle/sample_util/random_utils.cpp')
-rw-r--r--chromium/third_party/angle/samples/angle/sample_util/random_utils.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/chromium/third_party/angle/samples/angle/sample_util/random_utils.cpp b/chromium/third_party/angle/samples/angle/sample_util/random_utils.cpp
new file mode 100644
index 00000000000..b7b7ae3f7aa
--- /dev/null
+++ b/chromium/third_party/angle/samples/angle/sample_util/random_utils.cpp
@@ -0,0 +1,22 @@
+//
+// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#include "random_utils.h"
+#include <time.h>
+#include <cstdlib>
+
+float RandomBetween(float min, float max)
+{
+ static bool randInitialized = false;
+ if (!randInitialized)
+ {
+ srand(time(NULL));
+ randInitialized = true;
+ }
+
+ const size_t divisor = 10000;
+ return min + ((rand() % divisor) / static_cast<float>(divisor)) * (max - min);
+}