graphicsdriver/opengl: Refactoring

This commit is contained in:
Hajime Hoshi 2020-05-17 19:01:46 +09:00
parent 9cc128fb40
commit 8ab12827c0
2 changed files with 5 additions and 4 deletions

View File

@ -114,7 +114,10 @@ func (g *Graphics) SetVertices(vertices []float32, indices []uint16) {
func (g *Graphics) Draw(indexLen int, indexOffset int, mode driver.CompositeMode, colorM *affine.ColorM, filter driver.Filter, address driver.Address) error { func (g *Graphics) Draw(indexLen int, indexOffset int, mode driver.CompositeMode, colorM *affine.ColorM, filter driver.Filter, address driver.Address) error {
g.drawCalled = true g.drawCalled = true
if err := g.useProgram(mode, colorM, filter, address); err != nil {
g.context.blendFunc(mode)
if err := g.useProgram(colorM, filter, address); err != nil {
return err return err
} }
g.context.drawElements(indexLen, indexOffset*2) // 2 is uint16 size in bytes g.context.drawElements(indexLen, indexOffset*2) // 2 is uint16 size in bytes

View File

@ -241,7 +241,7 @@ func areSameFloat32Array(a, b []float32) bool {
} }
// useProgram uses the program (programTexture). // useProgram uses the program (programTexture).
func (g *Graphics) useProgram(mode driver.CompositeMode, colorM *affine.ColorM, filter driver.Filter, address driver.Address) error { func (g *Graphics) useProgram(colorM *affine.ColorM, filter driver.Filter, address driver.Address) error {
destination := g.state.destination destination := g.state.destination
if destination == nil { if destination == nil {
panic("destination image is not set") panic("destination image is not set")
@ -257,8 +257,6 @@ func (g *Graphics) useProgram(mode driver.CompositeMode, colorM *affine.ColorM,
dstW := destination.width dstW := destination.width
srcW, srcH := source.width, source.height srcW, srcH := source.width, source.height
g.context.blendFunc(mode)
program := g.state.programs[programKey{ program := g.state.programs[programKey{
useColorM: colorM != nil, useColorM: colorM != nil,
filter: filter, filter: filter,