#include "parameters.h"
#include <cstdlib>
#include <memory.h>

namespace render{
namespace fx{

textureIndexParam::~textureIndexParam() noexcept
{
    free();
}

void textureIndexParam::free() noexcept
{
    if(_size)
        delete [] _values;
}

uint32_t textureIndexParam::getValue() const noexcept
{
    if(_size == 1)
        return _values[0];
    return _values[rand()%_size];
}

void textureIndexParam::setValues(uint32_t *values, size_t size) noexcept
{
    _size = size;
    _values = new uint32_t[_size];
    memcpy(_values, values, _size*sizeof(uint32_t));
}

textureIndexParam::textureIndexParam(const textureIndexParam &r)
{
    time = r.time;
    _size = r._size;
    _values = new uint32_t[_size];
    memcpy(_values, r._values, _size*sizeof(uint32_t));
}

}}
