feat(gx): handle window messages in d3d backend

This commit is contained in:
fallenoak 2023-03-06 08:44:13 -06:00 committed by GitHub
parent 49237bf68d
commit c34ea0f30d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 109 additions and 0 deletions

View file

@ -72,6 +72,100 @@ void CGxDeviceD3d::IUnloadD3dLib(HINSTANCE& d3dLib, LPDIRECT3D9& d3d) {
}
LRESULT CGxDeviceD3d::WindowProcD3d(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
auto device = reinterpret_cast<CGxDeviceD3d*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
switch (uMsg) {
case WM_CREATE: {
auto lpcs = reinterpret_cast<LPCREATESTRUCT>(lParam);
SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LPARAM>(lpcs->lpCreateParams));
return 0;
}
case WM_DESTROY: {
device->DeviceWM(GxWM_Destroy, 0, 0);
return 0;
}
case WM_SIZE: {
CRect windowRect = {
0.0f,
0.0f,
static_cast<float>(HIWORD(lParam)),
static_cast<float>(LOWORD(lParam))
};
int32_t resizeType = 0;
if (wParam == SIZE_MINIMIZED) {
resizeType = 1;
} else if (wParam == SIZE_MAXHIDE) {
resizeType = 2;
}
device->DeviceWM(GxWM_Size, reinterpret_cast<uintptr_t>(&windowRect), resizeType);
break;
}
case WM_ACTIVATE: {
// TODO
break;
}
case WM_SETFOCUS: {
device->DeviceWM(GxWM_SetFocus, 0, 0);
return 0;
}
case WM_KILLFOCUS: {
device->DeviceWM(GxWM_KillFocus, 0, 0);
return 0;
}
case WM_PAINT: {
PAINTSTRUCT paint;
BeginPaint(hWnd, &paint);
EndPaint(hWnd, &paint);
return 0;
}
case WM_ERASEBKGND: {
return 0;
}
case WM_SETCURSOR: {
// TODO
return 1;
}
case WM_DISPLAYCHANGE: {
// TODO
break;
}
case WM_SYSCOMMAND: {
// TODO
break;
}
case WM_SIZING: {
// TODO
break;
}
default:
break;
}
// TODO
return DefWindowProc(hWnd, uMsg, wParam, lParam);
@ -143,6 +237,10 @@ int32_t CGxDeviceD3d::DeviceSetFormat(const CGxFormat& format) {
}
}
void CGxDeviceD3d::DeviceWM(EGxWM wm, uintptr_t param1, uintptr_t param2) {
// TODO
}
int32_t CGxDeviceD3d::ICreateD3d() {
if (CGxDeviceD3d::ILoadD3dLib(this->m_d3dLib, this->m_d3d) && this->m_d3d->GetDeviceCaps(0, D3DDEVTYPE_HAL, &this->m_d3dCaps) >= S_OK) {
if (this->m_desktopDisplayMode.Format != D3DFMT_UNKNOWN) {