feat(d3d): add hardware cursor support

This commit is contained in:
VDm 2025-03-29 18:04:21 +04:00
parent c4a516c44d
commit d80e2b4b4f
2 changed files with 17 additions and 4 deletions

View File

@ -334,7 +334,7 @@ LRESULT CGxDeviceD3d::WindowProcD3d(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
case WM_SETCURSOR: {
if (device) {
if (device->m_d3dDevice && lParam == 1) {
if (device->m_d3dDevice && LOWORD(lParam) == HTCLIENT) {
SetCursor(nullptr);
BOOL show = device->m_cursorVisible && device->m_hardwareCursor ? TRUE : FALSE;
device->m_d3dDevice->ShowCursor(show);
@ -474,7 +474,7 @@ int32_t CGxDeviceD3d::DeviceSetFormat(const CGxFormat& format) {
ShowWindow(this->m_hwnd, 0);
}
// TODO
this->IDestroyD3dDevice();
if (this->m_hwnd) {
DestroyWindow(this->m_hwnd);
@ -488,8 +488,7 @@ int32_t CGxDeviceD3d::DeviceSetFormat(const CGxFormat& format) {
if (this->ICreateWindow(createFormat) && this->ICreateD3dDevice(createFormat) && this->CGxDevice::DeviceSetFormat(format)) {
this->intF64 = 1;
// TODO
this->m_hwCursorNeedsUpdate = 1;
if (this->m_format.window == 0) {
RECT windowRect;
@ -498,6 +497,14 @@ int32_t CGxDeviceD3d::DeviceSetFormat(const CGxFormat& format) {
}
return 1;
} else {
CGxDevice::Log("CGxDeviceD3d::DeviceSetFormat(): unable to set format!");
this->IDestroyD3dDevice();
if (this->m_hwnd) {
DestroyWindow(this->m_hwnd);
}
this->m_hwnd = nullptr;
return 0;
}
}
@ -1249,6 +1256,11 @@ void CGxDeviceD3d::CursorSetVisible(int32_t visible) {
}
}
void CGxDeviceD3d::CursorUnlock(uint32_t x, uint32_t y) {
CGxDevice::CursorUnlock(x, y);
this->m_hwCursorNeedsUpdate = 1;
}
void CGxDeviceD3d::ICursorDraw() {
if (!this->m_hardwareCursor) {
this->ISceneBegin();

View File

@ -252,6 +252,7 @@ class CGxDeviceD3d : public CGxDevice {
virtual void ICursorDestroy();
virtual void ICursorDraw();
virtual void CursorSetVisible(int32_t visible);
virtual void CursorUnlock(uint32_t x, uint32_t y);
virtual int32_t DeviceCreate(int32_t (*windowProc)(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam), const CGxFormat& format);
virtual int32_t DeviceSetFormat(const CGxFormat& format);
virtual void* DeviceWindow();