From ae04bb17f602f88e0c4543067e5b20e4877d9435 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 3 Jan 2015 01:14:36 +0900 Subject: [PATCH] Reduce calling glFlush --- internal/graphics/internal/shader/drawtexture.go | 2 -- internal/opengl/context.go | 1 + internal/opengl/context_js.go | 1 + internal/ui/ui_js.go | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/graphics/internal/shader/drawtexture.go b/internal/graphics/internal/shader/drawtexture.go index 8767cd8f7..dc358e121 100644 --- a/internal/graphics/internal/shader/drawtexture.go +++ b/internal/graphics/internal/shader/drawtexture.go @@ -86,7 +86,5 @@ func DrawTexture(c *opengl.Context, texture opengl.Texture, projectionMatrix [4] } c.BufferSubData(c.ArrayBuffer, vertices) c.DrawElements(6 * quads.Len()) - - c.Flush() return nil } diff --git a/internal/opengl/context.go b/internal/opengl/context.go index 3dfa2d8db..77b6883b6 100644 --- a/internal/opengl/context.go +++ b/internal/opengl/context.go @@ -68,6 +68,7 @@ func (c *Context) NewTexture(width, height int, pixels []uint8, filter FilterTyp } func (c *Context) TexturePixels(t Texture, width, height int) ([]uint8, error) { + gl.Flush() // TODO: Use glGetTexLevelParameteri and GL_TEXTURE_WIDTH? pixels := make([]uint8, 4*width*height) gl.Texture(t).Bind(gl.TEXTURE_2D) diff --git a/internal/opengl/context_js.go b/internal/opengl/context_js.go index 9a71e33a5..d84dbe6bf 100644 --- a/internal/opengl/context_js.go +++ b/internal/opengl/context_js.go @@ -84,6 +84,7 @@ func (c *Context) NewTexture(width, height int, pixels []uint8, filter FilterTyp func (c *Context) TexturePixels(t Texture, width, height int) ([]uint8, error) { gl := c.gl + gl.Flush() // TODO: Use glGetTexLevelParameteri and GL_TEXTURE_WIDTH? pixels := js.Global.Get("Uint8Array").New(4 * width * height) gl.BindTexture(gl.TEXTURE_2D, t) diff --git a/internal/ui/ui_js.go b/internal/ui/ui_js.go index ad64f4b33..512a91a03 100644 --- a/internal/ui/ui_js.go +++ b/internal/ui/ui_js.go @@ -31,7 +31,7 @@ func Use(f func(*opengl.Context)) { } func DoEvents() { - time.Sleep(1) + time.Sleep(0) } func Terminate() {