Exemple #1
0
        /// <summary>
        /// Set the scissor test rectangle.
        /// </summary>
        /// <param name="rectangle">The new scissor test rectangle, in normalized screen coordinates.</param>
        /// <param name="screen">The screen to apply the test to.</param>
        public static void SetScissorTest(Rectangle rectangle, Screen screen)
        {
            if (rectangle.X < 0 || rectangle.Y < 0 || rectangle.Width < 0 || rectangle.Height < 0)
            {
                throw new ArgumentException("Invalid viewport.");
            }

            if (rectangle == scissorTestArea)
            {
                return;
            }

            RenderQueue.Flush();             // Render batches should use the render settings at the start of the batch
            scissorTestArea = rectangle;

            if (scissorTestArea != null)
            {
                var r = (Rectangle)screen.VirtualToScreen((RectangleF)scissorTestArea.Value);
                GL.Enable(EnableCap.ScissorTest);
                GL.Scissor(r.X, screen.ScreenSize.Y - r.Y - r.Height, r.Width, r.Height);
            }
            else
            {
                ClearScissorTest();
            }
        }
Exemple #2
0
        /// <summary>
        /// Set the viewport.
        /// </summary>
        /// <param name="viewport"></param>
        /// <param name="screen"></param>
        /// <returns></returns>
        public static void SetViewport(Rectangle viewport, Screen screen)
        {
            if (viewport.X < 0 || viewport.Y < 0 || viewport.Width < 0 || viewport.Height < 0)
            {
                throw new ArgumentException("Invalid viewport.");
            }

            viewport = (Rectangle)screen.VirtualToScreen((RectangleF)viewport);

            if (GraphicsDevice.viewport.Equals(viewport))
            {
                return;
            }

            RenderQueue.Flush();             // Render batches should use the render settings at the start of the batch
            GraphicsDevice.viewport = viewport;

            GL.Viewport(viewport.X, screen.ScreenSize.Y - viewport.Y - viewport.Height, viewport.Width, viewport.Height);
        }
Exemple #3
0
 public void End()
 {
     Debug.Assert(hasBegun, "Called End() without calling Begin()");
     RenderQueue.Flush();
     hasBegun = false;
 }