const rString FrameCounter::GetAverageFPSString() const { rOStringStream oss; oss.precision( FRAMECOUNTER_STRING_FPS_PRECISION ); oss << std::fixed << GetAverageFPS(); return rString( oss.str().c_str() ); }
Void RPGGame::OnFrameRender() { // Clear scene RenderingFn->ClearRenderTarget( RenderingFn->GetScreenRenderTarget(), (Float*)Color4::DarkGray ); RenderingFn->ClearDepthStencil( RenderingFn->GetScreenDepthStencil(), true, true, 1.0f ); // Render World WorldFn->RenderWorld(); // Render GUI InterfaceFn->Render(); // Render Debug text Vertex3 vPosition = GameplayFn->GetCharacter( TEXT("Shiki") )->GetEntity()->GetBody()->GetPosition(); StringFn->Format( m_strFPSText, TEXT("FPS = %2.5f"), GetAverageFPS() ); StringFn->Format( m_strCoordsText, TEXT("Coords = (%3f, %3f, %3f)"), vPosition.X, vPosition.Y, vPosition.Z ); StringFn->Format( m_strCullerText, TEXT("Visible leaves = %d"), WorldFn->GetVisibleGroup().GetCount() ); GPU2DContext * pContext2D = RenderingFn->GetScreen2DContext(); GPU2DRectangle hDstRect; hDstRect.fLeft = 16.0f; hDstRect.fTop = 64.0f; hDstRect.fRight = hDstRect.fLeft + 256.0f; hDstRect.fBottom = hDstRect.fTop + 16.0f; pContext2D->Begin(); pContext2D->DrawText( m_strFPSText, StringFn->Length(m_strFPSText), m_pDebugTextFormat, &hDstRect, m_pDebugTextBrush, GPU2DTEXT_DRAWOPTION_CLIP ); hDstRect.fTop += 16.0f; hDstRect.fBottom += 16.0f; pContext2D->DrawText( m_strCoordsText, StringFn->Length(m_strCoordsText), m_pDebugTextFormat, &hDstRect, m_pDebugTextBrush, GPU2DTEXT_DRAWOPTION_CLIP ); hDstRect.fTop += 16.0f; hDstRect.fBottom += 16.0f; pContext2D->DrawText( m_strCullerText, StringFn->Length(m_strCullerText), m_pDebugTextFormat, &hDstRect, m_pDebugTextBrush, GPU2DTEXT_DRAWOPTION_CLIP ); pContext2D->End(); // Present frame RenderingFn->Present(); }
Void EngineTests::OnFrameRender() { // Clear scene RenderingFn->ClearRenderTarget( RenderingFn->GetScreenRenderTarget(), (const Float*)Color4::DarkGray ); RenderingFn->ClearDepthStencil( RenderingFn->GetScreenDepthStencil(), true, true, 1.0f ); // Render World WorldFn->RenderWorld(); // Render GUI GUIFn->Render(); // Render Debug text Vector3 vPosition = m_pWorldCamera->GetTarget()->WorldTransform.GetTranslate(); StringFn->Format( m_strFPSText, TEXT("FPS = %2.5f"), GetAverageFPS() ); StringFn->Format( m_strCoordsText, TEXT("Coords = (%3f, %3f, %3f)"), vPosition.X, vPosition.Y, vPosition.Z ); StringFn->Format( m_strCullerText, TEXT("Visible leaves = %d"), WorldFn->GetVisibleGroup().GetCount() ); GPU2DContext * pContext2D = RenderingFn->GetScreen2DContext(); GPU2DRectangle hDstRect; hDstRect.fLeft = 16.0f; hDstRect.fTop = 16.0f; hDstRect.fRight = hDstRect.fLeft + 256.0f; hDstRect.fBottom = hDstRect.fTop + 16.0f; pContext2D->Begin(); pContext2D->DrawText( m_strFPSText, StringFn->Length(m_strFPSText), m_pDebugTextFormat, &hDstRect, m_pDebugTextBrush, GPU2DTEXT_DRAWOPTION_CLIP ); hDstRect.fTop += 16.0f; hDstRect.fBottom += 16.0f; pContext2D->DrawText( m_strCoordsText, StringFn->Length(m_strCoordsText), m_pDebugTextFormat, &hDstRect, m_pDebugTextBrush, GPU2DTEXT_DRAWOPTION_CLIP ); hDstRect.fTop += 16.0f; hDstRect.fBottom += 16.0f; pContext2D->DrawText( m_strCullerText, StringFn->Length(m_strCullerText), m_pDebugTextFormat, &hDstRect, m_pDebugTextBrush, GPU2DTEXT_DRAWOPTION_CLIP ); pContext2D->End(); // Present frame RenderingFn->Present(); }