Пример #1
0
 internal static void Dispose(ref VertexBuffer buffer)
 {
     if (buffer != null)
     {
         buffer.Dispose();
         buffer = null;
     }
 }
Пример #2
0
        internal void ProfilerSnapshot()
        {
            VertexBuffer.Dispose(ref profileVertexBuffer);

            t.ResetTransformation();
            FontRenderer f      = FontRenderer.Instance;
            Player       player = World.Instance.Player;

            f.BeginBatch();
            f.CharScale = 1;
            string report = p.Report();
            float  y      = TheGame.Instance.Height - FontRenderer.Instance.LineHeight;

            using (StringReader sr = new StringReader(report))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    f.RenderTextShadow(line, 0, y);
                    y -= f.LineHeight;
                }
            }

            // log...
            y -= f.LineHeight;

            if (World.Instance.PlayerVoxelTrace.Hit)
            {
                Vector4 impactpos = World.Instance.PlayerVoxelTrace.ImpactPosition;
                string  line      = string.Format(GetVectorAsString("impactpos", impactpos));
                f.RenderTextShadow(line, 0, y);
                y -= f.LineHeight;
            }
            else
            {
                f.RenderTextShadow("impactpos", 0, y);
                y -= f.LineHeight;

                Vector3 pos = new Vector3(player.Position.X, player.Position.Y, player.Position.Z);
                if (pos.Y > Chunk.MaxSizeY - 1)
                {
                    pos.Y = Chunk.MaxSizeY - 1;
                }
                else if (pos.Y < 0)
                {
                    pos.Y = 0;
                }
                PositionChunk chunkPos  = PositionChunk.CreateFrom(pos);
                Vector3       chunkPos3 = new Vector3(chunkPos.X, chunkPos.Y, chunkPos.Z);
                f.RenderTextShadow(string.Format(GetVectorAsString("chunkpos", chunkPos3)), 0, y);
                y -= f.LineHeight;
                ChunkCache cache = World.Instance.GetCachedChunks();
                Chunk      c     = cache.GetChunk(chunkPos);
                if (c != null)
                {
                    f.RenderTextShadow(string.Format("chunk.Stage      = {0}", c.Stage.ToString()), 0, y);
                    y -= f.LineHeight;
                    f.RenderTextShadow(string.Format("chunk.col.stage  = {0}", c.Column.Stage.ToString()), 0, y);
                    y -= f.LineHeight;
                    f.RenderTextShadow(string.Format("chunk.col.active = {0}", c.Column.Active.ToString()), 0, y);
                    y -= f.LineHeight;
                    f.RenderTextShadow(string.Format("cache.alleighbors= {0}", cache.AllNeighborColumns(c.Column).Where(cc => cc != null).Count()), 0, y);
                    y -= f.LineHeight;

                    List <Chunk> chunks = new List <Chunk>();
                    for (int i = 0; i < 8; i++)
                    {
                        chunks.Add(cache.GetChunk(new PositionChunk(c.Position.X, i, c.Position.Z)));
                    }
                }
            }
            f.RenderTextShadow(GetVectorAsString("direction", player.Direction), 0, y);

            y -= f.LineHeight;
            f.RenderTextShadow(GetVectorAsString("position", player.Position), 0, y);

            y -= f.LineHeight;
            y -= f.LineHeight;
            string[] lastLines = Log.Instance.Last(70);
            foreach (string line in lastLines)
            {
                f.RenderTextShadow(line, 0, y);
                y -= f.LineHeight;
            }
            f.StopBatch();
            profileVertexBuffer = t.GetVertexBuffer();
        }
Пример #3
0
 public void Dispose()
 {
     VertexBuffer.Dispose(ref buffer);
 }