Edit

kc3-lang/angle/util/random_utils.cpp

Branch :

  • Show log

    Commit

  • Author : Jamie Madill
    Date : 2014-09-24 10:26:49
    Hash : ea0e8733
    Message : Add a point sprite benchmark. This benchmark will attempt to reproduce the slowdown we see in D3D11 on the turbulenz GPU particles demo. BUG=angle:705 Change-Id: I9c4c2f09d4282feae30f448fd374cdbb6bceae9b Reviewed-on: https://chromium-review.googlesource.com/216467 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>

  • util/random_utils.cpp
  • //
    // 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);
    }