コード例 #1
0
ファイル: Emu.cs プロジェクト: pabru/YCPU
        protected override void Draw(GameTime gameTime)
        {
            // render the debug console contents to a RenderTarget
            Depth.ResetZ();
            if (debug == null)
            {
                debug = new RenderTarget2D(GraphicsDevice, m_Curses.DisplayWidth, m_Curses.DisplayHeight);
            }
            GraphicsDevice.SetRenderTarget(debug);
            m_SpriteBatch.Begin(new Color(0, 0, 0, 255));
            m_Curses.Render(m_SpriteBatch, m_Effect, Vector2.Zero);
            m_SpriteBatch.End(GraphicsUtility.CreateProjectionMatrixScreenOffset(m_SpriteBatch.Graphics), Matrix.Identity, Matrix.Identity);
            GraphicsDevice.SetRenderTarget(null);

            if (m_DoScreenshot)
            {
                GraphicsDevice.PrepareScreenShot();
            }

            // clear the screen:
            Depth.ResetZ();
            m_SpriteBatch.Begin(new Color(32, 32, 32, 255));

            // draw the debug console device
            m_SpriteBatch.DrawSprite(
                m_EffectCRT,
                debug,
                Vector3.Zero,
                new Vector2(c_WindowW, c_WindowH),
                new Vector4(0, 0, 1, 1),
                new Color(64, 255, 64),
                new Vector4(c_WindowW, c_WindowH, 0, 0));

            // render the devices
            m_DeviceTextures.Clear();
            m_Emulator.Draw(m_DeviceTextures);
            for (int i = 0; i < m_DeviceTextures.Count; i++)
            {
                YTexture texture = (m_DeviceTextures[i] as YTexture);
                if (texture == null)
                {
                    continue;
                }

                m_SpriteBatch.DrawSprite(
                    m_EffectCRT,
                    texture.Texture,
                    new Vector3(c_WindowW, 0, 0),
                    new Vector2(c_WindowW, c_WindowH),
                    new Vector4(0, 0, 1, 1),
                    Color.White,
                    new Vector4(c_WindowW, c_WindowH, 0, 0));
            }

            // End the spritebatch.
            m_SpriteBatch.End(GraphicsUtility.CreateProjectionMatrixScreenOffset(m_SpriteBatch.Graphics), Matrix.Identity, Matrix.Identity);

            if (m_DoScreenshot)
            {
                GraphicsDevice.SaveScreenshot();
                m_DoScreenshot = false;
            }
        }