Esempio n. 1
0
        /// <summary>
        ///  进行游戏图像渲染帧中的渲染操作
        /// </summary>
        public void Draw()
        {
            RenderTarget defRt = renderSys.GetRenderTarget(0);

            if (currentGame == null)
            {
                renderSys.Clear(ClearFlags.Target | ClearFlags.DepthBuffer, ColorValue.Transparent, 1, 0);
            }
            else
            {
                currentGame.Render();
            }

            if (menu != null)
            {
                menu.Render();
            }

            renderSys.SetRenderTarget(0, defRt);


            sprite.Begin();

            if (currentGame != null)
            {
                currentGame.Render(sprite);
            }
            if (menu != null)
            {
                menu.Render(sprite);
            }

            sprite.End();
        }
Esempio n. 2
0
        public void Draw()
        {
            renderSys.Clear(ClearFlags.DepthBuffer | ClearFlags.Target, ColorValue.White, 1, 0);

            if (CurrentTexture != null)
            {
                if (CurrentTexture.State == ResourceState.Loaded)
                {
                    Texture tex = CurrentTexture;

                    sprite.Begin();

                    Size clSize = Program.Window.ClientSize;

                    float aspect = tex.Width / (float)tex.Height;

                    if (tex.Width < clSize.Width)
                    {
                        clSize.Width = tex.Width;
                    }
                    if (tex.Height < clSize.Height)
                    {
                        clSize.Height = tex.Height;
                    }


                    sprite.Draw(tex, new Rectangle(0, 0, clSize.Width, clSize.Height), ColorValue.White);

                    string msg = "Format: " + tex.Format.ToString() +
                                 "\nSize: " + tex.Width.ToString() + "x" + tex.Height.ToString() +
                                 "\nLevels:" + tex.SurfaceCount.ToString();

                    unchecked
                    {
                        font.DrawString(sprite, msg, 11, 11, 15, DrawTextFormat.Left, (int)0xff000000);
                    }

                    font.DrawString(sprite, msg, 10, 10, 15, DrawTextFormat.Left, -1);

                    sprite.End();
                }
                else
                {
                    CurrentTexture.Touch();
                }
            }
        }