Beispiel #1
0
        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();
        }
Beispiel #2
0
        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();
        }
Beispiel #3
0
        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();
                }
            }
        }
        public override void Draw()
        {
            base.Draw();

            // Set camera uniforms
            Shader.SetGlobalProperty(@"g_ProjMatrix", ProjectionMatrix);
            Shader.SetGlobalProperty(@"g_ViewMatrix", ViewMatrix);
            Shader.SetGlobalProperty(@"g_InvViewMatrix", InverseViewMatrix);

            // Invert culling
            //GL.CullFace(CullFaceMode.Front); // Flip culling for 3D

            foreach (var child in Children)
            {
                child.Draw();
            }

            // Flush batch before disabling state
            GLWrapper.FlushCurrentBatch();

            // Restore 3D states
            //GL.CullFace(CullFaceMode.Back);
        }