Exemplo n.º 1
0
            public void DrawSprites(GroupedElementVertexArray vertexData, int numVertices)
            {
                Array.Copy(vertexData.positions, Vertices, numVertices);
                Array.Copy(vertexData.texcoords, UVs, numVertices);
                Array.Copy(vertexData.colors, Colors, numVertices);

                Array.Clear(Vertices, numVertices, Vertices.Length - numVertices);

                DrawFunction(this);
            }
Exemplo n.º 2
0
        internal void DrawSpritePrimitives(GroupedElementVertexArray vertexData, int numVertices)
        {
            Material mat = activeEffect.Material;

            mat.mainTexture = Textures[0].UnityTexture;
            activeEffect.OnApplyPostTexture();
            mat.SetPass(0);

            SpriteMeshHolder mesh = spriteMeshPool.Get(numVertices / 4);

            mesh.DrawSprites(vertexData, numVertices);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Resize and recreate the missing indices for the index and vertex position color buffers.
        /// </summary>
        /// <param name="numBatchItems"></param>
        private void EnsureArrayCapacity(int numBatchItems)
        {
            //int neededCapacity = 6 * numBatchItems;
            //if (_index != null && neededCapacity <= _index.Length)
            //{
            //	// Short circuit out of here because we have enough capacity.
            //	return;
            //}
            //short[] newIndex = new short[6 * numBatchItems];
            //int start = 0;
            //if (_index != null)
            //{
            //	_index.CopyTo(newIndex, 0);
            //	start = _index.Length / 6;
            //}
            //for (var i = start; i < numBatchItems; i++)
            //{
            //	/*
            //	 *  TL    TR
            //	 *   0----1 0,1,2,3 = index offsets for vertex indices
            //	 *   |   /| TL,TR,BL,BR are vertex references in SpriteBatchItem.
            //	 *   |  / |
            //	 *   | /  |
            //	 *   |/   |
            //	 *   2----3
            //	 *  BL    BR
            //	 */
            //	// Triangle 1
            //	newIndex[i * 6 + 0] = (short)(i * 4);
            //	newIndex[i * 6 + 1] = (short)(i * 4 + 1);
            //	newIndex[i * 6 + 2] = (short)(i * 4 + 2);
            //	// Triangle 2
            //	newIndex[i * 6 + 3] = (short)(i * 4 + 1);
            //	newIndex[i * 6 + 4] = (short)(i * 4 + 3);
            //	newIndex[i * 6 + 5] = (short)(i * 4 + 2);
            //}
            //_index = newIndex;

            //_vertexArray = new VertexPositionColorTexture[4 * numBatchItems];

            int requiredSize = 4 * numBatchItems;

            if (_vertexArray.Size < requiredSize)
            {
                _vertexArray = new GroupedElementVertexArray(requiredSize);
            }
        }