-
Notifications
You must be signed in to change notification settings - Fork 0
/
D2DRenderer.h
60 lines (52 loc) · 1.5 KB
/
D2DRenderer.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
//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//// PARTICULAR PURPOSE.
////
//// Copyright (c) Microsoft Corporation. All rights reserved
#pragma once
#include "DirectXBase.h"
#include "Box2D\Box2D.h"
#include "Objects\Game.h"
#include "Utility.h"
#ifndef HINST_THISCOMPONENT
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
#define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)
#endif
template<class Interface>
inline void
SafeRelease(
Interface **ppInterfaceToRelease
)
{
if (*ppInterfaceToRelease != NULL)
{
(*ppInterfaceToRelease)->Release();
(*ppInterfaceToRelease) = NULL;
}
}
ref class D2DRenderer : public DirectXBase
{
public:
D2DRenderer();
~D2DRenderer();
virtual void CreateDeviceIndependentResources() override;
virtual void CreateDeviceResources() override;
virtual void Render() override;
void OnMouseMove(PointerEventArgs^ args);
void OnMouseDown(PointerEventArgs^ args);
private:
void RecreateTarget();
void RenderFPS(D2D1_SIZE_F);
Game *m_game;
int m_frameCounter;
int m_fps;
WORD m_lastFrameSecond;
WriteFactory *m_dwriteFactory; // used for FPS text and game menu
#ifdef DEBUG
SolidColorBrush *m_whiteBrush; // used only for FPS text
IDWriteTextFormat *m_textFormat; // only used for FPS text
WCHAR m_fpsText[10]; // used only for FPS text
uint32 m_fpsTextLength; // used only for FPS text
#endif
};