void DrawGraph()
    {
        float maxtime = 0;

        for (int i = 0; i < MaxCount; i++)
        {
            float v = dtHistory[i];
            if (v > maxtime)
            {
                maxtime = v;
            }
        }
        int historyheight = 80;
        int posx          = 25;
        int posy          = m.GetWindowHeight() - historyheight - 20;

        int[] colors = new int[2];
        colors[0] = Game.ColorFromArgb(255, 0, 0, 0);
        colors[1] = Game.ColorFromArgb(255, 255, 0, 0);
        int linecolor = Game.ColorFromArgb(255, 255, 255, 255);

        for (int i = 0; i < MaxCount; i++)
        {
            float time = dtHistory[i];
            time = (time * 60) * historyheight;
            int c = InterpolationCi.InterpolateColor(m.GetPlatform(), (one * i) / MaxCount, colors, 2);
            todraw[i].x1        = posx + i;
            todraw[i].y1        = posy - time;
            todraw[i].width     = 1;
            todraw[i].height    = time;
            todraw[i].inAtlasId = null;
            todraw[i].color     = c;
        }
        m.Draw2dTextures(todraw, MaxCount, m.WhiteTexture());

        m.Draw2dTexture(m.WhiteTexture(), posx, posy - historyheight, MaxCount, 1, null, linecolor);
        m.Draw2dTexture(m.WhiteTexture(), posx, posy - historyheight * (one * 60 / 75), MaxCount, 1, null, linecolor);
        m.Draw2dTexture(m.WhiteTexture(), posx, posy - historyheight * (one * 60 / 30), MaxCount, 1, null, linecolor);
        m.Draw2dTexture(m.WhiteTexture(), posx, posy - historyheight * (one * 60 / 150), MaxCount, 1, null, linecolor);
        m.Draw2dText("60", posx, posy - historyheight * (one * 60 / 60), 6);
        m.Draw2dText("75", posx, posy - historyheight * (one * 60 / 75), 6);
        m.Draw2dText("30", posx, posy - historyheight * (one * 60 / 30), 6);
        m.Draw2dText("150", posx, posy - historyheight * (one * 60 / 150), 6);
    }
Exemple #2
0
    void DrawFpsGraph(int posx, int posy)
    {
        // general size settings
        const int historyheight = 80;

        // color settings
        int color_graph      = Game.ColorFromArgb(128, 220, 20, 20);
        int color_outofrange = Game.ColorFromArgb(128, 255, 255, 0);
        int color_lines      = Game.ColorFromArgb(255, 255, 255, 255);

        posy += historyheight;

        // draw graph
        DrawGraph(posx, posy, MaxCount, historyheight, dtHistory, color_graph, color_outofrange);

        // draw legend
        m.Draw2dTexture(m.WhiteTexture(), posx, posy - HISTORY_FPS_SCALE, MaxCount, 1, null, color_lines);
        m.Draw2dTexture(m.WhiteTexture(), posx, posy - HISTORY_FPS_SCALE * (one * 60 / 30), MaxCount, 1, null, color_lines);
        m.Draw2dText("60", posx, posy - HISTORY_FPS_SCALE * (one * 60 / 60), displayFont);
        m.Draw2dText("30", posx, posy - HISTORY_FPS_SCALE * (one * 60 / 30), displayFont);
        m.Draw2dText("FPS", posx, posy - historyheight, displayFontHeadings);
    }