diff --git a/internal/graphicsdriver/directx/graphics11_windows.go b/internal/graphicsdriver/directx/graphics11_windows.go index 697da3bac..fc73867f5 100644 --- a/internal/graphicsdriver/directx/graphics11_windows.go +++ b/internal/graphicsdriver/directx/graphics11_windows.go @@ -356,11 +356,12 @@ func (g *graphics11) NewImage(width, height int) (graphicsdriver.Image, error) { } func (g *graphics11) NewScreenFramebufferImage(width, height int) (graphicsdriver.Image, error) { + if g.screenImage != nil { + g.screenImage.Dispose() + g.screenImage = nil + } + if g.graphicsInfra.isSwapChainInited() { - if g.screenImage != nil { - g.screenImage.Dispose() - g.screenImage = nil - } if err := g.graphicsInfra.resizeSwapChain(width, height); err != nil { return nil, err } @@ -370,11 +371,6 @@ func (g *graphics11) NewScreenFramebufferImage(width, height int) (graphicsdrive } } - if g.screenImage != nil { - g.screenImage.Dispose() - g.screenImage = nil - } - t, err := g.graphicsInfra.getBuffer(0, &_IID_ID3D11Texture2D) if err != nil { return nil, err