Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cDXDeviceWindow.h
Go to the documentation of this file.
1 //
5 //
6 
7 #ifndef _INC_cDXDeviceWindow_H
8 #define _INC_cDXDeviceWindow_H
9 #ifndef NO_PRAGMA_ONCE
10 #pragma once
11 #endif
12 
13 #include "cDXDevice.h"
14 #include "cDXSettings.h"
15 
16 #ifdef USE_DX9
22 
23 #define USE_DEV_FEATURES
24 
25 namespace Gray3D
26 {
27  class GRAY3D_LINK cDXDevicePrefs
28  {
31 
32  public:
33  bool m_bFullScreenPref;
34  cWinSize m_SizeFullScreen;
35 
37  cWindowPlacement m_WindowPlacement;
38 
39  bool m_VideoSync;
40 
46  bool m_bClipCursorWhenFullScreen;
47 
48  public:
49  cDXDevicePrefs();
50  };
51 
52  class GRAY3D_LINK cDXDeviceWindow
53  : public cDXDevice
54  , public cWindow
55  {
59 
60  typedef cWindow SUPER_t;
61 
62  public:
63  cString m_sWindowTitle;
64  cDXDevicePrefs& m_rPrefs;
65  cDXEnumeration& m_rEnumeration;
66 
67  cDXSettings m_d3dSettings;
68 
69  cThreadLockMutex m_LoaderMutex;
70  bool m_bInitInstanceComplete;
71 
72  // size also updated to m_rPrefs
73  cRectI m_rcWindowBounds;
74  cWinSize m_szWindowedClient;
75 
76  // Internal variables for the state of the app
77  int m_nPauseCount;
78 
79  bool m_bDeviceLost;
80  bool m_bForceReset;
81 
82  int m_iSizeState;
83  cTimeSys m_timeSizing;
84  bool m_bIgnoreSizeChange;
85 
86  DWORD m_dwWindowStyle;
87 
88  // Main objects used for creating and rendering the 3D scene
89  cRectI m_rcDraw;
90 
91  D3DPRESENT_PARAMETERS m_d3dpp;
92  D3DCAPS9 m_d3dCaps;
93  D3DSURFACE_DESC m_d3dsdBackBuffer;
94  DWORD m_dwDeviceCreateFlags;
95 
96  // Status Variables for timing
97  cValueStats<float> m_FPS;
98  cString m_strFrameDisplay;
99  cString m_strDeviceDesc;
100  cString m_strDeviceFormat;
101 
102  protected:
103  // Internal error handling function
104  virtual HRESULT DisplayErrorMsg(LOGLEV_TYPE eMsgType, HRESULT hRes, const GChar_t* pszMsg = nullptr);
105 
106  HRESULT Initialize3DDevice();
107 
108  HRESULT Initialize3DEnvironment();
109  HRESULT HandlePossibleSizeChange();
110  HRESULT Reset3DEnvironment();
111 
112  void Cleanup3DEnvironment();
113 
114  virtual void BuildPresentParamsFromSettings();
115  virtual HRESULT AdjustWindowForChange();
116 
117  // Overridable functions for the 3D scene created by the app
118  virtual HRESULT OneTimeSceneInit() = 0;
119  virtual void FinalCleanup() = 0;
120 
121  virtual HRESULT FrameMoveApp(TIMESECF_t fDelayTime) = 0;
122  virtual HRESULT RenderApp() = 0;
123 
124  void OnSize(UINT nType);
125  void OnClose();
126  bool OnPaint(HDC hDCAlt);
127 
128  public:
129  cDXDeviceWindow(cString sWindowTitle, cDXDevicePrefs& rPrefs, cDXEnumeration& rEnumeration);
130  virtual ~cDXDeviceWindow();
131 
132  // Functions to create, run, pause, and clean up the application
133 
134  cString GetDeviceDescStr();
135  cString GetDeviceFormatStr();
136  HRESULT UpdateDevice();
137 
138  virtual void Pause(bool bPause);
139 
140 #ifdef USE_DEV_FEATURES
141  HRESULT OpenDisplayAdvancedDlg();
142 #endif
143  HRESULT RenderFrame();
144  virtual HRESULT PresentFrame();
145  HRESULT RenderAndPresentFrame();
146 
147  HRESULT SetFullScreenMode(bool bFullScreen);
148 
149  virtual LRESULT WindowProc(WINMSG_t uMsg, WPARAM wParam, LPARAM lParam) override;
150  HRESULT InitInstance(const GChar_t* pszClassName, SHOWWINDOW_t nCmdShow, RESOURCEID_t idIcon);
151 
152  UNITTEST_FRIEND(cDXDeviceWindow);
153  };
154 }
155 #endif
156 #endif
#define GRAY3D_LINK
Definition: Gray3D.h:15
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
UINT WINMSG_t
Supplement _WIN32 "windows.h".
Definition: WinTypes.h:111
#define UNITTEST_FRIEND(n)
Define this in the class body to be unit tested. Allow the unit test to access private/protected stuf...
Definition: cUnitTestDecl.h:17
Definition: Gray3D.cpp:12
LOGLEV_TYPE
Definition: cLogLevel.h:22
WORD RESOURCEID_t
A resource in .RC attached to a file/module. like MAKEINTRESOURCE(). https://docs....
Definition: cResourceBase.h:19
char GChar_t
My version of TCHAR, _TCHAR.
Definition: StrConst.h:26
float TIMESECF_t
delta float seconds.
Definition: cTimeSys.h:20
cStringT< GChar_t > cString
Definition: cString.h:636
Definition: UseDX.h:326