-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathSampleFpsTextRenderer.h
31 lines (27 loc) · 1.04 KB
/
SampleFpsTextRenderer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#pragma once
#include <string>
#include "..\Common\DeviceResources.h"
#include "..\Common\StepTimer.h"
namespace VBA10
{
// 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<ID2D1DrawingStateBlock> m_stateBlock;
Microsoft::WRL::ComPtr<IDWriteTextLayout> m_textLayout;
Microsoft::WRL::ComPtr<IDWriteTextFormat> m_textFormat;
};
}