protected virtual void DrawFrame() { if (Root == null) { return; } using (drawMonitor.BeginCollecting(PerformanceCollectionType.GLReset)) { GLWrapper.Reset(Root.DrawSize); GLWrapper.ClearColour(Color4.Black); } while (true) { using (var buffer = DrawRoots.Get(UsageType.Read)) { if (buffer?.Object != null && buffer.FrameId != lastDrawFrameId) { buffer.Object.Draw(null); lastDrawFrameId = buffer.FrameId; break; } } Thread.Sleep(1); } GLWrapper.FlushCurrentBatch(); using (drawMonitor.BeginCollecting(PerformanceCollectionType.SwapBuffer)) Window.SwapBuffers(); }
private void drawLoop() { GLControl.Initialize(); GLWrapper.Initialize(); while (!exitRequested) { DrawMonitor.NewFrame(DrawClock); using (DrawMonitor.BeginCollecting(PerformanceCollectionType.Draw)) { GLWrapper.Reset(Size); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); pendingRootNode?.DrawSubTree(); } using (DrawMonitor.BeginCollecting(PerformanceCollectionType.SwapBuffer)) { GLControl.SwapBuffers(); GLControl.Invalidate(); } using (DrawMonitor.BeginCollecting(PerformanceCollectionType.Sleep)) DrawClock.ProcessFrame(); } }
protected virtual void DrawInitialize() { Window.MakeCurrent(); GLWrapper.Initialize(this); setVSyncMode(); GLWrapper.Reset(new Vector2(Window.ClientSize.Width, Window.ClientSize.Height)); GLWrapper.ClearColour(Color4.Black); }
protected virtual void DrawFrame() { using (DrawMonitor.BeginCollecting(PerformanceCollectionType.Draw)) { GLWrapper.Reset(Size); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); using (var buffer = DrawRoots.Get(UsageType.Read)) buffer?.Object?.DrawSubTree(); } }
protected sealed override void OnInitialize() { var window = host.Window; if (window != null) { window.MakeCurrent(); GLWrapper.Initialize(host); GLWrapper.Reset(new Vector2(window.ClientSize.Width, window.ClientSize.Height)); } }
protected virtual void OnIdle(object sender, EventArgs args) { GLWrapper.Reset(); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); UpdateSubTree(); DrawSubTree(); Idle?.Invoke(this, EventArgs.Empty); GLControl.SwapBuffers(); }
protected virtual void DrawFrame() { using (DrawMonitor.BeginCollecting(PerformanceCollectionType.GLReset)) { GLWrapper.Reset(DrawSize); GLWrapper.ClearColour(Color4.Black); } using (var buffer = DrawRoots.Get(UsageType.Read)) buffer?.Object?.Draw(null); GLWrapper.FlushCurrentBatch(); using (DrawMonitor.BeginCollecting(PerformanceCollectionType.SwapBuffer)) Window.SwapBuffers(); }
protected virtual void DrawFrame() { if (Root == null) { return; } while (!exitInitiated) { using (var buffer = DrawRoots.Get(UsageType.Read)) { if (buffer?.Object == null || buffer.FrameId == lastDrawFrameId) { Thread.Sleep(1); continue; } using (drawMonitor.BeginCollecting(PerformanceCollectionType.GLReset)) { GLWrapper.Reset(new Vector2(Window.ClientSize.Width, Window.ClientSize.Height)); GLWrapper.ClearColour(Color4.Black); } buffer.Object.Draw(null); lastDrawFrameId = buffer.FrameId; break; } } GLWrapper.FlushCurrentBatch(); using (drawMonitor.BeginCollecting(PerformanceCollectionType.SwapBuffer)) { Window.SwapBuffers(); if (Window.VSync == VSyncMode.On) { // without glFinish, vsync is basically unplayable due to the extra latency introduced. // we will likely want to give the user control over this in the future as an advanced setting. GL.Finish(); } } }