From 57c8c089e966c4c75d9ae3332c3991e2fdc17c88 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 6 Nov 2018 03:18:45 +0900 Subject: [PATCH] opengl: Unexport BlendFunc --- internal/graphicscommand/command.go | 3 +-- internal/opengl/context_desktop.go | 4 ++-- internal/opengl/context_js.go | 4 ++-- internal/opengl/context_mobile.go | 4 ++-- internal/opengl/program.go | 3 ++- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/graphicscommand/command.go b/internal/graphicscommand/command.go index 1081962e0..54ccf2688 100644 --- a/internal/graphicscommand/command.go +++ b/internal/graphicscommand/command.go @@ -233,7 +233,6 @@ func (c *drawImageCommand) Exec(indexOffsetInBytes int) error { if err := c.dst.image.SetViewport(); err != nil { return err } - opengl.GetContext().BlendFunc(c.mode) if c.nindices == 0 { return nil @@ -241,7 +240,7 @@ func (c *drawImageCommand) Exec(indexOffsetInBytes int) error { proj := c.dst.image.ProjectionMatrix() dw, dh := c.dst.Size() sw, sh := c.src.Size() - opengl.UseProgram(proj, c.src.image, dw, dh, sw, sh, c.color, c.filter) + opengl.UseProgram(c.mode, proj, c.src.image, dw, dh, sw, sh, c.color, c.filter) opengl.GetContext().DrawElements(c.nindices, indexOffsetInBytes) // glFlush() might be necessary at least on MacBook Pro (a smilar problem at #419), diff --git a/internal/opengl/context_desktop.go b/internal/opengl/context_desktop.go index 9199e4f2c..db9debe01 100644 --- a/internal/opengl/context_desktop.go +++ b/internal/opengl/context_desktop.go @@ -102,7 +102,7 @@ func (c *Context) reset() error { gl.Enable(gl.BLEND) return nil }) - c.BlendFunc(graphics.CompositeModeSourceOver) + c.blendFunc(graphics.CompositeModeSourceOver) _ = mainthread.Run(func() error { f := int32(0) gl.GetIntegerv(gl.FRAMEBUFFER_BINDING, &f) @@ -112,7 +112,7 @@ func (c *Context) reset() error { return nil } -func (c *Context) BlendFunc(mode graphics.CompositeMode) { +func (c *Context) blendFunc(mode graphics.CompositeMode) { _ = mainthread.Run(func() error { if c.lastCompositeMode == mode { return nil diff --git a/internal/opengl/context_js.go b/internal/opengl/context_js.go index a891b1f6f..bda5d85d7 100644 --- a/internal/opengl/context_js.go +++ b/internal/opengl/context_js.go @@ -158,13 +158,13 @@ func (c *Context) reset() error { c.ensureGL() gl := c.gl gl.Call("enable", blend) - c.BlendFunc(graphics.CompositeModeSourceOver) + c.blendFunc(graphics.CompositeModeSourceOver) f := gl.Call("getParameter", framebufferBinding) c.screenFramebuffer = framebufferNative(f) return nil } -func (c *Context) BlendFunc(mode graphics.CompositeMode) { +func (c *Context) blendFunc(mode graphics.CompositeMode) { if c.lastCompositeMode == mode { return } diff --git a/internal/opengl/context_mobile.go b/internal/opengl/context_mobile.go index b49246f4d..4b3125ae0 100644 --- a/internal/opengl/context_mobile.go +++ b/internal/opengl/context_mobile.go @@ -111,14 +111,14 @@ func (c *Context) reset() error { c.lastViewportHeight = 0 c.lastCompositeMode = graphics.CompositeModeUnknown c.gl.Enable(mgl.BLEND) - c.BlendFunc(graphics.CompositeModeSourceOver) + c.blendFunc(graphics.CompositeModeSourceOver) f := c.gl.GetInteger(mgl.FRAMEBUFFER_BINDING) c.screenFramebuffer = framebufferNative(mgl.Framebuffer{uint32(f)}) // TODO: Need to update screenFramebufferWidth/Height? return nil } -func (c *Context) BlendFunc(mode graphics.CompositeMode) { +func (c *Context) blendFunc(mode graphics.CompositeMode) { gl := c.gl if c.lastCompositeMode == mode { return diff --git a/internal/opengl/program.go b/internal/opengl/program.go index 2713c391b..f6b0c02a1 100644 --- a/internal/opengl/program.go +++ b/internal/opengl/program.go @@ -265,7 +265,8 @@ func BufferSubData(vertices []float32, indices []uint16) { c.elementArrayBufferSubData(indices) } -func UseProgram(proj []float32, src *Image, dstW, dstH, srcW, srcH int, colorM *affine.ColorM, filter graphics.Filter) { +func UseProgram(mode graphics.CompositeMode, proj []float32, src *Image, dstW, dstH, srcW, srcH int, colorM *affine.ColorM, filter graphics.Filter) { + GetContext().blendFunc(mode) theOpenGLState.useProgram(proj, src.textureNative, dstW, dstH, srcW, srcH, colorM, filter) }