diff --git a/examples/glut/main.go b/examples/glut/main.go index 8baedaa2d..b6ff8ee8d 100644 --- a/examples/glut/main.go +++ b/examples/glut/main.go @@ -120,8 +120,8 @@ func (game *DemoGame) Draw(g graphics.GraphicsContext, offscreen graphics.Textur return } geometryMatrix := graphics.IdentityGeometryMatrix() - geometryMatrix.SetTx(graphics.AffineMatrixElement(game.x)) - geometryMatrix.SetTy(graphics.AffineMatrixElement(game.x)) + geometryMatrix.SetTx(float64(game.x)) + geometryMatrix.SetTy(float64(game.x)) g.DrawTexture(game.ebitenTexture, 0, 0, game.ebitenTexture.Width(), game.ebitenTexture.Height(), geometryMatrix, diff --git a/graphics/affine_matrix.go b/graphics/affine_matrix.go index b5f20ec31..d2467b550 100644 --- a/graphics/affine_matrix.go +++ b/graphics/affine_matrix.go @@ -1,9 +1,9 @@ package graphics -type AffineMatrixElement float64 +type affineMatrixElement float64 type AffineMatrix struct { - elements []AffineMatrixElement + elements []affineMatrixElement dimension int } @@ -13,7 +13,7 @@ func NewAffineMatrix(dimension int) *AffineMatrix { } matrix := &AffineMatrix{} elementsNumber := dimension * (dimension - 1) - matrix.elements = make([]AffineMatrixElement, elementsNumber) + matrix.elements = make([]affineMatrixElement, elementsNumber) matrix.dimension = dimension return matrix } @@ -41,7 +41,7 @@ func (matrix *AffineMatrix) Clone() *AffineMatrix { return result } -func (matrix *AffineMatrix) Element(i, j int) AffineMatrixElement { +func (matrix *AffineMatrix) Element(i, j int) float64 { dimension := matrix.dimension if i < 0 || dimension <= i { panic("out of range index i") @@ -55,10 +55,10 @@ func (matrix *AffineMatrix) Element(i, j int) AffineMatrixElement { } return 0 } - return matrix.elements[i*dimension+j] + return float64(matrix.elements[i*dimension+j]) } -func (matrix *AffineMatrix) SetElement(i, j int, element AffineMatrixElement) { +func (matrix *AffineMatrix) SetElement(i, j int, element float64) { dimension := matrix.dimension if i < 0 || dimension-1 <= i { panic("out of range index i") @@ -66,7 +66,7 @@ func (matrix *AffineMatrix) SetElement(i, j int, element AffineMatrixElement) { if j < 0 || dimension <= j { panic("out of range index j") } - matrix.elements[i*dimension+j] = element + matrix.elements[i*dimension+j] = affineMatrixElement(element) } func (matrix *AffineMatrix) IsIdentity() bool { @@ -96,7 +96,7 @@ func (rhs *AffineMatrix) Concat(lhs *AffineMatrix) *AffineMatrix { for i := 0; i < dimension-1; i++ { for j := 0; j < dimension; j++ { - var element AffineMatrixElement = 0.0 + element := affineMatrixElement(0.0) for k := 0; k < dimension-1; k++ { element += lhs.elements[i*dimension+k] * rhs.elements[k*dimension+j] diff --git a/graphics/geometry_matrix.go b/graphics/geometry_matrix.go index 48b5c520e..fbe0381a2 100644 --- a/graphics/geometry_matrix.go +++ b/graphics/geometry_matrix.go @@ -18,50 +18,50 @@ func (matrix *GeometryMatrix) Clone() *GeometryMatrix { return &GeometryMatrix{*(matrix.AffineMatrix.Clone())} } -func (matrix *GeometryMatrix) A() AffineMatrixElement { +func (matrix *GeometryMatrix) A() float64 { return matrix.Element(0, 0) } -func (matrix *GeometryMatrix) B() AffineMatrixElement { +func (matrix *GeometryMatrix) B() float64 { return matrix.Element(0, 1) } -func (matrix *GeometryMatrix) C() AffineMatrixElement { +func (matrix *GeometryMatrix) C() float64 { return matrix.Element(1, 0) } -func (matrix *GeometryMatrix) D() AffineMatrixElement { +func (matrix *GeometryMatrix) D() float64 { return matrix.Element(1, 1) } -func (matrix *GeometryMatrix) Tx() AffineMatrixElement { +func (matrix *GeometryMatrix) Tx() float64 { return matrix.Element(0, 2) } -func (matrix *GeometryMatrix) Ty() AffineMatrixElement { +func (matrix *GeometryMatrix) Ty() float64 { return matrix.Element(1, 2) } -func (matrix *GeometryMatrix) SetA(a AffineMatrixElement) { +func (matrix *GeometryMatrix) SetA(a float64) { matrix.SetElement(0, 0, a) } -func (matrix *GeometryMatrix) SetB(b AffineMatrixElement) { +func (matrix *GeometryMatrix) SetB(b float64) { matrix.SetElement(0, 1, b) } -func (matrix *GeometryMatrix) SetC(c AffineMatrixElement) { +func (matrix *GeometryMatrix) SetC(c float64) { matrix.SetElement(1, 0, c) } -func (matrix *GeometryMatrix) SetD(d AffineMatrixElement) { +func (matrix *GeometryMatrix) SetD(d float64) { matrix.SetElement(1, 1, d) } -func (matrix *GeometryMatrix) SetTx(tx AffineMatrixElement) { +func (matrix *GeometryMatrix) SetTx(tx float64) { matrix.SetElement(0, 2, tx) } -func (matrix *GeometryMatrix) SetTy(ty AffineMatrixElement) { +func (matrix *GeometryMatrix) SetTy(ty float64) { matrix.SetElement(1, 2, ty) } diff --git a/graphics/opengl/device.go b/graphics/opengl/device.go index 9e3223af7..d061eafa0 100644 --- a/graphics/opengl/device.go +++ b/graphics/opengl/device.go @@ -54,8 +54,8 @@ func (device *Device) Update() { g.resetOffscreen() g.Clear() geometryMatrix := graphics.IdentityGeometryMatrix() - geometryMatrix.SetA(graphics.AffineMatrixElement(g.screenScale)) - geometryMatrix.SetD(graphics.AffineMatrixElement(g.screenScale)) + geometryMatrix.SetA(float64(g.screenScale)) + geometryMatrix.SetD(float64(g.screenScale)) g.DrawTexture(device.offscreenTexture, 0, 0, device.screenWidth, device.screenHeight, geometryMatrix, graphics.IdentityColorMatrix())