コード例 #1
0
ファイル: Runner.cs プロジェクト: SweetTini/FrogWorks
 protected Runner(int width, int height, int scale, bool fullscreen)
 {
     Application = this;
     Size        = new Point(width, height).Abs();
     Game        = new GameAdapter(this);
     Display     = new DisplayAdapter(Game, Size, scale, fullscreen);
 }
コード例 #2
0
ファイル: Scene.cs プロジェクト: SweetTini/FrogWorks
        internal void Draw(
            DisplayAdapter display,
            RendererBatch batch,
            out RenderTarget2D renderTarget)
        {
            renderTarget = _renderTarget;

            var projection   = new Rectangle(Point.Zero, display.Size);
            var clearOptions = ClearOptions.Target
                               | ClearOptions.Stencil
                               | ClearOptions.DepthBuffer;

            display.GraphicsDevice.SetRenderTarget(renderTarget);
            display.GraphicsDevice.Viewport = new Viewport(projection);
            display.GraphicsDevice.Clear(clearOptions, ClearColor, 0, 0);

            BeforeDraw(batch);

            Entities.State = ManagerState.ThrowError;
            batch.Configure(transformMatrix: Camera.Matrix);
            batch.Begin();

            foreach (var entity in Entities.OnLayer(null))
            {
                if (entity.IsVisible)
                {
                    entity.DrawInternally(batch);
                }
            }

            batch.End();
            Entities.State = ManagerState.Opened;

            Layers.State = ManagerState.ThrowError;

            foreach (var layer in Layers)
            {
                display.GraphicsDevice.SetRenderTarget(layer.RenderTarget);
                display.GraphicsDevice.Clear(clearOptions, Color.Transparent, 0, 0);

                if (!layer.RenderBeforeMerge)
                {
                    batch.Sprite.Begin(samplerState: SamplerState.PointClamp);
                    batch.Sprite.Draw(renderTarget, Vector2.Zero, Color.White);
                    batch.Sprite.End();
                }

                if (layer.IsVisible)
                {
                    layer.DrawInternally(batch);
                }

                display.GraphicsDevice.SetRenderTarget(_backupRenderTarget);
                display.GraphicsDevice.Clear(clearOptions, Color.Transparent, 0, 0);

                if (layer.RenderBeforeMerge)
                {
                    batch.Sprite.Begin(samplerState: SamplerState.PointClamp);
                    batch.Sprite.Draw(renderTarget, Vector2.Zero, Color.White);
                    batch.Sprite.End();
                }

                batch.Sprite.Begin(
                    samplerState: SamplerState.PointClamp,
                    effect: layer.Effect);
                batch.Sprite.Draw(layer.RenderTarget, Vector2.Zero, layer.Color);
                batch.Sprite.End();

                display.GraphicsDevice.SetRenderTarget(layer.RenderTarget);
                display.GraphicsDevice.Clear(clearOptions, Color.Transparent, 0, 0);

                batch.Sprite.Begin(samplerState: SamplerState.PointClamp);
                batch.Sprite.Draw(_backupRenderTarget, Vector2.Zero, Color.White);
                batch.Sprite.End();

                renderTarget = layer.RenderTarget;
            }

            Layers.State = ManagerState.Opened;

            AfterDraw(batch);
        }