示例#1
0
        /// <inheritdoc />
        protected override void OnPaint(object sender, NvgContext e)
        {
            base.OnPaint(sender, e);

            e.FillColor(NanoVg.Rgba(ForeColor));
            e.FontFace(Font.Family);
            e.FontSize(Font.Size);
            e.TextAlign(NvgAlign.Left | NvgAlign.Top);
            e.Text(ClientLocation.X, ClientLocation.Y, Text);
        }
示例#2
0
        public virtual void Render(Flat6Engine engine, NvgContext context, FrameEventArgs e)
        {
            _fpsGraph.UpdateGraph((float)engine.Window.RenderTime);

            context.FillColor(NanoVg.Rgba(255, 255, 255, 255));
            context.FontFace("engine_mono");
            context.FontSize(18);
            context.TextAlign(NvgAlign.Top | NvgAlign.Left);

            _fpsGraph.RenderGraph(context, 3, 3);
            _tpsGraph.RenderGraph(context, 3, 45);
        }
示例#3
0
        /// <inheritdoc />
        protected override void OnPaint(object sender, NvgContext e)
        {
            base.OnPaint(sender, e);

            e.BeginPath();
            e.Circle(ClientLocation.X + Size.Width / 2f, ClientLocation.Y + Size.Height / 2f, Size.Width / 2f);

            e.FillColor(Lit ? NanoVg.Rgba(ActiveColor) : NanoVg.Rgba(0xFF475054));
            e.Fill();

            e.StrokeColor(NanoVg.Rgba(0xFF192025));
            e.Stroke();
        }
示例#4
0
        /// <inheritdoc />
        protected override void OnPaint(object sender, NvgContext e)
        {
            base.OnPaint(sender, e);

            e.BeginPath();
            e.RoundedRect(ClientLocation.X, ClientLocation.Y, Size.Width, Size.Height, 2);

            e.StrokeColor(NanoVg.Rgba(43, 51, 55, 255));
            e.Stroke();

            e.FillColor(NanoVg.Rgba(ForeColor));
            e.FontFace(Font.Family);
            e.FontSize(Font.Size);
            e.TextAlign(NvgAlign.Baseline | NvgAlign.Left);
            e.Text(ClientLocation.X, ClientLocation.Y - 3, Text);
        }
        /// <inheritdoc />
        protected override void OnPaint(object sender, NvgContext e)
        {
            base.OnPaint(sender, e);

            e.BeginPath();
            e.Circle(ClientLocation.X + 7, ClientLocation.Y + 7, 7);

            e.FillColor(Checked ? NanoVg.Rgba(ActiveColor) : NanoVg.Rgba(0xFF475054));
            e.Fill();

            e.StrokeColor(NanoVg.Rgba(0xFF192025));
            e.Stroke();

            e.FillColor(NanoVg.Rgba(ForeColor));
            e.FontFace(Font.Family);
            e.FontSize(Font.Size);
            e.TextAlign(NvgAlign.Left | NvgAlign.Middle);
            e.Text(ClientLocation.X + 18, ClientLocation.Y + 7.5f, Text);
        }
示例#6
0
        /// <inheritdoc />
        protected override void OnPaint(object sender, NvgContext e)
        {
            float x = Location.X;
            float y = Location.Y;

            e.BeginPath();
            e.Rect(x, y, Width, Height);
            e.FillColor(NanoVg.Rgba(255, 255, 255, 64));
            e.Fill();

            x += FrameWidth;
            y += FrameWidth;

            var usableWidth  = Width - 2 * FrameWidth;
            var usableHeight = Height - 2 * FrameWidth;


            var i    = 0;
            var hPos = 0f;

            e.FontSize(15);
            e.FontFace("sans");
            e.TextAlign(NvgAlign.Left | NvgAlign.Top);

            foreach (var pair in _profiles)
            {
                var perc     = pair.Value.Average.GetAverage() / _totalTime;
                var barWidth = perc * usableWidth;

                e.FillColor(NanoVg.Rgba(Colors[i % Colors.Length]));

                e.BeginPath();
                e.Rect(x + hPos, y, barWidth, usableHeight);
                e.Fill();

                e.Text(x + hPos, y + Height + 15 * i, $"{perc:N2} {pair.Key}");

                hPos += barWidth;
                i++;
            }

            base.OnPaint(sender, e);
        }
示例#7
0
        /// <inheritdoc />
        protected override void OnPaint(object sender, NvgContext e)
        {
            base.OnPaint(sender, e);

            e.BeginPath();
            e.RoundedRect(ClientLocation.X, ClientLocation.Y, Size.Width, Size.Height, 2);

            e.FillColor(Checked ? NanoVg.Rgba(ActiveColor) : NanoVg.Rgba(0xFF475054));
            e.Fill();

            e.StrokeColor(NanoVg.Rgba(0xFF192025));
            e.Stroke();

            e.FillColor(NanoVg.Rgba(ForeColor));
            e.FontFace(Font.Family);
            e.FontSize(Font.Size);
            e.TextAlign(NvgAlign.Left | NvgAlign.Middle);
            e.Text(ClientLocation.X + Size.Width + 4, ClientLocation.Y + Size.Height / 2f, Text);
        }
示例#8
0
        /// <inheritdoc />
        protected override void OnPaint(object sender, NvgContext e)
        {
            base.OnPaint(sender, e);

            e.BeginPath();
            e.RoundedRect(ClientLocation.X, ClientLocation.Y, Size.Width, Size.Height, 2);

            if (Active)
            {
                e.FillPaint(e.LinearGradient(ClientLocation.X, ClientLocation.Y, ClientLocation.X,
                                             ClientLocation.Y + Size.Height, NanoVg.Rgba(0xFF323B40), NanoVg.Rgba(0xFF323B40)));
            }
            else
            {
                e.FillPaint(e.LinearGradient(ClientLocation.X, ClientLocation.Y, ClientLocation.X,
                                             ClientLocation.Y + Size.Height, NanoVg.Rgba(0xFF50595E), NanoVg.Rgba(0xFF2B3337)));
            }
            e.Fill();

            e.StrokeColor(NanoVg.Rgba(0xFF192025));
            e.Stroke();

            e.BeginPath();
            e.RoundedRect(ClientLocation.X + 1, ClientLocation.Y + 1, Size.Width - 2, Size.Height - 2, 1);

            if (Active)
            {
                e.StrokeColor(NanoVg.Rgba(0xFF293034));
            }
            else
            {
                e.StrokePaint(e.LinearGradient(ClientLocation.X, ClientLocation.Y, ClientLocation.X,
                                               ClientLocation.Y + Size.Height, NanoVg.Rgba(0xFF6E757B), NanoVg.Rgba(0xFF323B40)));
            }
            e.Stroke();

            e.FillColor(NanoVg.Rgba(ForeColor));
            e.FontFace(Font.Family);
            e.FontSize(Font.Size);
            e.TextAlign(NvgAlign.Center | NvgAlign.Middle);
            e.Text(ClientLocation.X + Size.Width / 2, ClientLocation.Y + Size.Height / 2, Text);
        }
        public void Render(Matrix4 model, Matrix4 view, Matrix4 projection)
        {
            _framebuffer.Use();
            GL.PushMatrix();

            GL.Clear(ClearBufferMask.ColorBufferBit |
                     ClearBufferMask.DepthBufferBit |
                     ClearBufferMask.StencilBufferBit);

            GL.Color3(Color.White);

            // Set up uniforms
            _uTint.Value          = TintColor;
            _uLightPos.Value      = LightPosition;
            _uMatModel.Value      = model;
            _uMatView.Value       = view;
            _uMatProjection.Value = projection;
            _uSamples.Value       = _framebuffer.Samples;
            _uTexRandom.Value     = 1;

            GL.ActiveTexture(TextureUnit.Texture1);
            GL.BindTexture(TextureTarget.Texture2D, _texRandom);

            // Engage shader, render, disengage
            _shaderModel.Use(_uTint, _uLightPos, _uMatModel, _uMatView, _uMatProjection, _uSamples, _uTexRandom);

            foreach (var chunk in Chunks)
            {
                chunk?.Draw();
            }

            _shaderScreen.Release();

            // Render the ocean
            GL.Color3(Color.MediumBlue);

            var waterLevel = _generator.GetWaterLevel();

            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadMatrix(ref projection);
            GL.MatrixMode(MatrixMode.Modelview);
            var mat = view * model;

            GL.LoadMatrix(ref mat);

            GL.Begin(PrimitiveType.Quads);
            GL.Normal3(Vector3.UnitY);
            GL.Vertex3(-1, waterLevel - 0.4, -1);
            GL.Vertex3(SideLength * 16 - 1, waterLevel - 0.4, -1);
            GL.Vertex3(SideLength * 16 - 1, waterLevel - 0.4, SideLength * 16 - 1);
            GL.Vertex3(-1, waterLevel - 0.4, SideLength * 16 - 1);
            GL.End();

            GL.PopMatrix();
            _framebuffer.Release();

            _framebufferUi.Use();
            GL.ClearColor(0, 0, 0, 0);
            GL.Clear(ClearBufferMask.ColorBufferBit |
                     ClearBufferMask.DepthBufferBit |
                     ClearBufferMask.StencilBufferBit);

            _nvg.BeginFrame(_window.Width, _window.Height, 1);
            _nvg.Save();

            _nvg.FillColor(NanoVg.Rgba(255, 255, 255, 255));
            _nvg.FontFace("sans");
            _nvg.FontSize(18);
            _nvg.TextAlign(NvgAlign.Top | NvgAlign.Left);

            _perfGraphFps.RenderGraph(_nvg, 4, 4);

            _nvg.Restore();

            _ui.Render(this, _nvg);

            _nvg.EndFrame();
            _framebufferUi.Release();

            _uWidth.Value     = _window.Width;
            _uHeight.Value    = _window.Height;
            _uTexColor.Value  = 0;
            _uTexUi.Value     = 1;
            _uSamples.Value   = _framebuffer.Samples;
            _uSamplesUi.Value = _framebufferUi.Samples;

            _shaderScreen.Use(_uWidth, _uHeight, _uTexColor, _uTexUi, _uSamples, _uSamplesUi);
            DrawFullscreenQuad(_framebuffer.TextureId, _framebufferUi.TextureId);
            _shaderScreen.Release();
        }
示例#10
0
        public static void RenderGraph(NvgContext vg, float x, float y)
        {
            int         i;
            string      str;
            var         avg = GetGraphAverage();
            const float w   = 200;
            const float h   = 35;

            vg.BeginPath();
            vg.Rect(x, y, w, h);
            vg.FillColor(NanoVg.Rgba(0, 0, 0, 128));
            vg.Fill();

            vg.BeginPath();
            vg.MoveTo(x, y + h);
            if (_style == (int)GraphRenderStyle.Fps)
            {
                for (i = 0; i < GraphHistoryCount; i++)
                {
                    var   v = 1.0f / (0.00001f + _values[(_head + i) % GraphHistoryCount]);
                    float vx, vy;
                    if (v > 80.0f)
                    {
                        v = 80.0f;
                    }
                    vx = x + (float)i / (GraphHistoryCount - 1) * w;
                    vy = y + h - v / 80.0f * h;
                    vg.LineTo(vx, vy);
                }
            }
            else if (_style == (int)GraphRenderStyle.Percent)
            {
                for (i = 0; i < GraphHistoryCount; i++)
                {
                    var   v = _values[(_head + i) % GraphHistoryCount] * 1.0f;
                    float vx, vy;
                    if (v > 100.0f)
                    {
                        v = 100.0f;
                    }
                    vx = x + (float)i / (GraphHistoryCount - 1) * w;
                    vy = y + h - v / 100.0f * h;
                    vg.LineTo(vx, vy);
                }
            }
            else
            {
                for (i = 0; i < GraphHistoryCount; i++)
                {
                    var   v = _values[(_head + i) % GraphHistoryCount] * 1000.0f;
                    float vx, vy;
                    if (v > 20.0f)
                    {
                        v = 20.0f;
                    }
                    vx = x + (float)i / (GraphHistoryCount - 1) * w;
                    vy = y + h - v / 20.0f * h;
                    vg.LineTo(vx, vy);
                }
            }
            vg.LineTo(x + w, y + h);
            vg.FillColor(NanoVg.Rgba(255, 192, 0, 128));
            vg.Fill();

            vg.FontFace("sans");

            if (_name[0] != '\0')
            {
                vg.FontSize(14.0f);
                vg.TextAlign(NvgAlign.Left | NvgAlign.Top);
                vg.FillColor(NanoVg.Rgba(240, 240, 240, 192));
                vg.Text(x + 3, y + 1, _name);
            }

            if (_style == (int)GraphRenderStyle.Fps)
            {
                vg.FontSize(18.0f);
                vg.TextAlign(NvgAlign.Right | NvgAlign.Top);
                vg.FillColor(NanoVg.Rgba(240, 240, 240, 255));
                str = $"{1.0f / avg:0.00} FPS";
                vg.Text(x + w - 3, y + 1, str);

                vg.FontSize(15.0f);
                vg.TextAlign(NvgAlign.Right | NvgAlign.Bottom);
                vg.FillColor(NanoVg.Rgba(240, 240, 240, 160));
                str = $"{avg * 1000.0f:0.00} ms";
                vg.Text(x + w - 3, y + h - 1, str);
            }
            else if (_style == (int)GraphRenderStyle.Percent)
            {
                vg.FontSize(18.0f);
                vg.TextAlign(NvgAlign.Right | NvgAlign.Top);
                vg.FillColor(NanoVg.Rgba(240, 240, 240, 255));
                str = $"{avg * 1.0f:0.0} %";
                vg.Text(x + w - 3, y + 1, str);
            }
            else
            {
                vg.FontSize(18.0f);
                vg.TextAlign(NvgAlign.Right | NvgAlign.Top);
                vg.FillColor(NanoVg.Rgba(240, 240, 240, 255));
                str = $"{avg * 1000.0f:0.00} ms";
                vg.Text(x + w - 3, y + 1, str);
            }
        }
示例#11
0
        public void RenderGraph(NvgContext vg, float x, float y)
        {
            int         i;
            string      str;
            var         avg = GetGraphAverage();
            const float d   = 1 / 60f;
            var         min = GetGraphMin() + d;
            var         max = GetGraphMax() - d;
            const float w   = 100;
            const float h   = 35;

            vg.BeginPath();
            vg.Rect(x, y, w, h);
            vg.FillColor(NanoVg.Rgba(255, 255, 255, 64));
            vg.Fill();

            vg.BeginPath();
            vg.MoveTo(x, y + h);
            switch (Style)
            {
            case GraphRenderStyle.Fps:
                for (i = 0; i < _graphHistoryCount; i++)
                {
                    var v    = _values[(_head + i) % _graphHistoryCount];
                    var vx   = x + (float)i / (_graphHistoryCount - 1) * w;
                    var perc = MathHelper.Clamp((v - min) / (max - min), 0, 1);
                    var vy   = y + h - perc * h;
                    vg.LineTo(vx, vy);
                }
                break;

            case GraphRenderStyle.Raw:
                for (i = 0; i < _graphHistoryCount; i++)
                {
                    var v = _values[(_head + i) % _graphHistoryCount];
                    if (v > 100.0f)
                    {
                        v = 100.0f;
                    }
                    var vx = x + (float)i / (_graphHistoryCount - 1) * w;
                    var vy = y + h - v / 100.0f * h;
                    vg.LineTo(vx, vy);
                }
                break;

            case GraphRenderStyle.Milliseconds:
                for (i = 0; i < _graphHistoryCount; i++)
                {
                    var v = _values[(_head + i) % _graphHistoryCount] * 1000.0f;
                    if (v > 20.0f)
                    {
                        v = 20.0f;
                    }
                    var vx = x + (float)i / (_graphHistoryCount - 1) * w;
                    var vy = y + h - v / 20.0f * h;
                    vg.LineTo(vx, vy);
                }
                break;
            }
            vg.LineTo(x + w, y + h);
            vg.FillColor(NanoVg.Rgba(255, 192, 0, 128));
            vg.Fill();

            var avgPerc = MathHelper.Clamp(1 - (avg - min) / (max - min), 0, 1);

            vg.BeginPath();
            vg.MoveTo(x, y + h - avgPerc * h);
            vg.LineTo(x + w, y + h - avgPerc * h);
            vg.StrokeColor(NanoVg.Rgba(255, 255, 255, 128));
            vg.Stroke();

            vg.FontFace(Font);

            if (Name != null)
            {
                vg.FontSize(14.0f);
                vg.TextAlign(NvgAlign.Left | NvgAlign.Top);
                vg.FillColor(NanoVg.Rgba(240, 240, 240, 192));
                vg.Text(x + 3, y + 1, Name);
            }

            switch (Style)
            {
            case GraphRenderStyle.Fps:
                vg.FontSize(16.0f);
                vg.TextAlign(NvgAlign.Right | NvgAlign.Top);
                vg.FillColor(NanoVg.Rgba(240, 240, 240, 255));
                str = $"{1.0f / avg:0.00} FPS";
                vg.Text(x + w - 3, y + 1, str);

                vg.FontSize(15.0f);
                vg.TextAlign(NvgAlign.Right | NvgAlign.Bottom);
                vg.FillColor(NanoVg.Rgba(240, 240, 240, 160));
                str = $"{avg * 1000.0f:0.00} ms/f";
                vg.Text(x + w - 3, y + h - 1, str);
                break;

            case GraphRenderStyle.Raw:
                vg.FontSize(16.0f);
                vg.TextAlign(NvgAlign.Right | NvgAlign.Top);
                vg.FillColor(NanoVg.Rgba(240, 240, 240, 255));
                str = $"{avg:0.00}";
                vg.Text(x + w - 3, y + 1, str);
                break;

            case GraphRenderStyle.Milliseconds:
                vg.FontSize(16.0f);
                vg.TextAlign(NvgAlign.Right | NvgAlign.Top);
                vg.FillColor(NanoVg.Rgba(240, 240, 240, 255));
                str = $"{avg * 1000.0f:0.00} ms";
                vg.Text(x + w - 3, y + 1, str);
                break;
            }
        }
示例#12
0
        /// <inheritdoc />
        protected override void OnPaint(object sender, NvgContext e)
        {
            int i;

            float x = Location.X;
            float y = Location.Y;

            e.BeginPath();
            e.Rect(x, y, Width, Height);
            e.FillColor(NanoVg.Rgba(255, 255, 255, 64));
            e.Fill();

            e.BeginPath();

            if (Fill)
            {
                e.MoveTo(x, y + Height);
            }
            else
            {
                var v0 = _values[_head % HistoryCount];
                v0 = F6Math.RemapClamp(v0, Min, Max, 0, Height);
                e.MoveTo(x, y + Height - v0);
            }

            for (i = 0; i < HistoryCount; i++)
            {
                var v  = _values[(_head + i) % HistoryCount];
                var vx = x + (float)i / (HistoryCount - 1) * Width;
                var vy = y + Height - F6Math.RemapClamp(v, Min, Max, 0, Height);
                e.LineTo(vx, vy);
            }

            if (Fill)
            {
                e.LineTo(x + Width, y + Height);
                e.FillColor(NanoVg.Rgba(Color));
                e.Fill();
            }
            else
            {
                e.StrokeColor(NanoVg.Rgba(Color));
                e.Stroke();
            }

            var avgY = F6Math.RemapClamp(_avg, Min, Max, 0, Height);

            e.BeginPath();
            e.MoveTo(x, y + Height - avgY);
            e.LineTo(x + Width, y + Height - avgY);
            e.StrokeColor(NanoVg.Rgba(255, 255, 255, 128));
            e.Stroke();

            e.FontFace(FontFamily);

            if (Title != null)
            {
                e.FontSize(14.0f);
                e.TextAlign(NvgAlign.Left | NvgAlign.Top);
                e.FillColor(NanoVg.Rgba(240, 240, 240, 192));
                e.Text(x + 3, y + 1, Title);
            }

            e.FontSize(16.0f);
            e.TextAlign(NvgAlign.Right | NvgAlign.Top);
            e.FillColor(NanoVg.Rgba(240, 240, 240, 255));
            var str = string.Format(Number, _avg.ToString(NumberFormatStyle));

            e.Text(x + Width - 3, y + 1, str);

            if (Unit != null)
            {
                e.FontSize(15.0f);
                e.TextAlign(NvgAlign.Right | NvgAlign.Bottom);
                e.FillColor(NanoVg.Rgba(240, 240, 240, 160));
                e.Text(x + Width - 3, y + Height - 1, Unit);
            }

            base.OnPaint(sender, e);
        }