mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +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 {
|
if err := graphics.FlushCommands(context); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Call glFlush to prevent black flicking (especially on Android (#226) and iOS).
|
|
||||||
context.Flush()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *graphicsContext) UpdateAndDraw(context *opengl.Context, updateCount int) error {
|
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 {
|
if err := c.initializeIfNeeded(context); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,8 @@ func (q *commandQueue) Enqueue(command command) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (q *commandQueue) Flush(context *opengl.Context) error {
|
func (q *commandQueue) Flush(context *opengl.Context) error {
|
||||||
|
// glViewport must be called at least at every frame on iOS.
|
||||||
|
context.ResetViewportSize()
|
||||||
q.indexOffsetInBytes = 0
|
q.indexOffsetInBytes = 0
|
||||||
vertices := []int16{}
|
vertices := []int16{}
|
||||||
for _, c := range q.commands {
|
for _, c := range q.commands {
|
||||||
@ -59,12 +61,17 @@ func (q *commandQueue) Flush(context *opengl.Context) error {
|
|||||||
if MaxQuads < len(vertices)/16 {
|
if MaxQuads < len(vertices)/16 {
|
||||||
return errors.New(fmt.Sprintf("len(quads) must be equal to or less than %d", MaxQuads))
|
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 {
|
for _, c := range q.commands {
|
||||||
if err := c.Exec(context); err != nil {
|
if err := c.Exec(context); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
q.commands = []command{}
|
q.commands = []command{}
|
||||||
|
if 0 < numc {
|
||||||
|
// Call glFlush to prevent black flicking (especially on Android (#226) and iOS).
|
||||||
|
context.Flush()
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user