From aa0f7462ec3cf2f1db7da9dac9f1b8ac2441460a Mon Sep 17 00:00:00 2001 From: faiface Date: Fri, 13 Jan 2017 01:07:13 +0100 Subject: [PATCH] performance optimizations --- graphics.go | 2 +- window.go | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/graphics.go b/graphics.go index ccf1af9..b83a595 100644 --- a/graphics.go +++ b/graphics.go @@ -78,7 +78,7 @@ func (td *TrianglesData) Position(i int) Vec { } // Color returns the color property of i-th vertex. -func (td *TrianglesData) Color(i int) color.Color { +func (td *TrianglesData) Color(i int) NRGBA { return (*td)[i].Color } diff --git a/window.go b/window.go index 8eb9d29..1ee5ba7 100644 --- a/window.go +++ b/window.go @@ -414,10 +414,10 @@ func (wt *windowTriangles) resize(len int) { func (wt *windowTriangles) updateData(offset int, t Triangles) { if t, ok := t.(TrianglesPosition); ok { for i := offset; i < offset+t.Len(); i++ { - pos := t.Position(i) + px, py := t.Position(i).XY() wt.data[i][positionVec2] = mgl32.Vec2{ - float32(pos.X()), - float32(pos.Y()), + float32(px), + float32(py), } } } @@ -434,10 +434,10 @@ func (wt *windowTriangles) updateData(offset int, t Triangles) { } if t, ok := t.(TrianglesTexture); ok { for i := offset; i < offset+t.Len(); i++ { - tex := t.Texture(i) + tx, ty := t.Texture(i).XY() wt.data[i][textureVec2] = mgl32.Vec2{ - float32(tex.X()), - float32(tex.Y()), + float32(tx), + float32(ty), } } } @@ -484,7 +484,7 @@ func (wt *windowTriangles) Position(i int) Vec { return V(float64(v.X()), float64(v.Y())) } -func (wt *windowTriangles) Color(i int) color.Color { +func (wt *windowTriangles) Color(i int) NRGBA { c := wt.data[i][colorVec4].(mgl32.Vec4) return NRGBA{ R: float64(c.X()),