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(); }
protected virtual void DrawInitialize() { Window.MakeCurrent(); GLWrapper.Initialize(this); setVSyncMode(); GLWrapper.Reset(new Vector2(Window.ClientSize.Width, Window.ClientSize.Height)); GLWrapper.ClearColour(Color4.Black); }
private void drawChildren(IVertexBatch vertexBatch, Vector2 frameBufferSize) { // Fill the frame buffer with drawn children using (bindFrameBuffer(currentFrameBuffer, frameBufferSize)) { // We need to draw children as if they were zero-based to the top-left of the texture. // We can do this by adding a translation component to our (orthogonal) projection matrix. GLWrapper.PushOrtho(ScreenSpaceDrawRectangle); GLWrapper.ClearColour(BackgroundColour); base.Draw(vertexBatch); GLWrapper.PopOrtho(); } }
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(); } } }