vr fps
This commit is contained in:
@@ -195,7 +195,7 @@ void Vive::Draw()
|
|||||||
}
|
}
|
||||||
comp_attempts = 0;
|
comp_attempts = 0;
|
||||||
|
|
||||||
glFlush();
|
//glFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Vive::Valid()
|
bool Vive::Valid()
|
||||||
|
|||||||
22
src/main.cpp
22
src/main.cpp
@@ -34,6 +34,7 @@ std::map<kKey, int> vkey_map;
|
|||||||
|
|
||||||
std::thread hmd_renderer;
|
std::thread hmd_renderer;
|
||||||
std::thread renderer;
|
std::thread renderer;
|
||||||
|
int vr_frames = 0;
|
||||||
int running = -1;
|
int running = -1;
|
||||||
int vr_running = 0;
|
int vr_running = 0;
|
||||||
std::mutex render_mutex;
|
std::mutex render_mutex;
|
||||||
@@ -506,13 +507,24 @@ bool win32_vr_start()
|
|||||||
};
|
};
|
||||||
|
|
||||||
const float target_tick_rate = 90;
|
const float target_tick_rate = 90;
|
||||||
unsigned long t0 = GetTickCount();
|
auto t0 = GetTickCount();
|
||||||
|
float one_sec_timer = 0;
|
||||||
|
int frames = 0;
|
||||||
while (vr_running && running == 1 && vive->Valid())
|
while (vr_running && running == 1 && vive->Valid())
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(hmd_render_mutex);
|
std::unique_lock<std::mutex> lock(hmd_render_mutex);
|
||||||
unsigned long t1 = GetTickCount();
|
auto t1 = GetTickCount();
|
||||||
float dt = (float)(t1 - t0) / 1000.0f;
|
float dt = (float)(t1 - t0) / 1000.0f;
|
||||||
|
|
||||||
|
one_sec_timer += dt;
|
||||||
|
if (one_sec_timer >= 1.f)
|
||||||
|
{
|
||||||
|
one_sec_timer = 0;
|
||||||
|
vr_frames = frames;
|
||||||
|
frames = 0;
|
||||||
|
}
|
||||||
|
frames++;
|
||||||
|
|
||||||
vive->Update();
|
vive->Update();
|
||||||
App::I.vr_active = vive->m_active;
|
App::I.vr_active = vive->m_active;
|
||||||
App::I.vr_controller = vive->m_controllers[0].m_mat;
|
App::I.vr_controller = vive->m_controllers[0].m_mat;
|
||||||
@@ -541,6 +553,7 @@ bool win32_vr_start()
|
|||||||
|
|
||||||
const int framerate = (1.f / target_tick_rate) * 1000;
|
const int framerate = (1.f / target_tick_rate) * 1000;
|
||||||
const int diff = framerate - (t1 - t0);
|
const int diff = framerate - (t1 - t0);
|
||||||
|
t0 = t1;
|
||||||
hmd_render_cv.wait_for(lock, std::chrono::milliseconds(diff));
|
hmd_render_cv.wait_for(lock, std::chrono::milliseconds(diff));
|
||||||
}
|
}
|
||||||
App::I.vr_active = false;
|
App::I.vr_active = false;
|
||||||
@@ -881,7 +894,10 @@ int main(int argc, char** argv)
|
|||||||
if (one_sec > 1.f)
|
if (one_sec > 1.f)
|
||||||
{
|
{
|
||||||
static wchar_t title_fps[512];
|
static wchar_t title_fps[512];
|
||||||
swprintf_s(title_fps, L"%s - %d fps", window_title, frames);
|
if (App::I.vr_active)
|
||||||
|
swprintf_s(title_fps, L"%s - %d fps - %d vr fps", window_title, frames, vr_frames);
|
||||||
|
else
|
||||||
|
swprintf_s(title_fps, L"%s - %d fps", window_title, frames);
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(main_task_mutex);
|
std::lock_guard<std::mutex> lock(main_task_mutex);
|
||||||
main_tasklist.emplace_back([=] {
|
main_tasklist.emplace_back([=] {
|
||||||
|
|||||||
Reference in New Issue
Block a user