コード例 #1
0
 public static void ReleaseBuffer(RendererBuffer buffer)
 {
     if (buffer != null)
     {
         freeBuffers.Enqueue(buffer);
     }
 }
コード例 #2
0
        public void Calculate(Chunk chunk)
        {
            var tessellator = new Tessellator();

            foreach (var tileEntity in chunk.GetTileEntities())
            {
                if (tileEntity == null)
                {
                    continue;
                }

                var ax  = tileEntity.TilePosition.X * 16.0f;
                var ay  = tileEntity.TilePosition.Y * 16.0f;
                var aax = ax - ay;
                var aay = (ax + ay) / 2;

                var color = Color.White;
                if (tileEntity.Tile.GetLayer().Transparency < 1.0f)
                {
                    var aColor = color.A * tileEntity.Tile.GetLayer().Transparency;
                    color = Color.FromArgb((int)aColor, color.R, color.G, color.B);
                }


                tessellator.Draw(new Vector3(
                                     aax - tileEntity.Tile.GetLayer().Origin.X,
                                     aay - tileEntity.Tile.GetLayer().Origin.Y - (tileEntity.TilePosition.Z * 16.0f), 1),
                                 tileEntity.Tile.GetLayer().SourceRectangle, color);
            }

            _dirty  = false;
            _buffer = GraphicsManager.GetBuffer(tessellator.GetBufferData());
        }
コード例 #3
0
        public static RendererBuffer GetBuffer(BufferData data)
        {
            RendererBuffer rendererBuffer;

            if (freeBuffers.Count > 0)
            {
                rendererBuffer = freeBuffers.Dequeue();
            }
            else
            {
                rendererBuffer = new RendererBuffer();
            }
            rendererBuffer.RegisterBufferData(data);
            return(rendererBuffer);
        }