mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
ebiten: Add CompositeModeMultiply (#1251)
This change adds a new composite mode called `CompositeModeMultiply`, which multiplies the source color with the destination color. This is tested on Linux and Windows only. Fixes #410
This commit is contained in:
parent
4bd3bc16ac
commit
72babcd420
@ -85,4 +85,8 @@ const (
|
|||||||
// Sum of source and destination (a.k.a. 'plus' or 'additive')
|
// Sum of source and destination (a.k.a. 'plus' or 'additive')
|
||||||
// c_out = c_src + c_dst
|
// c_out = c_src + c_dst
|
||||||
CompositeModeLighter CompositeMode = CompositeMode(driver.CompositeModeLighter)
|
CompositeModeLighter CompositeMode = CompositeMode(driver.CompositeModeLighter)
|
||||||
|
|
||||||
|
// The product of source and destination (a.k.a 'multiply blend mode')
|
||||||
|
// c_out = c_src * c_dst
|
||||||
|
CompositeModeMultiply CompositeMode = CompositeMode(driver.CompositeModeMultiply)
|
||||||
)
|
)
|
||||||
|
@ -35,8 +35,9 @@ const (
|
|||||||
CompositeModeDestinationAtop
|
CompositeModeDestinationAtop
|
||||||
CompositeModeXor
|
CompositeModeXor
|
||||||
CompositeModeLighter
|
CompositeModeLighter
|
||||||
|
CompositeModeMultiply
|
||||||
|
|
||||||
CompositeModeMax = CompositeModeLighter
|
CompositeModeMax = CompositeModeMultiply
|
||||||
)
|
)
|
||||||
|
|
||||||
type Operation int
|
type Operation int
|
||||||
@ -48,6 +49,7 @@ const (
|
|||||||
DstAlpha
|
DstAlpha
|
||||||
OneMinusSrcAlpha
|
OneMinusSrcAlpha
|
||||||
OneMinusDstAlpha
|
OneMinusDstAlpha
|
||||||
|
DstColor
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c CompositeMode) Operations() (src Operation, dst Operation) {
|
func (c CompositeMode) Operations() (src Operation, dst Operation) {
|
||||||
@ -78,6 +80,8 @@ func (c CompositeMode) Operations() (src Operation, dst Operation) {
|
|||||||
return OneMinusDstAlpha, OneMinusSrcAlpha
|
return OneMinusDstAlpha, OneMinusSrcAlpha
|
||||||
case CompositeModeLighter:
|
case CompositeModeLighter:
|
||||||
return One, One
|
return One, One
|
||||||
|
case CompositeModeMultiply:
|
||||||
|
return DstColor, Zero
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("graphics: invalid composite mode: %d", c))
|
panic(fmt.Sprintf("graphics: invalid composite mode: %d", c))
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,8 @@ func convertOperation(op driver.Operation) operation {
|
|||||||
return oneMinusSrcAlpha
|
return oneMinusSrcAlpha
|
||||||
case driver.OneMinusDstAlpha:
|
case driver.OneMinusDstAlpha:
|
||||||
return oneMinusDstAlpha
|
return oneMinusDstAlpha
|
||||||
|
case driver.DstColor:
|
||||||
|
return dstColor
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("opengl: invalid operation %d at convertOperation", op))
|
panic(fmt.Sprintf("opengl: invalid operation %d at convertOperation", op))
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,7 @@ const (
|
|||||||
dstAlpha = operation(gl.DST_ALPHA)
|
dstAlpha = operation(gl.DST_ALPHA)
|
||||||
oneMinusSrcAlpha = operation(gl.ONE_MINUS_SRC_ALPHA)
|
oneMinusSrcAlpha = operation(gl.ONE_MINUS_SRC_ALPHA)
|
||||||
oneMinusDstAlpha = operation(gl.ONE_MINUS_DST_ALPHA)
|
oneMinusDstAlpha = operation(gl.ONE_MINUS_DST_ALPHA)
|
||||||
|
dstColor = operation(gl.DST_COLOR)
|
||||||
)
|
)
|
||||||
|
|
||||||
type contextImpl struct {
|
type contextImpl struct {
|
||||||
|
@ -90,6 +90,7 @@ var (
|
|||||||
dstAlpha operation
|
dstAlpha operation
|
||||||
oneMinusSrcAlpha operation
|
oneMinusSrcAlpha operation
|
||||||
oneMinusDstAlpha operation
|
oneMinusDstAlpha operation
|
||||||
|
dstColor operation
|
||||||
|
|
||||||
blend js.Value
|
blend js.Value
|
||||||
clampToEdge js.Value
|
clampToEdge js.Value
|
||||||
@ -144,6 +145,7 @@ func init() {
|
|||||||
dstAlpha = operation(contextPrototype.Get("DST_ALPHA").Int())
|
dstAlpha = operation(contextPrototype.Get("DST_ALPHA").Int())
|
||||||
oneMinusSrcAlpha = operation(contextPrototype.Get("ONE_MINUS_SRC_ALPHA").Int())
|
oneMinusSrcAlpha = operation(contextPrototype.Get("ONE_MINUS_SRC_ALPHA").Int())
|
||||||
oneMinusDstAlpha = operation(contextPrototype.Get("ONE_MINUS_DST_ALPHA").Int())
|
oneMinusDstAlpha = operation(contextPrototype.Get("ONE_MINUS_DST_ALPHA").Int())
|
||||||
|
dstColor = operation(contextPrototype.Get("DST_COLOR").Int())
|
||||||
|
|
||||||
blend = contextPrototype.Get("BLEND")
|
blend = contextPrototype.Get("BLEND")
|
||||||
clampToEdge = contextPrototype.Get("CLAMP_TO_EDGE")
|
clampToEdge = contextPrototype.Get("CLAMP_TO_EDGE")
|
||||||
|
@ -91,6 +91,7 @@ const (
|
|||||||
dstAlpha = operation(mgl.DST_ALPHA)
|
dstAlpha = operation(mgl.DST_ALPHA)
|
||||||
oneMinusSrcAlpha = operation(mgl.ONE_MINUS_SRC_ALPHA)
|
oneMinusSrcAlpha = operation(mgl.ONE_MINUS_SRC_ALPHA)
|
||||||
oneMinusDstAlpha = operation(mgl.ONE_MINUS_DST_ALPHA)
|
oneMinusDstAlpha = operation(mgl.ONE_MINUS_DST_ALPHA)
|
||||||
|
dstColor = operation(mgl.DST_COLOR)
|
||||||
)
|
)
|
||||||
|
|
||||||
type contextImpl struct {
|
type contextImpl struct {
|
||||||
|
@ -31,6 +31,7 @@ const (
|
|||||||
DST_ALPHA = 0x0304
|
DST_ALPHA = 0x0304
|
||||||
ONE_MINUS_SRC_ALPHA = 0x0303
|
ONE_MINUS_SRC_ALPHA = 0x0303
|
||||||
ONE_MINUS_DST_ALPHA = 0x0305
|
ONE_MINUS_DST_ALPHA = 0x0305
|
||||||
|
DST_COLOR = 0x0306
|
||||||
|
|
||||||
FALSE = 0
|
FALSE = 0
|
||||||
TRUE = 1
|
TRUE = 1
|
||||||
|
Loading…
Reference in New Issue
Block a user