internal/graphicsdriver: bug fix: render semi-transparent vectors correctly

Closes #1933
This commit is contained in:
Hajime Hoshi 2022-01-06 03:00:23 +09:00
parent 1f17a63084
commit 202f642395
5 changed files with 8 additions and 7 deletions

View File

@ -43,7 +43,7 @@ const (
screenHeight = 480
)
func drawEbitenText(screen *ebiten.Image) {
func drawEbitenText(screen *ebiten.Image, counter int) {
var path vector.Path
// E
@ -119,6 +119,7 @@ func drawEbitenText(screen *ebiten.Image) {
vs[i].ColorR = 0xdb / float32(0xff)
vs[i].ColorG = 0x56 / float32(0xff)
vs[i].ColorB = 0x20 / float32(0xff)
vs[i].ColorA = float32((counter/30)%2)/2 + 0.5
}
screen.DrawTriangles(vs, is, emptySubImage, op)
}
@ -245,7 +246,7 @@ func (g *Game) Update() error {
func (g *Game) Draw(screen *ebiten.Image) {
screen.Fill(color.White)
drawEbitenText(screen)
drawEbitenText(screen, g.counter)
drawEbitenLogo(screen, 20, 90)
drawArc(screen, g.counter)
drawWave(screen, g.counter)

View File

@ -737,13 +737,13 @@ func (g *Graphics) Initialize() error {
BackFaceStencil: mtl.StencilDescriptor{
StencilFailureOperation: mtl.StencilOperationKeep,
DepthFailureOperation: mtl.StencilOperationKeep,
DepthStencilPassOperation: mtl.StencilOperationKeep,
DepthStencilPassOperation: mtl.StencilOperationZero,
StencilCompareFunction: mtl.CompareFunctionNotEqual,
},
FrontFaceStencil: mtl.StencilDescriptor{
StencilFailureOperation: mtl.StencilOperationKeep,
DepthFailureOperation: mtl.StencilOperationKeep,
DepthStencilPassOperation: mtl.StencilOperationKeep,
DepthStencilPassOperation: mtl.StencilOperationZero,
StencilCompareFunction: mtl.CompareFunctionNotEqual,
},
})

View File

@ -520,6 +520,6 @@ func (c *context) beginStencilWithEvenOddRule() {
func (c *context) endStencilWithEvenOddRule() {
gl.StencilFunc(gl.NOTEQUAL, 0x00, 0xff)
gl.StencilOp(gl.KEEP, gl.KEEP, gl.KEEP)
gl.StencilOp(gl.KEEP, gl.KEEP, gl.ZERO)
gl.ColorMask(true, true, true, true)
}

View File

@ -660,6 +660,6 @@ func (c *context) beginStencilWithEvenOddRule() {
func (c *context) endStencilWithEvenOddRule() {
gl := c.gl
gl.stencilFunc.Invoke(gles.NOTEQUAL, 0x00, 0xff)
gl.stencilOp.Invoke(gles.KEEP, gles.KEEP, gles.KEEP)
gl.stencilOp.Invoke(gles.KEEP, gles.KEEP, gles.ZERO)
gl.colorMask.Invoke(true, true, true, true)
}

View File

@ -488,6 +488,6 @@ func (c *context) beginStencilWithEvenOddRule() {
func (c *context) endStencilWithEvenOddRule() {
c.ctx.StencilFunc(gles.NOTEQUAL, 0x00, 0xff)
c.ctx.StencilOp(gles.KEEP, gles.KEEP, gles.KEEP)
c.ctx.StencilOp(gles.KEEP, gles.KEEP, gles.ZERO)
c.ctx.ColorMask(true, true, true, true)
}