I am writing a UTimer timer component inherited from UObject. I need to somehow write an analog of this code that is not intended for Unreal:
LARGE_INTEGER freq;
if ( QueryPerformanceFrequency(&freq) )
{
int32 counter;
int32 cycles = freq.QuadPart / 1000;
QueryPerformanceCounter(&counter);
}
How can I do this? Thanks for answer!
3dRaven
(3dRaven)
2
You can’t just use windows functions if you want to keep the engine cross platform.
You would need to use
std::chrono::high_resolution_clock to get a high resolution snapshot
You’ll probably have to replace LARGE_INTEGER with std::uint64_t
Or if you want to stick to windows then you can try
#include “AllowWindowsPlatformTypes.h”
#include <windows.h>
// your windows code here
#include “HideWindowsPlatformTypes.h”
Edit:
You can find an implementation within the plugin “Geometry processing”
GteTimers.cpp
unreal seems to have it’s own version of some of the variables like
ULARGE_INTEGER that internally replaces LARGE_INTEGER