void Syscfg::GetStreamInfo(StreamInfo & info) { info.dir_name_ = GetDir(); info.dir_name_push_ = GetDir(true); info.ip_push_ = GetIpaddr(); info.ip_server_ = GetIpaddr(true); info.is_start_serve_ = GetRunState(); info.port_ = GetPort(); info.port_push_ = GetPort(true); info.screen_fps_ = GetFPS(); info.screen_fps_push_ = GetFPS(true); info.screen_quality_ = GetQuality(); info.screen_quality_push_ = GetQuality(true); }
RString RageDisplay::GetStats() const { RString s; // If FPS == 0, we don't have stats yet. if( !GetFPS() ) s = "-- FPS\n-- av FPS\n-- VPF"; s = ssprintf( "%i FPS\n%i av FPS\n%i VPF", GetFPS(), GetCumFPS(), GetVPF() ); // #if defined(_WINDOWS) s += "\n"+this->GetApiDescription(); // #endif return s; }
void EngineInstruments::Render() { Gauge::Render(); glColor3ub(0,190,190); // cyan // We want to draw the divider between the engine instruments and the PFD/Nav above glLineWidth( 2.0 ); glColor3ub( 0, 190, 190 ); // cyan static const float vertices[] = {0.0, m_PhysicalSize.y, m_PhysicalSize.x, m_PhysicalSize.y}; glVertexPointer(2, GL_FLOAT, 0, &vertices); glDrawArrays(GL_LINES, 0, 2); // Draw the text labels globals->m_FontManager->SetSize(m_Font, 5, 6); globals->m_FontManager->Print(15, 70, "RPM", m_Font); globals->m_FontManager->Print(66, 70, "EGT", m_Font); globals->m_FontManager->Print(111, 70, "CHT", m_Font); // Draw frames per second char buffer[16]; snprintf(buffer, sizeof(buffer), "FPS %2.1f", GetFPS()); globals->m_FontManager->SetSize(m_Font, 3, 3); globals->m_FontManager->Print(169, 2, buffer, m_Font); }
CString RageDisplay::GetStats() const { CString s; /* If FPS == 0, we don't have stats yet. */ if( !GetFPS() ) s = "-- FPS\n-- av FPS\n-- VPF"; else s = ssprintf( "%i FPS\n%i av FPS\n%i VPF", GetFPS(), GetCumFPS(), GetVPF() ); #ifdef _WINDOWS s += "\n" + this->GetApiDescription(); #endif return s; }
void DrawObjects(void) { // Draw the Star Field SpaceMap1->DrawTrans(Screen->GetBack()); // Draw the Player Player->Draw(Screen->GetBack(), 0, 0, CDXBLT_TRANS); // Draw all the sprites in the list Sprites.Draw(Screen->GetBack(), 0, 0, CDXBLT_TRANS); // If debugging Display the FPS if (FPSFlag == 1) DisplayFPS(); // Display text on the back buffer DisplayScore(); DisplayHighScore(); DisplayLives(); DisplaySpaceyMsg(); // Flip the Flippin screen buffers Screen->Flip(); // calculate the FPS after all drawing and page flipping have been performed. GetFPS(); }
// Shows current FPS on top-left corner // NOTE: Uses default font void DrawFPS(int posX, int posY) { char buffer[20]; // NOTE: We are rendering fps every second for better viewing on high framerates // TODO: Not working properly on ANDROID and RPI static float fps = 0.0f; static int counter = 0; static int refreshRate = 20; if (counter < refreshRate) { counter++; } else { fps = GetFPS(); refreshRate = fps; counter = 0; } sprintf(buffer, "%2.0f FPS", fps); DrawText(buffer, posX, posY, 20, LIME); }
void Direct3DUpdate(HWND hwnd) { ////////////////////////////////////////////////////////////////////////// // Five steps of rendering: clear, beginScene, render, EndScene, present ////////////////////////////////////////////////////////////////////////// gPD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); RECT formatRect; GetClientRect(hwnd, &formatRect); gPD3DDevice->BeginScene(); gPD3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); gPD3DDevice->SetStreamSource(0, gPVertexBuffer, 0, sizeof(CUSTOM_VERTEX)); gPD3DDevice->SetFVF(D3DFVF_CUSTOM_VERTEX); gPD3DDevice->SetIndices(gPIndexBuffer); gPD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 17, 0, 16); int charCount = swprintf_s(gStrFPS, 20, _T("FPS:%0.3f"), GetFPS()); gPFont->DrawText(NULL, gStrFPS, charCount, &formatRect, DT_TOP | DT_RIGHT, D3DCOLOR_XRGB(255, 39, 136)); gPD3DDevice->EndScene(); gPD3DDevice->Present(nullptr, nullptr, nullptr, nullptr); }
const rString FrameCounter::GetFPSString() const { rOStringStream oss; oss.precision( FRAMECOUNTER_STRING_FPS_PRECISION ); oss << std::fixed << GetFPS(); return rString( oss.str().c_str() ); }
void Render(HWND hWnd) { g_pDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(123, 65, 255), 1.0f, 0); g_pDevice->BeginScene(); SetMatrix(); if (::GetAsyncKeyState(0x31) & 0x8000f) g_pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME); if (::GetAsyncKeyState(0x32) & 0x8000f) g_pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); g_pDevice->SetRenderState(D3DRS_LIGHTING, FALSE); g_pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);//开启背面消隐 g_pDevice->SetStreamSource(0, g_pVertexBuffer, 0, sizeof(CUSTOMVERTEX)); g_pDevice->SetFVF(D3DFVF_CUSTOMVERTEX); g_pDevice->SetIndices(g_pIndexBuffer); g_pDevice->SetTexture(0, g_pTexture); g_pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 24, 0, 12); RECT rect; GetClientRect(hWnd, &rect); int count = _stprintf_s(g_strFPS, 20, TEXT("FPS : %0.3f"), GetFPS()); g_pFont->DrawText(NULL, g_strFPS, count, &rect, DT_TOP | DT_RIGHT, D3DCOLOR_XRGB(255, 239, 136)); g_pDevice->EndScene(); g_pDevice->Present(NULL, NULL, NULL, NULL); }
void FileSaver::StoreAsGif(const std::string& src, const std::string& dst) { if (ee::SymbolFile::Instance()->Type(src) != s2::SYM_ANIMATION) { return; } auto sym = ee::SymbolMgr::Instance()->FetchSymbol(src); auto anim = std::dynamic_pointer_cast<libanim::Symbol>(sym); sm::vec2 sz = sym->GetBounding().Size(); AnimatedGifSaver saver(sz.x, sz.y); s2::DrawRT rt(sz.x, sz.y); int max_frame = anim->GetMaxFrameIdx(); for (int i = 0; i < max_frame; ++i) { rt.Draw(*sym, true); uint8_t* rgb = rt.StoreToMemory(-1, -1, 3); // anim->setFrameIndex(i + 1); saver.AddFrame(rgb, 1.0f / anim->GetFPS()); delete[] rgb; } // anim->setFrameIndex(0); saver.Save(dst.c_str()); }
XnStatus XnSensorDepthStream::ConfigureStreamImpl() { XnStatus nRetVal = XN_STATUS_OK; xnUSBShutdownReadThread(GetHelper()->GetPrivateData()->pSpecificDepthUsb->pUsbConnection->UsbEp); nRetVal = SetActualRead(TRUE); XN_IS_STATUS_OK(nRetVal); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_InputFormat)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(ResolutionProperty())); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(FPSProperty())); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_HoleFilter)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_Gain)); // we need to turn decimation on when resolution is QVGA, and FPS is different than 60 // NOTE: this is ugly as hell. This logic should be moved to firmware. XnBool bDecimation = (GetResolution() == XN_RESOLUTION_QVGA && GetFPS() != 60); nRetVal = GetFirmwareParams()->m_DepthDecimation.SetValue(bDecimation); XN_IS_STATUS_OK(nRetVal); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareRegistration)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareMirror)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_GMCMode)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_WhiteBalance)); nRetVal = m_Helper.GetCmosInfo()->SetCmosConfig(XN_CMOS_TYPE_DEPTH, GetResolution(), GetFPS()); XN_IS_STATUS_OK(nRetVal); return XN_STATUS_OK; }
void App::FrameMove() { if(GetInput()->KeyDown(DIK_ESCAPE)) {::PostQuitMessage(0);} if(GetInput()->ButtonDown(0)) { static C3DFLOAT32 fRotX = 0.0f, fRotY = 0.0f; C3DINT32 iDeltaX, iDeltaY; GetInput()->GetMovement(&iDeltaX, &iDeltaY); fRotX += -2.0f * (C3DFLOAT32)iDeltaX * GetInvFPS(); fRotY += 2.0f * (C3DFLOAT32)iDeltaY * GetInvFPS(); const C3DFLOAT32 fCamPosX = -2.0f * sinf(Core3D::DegToRad(fRotX)); const C3DFLOAT32 fCamPosY = -2.0f * sinf(Core3D::DegToRad(fRotY)); const C3DFLOAT32 fCamPosZ = -2.0f * cosf(Core3D::DegToRad(fRotX)); m_pkCamera->SetPosition(C3DVECTOR3(fCamPosX, fCamPosY, fCamPosZ)); m_pkCamera->SetLookAt(C3DVECTOR3(0.0f, 0.0f, 0.0f), C3DVECTOR3(0.0f, 1.0f, 0.0f)); m_pkCamera->CalculateView(); } if(0 == GetFrameIdent() % 5) { tchar szCaption[256] = _T(""); _stprintf_s(szCaption, _T("DisplacedSphere, FPS: %3.1f"), GetFPS()); ::SetWindowText(GetWindowHandle(), szCaption); } }
void EngineInstruments::Render() { Gauge::Render(); glColor3ub(0,190,190); // cyan // We want to draw the divider between the engine instruments and the PFD/Nav above glLineWidth( 2.0 ); glColor3ub( 0, 190, 190 ); // cyan glBegin(GL_LINES); glVertex2f(0.0, m_PhysicalSize.y); glVertex2f(m_PhysicalSize.x, m_PhysicalSize.y); glEnd(); // Draw the text labels globals->m_FontManager->SetSize(m_Font, 5, 6); globals->m_FontManager->Print(15, 70, "RPM", m_Font); globals->m_FontManager->Print(66, 70, "EGT", m_Font); globals->m_FontManager->Print(111, 70, "CHT", m_Font); // Draw frames per second char buffer[10]; sprintf(buffer, "FPS %.1f", GetFPS()); globals->m_FontManager->SetSize(m_Font, 3, 3); globals->m_FontManager->Print(169, 2, buffer, m_Font); }
void LockFPS(float TargetFPS) { LARGE_INTEGER OldLastTime = Stop; while (GetFPS() > TargetFPS) { QueryPerformanceCounter(&Stop); } Stop = OldLastTime; }
XnStatus XnSensorImageStream::ValidateMode() { XnStatus nRetVal = XN_STATUS_OK; // validity checks XnIOImageFormats nInputFormat = (XnIOImageFormats)m_InputFormat.GetValue(); XnOutputFormats nOutputFormat = GetOutputFormat(); XnResolutions nResolution = GetResolution(); XnUInt32 nFPS = GetFPS(); // check that input format matches output format switch (nOutputFormat) { case XN_OUTPUT_FORMAT_RGB24: if (nInputFormat != XN_IO_IMAGE_FORMAT_YUV422 && nInputFormat != XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422 && nInputFormat != XN_IO_IMAGE_FORMAT_BAYER) { // --avin mod-- //XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Input format %d cannot be converted to RGB24!", nInputFormat); } break; case XN_OUTPUT_FORMAT_YUV422: if (nInputFormat != XN_IO_IMAGE_FORMAT_YUV422 && nInputFormat != XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422) { XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Input format %d cannot be converted to YUV422!", nInputFormat); } break; case XN_OUTPUT_FORMAT_JPEG: if (nInputFormat != XN_IO_IMAGE_FORMAT_JPEG) { XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Input format %d cannot be converted to JPEG!", nInputFormat); } break; case XN_OUTPUT_FORMAT_GRAYSCALE8: if (nInputFormat != XN_IO_IMAGE_FORMAT_UNCOMPRESSED_GRAY8 && nInputFormat != XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER && nInputFormat != XN_IO_IMAGE_FORMAT_BAYER) { XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Input format %d cannot be converted to Gray8!", nInputFormat); } break; default: // we shouldn't have reached here. Theres a check at SetOutputFormat. XN_ASSERT(FALSE); XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Unsupported image output format: %d!", nOutputFormat); } // now check that mode exists XnCmosPreset preset = { (XnUInt16)nInputFormat, (XnUInt16)nResolution, (XnUInt16)nFPS }; nRetVal = ValidateSupportedMode(preset); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
void App::Update(const delta_t dt, const delta_t elapsed) { // retrieve current mouse state mouse_info mi = GetMouse(); string buffer; // write program information to window title if (blurEnabled) buffer = "[B]"; SetWindowTitle("firefly-demo v%d.%d (FPS: %.2lf)" " x-%d y-%d %s", FF_MAJOR_VERSION, FF_MINOR_VERSION, GetFPS(), mi.x, mi.y, buffer.c_str()); // calculate movement rate and direction bool forceBlur = false; if (GetKey('A')) { cameraFrame.MoveRight(MOVE_SPEED*dt); forceBlur = true; } if (GetKey('D')) { cameraFrame.MoveRight(-MOVE_SPEED*dt); forceBlur = true; } if (GetKey('W')) { cameraFrame.MoveForward(MOVE_SPEED*dt); forceBlur = true; } if (GetKey('S')) { cameraFrame.MoveForward(-MOVE_SPEED*dt); forceBlur = true; } // calculate mouse delta float delta = (GetWidth() / 2.f) - mi.x; moveBlur = (abs(delta) > BLUR_MIN_DELTA || forceBlur) ? true : false; cameraFrame.RotateWorld( -delta * TURN_SPEED * dt / 4, 0, 1, 0); // keep the mouse centered glfwSetMousePos(GetWidth() / 2, GetHeight() / 2); // handle current jumping state if (jumping) { jumpVel -= JUMP_GRAVITY * dt; cameraFrame.MoveUp(jumpVel * dt); // if we have landed if (cameraFrame.GetOriginY() < 0) { jumping = false; jumpVel = 0; // make sure we are positioned back at ground height float dist = cameraFrame.GetOriginY(); cameraFrame.MoveUp(cameraFrame.GetOriginY() - dist); } } }
void CTestGame::Update(long dTime) { //change angle of rotation angle += ANGLE_CHANGE * gamepad->GetAxis(GAMEPAD_SAXIS) * dTime; //change position x += POSITION_CHANGE * gamepad->GetAxis(GAMEPAD_LXAXIS) * dTime; y += POSITION_CHANGE * gamepad->GetAxis(GAMEPAD_LYAXIS) * dTime; //update stat box CGame::GameStats->Update(0,"FPS: ",GetFPS()); }
void CTestGame::Update(long dTime) { space->Update(dTime); SDLClasses::CGame::GameStats->Update(1,"Vx: ",(double)entity->velocity.x); SDLClasses::CGame::GameStats->Update(2,"Vy: ",(double)entity->velocity.y); seg->v2.x = mouse->GetX(); seg->v2.y = mouse->GetY(); //update stat box CGame::GameStats->Update(0,"FPS: ",GetFPS()); }
void PS3::PrintInfo() { std::cout << "GUID:\t" << GUID2String( GetGUID(), '-', true ) << std::endl; std::cout << "Framerate:\t" << _frameRate << std::endl; std::cout << "Running:\t" << _bRunning << std::endl; std::cout << "Capturing:\t" << _bCapture << std::endl; std::cout << "Window title:\t" << _windowTitle << std::endl; std::cout << "Horizontal flip:\t" << _bHFlip << std::endl; std::cout << "Vertical flip:\t" << _bVFlip << std::endl; std::cout << "FPS:\t" << GetFPS() << std::endl; std::cout << "Width:\t" << GetWidth() << std::endl; std::cout << "Height:\t" << GetHeight() << std::endl; std::cout << "FrameCount:\t" << GetFrameCount() << std::endl; }
XnStatus XnSensorDepthStream::DecideFirmwareRegistration(XnBool bRegistration, XnProcessingType registrationType, XnResolutions nRes) { XnStatus nRetVal = XN_STATUS_OK; // start with request XnBool bFirmwareRegistration = bRegistration; if (bFirmwareRegistration) { // old chip (PS1000) does not support registration for VGA XnBool bHardwareRegistrationSupported = m_Helper.GetPrivateData()->ChipInfo.nChipVer != XN_SENSOR_CHIP_VER_PS1000 || nRes == XN_RESOLUTION_QVGA; switch (registrationType) { case XN_PROCESSING_HARDWARE: if (!bHardwareRegistrationSupported) { XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Sensor does not support hardware registration for current configuration!"); } break; case XN_PROCESSING_SOFTWARE: if (GetFPS() == 60) { XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Software registration is not supported in 60 FPS mode!"); } bFirmwareRegistration = FALSE; break; case XN_PROCESSING_DONT_CARE: bFirmwareRegistration = bHardwareRegistrationSupported; break; default: XN_LOG_ERROR_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Unknown registration type: %d", registrationType); } } if (bRegistration && !bFirmwareRegistration) { // make sure software registration is initialized if (!m_Registration.IsInitialized()) { nRetVal = m_Registration.Init(m_Helper.GetPrivateData(), this, GetDepthToShiftTable()); XN_IS_STATUS_OK(nRetVal); } } nRetVal = m_Helper.SimpleSetFirmwareParam(m_FirmwareRegistration, (XnUInt16)bFirmwareRegistration); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
void Render(HWND hWnd) { g_pDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); g_pDevice->BeginScene(); SetMatrix(); if (::GetAsyncKeyState(0x31) & 0x8000f) g_pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME); if (::GetAsyncKeyState(0x32) & 0x8000f) g_pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); if (::GetAsyncKeyState(0x51) & 0x8000f) SetLight(g_pDevice, 1); if (::GetAsyncKeyState(0x57) & 0x8000f) SetLight(g_pDevice, 2); if (::GetAsyncKeyState(0x45) & 0x8000f) SetLight(g_pDevice, 3); D3DXMatrixTranslation(&g_WorldMatrix[0], -3.0f, -3.0f, 0.0f); g_WorldMatrix[0] = g_WorldMatrix[0] * R; g_pDevice->SetTransform(D3DTS_WORLD, &g_WorldMatrix[0]); g_pTeapot->DrawSubset(0); D3DXMatrixTranslation(&g_WorldMatrix[1], 3.0f, -3.0f, 0.0f); g_WorldMatrix[1] = g_WorldMatrix[1] * R; g_pDevice->SetTransform(D3DTS_WORLD, &g_WorldMatrix[1]); g_pCube->DrawSubset(0); D3DXMatrixTranslation(&g_WorldMatrix[2], 3.0f, 3.0f, 0.0f); g_WorldMatrix[2] = g_WorldMatrix[2] * R; g_pDevice->SetTransform(D3DTS_WORLD, &g_WorldMatrix[2]); g_pTorus->DrawSubset(0); D3DXMatrixTranslation(&g_WorldMatrix[3], -3.0f, 3.0f, 0.0f); g_WorldMatrix[3] = g_WorldMatrix[3] * R; g_pDevice->SetTransform(D3DTS_WORLD, &g_WorldMatrix[3]); g_pSphere->DrawSubset(0); RECT rect; GetClientRect(hWnd, &rect); int count = _stprintf_s(g_strFPS, 20, TEXT("FPS : %0.3f"), GetFPS()); g_pFont->DrawText(NULL, g_strFPS, count, &rect, DT_TOP | DT_RIGHT, D3DCOLOR_XRGB(255, 239, 136)); g_pDevice->EndScene(); g_pDevice->Present(NULL, NULL, NULL, NULL); }
void BodymovinLoader::Load(const Json::Value& val, const std::string& dir) { auto sym_loader = std::make_shared<ee::SymbolLoader>(); auto spr_loader = std::make_shared<ee::SpriteLoader>(); auto sym = std::make_shared<s2::AnimSymbol>(); s2loader::BodymovinAnimLoader loader(*std::dynamic_pointer_cast<s2::AnimSymbol>(sym), sym_loader, spr_loader); loader.LoadJson(val, dir.c_str()); SetFpsSJ::Instance()->Set(sym->GetFPS()); ViewMgr::Instance()->toolbar->ChangeTemplateMode(true); DataMgr::Instance()->name = ""; DataMgr::Instance()->GetLayers().Clear(); ViewMgr::Instance()->library->Clear(); SetSelectedSJ::Instance()->Set(-1, -1); const auto& layers = sym->GetLayers(); for (int i = 0, n = layers.size(); i < n; ++i) { const auto& src_layer = layers[i]; Layer* dst_layer = new Layer; InsertLayerSJ::Instance()->Insert(dst_layer); SetSelectedSJ::Instance()->Set(0, 0); for (int j = 0, m = src_layer->frames.size(); j < m; ++j) { const auto& src_frame = src_layer->frames[j]; KeyFrame* dst_frame = new KeyFrame(src_frame->index); dst_frame->SetLayer(dst_layer); for (auto& spr : src_frame->sprs) { dst_frame->Insert(std::dynamic_pointer_cast<ee::Sprite>(spr->Clone()), INT_MAX); } dst_frame->SetClassicTween(src_frame->tween); dst_layer->InsertKeyFrame(dst_frame); dst_frame->RemoveReference(); } } ViewMgr::Instance()->library->LoadFromSymbolMgr(*ee::SymbolMgr::Instance()); SetSelectedSJ::Instance()->Set(0, 0); }
//------------------------------------------------------------------------------ void NBodyWnd::DrawStat() { double x0 = 10, y0 = 20, dy = 20; int line = 0; glColor3f(1, 1, 1); TextOut(x0, y0 + dy * line++, "FPS: %d", GetFPS()); TextOut(x0, y0 + dy * line++, "Time: %2.2e y", m_galaxy.GetTime()); TextOut(x0, y0 + dy * line++, "RadCore: %d pc", (int)m_galaxy.GetCoreRad()); TextOut(x0, y0 + dy * line++, "RadGalaxy: %d pc", (int)m_galaxy.GetRad()); TextOut(x0, y0 + dy * line++, "RadFarField: %d pc", (int)m_galaxy.GetFarFieldRad()); TextOut(x0, y0 + dy * line++, "ExInner: %2.2f", m_galaxy.GetExInner()); TextOut(x0, y0 + dy * line++, "ExOuter: %2.2f", m_galaxy.GetExOuter()); TextOut(x0, y0 + dy * line++, "Sigma: %2.2f", m_galaxy.GetSigma()); TextOut(x0, y0 + dy * line++, "AngOff: %1.4f deg/pc", m_galaxy.GetAngularOffset()); }
void RenderText( IDirect3DDevice9Ex* pDev ) { // The helper object simply helps keep track of text position, and color // and then it calls pFont->DrawText( m_pSprite, strMsg, -1, &rc, DT_NOCLIP, m_clr ); // If NULL is passed in as the sprite object, then it will work fine however the // pFont->DrawText() will not be batched together. Batching calls will improves perf. CTextHelper txtHelper( g_pFont, g_pSprite, 15 ); // Output statistics txtHelper.Begin(); txtHelper.SetInsertionPos( 2, 0 ); txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ) ); txtHelper.DrawTextLine( L"This sample demonstrates rendering a cursor indepedently of geometry." ); txtHelper.DrawTextLine( L"The scene (cubes in this case) is drawn by a D3D9Ex device that runs" ); txtHelper.DrawTextLine( L"in a lower priority background thread. The image is copied to a shared" ); txtHelper.DrawTextLine( L"surface. The main application thread contains a D3D9Ex device as well." ); txtHelper.DrawTextLine( L"This thread runs at a higher priority and composites the shared image" ); txtHelper.DrawTextLine( L"with a D3D9Ex drawn cursor and text in real time. This allows for" ); txtHelper.DrawTextLine( L"fluid cursor and text updates even when the scene is too complex to be" ); txtHelper.DrawTextLine( L"handled in real-time." ); txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 0.0f, 0.0f, 1.0f ) ); txtHelper.DrawTextLine( L"" ); txtHelper.DrawTextLine( L"Press the UP arrow key to increase the scene complexity." ); txtHelper.DrawTextLine( L"Press the DOWN arrow key to decrease the scene complexity." ); txtHelper.DrawTextLine( L"" ); txtHelper.DrawTextLine( L"Try increasing the Number of Cubes to a very high number. The cubes will" ); txtHelper.DrawTextLine( L"update slowly, but the cursor will still be responsive." ); txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) ); txtHelper.DrawTextLine( L"" ); txtHelper.DrawFormattedTextLine( L"Number of Cubes: %d", g_cubeCount*g_cubeCount ); // get stats from the background thread float FPS = GetFPS(); txtHelper.SetForegroundColor( D3DXCOLOR( 0.0f, 1.0f, 0.0f, 1.0f ) ); txtHelper.DrawTextLine( L"" ); txtHelper.DrawTextLine( L"Background Thread:" ); txtHelper.DrawFormattedTextLine( L"FPS: %0.2f", FPS ); txtHelper.DrawTextLine( L"" ); txtHelper.DrawTextLine( L"Foreground Thread:" ); txtHelper.DrawFormattedTextLine( L"FPS: %0.2f", 1.0f / g_fLastFrameTime ); txtHelper.DrawFormattedTextLine( L"Present Count: %d", g_PresentStats.PresentCount ); txtHelper.DrawFormattedTextLine( L"Present Refresh Count: %d", g_PresentStats.PresentRefreshCount ); txtHelper.DrawFormattedTextLine( L"Sync Refresh Count: %d", g_PresentStats.SyncRefreshCount ); txtHelper.End(); }
CBasicAnimation::CBasicAnimation(ALLEGRO_BITMAP* sheet, size_t rows, size_t cols, double fps) : IAnimationBase(rows, cols, fps) , m_animationSheet(sheet) , m_frame() , m_frameW(DEFAULTFRAMEW) , m_frameH(DEFAULTFRAMEH) { assert(m_animationSheet.IsValid() == true); assert(rows > 0); assert(cols > 0); assert(fps > 0.0); if (!m_animationSheet || !GetRows() || !GetCols() || (GetFPS() <= 0)) abort(); if (m_animationSheet) { m_frameW = m_animationSheet.GetWidth() / GetCols(); m_frameH = m_animationSheet.GetHeight() / GetRows(); FrameChanged(); } }
void THISCLASS::OnStep() { if (! mCapture) { return; } // Read the next frame int framenumber = (int)cvGetCaptureProperty(mCapture, CV_CAP_PROP_POS_FRAMES); int framescount = (int)cvGetCaptureProperty(mCapture, CV_CAP_PROP_FRAME_COUNT); mOutputImage = cvQueryFrame(mCapture); if (! mOutputImage) { AddError(wxT("Finished reading AVI file.")); mCore->TriggerStop(); return; } // Flip the image if desired if (mFlipVertically) { cvFlip(mOutputImage, 0, 0); } // Set DataStructureImage mCore->mDataStructureInput.mImage = mOutputImage; mCore->mDataStructureInput.mFrameNumber = framenumber; mCore->mDataStructureInput.mFramesCount = framescount; // On linux, directly readig the millisecond offset doesn't work. //double progress = GetProgressMSec(); double secondsInVideo = GetProgressFrameNumber() / GetFPS(); wxDateTime ts((time_t) secondsInVideo); double millis = (secondsInVideo - (int) secondsInVideo) * 1000; ts.SetMillisecond((int) millis); mCore->mDataStructureInput.SetFrameTimestamp(ts); // Set the display DisplayEditor de(&mDisplayOutput); if (de.IsActive()) { de.SetMainImage(mOutputImage); } }
// Shows current FPS on top-left corner // NOTE: Uses default font void DrawFPS(int posX, int posY) { // NOTE: We are rendering fps every second for better viewing on high framerates static float fps; static int counter = 0; static int refreshRate = 0; char buffer[20]; if (counter < refreshRate) { counter++; } else { fps = GetFPS(); refreshRate = fps; counter = 0; } sprintf(buffer, "%2.0f FPS", fps); DrawText(buffer, posX, posY, 20, LIME); }
XnStatus XnSensorDepthStream::ConfigureStreamImpl() { XnStatus nRetVal = XN_STATUS_OK; xnUSBShutdownReadThread(GetHelper()->GetPrivateData()->pSpecificDepthUsb->pUsbConnection->UsbEp); nRetVal = SetActualRead(TRUE); XN_IS_STATUS_OK(nRetVal); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_InputFormat)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(ResolutionProperty())); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(FPSProperty())); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_HoleFilter)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_Gain)); // we need to turn decimation on when resolution is QVGA, and FPS is different than 60 // NOTE: this is ugly as hell. This logic should be moved to firmware. XnBool bDecimation = (GetResolution() == XN_RESOLUTION_QVGA && GetFPS() != 60); nRetVal = GetFirmwareParams()->m_DepthDecimation.SetValue(bDecimation); XN_IS_STATUS_OK(nRetVal); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareRegistration)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareMirror)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_GMCMode)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_WhiteBalance)); nRetVal = m_Helper.GetCmosInfo()->SetCmosConfig(XN_CMOS_TYPE_DEPTH, GetResolution(), GetFPS()); XN_IS_STATUS_OK(nRetVal); // --avin mod-- //Turn off the IR projector anti-cover thingy. I find it annoying and It's off on the XBox360 so it must be safe :-) //This is probably not the best way to do it, but adding it as a real param is too much work for me at the moment... XnHostProtocolSetParam(GetHelper()->GetPrivateData(), 0x105, 0); return XN_STATUS_OK; }
char* OBS::EncMetaData(char *enc, char *pend, bool bFLVFile) { int maxBitRate = GetVideoEncoder()->GetBitRate(); int fps = GetFPS(); int audioBitRate = GetAudioEncoder()->GetBitRate(); CTSTR lpAudioCodec = GetAudioEncoder()->GetCodec(); double audioCodecID; const AVal *av_codecFourCC; #ifdef USE_AAC if(scmpi(lpAudioCodec, TEXT("AAC")) == 0) { av_codecFourCC = &av_mp4a; audioCodecID = 10.0; } else #endif { av_codecFourCC = &av_mp3; audioCodecID = 2.0; } if(bFLVFile) { *enc++ = AMF_ECMA_ARRAY; enc = AMF_EncodeInt32(enc, pend, 14); } else *enc++ = AMF_OBJECT; enc = AMF_EncodeNamedNumber(enc, pend, &av_duration, 0.0); enc = AMF_EncodeNamedNumber(enc, pend, &av_fileSize, 0.0); enc = AMF_EncodeNamedNumber(enc, pend, &av_width, double(outputCX)); enc = AMF_EncodeNamedNumber(enc, pend, &av_height, double(outputCY)); /*if(bFLVFile) enc = AMF_EncodeNamedNumber(enc, pend, &av_videocodecid, 7.0);//&av_avc1);// else*/ enc = AMF_EncodeNamedString(enc, pend, &av_videocodecid, &av_avc1);//7.0);// enc = AMF_EncodeNamedNumber(enc, pend, &av_videodatarate, double(maxBitRate)); enc = AMF_EncodeNamedNumber(enc, pend, &av_framerate, double(fps)); /*if(bFLVFile) enc = AMF_EncodeNamedNumber(enc, pend, &av_audiocodecid, audioCodecID);//av_codecFourCC);// else*/ enc = AMF_EncodeNamedString(enc, pend, &av_audiocodecid, av_codecFourCC);//audioCodecID);// enc = AMF_EncodeNamedNumber(enc, pend, &av_audiodatarate, double(audioBitRate)); //ex. 128kb\s enc = AMF_EncodeNamedNumber(enc, pend, &av_audiosamplerate, 44100.0); enc = AMF_EncodeNamedNumber(enc, pend, &av_audiosamplesize, 16.0); enc = AMF_EncodeNamedNumber(enc, pend, &av_audiochannels, 2.0); enc = AMF_EncodeNamedBoolean(enc, pend, &av_stereo, true); enc = AMF_EncodeNamedString(enc, pend, &av_encoder, &av_OBSVersion); *enc++ = 0; *enc++ = 0; *enc++ = AMF_OBJECT_END; return enc; }
XnStatus XnSensorIRStream::ConfigureStreamImpl() { XnStatus nRetVal = XN_STATUS_OK; xnUSBShutdownReadThread(GetHelper()->GetPrivateData()->pSpecificImageUsb->pUsbConnection->UsbEp); nRetVal = SetActualRead(TRUE); XN_IS_STATUS_OK(nRetVal); nRetVal = m_Helper.ConfigureFirmware(ResolutionProperty()); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.ConfigureFirmware(FPSProperty()); XN_IS_STATUS_OK(nRetVal);; // IR mirror is always off in firmware nRetVal = GetFirmwareParams()->m_IRMirror.SetValue(FALSE); XN_IS_STATUS_OK(nRetVal); // CMOS if (GetResolution() != XN_RESOLUTION_SXGA) { nRetVal = m_Helper.GetCmosInfo()->SetCmosConfig(XN_CMOS_TYPE_DEPTH, GetResolution(), GetFPS()); XN_IS_STATUS_OK(nRetVal); } return (XN_STATUS_OK); }