mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
graphics: Remove PutQuadVertices
This commit is contained in:
parent
6095cd965b
commit
629d58b93a
@ -19,21 +19,6 @@ const (
|
|||||||
VertexFloatNum = 12
|
VertexFloatNum = 12
|
||||||
)
|
)
|
||||||
|
|
||||||
type VertexPutter interface {
|
|
||||||
PutVertex(dst []float32, dx, dy, sx, sy float32, bx0, by0, bx1, by1 float32, cr, cg, cb, ca float32)
|
|
||||||
}
|
|
||||||
|
|
||||||
func PutQuadVertices(dst []float32, putter VertexPutter, sx0, sy0, sx1, sy1 int, a, b, c, d, tx, ty float32, cr, cg, cb, ca float32) {
|
|
||||||
x := float32(sx1 - sx0)
|
|
||||||
y := float32(sy1 - sy0)
|
|
||||||
ax, by, cx, dy := a*x, b*y, c*x, d*y
|
|
||||||
u0, v0, u1, v1 := float32(sx0), float32(sy0), float32(sx1), float32(sy1)
|
|
||||||
putter.PutVertex(dst[:VertexFloatNum], tx, ty, u0, v0, u0, v0, u1, v1, cr, cg, cb, ca)
|
|
||||||
putter.PutVertex(dst[VertexFloatNum:2*VertexFloatNum], ax+tx, cx+ty, u1, v0, u0, v0, u1, v1, cr, cg, cb, ca)
|
|
||||||
putter.PutVertex(dst[2*VertexFloatNum:3*VertexFloatNum], by+tx, dy+ty, u0, v1, u0, v0, u1, v1, cr, cg, cb, ca)
|
|
||||||
putter.PutVertex(dst[3*VertexFloatNum:4*VertexFloatNum], ax+by+tx, cx+dy+ty, u1, v1, u0, v0, u1, v1, cr, cg, cb, ca)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
quadIndices = []uint16{0, 1, 2, 1, 2, 3}
|
quadIndices = []uint16{0, 1, 2, 1, 2, 3}
|
||||||
)
|
)
|
||||||
|
@ -43,24 +43,13 @@ func TestMain(m *testing.M) {
|
|||||||
os.Exit(code)
|
os.Exit(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
type testVertexPutter struct {
|
func quadVertices(w, h float32) []float32 {
|
||||||
w float32
|
return []float32{
|
||||||
h float32
|
0, 0, 0, 0, 0, 0, w, h, 1, 1, 1, 1,
|
||||||
}
|
w, 0, w, 0, 0, 0, w, h, 1, 1, 1, 1,
|
||||||
|
0, w, 0, h, 0, 0, w, h, 1, 1, 1, 1,
|
||||||
func (t *testVertexPutter) PutVertex(vs []float32, dx, dy, sx, sy float32, bx0, by0, bx1, by1 float32, cr, cg, cb, ca float32) {
|
w, h, w, h, 0, 0, w, h, 1, 1, 1, 1,
|
||||||
vs[0] = dx
|
}
|
||||||
vs[1] = dy
|
|
||||||
vs[2] = sx
|
|
||||||
vs[3] = sy
|
|
||||||
vs[4] = bx0
|
|
||||||
vs[5] = by0
|
|
||||||
vs[6] = bx1
|
|
||||||
vs[7] = by1
|
|
||||||
vs[8] = cr
|
|
||||||
vs[9] = cg
|
|
||||||
vs[10] = cb
|
|
||||||
vs[11] = ca
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClear(t *testing.T) {
|
func TestClear(t *testing.T) {
|
||||||
@ -68,8 +57,7 @@ func TestClear(t *testing.T) {
|
|||||||
src := NewImage(w/2, h/2)
|
src := NewImage(w/2, h/2)
|
||||||
dst := NewImage(w, h)
|
dst := NewImage(w, h)
|
||||||
|
|
||||||
vs := make([]float32, 4*graphics.VertexFloatNum)
|
vs := quadVertices(w/2, h/2)
|
||||||
graphics.PutQuadVertices(vs, &testVertexPutter{w / 2, h / 2}, 0, 0, w/2, h/2, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
|
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dst.DrawTriangles(src, vs, is, nil, driver.CompositeModeClear, driver.FilterNearest, driver.AddressClampToZero)
|
dst.DrawTriangles(src, vs, is, nil, driver.CompositeModeClear, driver.FilterNearest, driver.AddressClampToZero)
|
||||||
|
|
||||||
@ -94,10 +82,9 @@ func TestReplacePixelsPartAfterDrawTriangles(t *testing.T) {
|
|||||||
}()
|
}()
|
||||||
const w, h = 32, 32
|
const w, h = 32, 32
|
||||||
clr := NewImage(w, h)
|
clr := NewImage(w, h)
|
||||||
src := NewImage(16, 16)
|
src := NewImage(w/2, h/2)
|
||||||
dst := NewImage(w, h)
|
dst := NewImage(w, h)
|
||||||
vs := make([]float32, 4*graphics.VertexFloatNum)
|
vs := quadVertices(w/2, h/2)
|
||||||
graphics.PutQuadVertices(vs, &testVertexPutter{w / 2, h / 2}, 0, 0, w, h, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
|
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dst.DrawTriangles(clr, vs, is, nil, driver.CompositeModeClear, driver.FilterNearest, driver.AddressClampToZero)
|
dst.DrawTriangles(clr, vs, is, nil, driver.CompositeModeClear, driver.FilterNearest, driver.AddressClampToZero)
|
||||||
dst.DrawTriangles(src, vs, is, nil, driver.CompositeModeSourceOver, driver.FilterNearest, driver.AddressClampToZero)
|
dst.DrawTriangles(src, vs, is, nil, driver.CompositeModeSourceOver, driver.FilterNearest, driver.AddressClampToZero)
|
||||||
|
Loading…
Reference in New Issue
Block a user