mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
graphics: Use affine.ColorM instead of graphics.Matrix
This commit is contained in:
parent
84baee8ca7
commit
d02c67a996
@ -140,9 +140,8 @@ func (i *imageImpl) DrawImage(image *Image, options *DrawImageOptions) error {
|
|||||||
if i.restorable == nil {
|
if i.restorable == nil {
|
||||||
return errors.New("ebiten: image is already disposed")
|
return errors.New("ebiten: image is already disposed")
|
||||||
}
|
}
|
||||||
colorm := options.ColorM
|
|
||||||
mode := opengl.CompositeMode(options.CompositeMode)
|
mode := opengl.CompositeMode(options.CompositeMode)
|
||||||
if err := i.restorable.DrawImage(image.impl.restorable, vs, &colorm, mode); err != nil {
|
if err := i.restorable.DrawImage(image.impl.restorable, vs, options.ColorM.impl, mode); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -23,13 +23,10 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphics/opengl"
|
"github.com/hajimehoshi/ebiten/internal/graphics/opengl"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Matrix interface {
|
|
||||||
Element(i, j int) float64
|
|
||||||
}
|
|
||||||
|
|
||||||
type command interface {
|
type command interface {
|
||||||
Exec(context *opengl.Context, indexOffsetInBytes int) error
|
Exec(context *opengl.Context, indexOffsetInBytes int) error
|
||||||
}
|
}
|
||||||
@ -185,7 +182,7 @@ type drawImageCommand struct {
|
|||||||
dst *Image
|
dst *Image
|
||||||
src *Image
|
src *Image
|
||||||
vertices []int16
|
vertices []int16
|
||||||
color Matrix
|
color affine.ColorM
|
||||||
mode opengl.CompositeMode
|
mode opengl.CompositeMode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import (
|
|||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
|
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphics/opengl"
|
"github.com/hajimehoshi/ebiten/internal/graphics/opengl"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -94,7 +95,7 @@ func (i *Image) Fill(clr color.RGBA) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Image) DrawImage(src *Image, vertices []int16, clr Matrix, mode opengl.CompositeMode) error {
|
func (i *Image) DrawImage(src *Image, vertices []int16, clr affine.ColorM, mode opengl.CompositeMode) error {
|
||||||
c := &drawImageCommand{
|
c := &drawImageCommand{
|
||||||
dst: i,
|
dst: i,
|
||||||
src: src,
|
src: src,
|
||||||
|
@ -17,6 +17,7 @@ package graphics
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphics/opengl"
|
"github.com/hajimehoshi/ebiten/internal/graphics/opengl"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -201,7 +202,7 @@ type programContext struct {
|
|||||||
context *opengl.Context
|
context *opengl.Context
|
||||||
projectionMatrix []float32
|
projectionMatrix []float32
|
||||||
texture opengl.Texture
|
texture opengl.Texture
|
||||||
colorM Matrix
|
colorM affine.ColorM
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *programContext) begin() error {
|
func (p *programContext) begin() error {
|
||||||
|
@ -19,6 +19,7 @@ import (
|
|||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
|
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphics/opengl"
|
"github.com/hajimehoshi/ebiten/internal/graphics/opengl"
|
||||||
)
|
)
|
||||||
@ -26,7 +27,7 @@ import (
|
|||||||
type drawImageHistoryItem struct {
|
type drawImageHistoryItem struct {
|
||||||
image *graphics.Image
|
image *graphics.Image
|
||||||
vertices []int16
|
vertices []int16
|
||||||
colorm graphics.Matrix
|
colorm affine.ColorM
|
||||||
mode opengl.CompositeMode
|
mode opengl.CompositeMode
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +145,7 @@ func (p *Image) ReplacePixels(pixels []uint8) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Image) DrawImage(img *Image, vertices []int16, colorm graphics.Matrix, mode opengl.CompositeMode) error {
|
func (p *Image) DrawImage(img *Image, vertices []int16, colorm affine.ColorM, mode opengl.CompositeMode) error {
|
||||||
if img.stale || img.volatile {
|
if img.stale || img.volatile {
|
||||||
p.makeStale()
|
p.makeStale()
|
||||||
} else {
|
} else {
|
||||||
@ -156,7 +157,7 @@ func (p *Image) DrawImage(img *Image, vertices []int16, colorm graphics.Matrix,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Image) appendDrawImageHistory(image *graphics.Image, vertices []int16, colorm graphics.Matrix, mode opengl.CompositeMode) {
|
func (p *Image) appendDrawImageHistory(image *graphics.Image, vertices []int16, colorm affine.ColorM, mode opengl.CompositeMode) {
|
||||||
if p.stale {
|
if p.stale {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user