mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
internal/graphicsdriver/directx: refactoring
This commit is contained in:
parent
4473557e23
commit
a56924b22f
@ -385,19 +385,17 @@ func (g *graphics11) NewImage(width, height int) (graphicsdriver.Image, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *graphics11) NewScreenFramebufferImage(width, height int) (graphicsdriver.Image, error) {
|
func (g *graphics11) NewScreenFramebufferImage(width, height int) (graphicsdriver.Image, error) {
|
||||||
var origWidth, origHeight int
|
imageWidth := width
|
||||||
|
imageHeight := height
|
||||||
if g.screenImage != nil {
|
if g.screenImage != nil {
|
||||||
origWidth, origHeight = g.screenImage.width, g.screenImage.height
|
imageWidth = g.screenImage.width
|
||||||
|
imageHeight = g.screenImage.height
|
||||||
g.screenImage.Dispose()
|
g.screenImage.Dispose()
|
||||||
g.screenImage = nil
|
g.screenImage = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if g.graphicsInfra.isSwapChainInited() {
|
if g.graphicsInfra.isSwapChainInited() {
|
||||||
// For a new image11 instance, use the original image size now.
|
g.newScreenWidth, g.newScreenHeight = width, height
|
||||||
// Use the new image size when a swap chain is actually resized.
|
|
||||||
newWidth, newHeight := width, height
|
|
||||||
width, height = origWidth, origHeight
|
|
||||||
g.newScreenWidth, g.newScreenHeight = newWidth, newHeight
|
|
||||||
} else {
|
} else {
|
||||||
if err := g.graphicsInfra.initSwapChain(width, height, unsafe.Pointer(g.device), g.window); err != nil {
|
if err := g.graphicsInfra.initSwapChain(width, height, unsafe.Pointer(g.device), g.window); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -412,8 +410,8 @@ func (g *graphics11) NewScreenFramebufferImage(width, height int) (graphicsdrive
|
|||||||
i := &image11{
|
i := &image11{
|
||||||
graphics: g,
|
graphics: g,
|
||||||
id: g.genNextImageID(),
|
id: g.genNextImageID(),
|
||||||
width: width,
|
width: imageWidth,
|
||||||
height: height,
|
height: imageHeight,
|
||||||
screen: true,
|
screen: true,
|
||||||
texture: (*_ID3D11Texture2D)(t),
|
texture: (*_ID3D11Texture2D)(t),
|
||||||
}
|
}
|
||||||
|
@ -990,14 +990,13 @@ func (g *graphics12) NewImage(width, height int) (graphicsdriver.Image, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *graphics12) NewScreenFramebufferImage(width, height int) (graphicsdriver.Image, error) {
|
func (g *graphics12) NewScreenFramebufferImage(width, height int) (graphicsdriver.Image, error) {
|
||||||
var imageWidth, imageHeight int
|
imageWidth := width
|
||||||
|
imageHeight := height
|
||||||
if g.screenImage != nil {
|
if g.screenImage != nil {
|
||||||
imageWidth, imageHeight = g.screenImage.width, g.screenImage.height
|
imageWidth = g.screenImage.width
|
||||||
|
imageHeight = g.screenImage.height
|
||||||
g.screenImage.Dispose()
|
g.screenImage.Dispose()
|
||||||
g.screenImage = nil
|
g.screenImage = nil
|
||||||
} else {
|
|
||||||
imageWidth = width
|
|
||||||
imageHeight = height
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := g.updateSwapChain(width, height); err != nil {
|
if err := g.updateSwapChain(width, height); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user