From b9d4b60486e224261990c0732852513e86dd94ff Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Fri, 2 Oct 2015 23:48:34 +0800 Subject: Add BLR3 files. Modify Readme. Currently BLR3 is VERY primitive!! --- src/master/scenemgr.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/master/scenemgr.cpp (limited to 'src/master/scenemgr.cpp') diff --git a/src/master/scenemgr.cpp b/src/master/scenemgr.cpp new file mode 100644 index 0000000..1399d63 --- /dev/null +++ b/src/master/scenemgr.cpp @@ -0,0 +1,63 @@ +#include "master.hpp" +#include +#include +int cmp(const void* a,const void* b){return ((pn*)b)->p-((pn*)a)->p;} +extern sceneManager *sceneMgr; +SMELT* sceneManager::sm=NULL; +std::thread* sceneManager::uth=NULL; +sceneManager::sceneManager(){sm=smGetInterface(SMELT_APILEVEL);utime=scnt=0;thactive=false;dlps=64;} +sceneManager::~sceneManager(){sm->smRelease();} +int sceneManager::registerScene(scenePrototype *sp,const char* scenename,int priority) +{ + for(int i=0;ijoin();delete uth;} +bool sceneManager::isThreadActive(){return thactive;} +int sceneManager::getSceneID(const char* scene) +{for(int i=0;isceneUpdate())return true; + sm->smRenderBegin2D(true); + for(int i=0;isceneRender(); + sm->smRenderEnd(); + if(sm->smGetKeyState(SMK_S)==SMKST_HIT)sm->smScreenShot("ss0.bmp"); + return false; +} +void sceneManager::threadUpdate() +{ + long ddlay; + while(thactive) + { + ddlay=1000000000/dlps; + using namespace std::chrono; + high_resolution_clock::time_point b=high_resolution_clock::now(); + for(int i=0;ithreadUpdate(); + high_resolution_clock::time_point a=high_resolution_clock::now(); + auto updateTime=a-b;utime=updateTime.count(); + ++lp;lpsud+=updateTime.count()>ddlay?updateTime.count():ddlay; + if(lpsud>=1000000000){lps=(float)lp/(lpsud/1000000000.);lp=0;lpsud=0;} + if(updateTime<(duration>)ddlay) + std::this_thread::sleep_for((duration>)ddlay-updateTime); + } +} -- cgit v1.2.3