mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphics: Move all context usages to internal/graphics
This commit is contained in:
parent
6e76c3ed6b
commit
f7a84fe969
@ -128,14 +128,10 @@ func (c *graphicsContext) drawToDefaultRenderTarget(context *opengl.Context) err
|
||||
if err := graphics.FlushCommands(context); err != nil {
|
||||
return err
|
||||
}
|
||||
// Call glFlush to prevent black flicking (especially on Android (#226) and iOS).
|
||||
context.Flush()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *graphicsContext) UpdateAndDraw(context *opengl.Context, updateCount int) error {
|
||||
// glViewport must be called at every frame on iOS
|
||||
context.ResetViewportSize()
|
||||
if err := c.initializeIfNeeded(context); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -43,6 +43,8 @@ func (q *commandQueue) Enqueue(command command) {
|
||||
}
|
||||
|
||||
func (q *commandQueue) Flush(context *opengl.Context) error {
|
||||
// glViewport must be called at least at every frame on iOS.
|
||||
context.ResetViewportSize()
|
||||
q.indexOffsetInBytes = 0
|
||||
vertices := []int16{}
|
||||
for _, c := range q.commands {
|
||||
@ -59,12 +61,17 @@ func (q *commandQueue) Flush(context *opengl.Context) error {
|
||||
if MaxQuads < len(vertices)/16 {
|
||||
return errors.New(fmt.Sprintf("len(quads) must be equal to or less than %d", MaxQuads))
|
||||
}
|
||||
numc := len(q.commands)
|
||||
for _, c := range q.commands {
|
||||
if err := c.Exec(context); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
q.commands = []command{}
|
||||
if 0 < numc {
|
||||
// Call glFlush to prevent black flicking (especially on Android (#226) and iOS).
|
||||
context.Flush()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user