Esempio n. 1
0
        public RenderBatch <TVertex> GetBatch <TVertex>(ITexture texture1, ITexture texture2, IMaterial material, int vertexCount, int indexCount)
            where TVertex : unmanaged
        {
            var atlas1         = texture1?.AtlasTexture;
            var atlas2         = texture2?.AtlasTexture;
            var typedLastBatch = lastBatch as RenderBatch <TVertex>;
            var needMesh       = typedLastBatch == null ||
                                 typedLastBatch.LastVertex + vertexCount > RenderBatchLimits.MaxVertices ||
                                 typedLastBatch.LastIndex + indexCount > RenderBatchLimits.MaxIndices;

            if (needMesh ||
                typedLastBatch.Texture1 != atlas1 ||
                typedLastBatch.Texture2 != atlas2 ||
                typedLastBatch.Material != material ||
                typedLastBatch.Material.PassCount != 1
                )
            {
                typedLastBatch = RenderBatch <TVertex> .Acquire(needMesh?null : typedLastBatch);

                typedLastBatch.Texture1 = atlas1;
                typedLastBatch.Texture2 = atlas2;
                typedLastBatch.Material = material;
                Batches.Add(typedLastBatch);
                lastBatch = typedLastBatch;
            }
            return(typedLastBatch);
        }
Esempio n. 2
0
        private void InitializeVerticesFrom(IRenderBatch useVerticesFrom)
        {
            var asDirectX9Batch = (DirectX9RenderBatch)useVerticesFrom;

            _vertices     = asDirectX9Batch._vertices;
            _vertexCount  = asDirectX9Batch._vertexCount;
            _vertexFormat = asDirectX9Batch._vertexFormat;
            _stride       = asDirectX9Batch._stride;
        }
Esempio n. 3
0
 public void Clear()
 {
     if (lastBatch == null)
     {
         return;
     }
     foreach (var i in Batches)
     {
         i.Release();
     }
     Batches.Clear();
     lastBatch = null;
 }
Esempio n. 4
0
        private void renderBatch(IRenderBatch batch)
        {
            _glUtils.AdjustResolution(batch.Resolution.Width, batch.Resolution.Height);

            var shader = applyObjectShader(batch.Shader);

            foreach (var instruction in batch.Instructions)
            {
                instruction.Render();
                instruction.Release();
            }

            removeObjectShader(shader);
        }
Esempio n. 5
0
 public void Record <TIndex>(TIndex[] indices, IRenderBatch useVerticesFrom) where TIndex : struct
 {
     RecordIndices(indices);
     InitializeVerticesFrom(useVerticesFrom);
 }