From c535efe56b8b94dc653a2c9a6831c782b5ca4035 Mon Sep 17 00:00:00 2001 From: surdeus Date: Tue, 23 May 2023 16:25:21 +0300 Subject: [PATCH] Damn shaders finally work. --- src/cmd/test/main.go | 1 + src/gx/rect.go | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/cmd/test/main.go b/src/cmd/test/main.go index 5edf799..7c4820d 100644 --- a/src/cmd/test/main.go +++ b/src/cmd/test/main.go @@ -143,6 +143,7 @@ func main() { gx.MaxColorV, }, Visible: true, + //Shader: gx.SolidWhiteColorShader, }) e.Run() } diff --git a/src/gx/rect.go b/src/gx/rect.go index 641880b..e224e73 100644 --- a/src/gx/rect.go +++ b/src/gx/rect.go @@ -60,18 +60,18 @@ func (r DrawableRectangle) Draw( e *Engine, i *Image, ) { + t := r.T + t.S.X *= r.W + t.S.Y *= r.H + + rm := e.Camera().RealMatrix(e, true) + m := t.Matrix(e) + m.Concat(rm) // Draw solid color if no shader. if r.Shader == nil { img := NewImage(1, 1) img.Set(0, 0, r.Color) - t := r.T - t.S.X *= r.W - t.S.Y *= r.H - - rm := e.Camera().RealMatrix(e, true) - m := t.Matrix(e) - m.Concat(rm) opts := &ebiten.DrawImageOptions{ GeoM: m, } @@ -80,7 +80,7 @@ func (r DrawableRectangle) Draw( } opts := &ebiten.DrawRectShaderOptions{ - GeoM: r.T.Matrix(e), + GeoM: m, Images: [4]*Image{ NewImage(1, 1), nil, @@ -92,6 +92,6 @@ func (r DrawableRectangle) Draw( //w := int(r.W * r.T.S.X) //h := int(r.H * r.T.S.Y) - i.DrawRectShader(1000, 1000, r.Shader, opts) + i.DrawRectShader(1, 1, r.Shader, opts) }