mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/graphics: rename constants
This commit is contained in:
parent
ce9274a29d
commit
31273c875f
@ -2742,7 +2742,7 @@ func TestIndicesOverflow(t *testing.T) {
|
|||||||
|
|
||||||
op := &ebiten.DrawTrianglesOptions{}
|
op := &ebiten.DrawTrianglesOptions{}
|
||||||
vs := make([]ebiten.Vertex, 3)
|
vs := make([]ebiten.Vertex, 3)
|
||||||
is := make([]uint16, graphics.MaxVertexCount/3*3)
|
is := make([]uint16, graphics.MaxVerticesCount/3*3)
|
||||||
dst.DrawTriangles(vs, is, src, op)
|
dst.DrawTriangles(vs, is, src, op)
|
||||||
|
|
||||||
// Cause an overflow for indices.
|
// Cause an overflow for indices.
|
||||||
@ -2813,7 +2813,7 @@ func TestVerticesOverflow(t *testing.T) {
|
|||||||
src.Fill(color.White)
|
src.Fill(color.White)
|
||||||
|
|
||||||
op := &ebiten.DrawTrianglesOptions{}
|
op := &ebiten.DrawTrianglesOptions{}
|
||||||
vs := make([]ebiten.Vertex, graphics.MaxVertexCount-1)
|
vs := make([]ebiten.Vertex, graphics.MaxVerticesCount-1)
|
||||||
is := make([]uint16, 3)
|
is := make([]uint16, 3)
|
||||||
dst.DrawTriangles(vs, is, src, op)
|
dst.DrawTriangles(vs, is, src, op)
|
||||||
|
|
||||||
@ -2885,7 +2885,7 @@ func TestTooManyVertices(t *testing.T) {
|
|||||||
src.Fill(color.White)
|
src.Fill(color.White)
|
||||||
|
|
||||||
op := &ebiten.DrawTrianglesOptions{}
|
op := &ebiten.DrawTrianglesOptions{}
|
||||||
vs := make([]ebiten.Vertex, graphics.MaxVertexCount+1)
|
vs := make([]ebiten.Vertex, graphics.MaxVerticesCount+1)
|
||||||
is := make([]uint16, 3)
|
is := make([]uint16, 3)
|
||||||
dst.DrawTriangles(vs, is, src, op)
|
dst.DrawTriangles(vs, is, src, op)
|
||||||
|
|
||||||
|
@ -54,12 +54,12 @@ const (
|
|||||||
const (
|
const (
|
||||||
VertexFloatCount = 8
|
VertexFloatCount = 8
|
||||||
|
|
||||||
// MaxVertexCount is the maximum number of vertices for one draw call.
|
// MaxVerticesCount is the maximum number of vertices for one draw call.
|
||||||
// This value is 2^16 - 1 = 65535, as the index type is uint16.
|
// This value is 2^16 - 1 = 65535, as the index type is uint16.
|
||||||
// This value cannot be exactly 2^16 == 65536 especially with WebGL 2, as 65536th vertex is not rendered correctly.
|
// This value cannot be exactly 2^16 == 65536 especially with WebGL 2, as 65536th vertex is not rendered correctly.
|
||||||
// See https://registry.khronos.org/webgl/specs/latest/2.0/#5.18 .
|
// See https://registry.khronos.org/webgl/specs/latest/2.0/#5.18 .
|
||||||
MaxVertexCount = math.MaxUint16
|
MaxVerticesCount = math.MaxUint16
|
||||||
MaxVertexFloatCount = MaxVertexCount * VertexFloatCount
|
MaxVertexFloatsCount = MaxVerticesCount * VertexFloatCount
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -86,14 +86,14 @@ func (q *commandQueue) appendIndices(indices []uint16, offset uint16) {
|
|||||||
|
|
||||||
// mustUseDifferentVertexBuffer reports whether a different vertex buffer must be used.
|
// mustUseDifferentVertexBuffer reports whether a different vertex buffer must be used.
|
||||||
func mustUseDifferentVertexBuffer(nextNumVertexFloats int) bool {
|
func mustUseDifferentVertexBuffer(nextNumVertexFloats int) bool {
|
||||||
return nextNumVertexFloats > graphics.MaxVertexFloatCount
|
return nextNumVertexFloats > graphics.MaxVertexFloatsCount
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnqueueDrawTrianglesCommand enqueues a drawing-image command.
|
// EnqueueDrawTrianglesCommand enqueues a drawing-image command.
|
||||||
func (q *commandQueue) EnqueueDrawTrianglesCommand(dst *Image, srcs [graphics.ShaderImageCount]*Image, offsets [graphics.ShaderImageCount - 1][2]float32, vertices []float32, indices []uint16, blend graphicsdriver.Blend, dstRegion, srcRegion graphicsdriver.Region, shader *Shader, uniforms []uint32, evenOdd bool) {
|
func (q *commandQueue) EnqueueDrawTrianglesCommand(dst *Image, srcs [graphics.ShaderImageCount]*Image, offsets [graphics.ShaderImageCount - 1][2]float32, vertices []float32, indices []uint16, blend graphicsdriver.Blend, dstRegion, srcRegion graphicsdriver.Region, shader *Shader, uniforms []uint32, evenOdd bool) {
|
||||||
if len(vertices) > graphics.MaxVertexFloatCount {
|
if len(vertices) > graphics.MaxVertexFloatsCount {
|
||||||
// The last part cannot be specified by indices. Just omit them.
|
// The last part cannot be specified by indices. Just omit them.
|
||||||
vertices = vertices[:graphics.MaxVertexFloatCount]
|
vertices = vertices[:graphics.MaxVertexFloatsCount]
|
||||||
}
|
}
|
||||||
|
|
||||||
split := false
|
split := false
|
||||||
|
@ -133,7 +133,7 @@ func (i *Image) WritePixels(pix []byte, x, y, width, height int) {
|
|||||||
i.dotsBuffer[[2]int{x, y}] = clr
|
i.dotsBuffer[[2]int{x, y}] = clr
|
||||||
|
|
||||||
// One square requires 6 indices (= 2 triangles).
|
// One square requires 6 indices (= 2 triangles).
|
||||||
if len(i.dotsBuffer) >= graphics.MaxVertexCount/6 {
|
if len(i.dotsBuffer) >= graphics.MaxVerticesCount/6 {
|
||||||
i.flushDotsBufferIfNeeded()
|
i.flushDotsBufferIfNeeded()
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user