Exemplo n.º 1
0
        public static void RenderCameras()
        {
            GraphicsDevice.SetRenderTarget(FinalRender);

            int screenWidth  = GraphicsDeviceManager.PreferredBackBufferWidth;
            int screenHeight = GraphicsDeviceManager.PreferredBackBufferHeight;

            Cameras.Sort(new CameraQueueComparer());
            ChangeDrawCall(SpriteSortMode.Deferred, null, BlendState.AlphaBlend, SamplerState.LinearClamp, null, RasterizerState.CullNone);
            foreach (Camera2D camera in Cameras)
            {
                Rectangle renderRegion = new Rectangle((int)(camera.RenderRegion.X * screenWidth),
                                                       (int)(camera.RenderRegion.Y * screenHeight),
                                                       (int)(camera.RenderRegion.Width * screenWidth),
                                                       (int)(camera.RenderRegion.Height * screenHeight));

                SpriteBatch.Draw(camera.renderTarget, renderRegion, Color.White);
            }
            EndDrawCall();
            GraphicsDevice.SetRenderTarget(null);
        }