void HumanClientApp::UpdateFPSLimit() { if (GetOptionsDB().Get<bool>("limit-fps")) { double fps = GetOptionsDB().Get<double>("max-fps"); SetMaxFPS(fps); DebugLogger() << "Limited FPS to " << fps; } else { SetMaxFPS(0.0); // disable fps limit DebugLogger() << "Disabled FPS limit"; } }
DavaGLWidget::DavaGLWidget(QWidget *parent) : QWidget(parent) , ui(new Ui::DavaGLWidget) , maxFPS(60) , minFrameTimeMs(0) { ui->setupUi(this); // Widget will try to expand to maximum available size setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); // Init OS-specific layer { #if defined (__DAVAENGINE_MACOS__) setMouseTracking(true); DAVA::QtLayerMacOS *qtLayer = (DAVA::QtLayerMacOS *) DAVA::QtLayer::Instance(); qtLayer->InitializeGlWindow((void *)this->winId(), this->size().width(), this->size().height()); #elif defined (__DAVAENGINE_WIN32__) DAVA::QtLayerWin32 *qtLayer = (DAVA::QtLayerWin32 *) DAVA::QtLayer::Instance(); HINSTANCE hInstance = (HINSTANCE)::GetModuleHandle(NULL); qtLayer->SetWindow(hInstance, this->winId(), this->size().width(), this->size().height()); qtLayer->OnResume(); #else DVASSERT(false && "Wrong platform"); #endif //#if defined (__DAVAENGINE_MACOS__) DAVA::QtLayer::Instance()->SetDelegate(this); DAVA::QtLayer::Instance()->Resize(size().width(), size().height()); } // Disable Widget blinking setAttribute(Qt::WA_OpaquePaintEvent, true); setAttribute(Qt::WA_NoSystemBackground, true); setAttribute(Qt::WA_PaintOnScreen, true); // Setup FPS SetMaxFPS(maxFPS); // start render in 1 ms QTimer::singleShot(1, this, SLOT(Render())); // acept drops this->setAcceptDrops(true); setMouseTracking(true); // Remember the previous size as current one. prevSize = size(); ScreenWrapper::Instance()->SetQtScreen(this); }
void FpsLimiter::Init(float maxFPS){ SetMaxFPS(maxFPS); }