示例#1
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);
        }
示例#2
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            base.OnRenderFrame(e);

            PerfGraph.UpdateGraph((float)e.Time);

            GL.Viewport(0, 0, Width, Height);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);

            NanoVG.nvgBeginFrame(ctx, Width, Height, 1);

            if (screen)
            {
                screen.Draw(ctx);
            }
            PerfGraph.RenderGraph(ctx, 5, 5);

            NanoVG.nvgEndFrame(ctx);

            this.SwapBuffers();
        }
        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();
        }