protected override void OnRenderFrame(FrameEventArgs args) { _frameCounter += args.Time; base.OnRenderFrame(args); Matrix4 vp = _camera.View * _projection; GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); _shader.Use(); _shader.UploadMatrix("viewproj", ref vp); _shader.UploadColor("color", Color4.White); Matrix4 m = _plane.Model; _shader.UploadMatrix("model", ref m); _plane.Draw(); m = debugDraw.Model; _shader.UploadMatrix("model", ref m); debugDraw.Draw(); _fontRenderer.DrawText(_frameTimeText, new Vector2(0.0f, 0.0f), 22.0f); _fontRenderer.EndRender(); SwapBuffers(); if (_frameCounter >= 1.0f) { _frameTimeText = $"Frame Time: {args.Time * 1000.0f}ms"; _frameCounter = 0.0f; } }
protected override void OnRenderFrame(FrameEventArgs args) { base.OnRenderFrame(args); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); Matrix4 vp = (_debugCam ? _debugView : _camera.View) * _projection; shader.Use(); shader.UploadMatrix("viewproj", ref vp); shader.UploadMatrix("model", ref _model); shader.UploadColor("color", Color4.White); GL.BindVertexArray(vao); GL.DrawArrays(PrimitiveType.Triangles, 0, 36); GL.BindVertexArray(0); if (_debugCam) { GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); shader.Use(); shader.UploadMatrix("viewproj", ref vp); shader.UploadMatrix("model", ref _debugModel); shader.UploadColor("color", Color4.White); GL.BindVertexArray(_debugVao); GL.BindBuffer(BufferTarget.ArrayBuffer, _debugVbo); GL.DrawArrays(PrimitiveType.Triangles, 0, 36); GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); GL.LineWidth(4.0f); GL.BindVertexArray(_debugCamCoordsVao); GL.BindBuffer(BufferTarget.ArrayBuffer, _debugCamCoords); float[] v = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, _camera.Forward.X, _camera.Forward.Y, _camera.Forward.Z, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, _camera.Up.X, _camera.Up.Y, _camera.Up.Z, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, _camera.Right.X, _camera.Right.Y, _camera.Right.Z, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, _camera.Direction.X, _camera.Direction.Y, _camera.Direction.Z, 1.0f, 1.0f, 0.0f }; GL.BufferSubData(BufferTarget.ArrayBuffer, (IntPtr)(0), 48 * sizeof(float), v); GL.DrawArrays(PrimitiveType.Lines, 0, 8); GL.BindVertexArray(0); GL.LineWidth(1.0f); } fontRenderer.DrawText($"Cam pos: {_camera.Position}", new Vector2(0.0f, 20.0f), 32.0f); fontRenderer.EndRender(); SwapBuffers(); }
public virtual void Render(double time) { systems?.Run(); fontRenderer.EndRender(); }