VulkanRaytracingCycles 0.0.0
Cycles Render Engine With VulkanRaytracingShaderModules. ( Experiment , in progress)
WindowVk Struct Reference

#include <WindowVk.h>

Public Member Functions

 ~WindowVk ()
 
LRESULT WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
void setSize (uint32_t w, uint32_t h)
 
void PostDestroy ()
 
HWND setupWindow (HINSTANCE hinstance, WNDPROC wndproc, std::tstring Name="NoName")
 
void setWindowTitle (int FPS)
 

Public Attributes

HWND window = NULL
 
HINSTANCE windowInstance
 
bool fullscreen
 
bool overlay
 
uint32_t width = 256
 
uint32_t height = 256
 
uint32_t frameCounter = 0
 
std::tstring deviceName
 

Detailed Description

Definition at line 10 of file WindowVk.h.

Constructor & Destructor Documentation

◆ ~WindowVk()

WindowVk::~WindowVk ( )
inline

Definition at line 23 of file WindowVk.h.

23 {
25 }
void PostDestroy()
Definition: WindowVk.h:72

Member Function Documentation

◆ PostDestroy()

void WindowVk::PostDestroy ( )
inline

Definition at line 72 of file WindowVk.h.

72 {
73 if (window) {
74
75 //PostQuitMessage(0);
76 DestroyWindow(window); window = nullptr;
77 std::this_thread::sleep_for(std::chrono::milliseconds(10));
78 window = NULL;
79
80 }
81
82 };
HWND window
Definition: WindowVk.h:12

◆ setSize()

void WindowVk::setSize ( uint32_t  w,
uint32_t  h 
)
inline

Definition at line 66 of file WindowVk.h.

66 {
67 width = w;
68 height = h;
69 window = NULL;
70 };
uint32_t height
Definition: WindowVk.h:18
uint32_t width
Definition: WindowVk.h:17

◆ setupWindow()

HWND WindowVk::setupWindow ( HINSTANCE  hinstance,
WNDPROC  wndproc,
std::tstring  Name = "NoName" 
)
inline

Definition at line 84 of file WindowVk.h.

85 {
86
87 std::tstring name = Name;
88 deviceName = Name;
89 fullscreen = false;
90 this->windowInstance = hinstance;
91
92 WNDCLASSEX wndClass;
93
94
95 wndClass.cbSize = sizeof(WNDCLASSEX);
96 wndClass.style = CS_HREDRAW | CS_VREDRAW;
97 wndClass.lpfnWndProc = wndproc;
98 wndClass.cbClsExtra = 0;
99 wndClass.cbWndExtra = 0;
100 wndClass.hInstance = hinstance;
101 wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
102 wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
103 wndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
104 wndClass.lpszMenuName = NULL;
105 wndClass.lpszClassName = name.c_str();
106 wndClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
107
108 if (!RegisterClassEx(&wndClass))
109 {
110 std::cout << "Could not register window class!\n";
111 fflush(stdout);
112 exit(1);
113 }
114
115 int screenWidth = GetSystemMetrics(SM_CXSCREEN);
116 int screenHeight = GetSystemMetrics(SM_CYSCREEN);
117
118
119 if (fullscreen)
120 {
121 DEVMODE dmScreenSettings;
122 memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
123 dmScreenSettings.dmSize = sizeof(dmScreenSettings);
124 dmScreenSettings.dmPelsWidth = screenWidth;
125 dmScreenSettings.dmPelsHeight = screenHeight;
126 dmScreenSettings.dmBitsPerPel = 32;
127 dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
128
129 if ((width != (uint32_t)screenWidth) && (height != (uint32_t)screenHeight))
130 {
131 if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
132 {
133 if (MessageBox(NULL, __T("Fullscreen Mode not supported!\n Switch to window mode?"), __T("Error"), MB_YESNO | MB_ICONEXCLAMATION) == IDYES)
134 {
135 fullscreen = false;
136 }
137 else
138 {
139 return nullptr;
140 }
141 }
142 }
143
144 }
145
146 DWORD dwExStyle;
147 DWORD dwStyle;
148
149 if (fullscreen)
150 {
151 dwExStyle = WS_EX_APPWINDOW;
152 dwStyle = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
153 }
154 else
155 {
156 dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
157 dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
158 //dwExStyle = WS_EX_APPWINDOW | WS_EX_LEFT;// WS_EX_WINDOWEDGE;
159 //dwStyle = (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX);// | WS_MAXIMIZEBOX);
160 }
161
162 RECT windowRect;
163 windowRect.left = 0L;
164 windowRect.top = 0L;
165 windowRect.right = fullscreen ? (long)screenWidth : (long)width;
166 windowRect.bottom = fullscreen ? (long)screenHeight : (long)height;
167
168 AdjustWindowRectEx(&windowRect, dwStyle, FALSE, dwExStyle);
169
170 uint32_t x = (GetSystemMetrics(SM_CXSCREEN) - windowRect.right) / 2;
171 uint32_t y = (GetSystemMetrics(SM_CYSCREEN) - windowRect.bottom) / 2;
172
173 window = CreateWindowEx(dwExStyle,
174 name.c_str(),
175 __T(""),
176 dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
177 x,
178 y + 100,
179 windowRect.right - windowRect.left,
180 windowRect.bottom - windowRect.top,
181 NULL,
182 NULL,
183 hinstance,
184 NULL);
185
186 //SetWindowPos(window, 0, x, y+100, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
187
188
189 if (!window)
190 {
191 printf("Could not create window!\n");
192 fflush(stdout);
193 return nullptr;
194
195 }
196
197 ShowWindow(window, SW_SHOW);
198 SetForegroundWindow(window);
199 SetFocus(window);
200
201 return window;
202 }
std::tstring deviceName
Definition: WindowVk.h:20
HINSTANCE windowInstance
Definition: WindowVk.h:13
bool fullscreen
Definition: WindowVk.h:15

◆ setWindowTitle()

void WindowVk::setWindowTitle ( int  FPS)
inline

Definition at line 205 of file WindowVk.h.

206 {
207 overlay = false;
208
209 std::tstring device(deviceName);
210 std::tstring windowTitle;
211 windowTitle = __T("notitile - ") + device;
212#ifdef UNICODE
213 windowTitle += __T(" - ") + std::to_wstring(FPS) + __T(" fps");
214#else
215 windowTitle += __T(" - ") + std::to_string(FPS) + __T(" fps");
216#endif
217
218
219 SetWindowText(window, windowTitle.c_str());
220 }
bool overlay
Definition: WindowVk.h:16
#define device

◆ WndProc()

LRESULT WindowVk::WndProc ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
inline

PAINTSTRUCT ps; HDC hdc;

Definition at line 27 of file WindowVk.h.

28 {
31
32 switch (message)
33 {
34 /*
35 case WM_COMMAND:
36 for each (auto f in Command)
37 if (f(LOWORD(wParam), HIWORD(wParam)))
38 return 0;
39 return DefWindowProc(hWnd, message, wParam, lParam);
40 case WM_PAINT:
41 hdc = BeginPaint(hWnd, &ps);
42 for each (auto f in Paint) f(hdc);
43 EndPaint(hWnd, &ps);
44 break;
45 case WM_LBUTTONDOWN: OnMouseDown(1, wParam, lParam); break;
46 case WM_RBUTTONDOWN: OnMouseDown(2, wParam, lParam); break;
47 case WM_MBUTTONDOWN: OnMouseDown(3, wParam, lParam); break;
48 case WM_XBUTTONDOWN: OnMouseDown(3 + HIWORD(wParam), LOWORD(wParam), lParam); break;
49 case WM_LBUTTONUP: OnMouseUp(1, wParam, lParam); break;
50 case WM_RBUTTONUP: OnMouseUp(2, wParam, lParam); break;
51 case WM_MBUTTONUP: OnMouseUp(3, wParam, lParam); break;
52 case WM_XBUTTONUP: OnMouseUp(3 + HIWORD(wParam), LOWORD(wParam), lParam); break;
53 case WM_MOUSEMOVE:
54 for each (auto f in MouseMove)
55 f(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), wParam);
56 break;
57 */
58 case WM_DESTROY:
59 PostQuitMessage(0);
60 break;
61 default:
62 return DefWindowProc(hWnd, message, wParam, lParam);
63 }
64 return 0;
65 }

Member Data Documentation

◆ deviceName

std::tstring WindowVk::deviceName

Definition at line 20 of file WindowVk.h.

◆ frameCounter

uint32_t WindowVk::frameCounter = 0

Definition at line 19 of file WindowVk.h.

◆ fullscreen

bool WindowVk::fullscreen

Definition at line 15 of file WindowVk.h.

◆ height

uint32_t WindowVk::height = 256

Definition at line 18 of file WindowVk.h.

◆ overlay

bool WindowVk::overlay

Definition at line 16 of file WindowVk.h.

◆ width

uint32_t WindowVk::width = 256

Definition at line 17 of file WindowVk.h.

◆ window

HWND WindowVk::window = NULL

Definition at line 12 of file WindowVk.h.

◆ windowInstance

HINSTANCE WindowVk::windowInstance

Definition at line 13 of file WindowVk.h.


The documentation for this struct was generated from the following file: