mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 11:48:55 +01:00
graphics: Accurate calculation of vbo values
This commit is contained in:
parent
79e763da35
commit
8219c56dd8
@ -84,9 +84,10 @@ type textureQuads struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *textureQuads) vertices() []uint8 {
|
func (t *textureQuads) vertices() []uint8 {
|
||||||
size := graphics.QuadVertexSizeInBytes()
|
totalSize := graphics.QuadVertexSizeInBytes()
|
||||||
|
oneSize := totalSize / 4
|
||||||
l := t.parts.Len()
|
l := t.parts.Len()
|
||||||
vertices := make([]uint8, l*size)
|
vertices := make([]uint8, l*totalSize)
|
||||||
p := t.parts
|
p := t.parts
|
||||||
w, h := t.width, t.height
|
w, h := t.width, t.height
|
||||||
width2p := graphics.NextPowerOf2Int(w)
|
width2p := graphics.NextPowerOf2Int(w)
|
||||||
@ -123,16 +124,16 @@ func (t *textureQuads) vertices() []uint8 {
|
|||||||
// Use direct assign here. `append` function might be slow on browsers.
|
// Use direct assign here. `append` function might be slow on browsers.
|
||||||
if endian.IsLittle() {
|
if endian.IsLittle() {
|
||||||
for i, v := range vs {
|
for i, v := range vs {
|
||||||
vertices[size*n+2*i] = uint8(v)
|
vertices[totalSize*n+oneSize*(i/4)+2*(i%4)] = uint8(v)
|
||||||
vertices[size*n+2*i+1] = uint8(v >> 8)
|
vertices[totalSize*n+oneSize*(i/4)+2*(i%4)+1] = uint8(v >> 8)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for i, v := range vs {
|
for i, v := range vs {
|
||||||
vertices[size*n+2*i] = uint8(v >> 8)
|
vertices[totalSize*n+oneSize*(i/4)+2*(i%4)] = uint8(v >> 8)
|
||||||
vertices[size*n+2*i+1] = uint8(v)
|
vertices[totalSize*n+oneSize*(i/4)+2*(i%4)+1] = uint8(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
n++
|
n++
|
||||||
}
|
}
|
||||||
return vertices[:n*size]
|
return vertices[:n*totalSize]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user