Camera-Renderer/Camera-Renderer_cpp/Content/SampleFpsTextRenderer.h

31 lines
1.0 KiB
C
Raw Normal View History

2021-10-05 00:17:24 +13:00
#pragma once
#include <string>
#include "..\Common\DeviceResources.h"
#include "..\Common\StepTimer.h"
2021-10-05 00:27:45 +13:00
namespace CameraRenderer_cpp
2021-10-05 00:17:24 +13:00
{
// Renders the current FPS value in the bottom right corner of the screen using Direct2D and DirectWrite.
class SampleFpsTextRenderer
{
public:
SampleFpsTextRenderer(const std::shared_ptr<DX::DeviceResources>& deviceResources);
void CreateDeviceDependentResources();
void ReleaseDeviceDependentResources();
void Update(DX::StepTimer const& timer);
void Render();
private:
// Cached pointer to device resources.
std::shared_ptr<DX::DeviceResources> m_deviceResources;
// Resources related to text rendering.
std::wstring m_text;
DWRITE_TEXT_METRICS m_textMetrics;
Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> m_whiteBrush;
Microsoft::WRL::ComPtr<ID2D1DrawingStateBlock1> m_stateBlock;
Microsoft::WRL::ComPtr<IDWriteTextLayout3> m_textLayout;
Microsoft::WRL::ComPtr<IDWriteTextFormat2> m_textFormat;
};
}