Avionics
Dropship Simulator
Viewport.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Screen.h"
4 
5 #define WindowClassStr L"MultiMon10Class"
6 
7 class Viewport
8 {
9 private:
10  Bus* bus = nullptr;
11  Logger* logger = nullptr;
12 
13  Viewport() = default;
14 
15  WNDCLASS g_WindowClass;
16  IDXGIFactory* g_pDXGIFactory = nullptr;
17  HRESULT EnumerateAdapters();
18 
20  {
21  IDXGIAdapter* pDXGIAdapter;
22  CGrowableArray<IDXGIOutput*> DXGIOutputArray;
23  };
24 
25  CGrowableArray<DEVICE_OBJECT*> g_DeviceArray;
26  CGrowableArray<ADAPTER_OBJECT*> g_AdapterArray;
27  CGrowableArray<WINDOW_OBJECT*> g_WindowObjects;
28  static HRESULT EnumerateOutputs(ADAPTER_OBJECT* pAdapterObj);
29  HRESULT CreateWindowClass(HINSTANCE hInstance);
30  HRESULT CreateMonitorWindows();
31  HRESULT SetWindowAssociation() const;
32  HRESULT CreateDevicePerAdapter(D3D10_DRIVER_TYPE DriverType);
33  HRESULT OnD3D10CreateDevice(DEVICE_OBJECT* pDevice);
34  HRESULT CreateSwapChainPerOutput() const;
35  static HRESULT CreateViewsForWindowObject(WINDOW_OBJECT* pWindow);
36  void DeviceCleanup();
37 
38 public:
39  bool exclusiveMode = false;
40  std::vector<Screen> screens;
41  std::vector<Font> fonts;
42 
43  Viewport(Bus*, Logger*);
44  void Initialize(HINSTANCE);
45  std::vector<HWND> GetWindowHandles() const;
46  void Destroy();
47  ~Viewport();
48 
49  void Render(float fElapsed);
50 
51  void FrameMove()
52  {
54  for (UINT i = 0; i < bus->commandStream.size(); i++)
55  {
56  Command command = bus->commandStream.at(i);
57  if (command.delay != 0.0f) continue;
58 
59  std::string prefix("Viewport-");
60  if (!command.name.compare(0, prefix.size(), prefix))
61  {
63  for (UINT s = 0; s < screens.size(); s++)
64  {
65  prefix = "Viewport-" + screens.at(s).name;
66  if (!command.name.compare(0, prefix.size(), prefix))
67  {
68  for (UINT p = 0; p < screens.at(s).pages.size(); p++)
69  {
70  if (screens.at(s).pages.at(p).name == command.svalue)
71  {
73  screens.at(s).currentPage = p;
74  bus->commandStream.erase(bus->commandStream.begin() + i);
75  }
76  }
77  }
78  }
79  }
80  }
81  }
82 };
CGrowableArray< WINDOW_OBJECT * > g_WindowObjects
Definition: Viewport.h:27
std::vector< HWND > GetWindowHandles() const
Definition: Viewport.cpp:570
std::vector< Command > commandStream
Definition: Bus.h:20
Viewport()=default
Definition: Logger.h:5
~Viewport()
Definition: Viewport.cpp:84
CGrowableArray< ADAPTER_OBJECT * > g_AdapterArray
Definition: Viewport.h:26
void Render(float fElapsed)
Definition: Viewport.cpp:65
CGrowableArray< IDXGIOutput * > DXGIOutputArray
Definition: Viewport.h:22
void FrameMove()
Definition: Viewport.h:51
HRESULT CreateSwapChainPerOutput() const
Definition: Viewport.cpp:352
char svalue[64]
Definition: Command.h:24
IDXGIAdapter * pDXGIAdapter
Definition: Viewport.h:21
void Initialize(HINSTANCE)
Definition: Viewport.cpp:9
static HRESULT CreateViewsForWindowObject(WINDOW_OBJECT *pWindow)
Definition: Viewport.cpp:416
Logger * logger
Definition: Viewport.h:11
std::vector< Font > fonts
Definition: Viewport.h:41
void Destroy()
Definition: Viewport.cpp:532
std::vector< Screen > screens
Definition: Viewport.h:40
Definition: Bus.h:12
std::string name
command name
Definition: Command.h:11
Bus * bus
Definition: Viewport.h:10
HRESULT CreateMonitorWindows()
Definition: Viewport.cpp:228
HRESULT CreateDevicePerAdapter(D3D10_DRIVER_TYPE DriverType)
Definition: Viewport.cpp:305
bool exclusiveMode
Definition: Viewport.h:39
void DeviceCleanup()
Definition: Viewport.cpp:481
HRESULT SetWindowAssociation() const
Definition: Viewport.cpp:291
Definition: Command.h:5
static HRESULT EnumerateOutputs(ADAPTER_OBJECT *pAdapterObj)
Definition: Viewport.cpp:157
WNDCLASS g_WindowClass
Definition: Viewport.h:15
HRESULT OnD3D10CreateDevice(DEVICE_OBJECT *pDevice)
Definition: Viewport.cpp:394
IDXGIFactory * g_pDXGIFactory
Definition: Viewport.h:16
float delay
wait number of seconds before executing command
Definition: Command.h:8
HRESULT CreateWindowClass(HINSTANCE hInstance)
Definition: Viewport.cpp:196
CGrowableArray< DEVICE_OBJECT * > g_DeviceArray
Definition: Viewport.h:25
HRESULT EnumerateAdapters()
Definition: Viewport.cpp:91