mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
graphics: Move command flushing to ebiten package
This commit is contained in:
parent
dfd4bc89ed
commit
b59206b777
@ -84,6 +84,19 @@ func (c *graphicsContext) Update() error {
|
|||||||
if err := c.defaultRenderTarget.DrawImage(c.screen, options); err != nil {
|
if err := c.defaultRenderTarget.DrawImage(c.screen, options); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := c.flush(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *graphicsContext) flush() error {
|
||||||
|
// TODO: imageM is necessary to call graphics functions. Move this to graphics package.
|
||||||
|
imageM.Lock()
|
||||||
|
defer imageM.Unlock()
|
||||||
|
if err := graphics.FlushCommands(ui.GLContext()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
// Call glFlush to prevent black flicking (especially on Android (#226)).
|
// Call glFlush to prevent black flicking (especially on Android (#226)).
|
||||||
ui.GLContext().Flush()
|
ui.GLContext().Flush()
|
||||||
return nil
|
return nil
|
||||||
|
2
image.go
2
image.go
@ -261,7 +261,7 @@ func (i *imageImpl) DrawImage(image *Image, options *DrawImageOptions) error {
|
|||||||
geom := &options.GeoM
|
geom := &options.GeoM
|
||||||
colorm := &options.ColorM
|
colorm := &options.ColorM
|
||||||
mode := opengl.CompositeMode(options.CompositeMode)
|
mode := opengl.CompositeMode(options.CompositeMode)
|
||||||
if err := i.framebuffer.DrawTexture(ui.GLContext(), image.impl.texture, vertices[:16*n], geom, colorm, mode); err != nil {
|
if err := i.framebuffer.DrawTexture(image.impl.texture, vertices[:16*n], geom, colorm, mode); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -105,7 +105,7 @@ func (f *Framebuffer) Fill(clr color.Color) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Framebuffer) DrawTexture(context *opengl.Context, t *Texture, vertices []int16, geo, clr Matrix, mode opengl.CompositeMode) error {
|
func (f *Framebuffer) DrawTexture(t *Texture, vertices []int16, geo, clr Matrix, mode opengl.CompositeMode) error {
|
||||||
c := &drawImageCommand{
|
c := &drawImageCommand{
|
||||||
dst: f,
|
dst: f,
|
||||||
src: t,
|
src: t,
|
||||||
@ -115,12 +115,6 @@ func (f *Framebuffer) DrawTexture(context *opengl.Context, t *Texture, vertices
|
|||||||
mode: mode,
|
mode: mode,
|
||||||
}
|
}
|
||||||
theCommandQueue.Enqueue(c)
|
theCommandQueue.Enqueue(c)
|
||||||
// TODO: Can we move this to graphicscontext.go (again)?
|
|
||||||
if f.native == opengl.ZeroFramebuffer {
|
|
||||||
if err := FlushCommands(context); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user