mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-10-07 17:01:03 +08:00
internal/graphicsdriver: let some functions return an error
This is a preparation for the DirectX driver. Updates #1007
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
package opengl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/graphics"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
||||
)
|
||||
@@ -118,12 +120,12 @@ func (i *Image) ensureStencilBuffer() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *Image) ReplacePixels(args []*graphicsdriver.ReplacePixelsArgs) {
|
||||
func (i *Image) ReplacePixels(args []*graphicsdriver.ReplacePixelsArgs) error {
|
||||
if i.screen {
|
||||
panic("opengl: ReplacePixels cannot be called on the screen, that doesn't have a texture")
|
||||
return errors.New("opengl: ReplacePixels cannot be called on the screen")
|
||||
}
|
||||
if len(args) == 0 {
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
// glFlush is necessary on Android.
|
||||
@@ -133,4 +135,5 @@ func (i *Image) ReplacePixels(args []*graphicsdriver.ReplacePixelsArgs) {
|
||||
}
|
||||
i.graphics.drawCalled = false
|
||||
i.graphics.context.texSubImage2D(i.texture, args)
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user