diff --git a/internal/graphicsdriver/directx/api_windows.go b/internal/graphicsdriver/directx/api_windows.go index 4da328d96..adb114b01 100644 --- a/internal/graphicsdriver/directx/api_windows.go +++ b/internal/graphicsdriver/directx/api_windows.go @@ -542,6 +542,9 @@ const ( _DXGI_CREATE_FACTORY_DEBUG = 0x01 _DXGI_ERROR_NOT_FOUND = windows.Errno(0x887A0002) + + _DXGI_MWA_NO_ALT_ENTER = 0x2 + _DXGI_MWA_NO_WINDOW_CHANGES = 0x1 ) var ( @@ -1953,6 +1956,14 @@ func (i *_IDXGIFactory4) EnumWarpAdapter() (*_IDXGIAdapter1, error) { return ptr, nil } +func (i *_IDXGIFactory4) MakeWindowAssociation(windowHandle windows.HWND, flags uint32) error { + r, _, _ := syscall.Syscall(i.vtbl.MakeWindowAssociation, 3, uintptr(unsafe.Pointer(i)), uintptr(windowHandle), uintptr(flags)) + if uint32(r) != uint32(windows.S_OK) { + return fmt.Errorf("directx: IDXGIFactory4::MakeWIndowAssociation failed: HRESULT(%d)", uint32(r)) + } + return nil +} + func (i *_IDXGIFactory4) Release() { syscall.Syscall(i.vtbl.Release, 1, uintptr(unsafe.Pointer(i)), 0, 0) } diff --git a/internal/graphicsdriver/directx/graphics_windows.go b/internal/graphicsdriver/directx/graphics_windows.go index 554c8529a..5af86e8c8 100644 --- a/internal/graphicsdriver/directx/graphics_windows.go +++ b/internal/graphicsdriver/directx/graphics_windows.go @@ -504,7 +504,12 @@ func (g *Graphics) initSwapChain(width, height int) (ferr error) { } }() - // TODO: Call factory.MakeWindowAssociation not to support fullscreen transitions? + // MakeWindowAssociation should be called after swap chain creation. + // https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgifactory-makewindowassociation + if err := g.factory.MakeWindowAssociation(g.window, _DXGI_MWA_NO_WINDOW_CHANGES | _DXGI_MWA_NO_ALT_ENTER); err != nil { + return err + } + // TODO: Get the current buffer index? if err := g.createRenderTargetViews(); err != nil {