void SoulLoader::Run() { g_app->m_soundSystem->TriggerOtherEvent( NULL, "LoaderSoul", SoundSourceBlueprint::TypeMusic ); while( !g_inputManager->controlEvent( ControlSkipMessage ) ) { if( g_app->m_requestQuit ) break; glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); float oldTime = m_time; m_time = GetHighResTime(); float timeThisFrame = m_time - oldTime; AdvanceAllSpirits( timeThisFrame ); RenderAllSpirits(); RenderMessage( timeThisFrame ); g_windowManager->Flip(); g_inputManager->Advance(); g_inputManager->PollForEvents(); Sleep(1); AdvanceSound(); } g_app->m_soundSystem->StopAllSounds( WorldObjectId(), "Music LoaderSoul" ); }
/** * Triggers the loading of data for the given area and also triggers rendering * of the data afterwards. */ void DBThread::TriggerMapRendering(const RenderMapRequest& request) { //std::cout << ">>> User triggered rendering" << std::endl; dataLoadingBreaker->Reset(); { QMutexLocker locker(&mutex); currentWidth=request.width; currentHeight=request.height; currentCoord=request.coord; currentAngle=request.angle; currentMagnification=request.magnification; if (database->IsOpen() && styleConfig) { osmscout::AreaSearchParameter searchParameter; searchParameter.SetBreaker(dataLoadingBreaker); if (currentMagnification.GetLevel()>=15) { searchParameter.SetMaximumAreaLevel(6); } else { searchParameter.SetMaximumAreaLevel(4); } searchParameter.SetUseMultithreading(true); searchParameter.SetUseLowZoomOptimization(true); projection.Set(currentCoord, currentAngle, currentMagnification, dpi, currentWidth, currentHeight); std::list<osmscout::TileRef> tiles; mapService->LookupTiles(projection,tiles); if (!mapService->LoadMissingTileDataAsync(searchParameter,*styleConfig,tiles)) { qDebug() << "*** Loading of data has error or was interrupted"; return; } emit TriggerInitialRendering(); } else { qDebug() << "Cannot draw map: " << database->IsOpen() << " " << styleConfig.get(); QPainter p; RenderMessage(p,request.width,request.height,"Database not open"); } } }
void LunaticDraw(void) { char s[32]; dword d; // add all the sprites to the list if (gameMode != GAMEMODE_PIC) { RenderGuys(1); RenderBullets(); RenderParticles(); RenderItAll(&curWorld, curMap, MAP_SHOWLIGHTS | MAP_SHOWITEMS | MAP_SHOWWALLS); RenderSpecialXes(gamemgl, curMap, worldNum); RenderMessage(); PlayerRenderInterface(gamemgl); if (gameMode == GAMEMODE_MENU) RenderPauseMenu(); if (gameMode == GAMEMODE_RAGE) ShowRage(gamemgl); } else { // nothing to do } if (showStats) { sprintf(s, "QFPS %02.2f", frmRate); Print(0, 180, s, 6, 0); sprintf(s, "VFPS %02.2f", ((float) visFrameCount / (float) ((timeGetTime() - gameStartTime) / 1000))); Print(0, 10, s, 6, 0); sprintf(s, "GFPS %02.2f", ((float) updFrameCount / (float) ((timeGetTime() - gameStartTime) / 1000))); Print(0, 50, s, 6, 0); sprintf(s, "Runs %d", numRunsToMakeUp); Print(0, 100, s, 6, 0); } // update statistics d = timeGetTime(); if (d - tickerTime > 999) { frmRate = (frmRate * 3 + ((float) visFrms / ((float) (d - tickerTime) / 1000.0f))) / 4; visFrms = 0; tickerTime = d; } gamemgl->Flip(); CDMessingTime += garbageTime; garbageTime = 0; visFrameCount++; visFrms++; }
/** * Copies the last rendered map in the backbuffer to the given painter */ bool DBThread::RenderMap(QPainter& painter, const RenderMapRequest& request) { //std::cout << "RenderMap()" << std::endl; QMutexLocker locker(&mutex); if (finishedImage==NULL) { RenderMessage(painter,request.width,request.height,"no image rendered (internal error?)"); // Since we assume that this is just a temporary problem, or we just were not instructed to render // a map yet, we trigger rendering an image... return false; } if (!styleConfig) { RenderMessage(painter,request.width,request.height,"no valid style sheet loaded"); return true; } osmscout::MercatorProjection projection; projection.Set(finishedCoord, finishedAngle, finishedMagnification, dpi, finishedImage->width(), finishedImage->height()); projection.SetLinearInterpolationUsage(finishedMagnification.GetLevel() >= 10); osmscout::GeoBox boundingBox; projection.GetDimensions(boundingBox); double d=boundingBox.GetWidth()*2*M_PI/360; double scaleSize; size_t minScaleWidth=request.width/20; size_t maxScaleWidth=request.width/10; double scaleValue=d*180*60/M_PI*1852.216/(request.width/minScaleWidth); //std::cout << "1/10 screen (" << width/10 << " pixels) are: " << scaleValue << " meters" << std::endl; scaleValue=pow(10,floor(log10(scaleValue))+1); scaleSize=scaleValue/(d*180*60/M_PI*1852.216/request.width); if (scaleSize>minScaleWidth && scaleSize/2>minScaleWidth && scaleSize/2<=maxScaleWidth) { scaleValue=scaleValue/2; scaleSize=scaleSize/2; } else if (scaleSize>minScaleWidth && scaleSize/5>minScaleWidth && scaleSize/5<=maxScaleWidth) { scaleValue=scaleValue/5; scaleSize=scaleSize/5; } else if (scaleSize>minScaleWidth && scaleSize/10>minScaleWidth && scaleSize/10<=maxScaleWidth) { scaleValue=scaleValue/10; scaleSize=scaleSize/10; } //std::cout << "VisualScale: value: " << scaleValue << " pixel: " << scaleSize << std::endl; double dx=0; double dy=0; if (request.coord!=finishedCoord) { double rx,ry,fx,fy; projection.GeoToPixel(request.coord, rx, ry); projection.GeoToPixel(finishedCoord, fx, fy); dx=fx-rx; dy=fy-ry; } if (dx!=0 || dy!=0) { osmscout::FillStyleRef unknownFillStyle; osmscout::Color backgroundColor; styleConfig->GetUnknownFillStyle(projection, unknownFillStyle); if (unknownFillStyle) { backgroundColor=unknownFillStyle->GetFillColor(); } else { backgroundColor=osmscout::Color(0,0,0); } painter.fillRect(0, 0, projection.GetWidth(), projection.GetHeight(), QColor::fromRgbF(backgroundColor.GetR(), backgroundColor.GetG(), backgroundColor.GetB(), backgroundColor.GetA())); } painter.drawImage(dx,dy,*finishedImage); bool needsNoRepaint=finishedImage->width()==(int) request.width && finishedImage->height()==(int) request.height && finishedCoord==request.coord && finishedAngle==request.angle && finishedMagnification==request.magnification; return needsNoRepaint; }