mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/driver: Add Graphics.Initialize
This commit is contained in:
parent
519363930a
commit
6213c17abc
@ -41,6 +41,7 @@ type Graphics interface {
|
||||
SetVertices(vertices []float32, indices []uint16)
|
||||
NewImage(width, height int) (Image, error)
|
||||
NewScreenFramebufferImage(width, height int) (Image, error)
|
||||
Initialize() error
|
||||
Reset() error
|
||||
SetVsyncEnabled(enabled bool)
|
||||
FramebufferYDirection() YDirection
|
||||
|
@ -654,7 +654,14 @@ func (c *newShaderCommand) Exec(indexOffset int) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// ResetGraphicsDriverState resets or initializes the current graphics driver state.
|
||||
// InitializeGraphicsDriverState initialize the current graphics driver state.
|
||||
func InitializeGraphicsDriverState() error {
|
||||
return runOnMainThread(func() error {
|
||||
return theGraphicsDriver.Initialize()
|
||||
})
|
||||
}
|
||||
|
||||
// ResetGraphicsDriverState resets the current graphics driver state.
|
||||
func ResetGraphicsDriverState() error {
|
||||
return runOnMainThread(func() error {
|
||||
return theGraphicsDriver.Reset()
|
||||
|
@ -565,12 +565,7 @@ func operationToBlendFactor(c driver.Operation) mtl.BlendFactor {
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Graphics) Reset() error {
|
||||
if g.cq != (mtl.CommandQueue{}) {
|
||||
g.cq.Release()
|
||||
g.cq = mtl.CommandQueue{}
|
||||
}
|
||||
|
||||
func (g *Graphics) Initialize() error {
|
||||
// Creating *State objects are expensive and reuse them whenever possible.
|
||||
// See https://developer.apple.com/library/archive/documentation/Miscellaneous/Conceptual/MetalProgrammingGuide/Cmd-Submiss/Cmd-Submiss.html
|
||||
|
||||
@ -753,6 +748,10 @@ func (g *Graphics) Reset() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *Graphics) Reset() error {
|
||||
panic("metal: Reset is not implemented")
|
||||
}
|
||||
|
||||
func (g *Graphics) flushRenderCommandEncoderIfNeeded() {
|
||||
if g.rce == (mtl.RenderCommandEncoder{}) {
|
||||
return
|
||||
|
@ -129,6 +129,10 @@ func (g *Graphics) removeImage(img *Image) {
|
||||
delete(g.images, img.id)
|
||||
}
|
||||
|
||||
func (g *Graphics) Initialize() error {
|
||||
return g.state.reset(&g.context)
|
||||
}
|
||||
|
||||
// Reset resets or initializes the current OpenGL state.
|
||||
func (g *Graphics) Reset() error {
|
||||
return g.state.reset(&g.context)
|
||||
|
@ -272,7 +272,7 @@ func (i *images) restore() error {
|
||||
|
||||
// InitializeGraphicsDriverState initializes the graphics driver state.
|
||||
func InitializeGraphicsDriverState() error {
|
||||
return graphicscommand.ResetGraphicsDriverState()
|
||||
return graphicscommand.InitializeGraphicsDriverState()
|
||||
}
|
||||
|
||||
// MaxImageSize returns the maximum size of an image.
|
||||
|
Loading…
Reference in New Issue
Block a user