mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphics: Move theDelayedImageTasks.exec() to newImageWithZeroFramebuffer
This commit is contained in:
parent
71a508ca7b
commit
dbd6ed8139
@ -25,7 +25,6 @@ type graphicsContext struct {
|
||||
screen *Image
|
||||
defaultRenderTarget *Image
|
||||
screenScale int
|
||||
initialized bool
|
||||
}
|
||||
|
||||
func (c *graphicsContext) SetSize(screenWidth, screenHeight, screenScale int) error {
|
||||
@ -46,13 +45,6 @@ func (c *graphicsContext) SetSize(screenWidth, screenHeight, screenScale int) er
|
||||
c.defaultRenderTarget.Clear()
|
||||
c.screen = screen
|
||||
c.screenScale = screenScale
|
||||
// TODO: This code is a little hacky. Refactor this.
|
||||
if !c.initialized {
|
||||
if err := theDelayedImageTasks.exec(); err != nil {
|
||||
return err
|
||||
}
|
||||
c.initialized = true
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
12
image.go
12
image.go
@ -557,6 +557,18 @@ func NewImageFromImage(source image.Image, filter Filter) (*Image, error) {
|
||||
}
|
||||
|
||||
func newImageWithZeroFramebuffer(width, height int) (*Image, error) {
|
||||
img, err := newImageWithZeroFramebufferImpl(width, height)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// When this is called, OpenGL context should exist.
|
||||
if err := theDelayedImageTasks.exec(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return img, nil
|
||||
}
|
||||
|
||||
func newImageWithZeroFramebufferImpl(width, height int) (*Image, error) {
|
||||
imageM.Lock()
|
||||
defer imageM.Unlock()
|
||||
f, err := graphics.NewZeroFramebuffer(ui.GLContext(), width, height)
|
||||
|
Loading…
Reference in New Issue
Block a user