Skip to content

Commit

Permalink
regenerated xmobile backend
Browse files Browse the repository at this point in the history
  • Loading branch information
tfriedel6 committed Jun 2, 2020
1 parent 6586c5c commit 631290f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions backend/xmobilebackend/clip.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func (b *XMobileBackend) Clip(pts []backendbase.Vec) {
b.glctx.BindBuffer(gl.ARRAY_BUFFER, b.buf)
b.glctx.BufferData(gl.ARRAY_BUFFER, byteSlice(unsafe.Pointer(&b.ptsBuf[0]), len(b.ptsBuf)*4), gl.STREAM_DRAW)
b.glctx.VertexAttribPointer(b.shd.Vertex, 2, gl.FLOAT, false, 0, 0)
b.glctx.VertexAttribPointer(b.shd.TexCoord, 2, gl.FLOAT, false, 0, 0)

b.glctx.UseProgram(b.shd.ID)
b.glctx.Uniform4f(b.shd.Color, 1, 1, 1, 1)
Expand All @@ -44,6 +45,7 @@ func (b *XMobileBackend) Clip(pts []backendbase.Vec) {
b.glctx.Uniform1i(b.shd.UseAlphaTex, 0)
b.glctx.Uniform1i(b.shd.Func, shdFuncSolid)
b.glctx.EnableVertexAttribArray(b.shd.Vertex)
b.glctx.EnableVertexAttribArray(b.shd.TexCoord)

b.glctx.ColorMask(false, false, false, false)

Expand All @@ -66,6 +68,7 @@ func (b *XMobileBackend) Clip(pts []backendbase.Vec) {
b.glctx.DrawArrays(gl.TRIANGLE_FAN, 0, 4)

b.glctx.DisableVertexAttribArray(b.shd.Vertex)
b.glctx.DisableVertexAttribArray(b.shd.TexCoord)

b.glctx.ColorMask(true, true, true, true)
b.glctx.StencilOp(gl.KEEP, gl.KEEP, gl.KEEP)
Expand Down
14 changes: 13 additions & 1 deletion backend/xmobilebackend/fill.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ func (b *XMobileBackend) Clear(pts [4]backendbase.Vec) {
b.glctx.StencilFunc(gl.EQUAL, 0, 0xFF)

b.glctx.VertexAttribPointer(b.shd.Vertex, 2, gl.FLOAT, false, 0, 0)
b.glctx.VertexAttribPointer(b.shd.TexCoord, 2, gl.FLOAT, false, 0, 0)
b.glctx.EnableVertexAttribArray(b.shd.Vertex)
b.glctx.EnableVertexAttribArray(b.shd.TexCoord)
b.glctx.DrawArrays(gl.TRIANGLE_FAN, 0, 4)
b.glctx.DisableVertexAttribArray(b.shd.Vertex)
b.glctx.DisableVertexAttribArray(b.shd.TexCoord)

b.glctx.StencilFunc(gl.ALWAYS, 0, 0xFF)

Expand Down Expand Up @@ -120,9 +123,12 @@ func (b *XMobileBackend) Fill(style *backendbase.FillStyle, pts []backendbase.Ve

b.glctx.StencilFunc(gl.EQUAL, 0, 0xFF)
b.glctx.EnableVertexAttribArray(vertex)
b.glctx.EnableVertexAttribArray(b.shd.TexCoord)
b.glctx.VertexAttribPointer(vertex, 2, gl.FLOAT, false, 0, 0)
b.glctx.VertexAttribPointer(b.shd.TexCoord, 2, gl.FLOAT, false, 0, 0)
b.glctx.DrawArrays(mode, 4, len(pts))
b.glctx.DisableVertexAttribArray(vertex)
b.glctx.DisableVertexAttribArray(b.shd.TexCoord)
b.glctx.StencilFunc(gl.ALWAYS, 0, 0xFF)
} else {
b.glctx.ColorMask(false, false, false, false)
Expand All @@ -140,20 +146,26 @@ func (b *XMobileBackend) Fill(style *backendbase.FillStyle, pts []backendbase.Ve
b.glctx.Uniform1i(b.shd.Func, shdFuncSolid)

b.glctx.EnableVertexAttribArray(b.shd.Vertex)
b.glctx.EnableVertexAttribArray(b.shd.TexCoord)
b.glctx.VertexAttribPointer(b.shd.Vertex, 2, gl.FLOAT, false, 0, 0)
b.glctx.VertexAttribPointer(b.shd.TexCoord, 2, gl.FLOAT, false, 0, 0)
b.glctx.DrawArrays(mode, 4, len(pts))
b.glctx.DisableVertexAttribArray(b.shd.Vertex)
b.glctx.DisableVertexAttribArray(b.shd.TexCoord)

b.glctx.ColorMask(true, true, true, true)

b.glctx.StencilFunc(gl.EQUAL, 1, 0xFF)

vertex, _ := b.useShader(style, mat3identity, false, 0)
b.glctx.EnableVertexAttribArray(vertex)
b.glctx.EnableVertexAttribArray(b.shd.TexCoord)
b.glctx.VertexAttribPointer(vertex, 2, gl.FLOAT, false, 0, 0)
b.glctx.VertexAttribPointer(b.shd.TexCoord, 2, gl.FLOAT, false, 0, 0)

b.glctx.DrawArrays(gl.TRIANGLE_FAN, 0, 4)
b.glctx.DisableVertexAttribArray(vertex)
b.glctx.DisableVertexAttribArray(b.shd.TexCoord)

b.glctx.StencilOp(gl.KEEP, gl.KEEP, gl.KEEP)
b.glctx.StencilFunc(gl.ALWAYS, 0, 0xFF)
Expand Down Expand Up @@ -203,7 +215,7 @@ func (b *XMobileBackend) FillImageMask(style *backendbase.FillStyle, mask *image
var buf [16]float32
data := buf[:0]
for _, pt := range pts {
data = append(data, float32(pt[0]), float32(pt[1]))
data = append(data, float32(math.Round(pt[0])), float32(math.Round(pt[1])))
}
data = append(data, 0, 0, 0, float32(th), float32(tw), float32(th), float32(tw), 0)

Expand Down

0 comments on commit 631290f

Please sign in to comment.