mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
graphics: Remove passing GeoM to the lower layers
This commit is contained in:
parent
96053702ed
commit
a70f61b1d5
@ -140,10 +140,9 @@ func (i *imageImpl) DrawImage(image *Image, options *DrawImageOptions) error {
|
||||
if i.restorable == nil {
|
||||
return errors.New("ebiten: image is already disposed")
|
||||
}
|
||||
geom := options.GeoM
|
||||
colorm := options.ColorM
|
||||
mode := opengl.CompositeMode(options.CompositeMode)
|
||||
if err := i.restorable.DrawImage(image.impl.restorable, vs, &geom, &colorm, mode); err != nil {
|
||||
if err := i.restorable.DrawImage(image.impl.restorable, vs, &colorm, mode); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
@ -156,7 +156,6 @@ type drawImageCommand struct {
|
||||
dst *Image
|
||||
src *Image
|
||||
vertices []uint8
|
||||
geo Matrix
|
||||
color Matrix
|
||||
mode opengl.CompositeMode
|
||||
}
|
||||
@ -183,7 +182,6 @@ func (c *drawImageCommand) Exec(context *opengl.Context, indexOffsetInBytes int)
|
||||
context: context,
|
||||
projectionMatrix: proj,
|
||||
texture: c.src.texture.native,
|
||||
geoM: c.geo,
|
||||
colorM: c.color,
|
||||
}
|
||||
if err := p.begin(); err != nil {
|
||||
|
@ -94,12 +94,11 @@ func (i *Image) Fill(clr color.RGBA) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *Image) DrawImage(src *Image, vertices []uint8, geo, clr Matrix, mode opengl.CompositeMode) error {
|
||||
func (i *Image) DrawImage(src *Image, vertices []uint8, clr Matrix, mode opengl.CompositeMode) error {
|
||||
c := &drawImageCommand{
|
||||
dst: i,
|
||||
src: src,
|
||||
vertices: vertices,
|
||||
geo: geo,
|
||||
color: clr,
|
||||
mode: mode,
|
||||
}
|
||||
|
@ -102,7 +102,6 @@ type openGLState struct {
|
||||
|
||||
lastProgram opengl.Program
|
||||
lastProjectionMatrix []float32
|
||||
lastModelviewMatrix []float32
|
||||
lastColorMatrix []float32
|
||||
lastColorMatrixTranslation []float32
|
||||
}
|
||||
@ -130,7 +129,6 @@ func (s *openGLState) reset(context *opengl.Context) error {
|
||||
}
|
||||
s.lastProgram = zeroProgram
|
||||
s.lastProjectionMatrix = nil
|
||||
s.lastModelviewMatrix = nil
|
||||
s.lastColorMatrix = nil
|
||||
s.lastColorMatrixTranslation = nil
|
||||
|
||||
@ -198,7 +196,6 @@ type programContext struct {
|
||||
context *opengl.Context
|
||||
projectionMatrix []float32
|
||||
texture opengl.Texture
|
||||
geoM Matrix
|
||||
colorM Matrix
|
||||
}
|
||||
|
||||
@ -213,7 +210,6 @@ func (p *programContext) begin() error {
|
||||
|
||||
p.state.lastProgram = p.state.programTexture
|
||||
p.state.lastProjectionMatrix = nil
|
||||
p.state.lastModelviewMatrix = nil
|
||||
p.state.lastColorMatrix = nil
|
||||
p.state.lastColorMatrixTranslation = nil
|
||||
c.BindElementArrayBuffer(p.state.indexBufferQuads)
|
||||
@ -228,25 +224,6 @@ func (p *programContext) begin() error {
|
||||
copy(p.state.lastProjectionMatrix, p.projectionMatrix)
|
||||
}
|
||||
|
||||
ma := float32(p.geoM.Element(0, 0))
|
||||
mb := float32(p.geoM.Element(0, 1))
|
||||
mc := float32(p.geoM.Element(1, 0))
|
||||
md := float32(p.geoM.Element(1, 1))
|
||||
tx := float32(p.geoM.Element(0, 2))
|
||||
ty := float32(p.geoM.Element(1, 2))
|
||||
modelviewMatrix := []float32{
|
||||
ma, mc, 0, 0,
|
||||
mb, md, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
tx, ty, 0, 1,
|
||||
}
|
||||
if !areSameFloat32Array(p.state.lastModelviewMatrix, modelviewMatrix) {
|
||||
if p.state.lastModelviewMatrix == nil {
|
||||
p.state.lastModelviewMatrix = make([]float32, 16)
|
||||
}
|
||||
copy(p.state.lastModelviewMatrix, modelviewMatrix)
|
||||
}
|
||||
|
||||
e := [4][5]float32{}
|
||||
for i := 0; i < 4; i++ {
|
||||
for j := 0; j < 5; j++ {
|
||||
|
@ -26,7 +26,6 @@ import (
|
||||
type drawImageHistoryItem struct {
|
||||
image *graphics.Image
|
||||
vertices []uint8
|
||||
geom graphics.Matrix
|
||||
colorm graphics.Matrix
|
||||
mode opengl.CompositeMode
|
||||
}
|
||||
@ -145,19 +144,19 @@ func (p *Image) ReplacePixels(pixels []uint8) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Image) DrawImage(img *Image, vertices []uint8, geom graphics.Matrix, colorm graphics.Matrix, mode opengl.CompositeMode) error {
|
||||
func (p *Image) DrawImage(img *Image, vertices []uint8, colorm graphics.Matrix, mode opengl.CompositeMode) error {
|
||||
if img.stale || img.volatile {
|
||||
p.makeStale()
|
||||
} else {
|
||||
p.appendDrawImageHistory(img.image, vertices, geom, colorm, mode)
|
||||
p.appendDrawImageHistory(img.image, vertices, colorm, mode)
|
||||
}
|
||||
if err := p.image.DrawImage(img.image, vertices, geom, colorm, mode); err != nil {
|
||||
if err := p.image.DrawImage(img.image, vertices, colorm, mode); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Image) appendDrawImageHistory(image *graphics.Image, vertices []uint8, geom graphics.Matrix, colorm graphics.Matrix, mode opengl.CompositeMode) {
|
||||
func (p *Image) appendDrawImageHistory(image *graphics.Image, vertices []uint8, colorm graphics.Matrix, mode opengl.CompositeMode) {
|
||||
if p.stale {
|
||||
return
|
||||
}
|
||||
@ -166,7 +165,6 @@ func (p *Image) appendDrawImageHistory(image *graphics.Image, vertices []uint8,
|
||||
item := &drawImageHistoryItem{
|
||||
image: image,
|
||||
vertices: vertices,
|
||||
geom: geom,
|
||||
colorm: colorm,
|
||||
mode: mode,
|
||||
}
|
||||
@ -284,7 +282,7 @@ func (p *Image) Restore(context *opengl.Context) error {
|
||||
/*if c.image.impl.hasHistory() {
|
||||
panic("not reach")
|
||||
}*/
|
||||
if err := gimg.DrawImage(c.image, c.vertices, c.geom, c.colorm, c.mode); err != nil {
|
||||
if err := gimg.DrawImage(c.image, c.vertices, c.colorm, c.mode); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user