mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
graphcis: Move IndicesNum from opengl to graphics
This commit is contained in:
parent
07ae1db0dd
commit
09c8516545
@ -23,7 +23,10 @@ type verticesBackend struct {
|
||||
head int
|
||||
}
|
||||
|
||||
const VertexFloatNum = 10
|
||||
const (
|
||||
IndicesNum = (1 << 16) / 3 * 3 // Adjust num for triangles.
|
||||
VertexFloatNum = 10
|
||||
)
|
||||
|
||||
func (v *verticesBackend) slice(n int) []float32 {
|
||||
const num = 1024
|
||||
|
@ -89,7 +89,7 @@ func (q *commandQueue) appendIndices(indices []uint16, offset uint16) {
|
||||
}
|
||||
|
||||
func (q *commandQueue) doEnqueueDrawImageCommand(dst, src *Image, nvertices, nindices int, color *affine.ColorM, mode graphics.CompositeMode, filter graphics.Filter, forceNewCommand bool) {
|
||||
if nindices > opengl.IndicesNum {
|
||||
if nindices > graphics.IndicesNum {
|
||||
panic("not implemented for too many indices")
|
||||
}
|
||||
if !forceNewCommand && 0 < len(q.commands) {
|
||||
@ -113,12 +113,12 @@ func (q *commandQueue) doEnqueueDrawImageCommand(dst, src *Image, nvertices, nin
|
||||
|
||||
// EnqueueDrawImageCommand enqueues a drawing-image command.
|
||||
func (q *commandQueue) EnqueueDrawImageCommand(dst, src *Image, vertices []float32, indices []uint16, color *affine.ColorM, mode graphics.CompositeMode, filter graphics.Filter) {
|
||||
if len(indices) > opengl.IndicesNum {
|
||||
if len(indices) > graphics.IndicesNum {
|
||||
panic("not reached")
|
||||
}
|
||||
|
||||
split := false
|
||||
if q.tmpNumIndices+len(indices) > opengl.IndicesNum {
|
||||
if q.tmpNumIndices+len(indices) > graphics.IndicesNum {
|
||||
q.tmpNumIndices = 0
|
||||
q.nextIndex = 0
|
||||
split = true
|
||||
@ -155,10 +155,10 @@ func (q *commandQueue) Flush() {
|
||||
ne := 0
|
||||
nc := 0
|
||||
for _, c := range q.commands {
|
||||
if c.NumIndices() > opengl.IndicesNum {
|
||||
if c.NumIndices() > graphics.IndicesNum {
|
||||
panic("not reached")
|
||||
}
|
||||
if ne+c.NumIndices() > opengl.IndicesNum {
|
||||
if ne+c.NumIndices() > graphics.IndicesNum {
|
||||
break
|
||||
}
|
||||
nv += c.NumVertices()
|
||||
|
@ -54,7 +54,7 @@ func (a *arrayBufferLayout) totalBytes() int {
|
||||
|
||||
// newArrayBuffer creates OpenGL's buffer object for the array buffer.
|
||||
func (a *arrayBufferLayout) newArrayBuffer() buffer {
|
||||
return theContext.newArrayBuffer(a.totalBytes() * IndicesNum)
|
||||
return theContext.newArrayBuffer(a.totalBytes() * graphics.IndicesNum)
|
||||
}
|
||||
|
||||
// enable binds the array buffer the given program to use the array buffer.
|
||||
@ -144,8 +144,7 @@ var (
|
||||
)
|
||||
|
||||
const (
|
||||
IndicesNum = (1 << 16) / 3 * 3 // Adjust num for triangles.
|
||||
maxTriangles = IndicesNum / 3
|
||||
maxTriangles = graphics.IndicesNum / 3
|
||||
maxQuads = maxTriangles / 2
|
||||
)
|
||||
|
||||
@ -239,7 +238,7 @@ func (s *openGLState) reset() error {
|
||||
// Note that the indices passed to NewElementArrayBuffer is not under GC management
|
||||
// in opengl package due to unsafe-way.
|
||||
// See NewElementArrayBuffer in context_mobile.go.
|
||||
s.elementArrayBuffer = theContext.newElementArrayBuffer(IndicesNum * 2)
|
||||
s.elementArrayBuffer = theContext.newElementArrayBuffer(graphics.IndicesNum * 2)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user