Create presentation thread
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -196,6 +196,10 @@ private:
|
||||
#endif
|
||||
} SurfaceInfo;
|
||||
unordered_map<KrSurfaceHandle, SurfaceInfo> m_surfaces;
|
||||
std::thread m_presentationThread;
|
||||
void presentationThreadFunc();
|
||||
std::atomic<bool> m_stop;
|
||||
void renderFrame();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user