Skip to content

Commit

Permalink
Make DrawNodeTest CandyMixEffect behavior same with 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
halx99 committed Oct 5, 2024
1 parent 8dfac33 commit a0175da
Showing 1 changed file with 60 additions and 1 deletion.
61 changes: 60 additions & 1 deletion tests/cpp-tests/Source/DrawNodeTest/DrawNodeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ THE SOFTWARE.
#include "DrawNodeTest.h"
#include "renderer/Renderer.h"
#include "renderer/CustomCommand.h"
#include "yasio/utils.hpp"

#if defined(_WIN32)
# pragma push_macro("TRANSPARENT")
Expand Down Expand Up @@ -3584,14 +3585,72 @@ void CandyMixEeffect::renderLine(float x1, float x2, float y, ax::Color color, f
}
}

#if 0
class b2Timer
{
public:
/// Constructor
b2Timer();

/// Reset the timer.
void Reset();

/// Get the time since construction or the last reset.
float GetMilliseconds() const;

private:
# if defined(_WIN32)
double m_start;
static double s_invFrequency;
# elif defined(__linux__) || defined(__APPLE__)
unsigned long long m_start_sec;
unsigned long long m_start_usec;
# endif
};
b2Timer::b2Timer()
{
LARGE_INTEGER largeInteger;

if (s_invFrequency == 0.0)
{
QueryPerformanceFrequency(&largeInteger);
s_invFrequency = double(largeInteger.QuadPart);
if (s_invFrequency > 0.0)
{
s_invFrequency = 1000.0 / s_invFrequency;
}
}

QueryPerformanceCounter(&largeInteger);
m_start = double(largeInteger.QuadPart);
}

void b2Timer::Reset()
{
LARGE_INTEGER largeInteger;
QueryPerformanceCounter(&largeInteger);
m_start = double(largeInteger.QuadPart);
}

float b2Timer::GetMilliseconds() const
{
LARGE_INTEGER largeInteger;
QueryPerformanceCounter(&largeInteger);
double count = double(largeInteger.QuadPart);
float ms = float(s_invFrequency * (count - m_start));
return ms;
}
#endif

void CandyMixEeffect::update(float dt)
{
DrawNodeBaseTest::update(dt);
drawNode->clear();
static b2Timer timer = b2CreateTimer();

static float WID = 400;
static float HIG = 600;
float t = utils::getTimeInMilliseconds() / 1000.0f;
float t = b2GetMilliseconds(&timer) / 1000.0f;
float ta = sin(t * cos(t) * 0.02f) + t;
float tb = (1.0f + sin(t) * 1.0f) * 0.02f + 0.01f;
float xa = WID * 0.5f;
Expand Down

0 comments on commit a0175da

Please sign in to comment.