summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/render/bgfx/timeparameter.cpp
blob: cbcd56c8e6e772f77c686e189fbcc4099336e104 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
//============================================================
//
//  timeparameter.cpp - Time-based dynamic shader param
//
//============================================================

#include "timeparameter.h"

bgfx_time_parameter::bgfx_time_parameter(std::string name, parameter_type type, double limit)
	: bgfx_parameter(name, type)
	, m_current_time(0)
	, m_limit(limit)
{
}

float bgfx_time_parameter::value()
{
	return float(m_current_time * 1000.0 * 1000.0);
}

void bgfx_time_parameter::tick(double delta)
{
	m_current_time += delta;
	if (m_limit != 0)
	{
		while (m_current_time >= m_limit)
		{
			m_current_time -= m_limit;
		}
	}
}