mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
Reduce division operators
It looks like runtime.wasmDiv takes account for a big part at CPU usages with examples/sprites.
This commit is contained in:
parent
3cf867035d
commit
af6bda48c3
@ -192,7 +192,8 @@ func (q *commandQueue) Flush() {
|
||||
const dstAdjustmentFactor = 1.0 / 256.0
|
||||
const texelAdjustmentFactor = 1.0 / 512.0
|
||||
|
||||
for i := 0; i < q.nvertices/graphics.VertexFloatNum; i++ {
|
||||
n := q.nvertices / graphics.VertexFloatNum
|
||||
for i := 0; i < n; i++ {
|
||||
s := q.srcSizes[i]
|
||||
|
||||
// Convert pixels to texels.
|
||||
|
@ -303,7 +303,8 @@ func (i *Image) DrawTriangles(img *Image, vertices []float32, indices []uint16,
|
||||
|
||||
ox, oy, _, _ := img.region()
|
||||
oxf, oyf := float32(ox), float32(oy)
|
||||
for i := 0; i < len(vertices)/graphics.VertexFloatNum; i++ {
|
||||
n := len(vertices) / graphics.VertexFloatNum
|
||||
for i := 0; i < n; i++ {
|
||||
vertices[i*graphics.VertexFloatNum+2] += oxf
|
||||
vertices[i*graphics.VertexFloatNum+3] += oyf
|
||||
vertices[i*graphics.VertexFloatNum+4] += oxf
|
||||
|
Loading…
Reference in New Issue
Block a user