mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-03-08 00:15:16 +00:00
* There was a bug that existed in open GL ES 2.0 implementations where glTexImage2D could not convert GL_RGB formed textures into GL_RGBA while generating the noise textures. The GL error was GL_INVALID_OPERATION(0x502) This probably made the noise textures blank. So a new class was added that has the alpha channel for the values. * Added a fudge for render farming milkdrop where we control the time and the ticks. * User defined time: Got rid of testing code * Attempt to fix WIN32 compile - it doesnt use or need the ability to control the time * Got rid of debug - got rid of minor warning * projectM.hpp - type in ifdef projectM_SDL_main.cpp - there is code added to make the initial random number dependent on the time of day, making the sequence of visualizers more unexpected. But the posix command time does not exist in Win32 land, so we disable it.
117 lines
2.2 KiB
C++
117 lines
2.2 KiB
C++
#ifndef WIN32
|
|
#include <sys/time.h>
|
|
#else
|
|
#endif /** !WIN32 */
|
|
#include <stdlib.h>
|
|
|
|
#include "TimeKeeper.hpp"
|
|
#include "RandomNumberGenerators.hpp"
|
|
|
|
TimeKeeper::TimeKeeper(double presetDuration, double smoothDuration, double easterEgg)
|
|
{
|
|
_smoothDuration = smoothDuration;
|
|
_presetDuration = presetDuration;
|
|
_easterEgg = easterEgg;
|
|
|
|
#ifndef WIN32
|
|
projectm_gettimeofday ( &this->startTime, NULL );
|
|
#else
|
|
startTime = GetTickCount();
|
|
#endif /** !WIN32 */
|
|
|
|
UpdateTimers();
|
|
}
|
|
|
|
void TimeKeeper::UpdateTimers()
|
|
{
|
|
#ifndef WIN32
|
|
_currentTime = getTicks ( &startTime ) * 0.001;
|
|
#else
|
|
_currentTime = getTicks ( startTime ) * 0.001;
|
|
#endif /** !WIN32 */
|
|
|
|
_presetFrameA++;
|
|
_presetFrameB++;
|
|
|
|
}
|
|
|
|
void TimeKeeper::StartPreset()
|
|
{
|
|
_isSmoothing = false;
|
|
_presetTimeA = _currentTime;
|
|
_presetFrameA = 1;
|
|
_presetDurationA = sampledPresetDuration();
|
|
}
|
|
void TimeKeeper::StartSmoothing()
|
|
{
|
|
_isSmoothing = true;
|
|
_presetTimeB = _currentTime;
|
|
_presetFrameB = 1;
|
|
_presetDurationB = sampledPresetDuration();
|
|
}
|
|
void TimeKeeper::EndSmoothing()
|
|
{
|
|
_isSmoothing = false;
|
|
_presetTimeA = _presetTimeB;
|
|
_presetFrameA = _presetFrameB;
|
|
_presetDurationA = _presetDurationB;
|
|
}
|
|
|
|
bool TimeKeeper::CanHardCut()
|
|
{
|
|
return ((_currentTime - _presetTimeA) > HARD_CUT_DELAY);
|
|
}
|
|
|
|
double TimeKeeper::SmoothRatio()
|
|
{
|
|
return (_currentTime - _presetTimeB) / _smoothDuration;
|
|
}
|
|
bool TimeKeeper::IsSmoothing()
|
|
{
|
|
return _isSmoothing;
|
|
}
|
|
|
|
double TimeKeeper::GetRunningTime()
|
|
{
|
|
return _currentTime;
|
|
}
|
|
|
|
double TimeKeeper::PresetProgressA()
|
|
{
|
|
if (_isSmoothing) return 1.0;
|
|
else return (_currentTime - _presetTimeA) / _presetDurationA;
|
|
}
|
|
double TimeKeeper::PresetProgressB()
|
|
{
|
|
return (_currentTime - _presetTimeB) / _presetDurationB;
|
|
}
|
|
|
|
int TimeKeeper::PresetFrameB()
|
|
{
|
|
return _presetFrameB;
|
|
}
|
|
|
|
int TimeKeeper::PresetFrameA()
|
|
{
|
|
return _presetFrameA;
|
|
}
|
|
|
|
int TimeKeeper::PresetTimeB()
|
|
{
|
|
return _presetTimeB;
|
|
}
|
|
|
|
int TimeKeeper::PresetTimeA()
|
|
{
|
|
return _presetTimeA;
|
|
}
|
|
|
|
double TimeKeeper::sampledPresetDuration() {
|
|
#ifdef WIN32
|
|
return _presetDuration;
|
|
#else
|
|
return fmax(1, fmin(60, RandomNumberGenerators::gaussian
|
|
(_presetDuration, _easterEgg)));
|
|
#endif
|
|
}
|