-
Notifications
You must be signed in to change notification settings - Fork 8k
/
GameHud.h
60 lines (49 loc) · 2.38 KB
/
GameHud.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#pragma once
// GameHud:
// This class maintains the resources necessary to draw the Heads Up Display, which is a
// 2D overlay on top of the main 3D graphics generated for the game.
// The GameHud Render method expects to be called within the context of a D2D BeginDraw
// and makes D2D drawing calls to draw the text elements on the window.
#include "Simple3DGame.h"
#include "DirectXSample.h"
ref class Simple3DGame;
ref class GameHud
{
internal:
GameHud(
_In_ const std::shared_ptr<DX::DeviceResources>& deviceResources,
_In_ Platform::String^ titleHeader,
_In_ Platform::String^ titleBody
);
void CreateDeviceDependentResources();
void CreateWindowSizeDependentResources();
void ReleaseDeviceDependentResources();
void Render(_In_ Simple3DGame^ game);
private:
// Cached pointer to device resources.
std::shared_ptr<DX::DeviceResources> m_deviceResources;
Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> m_textBrush;
Microsoft::WRL::ComPtr<IDWriteTextFormat> m_textFormatBody;
Microsoft::WRL::ComPtr<IDWriteTextFormat> m_textFormatBodySymbol;
Microsoft::WRL::ComPtr<IDWriteTextFormat> m_textFormatTitleHeader;
Microsoft::WRL::ComPtr<IDWriteTextFormat> m_textFormatTitleBody;
Microsoft::WRL::ComPtr<ID2D1Bitmap> m_logoBitmap;
Microsoft::WRL::ComPtr<IDWriteTextLayout> m_titleHeaderLayout;
Microsoft::WRL::ComPtr<IDWriteTextLayout> m_titleBodyLayout;
bool m_showTitle;
Platform::String^ m_titleHeader;
Platform::String^ m_titleBody;
float m_titleBodyVerticalOffset;
D2D1_SIZE_F m_logoSize;
D2D1_SIZE_F m_maxTitleSize;
};