mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +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) {
|
||||
var origWidth, origHeight int
|
||||
imageWidth := width
|
||||
imageHeight := height
|
||||
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 = nil
|
||||
}
|
||||
|
||||
if g.graphicsInfra.isSwapChainInited() {
|
||||
// For a new image11 instance, use the original image size now.
|
||||
// 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
|
||||
g.newScreenWidth, g.newScreenHeight = width, height
|
||||
} else {
|
||||
if err := g.graphicsInfra.initSwapChain(width, height, unsafe.Pointer(g.device), g.window); err != nil {
|
||||
return nil, err
|
||||
@ -412,8 +410,8 @@ func (g *graphics11) NewScreenFramebufferImage(width, height int) (graphicsdrive
|
||||
i := &image11{
|
||||
graphics: g,
|
||||
id: g.genNextImageID(),
|
||||
width: width,
|
||||
height: height,
|
||||
width: imageWidth,
|
||||
height: imageHeight,
|
||||
screen: true,
|
||||
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) {
|
||||
var imageWidth, imageHeight int
|
||||
imageWidth := width
|
||||
imageHeight := height
|
||||
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 = nil
|
||||
} else {
|
||||
imageWidth = width
|
||||
imageHeight = height
|
||||
}
|
||||
|
||||
if err := g.updateSwapChain(width, height); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user