mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
configurable python renderer update rate
This commit is contained in:
18
PyInt.cpp
18
PyInt.cpp
@@ -1,6 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "PyInt.h"
|
||||
|
||||
#include "globals.h"
|
||||
#include "parser.h"
|
||||
#include "renderer.h"
|
||||
#include "Model3d.h"
|
||||
@@ -456,6 +457,7 @@ void TPythonScreens::init(cParser &parser, TModel3d *model, std::string const &n
|
||||
WriteLog( "Python Screen: null renderer for " + pyClassName + " - Ignoring screen" );
|
||||
return; // nie mozna utworzyc obiektu Pythonowego
|
||||
}
|
||||
m_updaterate = Global.PythonScreenUpdateRate;
|
||||
TPythonScreenRenderer *renderer = new TPythonScreenRenderer(textureId, pyRenderer);
|
||||
_screens.push_back(renderer);
|
||||
WriteLog( "Created python screen " + pyClassName + " on submodel " + subModelName + " (" + std::to_string(textureId) + ")" );
|
||||
@@ -485,10 +487,6 @@ void TPythonScreens::setLookupPath(std::string const &path)
|
||||
TPythonScreens::TPythonScreens()
|
||||
{
|
||||
TPythonInterpreter::getInstance()->loadClassFile("", "abstractscreenrenderer");
|
||||
_terminationFlag = false;
|
||||
_renderReadyFlag = false;
|
||||
_cleanupReadyFlag = false;
|
||||
_thread = NULL;
|
||||
}
|
||||
|
||||
TPythonScreens::~TPythonScreens()
|
||||
@@ -512,6 +510,7 @@ void TPythonScreens::run()
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
m_updatestopwatch.start();
|
||||
if (_terminationFlag)
|
||||
{
|
||||
return;
|
||||
@@ -535,12 +534,17 @@ void TPythonScreens::run()
|
||||
return;
|
||||
}
|
||||
_renderReadyFlag = true;
|
||||
m_updatestopwatch.stop();
|
||||
while (!_cleanupReadyFlag && !_terminationFlag)
|
||||
{
|
||||
auto const sleeptime {
|
||||
std::max(
|
||||
100,
|
||||
m_updaterate - static_cast<int>( m_updatestopwatch.average() ) ) };
|
||||
#ifdef _WIN32
|
||||
Sleep(100);
|
||||
Sleep( sleeptime );
|
||||
#elif __linux__
|
||||
usleep(100*1000);
|
||||
usleep( sleeptime * 1000 );
|
||||
#endif
|
||||
}
|
||||
if (_terminationFlag)
|
||||
@@ -553,7 +557,7 @@ void TPythonScreens::run()
|
||||
|
||||
void TPythonScreens::finish()
|
||||
{
|
||||
_thread = NULL;
|
||||
// nothing to do here, proper clean up takes place afterwards
|
||||
}
|
||||
|
||||
void ScreenRendererThread(TPythonScreens* renderer)
|
||||
|
||||
Reference in New Issue
Block a user