mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
internal/graphicsdriver/directx: bug fix: disable fullscreen by Alt+Enter
By default, DirectX 12 tries to make the window fullscreen by Alt+Enter. This caused application crashes. Let's disable this feature. Closes #2123
This commit is contained in:
parent
51fe48fb76
commit
0256b0cfbf
@ -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)
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user