diff --git a/kraken/KRContext.cpp b/kraken/KRContext.cpp index 28aa540..d0fc9ff 100755 --- a/kraken/KRContext.cpp +++ b/kraken/KRContext.cpp @@ -106,9 +106,13 @@ KRContext::KRContext(const KrInitializeInfo* initializeInfo) #endif createDeviceContexts(); + + m_presentationThread = std::thread(&KRContext::presentationThreadFunc, this); } KRContext::~KRContext() { + m_stop = true; + m_presentationThread.join(); if(m_pSceneManager) { delete m_pSceneManager; m_pSceneManager = NULL; @@ -1187,3 +1191,27 @@ KrResult KRContext::deleteWindowSurface(const KrDeleteWindowSurfaceInfo* deleteW m_surfaces.erase(itr); return KR_SUCCESS; } + +void KRContext::presentationThreadFunc() +{ +#if defined(ANDROID) + // TODO - Set thread names on Android +#elif defined(_WIN32) || defined(_WIN64) + // TODO - Set thread names on windows +#else + pthread_setname_np("Kraken - Presentation"); +#endif + + std::chrono::microseconds sleep_duration(15000); + + while (!m_stop) + { + renderFrame(); + std::this_thread::sleep_for(sleep_duration); + } +} + +void KRContext::renderFrame() +{ + +} \ No newline at end of file diff --git a/kraken/KRContext.h b/kraken/KRContext.h index 53ad64a..bb87ab2 100755 --- a/kraken/KRContext.h +++ b/kraken/KRContext.h @@ -196,6 +196,10 @@ private: #endif } SurfaceInfo; unordered_map m_surfaces; + std::thread m_presentationThread; + void presentationThreadFunc(); + std::atomic m_stop; + void renderFrame(); }; #endif diff --git a/tests/smoke/hello_cube/main_win.cpp b/tests/smoke/hello_cube/main_win.cpp index 5d2045b..1f89c48 100644 --- a/tests/smoke/hello_cube/main_win.cpp +++ b/tests/smoke/hello_cube/main_win.cpp @@ -59,8 +59,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine smoke_load(); - while (GetMessage(&msg, NULL, 0, 0) > 0) + while (GetMessage(&msg, NULL, 0, 0) > 0) { DispatchMessage(&msg); + } + // KrShutdown will delete the window surfaces for us; however, we // include this here for code coverage in tests.