mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +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)
|
SetVertices(vertices []float32, indices []uint16)
|
||||||
NewImage(width, height int) (Image, error)
|
NewImage(width, height int) (Image, error)
|
||||||
NewScreenFramebufferImage(width, height int) (Image, error)
|
NewScreenFramebufferImage(width, height int) (Image, error)
|
||||||
|
Initialize() error
|
||||||
Reset() error
|
Reset() error
|
||||||
SetVsyncEnabled(enabled bool)
|
SetVsyncEnabled(enabled bool)
|
||||||
FramebufferYDirection() YDirection
|
FramebufferYDirection() YDirection
|
||||||
|
@ -654,7 +654,14 @@ func (c *newShaderCommand) Exec(indexOffset int) error {
|
|||||||
return err
|
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 {
|
func ResetGraphicsDriverState() error {
|
||||||
return runOnMainThread(func() error {
|
return runOnMainThread(func() error {
|
||||||
return theGraphicsDriver.Reset()
|
return theGraphicsDriver.Reset()
|
||||||
|
@ -565,12 +565,7 @@ func operationToBlendFactor(c driver.Operation) mtl.BlendFactor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Graphics) Reset() error {
|
func (g *Graphics) Initialize() error {
|
||||||
if g.cq != (mtl.CommandQueue{}) {
|
|
||||||
g.cq.Release()
|
|
||||||
g.cq = mtl.CommandQueue{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Creating *State objects are expensive and reuse them whenever possible.
|
// 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
|
// 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *Graphics) Reset() error {
|
||||||
|
panic("metal: Reset is not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
func (g *Graphics) flushRenderCommandEncoderIfNeeded() {
|
func (g *Graphics) flushRenderCommandEncoderIfNeeded() {
|
||||||
if g.rce == (mtl.RenderCommandEncoder{}) {
|
if g.rce == (mtl.RenderCommandEncoder{}) {
|
||||||
return
|
return
|
||||||
|
@ -129,6 +129,10 @@ func (g *Graphics) removeImage(img *Image) {
|
|||||||
delete(g.images, img.id)
|
delete(g.images, img.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *Graphics) Initialize() error {
|
||||||
|
return g.state.reset(&g.context)
|
||||||
|
}
|
||||||
|
|
||||||
// Reset resets or initializes the current OpenGL state.
|
// Reset resets or initializes the current OpenGL state.
|
||||||
func (g *Graphics) Reset() error {
|
func (g *Graphics) Reset() error {
|
||||||
return g.state.reset(&g.context)
|
return g.state.reset(&g.context)
|
||||||
|
@ -272,7 +272,7 @@ func (i *images) restore() error {
|
|||||||
|
|
||||||
// InitializeGraphicsDriverState initializes the graphics driver state.
|
// InitializeGraphicsDriverState initializes the graphics driver state.
|
||||||
func InitializeGraphicsDriverState() error {
|
func InitializeGraphicsDriverState() error {
|
||||||
return graphicscommand.ResetGraphicsDriverState()
|
return graphicscommand.InitializeGraphicsDriverState()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaxImageSize returns the maximum size of an image.
|
// MaxImageSize returns the maximum size of an image.
|
||||||
|
Loading…
Reference in New Issue
Block a user