mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
all: refactoring
This commit is contained in:
parent
b9c24f786a
commit
5f80f4b3de
@ -71,32 +71,32 @@ func QuadVertices(dst []float32, sx0, sy0, sx1, sy1 float32, a, b, c, d, tx, ty
|
||||
dst[6] = cb
|
||||
dst[7] = ca
|
||||
|
||||
dst[8] = adjustDestinationPixel(ax + tx)
|
||||
dst[9] = adjustDestinationPixel(cx + ty)
|
||||
dst[10] = u1
|
||||
dst[11] = v0
|
||||
dst[12] = cr
|
||||
dst[13] = cg
|
||||
dst[14] = cb
|
||||
dst[15] = ca
|
||||
dst[VertexFloatCount] = adjustDestinationPixel(ax + tx)
|
||||
dst[VertexFloatCount+1] = adjustDestinationPixel(cx + ty)
|
||||
dst[VertexFloatCount+2] = u1
|
||||
dst[VertexFloatCount+3] = v0
|
||||
dst[VertexFloatCount+4] = cr
|
||||
dst[VertexFloatCount+5] = cg
|
||||
dst[VertexFloatCount+6] = cb
|
||||
dst[VertexFloatCount+7] = ca
|
||||
|
||||
dst[16] = adjustDestinationPixel(by + tx)
|
||||
dst[17] = adjustDestinationPixel(dy + ty)
|
||||
dst[18] = u0
|
||||
dst[19] = v1
|
||||
dst[20] = cr
|
||||
dst[21] = cg
|
||||
dst[22] = cb
|
||||
dst[23] = ca
|
||||
dst[2*VertexFloatCount] = adjustDestinationPixel(by + tx)
|
||||
dst[2*VertexFloatCount+1] = adjustDestinationPixel(dy + ty)
|
||||
dst[2*VertexFloatCount+2] = u0
|
||||
dst[2*VertexFloatCount+3] = v1
|
||||
dst[2*VertexFloatCount+4] = cr
|
||||
dst[2*VertexFloatCount+5] = cg
|
||||
dst[2*VertexFloatCount+6] = cb
|
||||
dst[2*VertexFloatCount+7] = ca
|
||||
|
||||
dst[24] = adjustDestinationPixel(ax + by + tx)
|
||||
dst[25] = adjustDestinationPixel(cx + dy + ty)
|
||||
dst[26] = u1
|
||||
dst[27] = v1
|
||||
dst[28] = cr
|
||||
dst[29] = cg
|
||||
dst[30] = cb
|
||||
dst[31] = ca
|
||||
dst[3*VertexFloatCount] = adjustDestinationPixel(ax + by + tx)
|
||||
dst[3*VertexFloatCount+1] = adjustDestinationPixel(cx + dy + ty)
|
||||
dst[3*VertexFloatCount+2] = u1
|
||||
dst[3*VertexFloatCount+3] = v1
|
||||
dst[3*VertexFloatCount+4] = cr
|
||||
dst[3*VertexFloatCount+5] = cg
|
||||
dst[3*VertexFloatCount+6] = cb
|
||||
dst[3*VertexFloatCount+7] = ca
|
||||
}
|
||||
|
||||
func adjustDestinationPixel(x float32) float32 {
|
||||
|
@ -183,9 +183,9 @@ func dstRegionFromVertices(vertices []float32) (minX, minY, maxX, maxY float32)
|
||||
maxX = negInf32
|
||||
maxY = negInf32
|
||||
|
||||
for i := 0; i < len(vertices)/graphics.VertexFloatCount; i++ {
|
||||
x := vertices[graphics.VertexFloatCount*i]
|
||||
y := vertices[graphics.VertexFloatCount*i+1]
|
||||
for i := 0; i < len(vertices); i += graphics.VertexFloatCount {
|
||||
x := vertices[i]
|
||||
y := vertices[i+1]
|
||||
if x < minX {
|
||||
minX = x
|
||||
}
|
||||
|
@ -73,20 +73,20 @@ func (m *Mipmap) DrawTriangles(srcs [graphics.ShaderSrcImageCount]*Mipmap, verti
|
||||
level := 0
|
||||
if !canSkipMipmap && srcs[0] != nil && canUseMipmap(srcs[0].imageType) {
|
||||
level = math.MaxInt32
|
||||
for i := 0; i < len(indices)/3; i++ {
|
||||
for i := 0; i < len(indices); i += 3 {
|
||||
const n = graphics.VertexFloatCount
|
||||
dx0 := vertices[n*indices[3*i]+0]
|
||||
dy0 := vertices[n*indices[3*i]+1]
|
||||
sx0 := vertices[n*indices[3*i]+2]
|
||||
sy0 := vertices[n*indices[3*i]+3]
|
||||
dx1 := vertices[n*indices[3*i+1]+0]
|
||||
dy1 := vertices[n*indices[3*i+1]+1]
|
||||
sx1 := vertices[n*indices[3*i+1]+2]
|
||||
sy1 := vertices[n*indices[3*i+1]+3]
|
||||
dx2 := vertices[n*indices[3*i+2]+0]
|
||||
dy2 := vertices[n*indices[3*i+2]+1]
|
||||
sx2 := vertices[n*indices[3*i+2]+2]
|
||||
sy2 := vertices[n*indices[3*i+2]+3]
|
||||
dx0 := vertices[n*indices[i]+0]
|
||||
dy0 := vertices[n*indices[i]+1]
|
||||
sx0 := vertices[n*indices[i]+2]
|
||||
sy0 := vertices[n*indices[i]+3]
|
||||
dx1 := vertices[n*indices[i+1]+0]
|
||||
dy1 := vertices[n*indices[i+1]+1]
|
||||
sx1 := vertices[n*indices[i+1]+2]
|
||||
sy1 := vertices[n*indices[i+1]+3]
|
||||
dx2 := vertices[n*indices[i+2]+0]
|
||||
dy2 := vertices[n*indices[i+2]+1]
|
||||
sx2 := vertices[n*indices[i+2]+2]
|
||||
sy2 := vertices[n*indices[i+2]+3]
|
||||
if l := mipmapLevelFromDistance(dx0, dy0, dx1, dy1, sx0, sy0, sx1, sy1); level > l {
|
||||
level = l
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user