当前位置: 首页>>代码示例>>C#>>正文


C# GraphicsDevice.Reset方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.GraphicsDevice.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsDevice.Reset方法的具体用法?C# GraphicsDevice.Reset怎么用?C# GraphicsDevice.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Graphics.GraphicsDevice的用法示例。


在下文中一共展示了GraphicsDevice.Reset方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

        public override void Initialize()
        {
            // A reference to the graphics service is mandatory since we need to get the graphics device after it's destroyed
            graphicsService = Game.Services.GetService(typeof(IGraphicsDeviceService)) as IGraphicsDeviceService;
            graphicsDevice = graphicsService.GraphicsDevice;

            // Those three events are necessary to keep a "fresh" state, see individual methods
            graphicsService.DeviceCreated += delegate { OnDeviceCreated(); };
            graphicsService.DeviceResetting += delegate { OnDeviceResetting(); };
            graphicsService.DeviceReset += delegate { OnDeviceReset(); };

            // Here's the trick... We know it's a form, so let's cast it as a form!
            // No need to say that this won't work on the Xbox 360...
            windowsGameForm = Control.FromHandle(Game.Window.Handle) as Form;

            // After, we add up our own components to it
            InitializeComponent();
            Game.Window.Title = "nu";

            // We can then map events to the components like in a normal Windows Forms context
            //someButton.Click += new EventHandler(someButton_Click);
            //quitMenuItem.Click += delegate { Game.Exit(); };

            // And force a reset so that we set the right target to begin with
            graphicsDevice.Reset();

            base.Initialize();
        }
开发者ID:codler,项目名称:RuneCrafter,代码行数:28,代码来源:WindowsFormsControls.cs

示例2: GraphicsDeviceService

        /// <summary>
        /// Constructor is private, because this is a singleton class:
        /// client controls should use the public AddRef method instead.
        /// </summary>
        private GraphicsDeviceService(IntPtr windowHandle, int width, int height) {
            parameters = new PresentationParameters {
                BackBufferWidth = Math.Max(width, 1),
                BackBufferHeight = Math.Max(height, 1),
                BackBufferFormat = SurfaceFormat.Color,
                DepthStencilFormat = DepthFormat.Depth24,
                DeviceWindowHandle = windowHandle,
                PresentationInterval = PresentInterval.Immediate,
                IsFullScreen = false
            };

            //graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.Reach, parameters);
            graphicsDevice = new GraphicsDevice();
            graphicsDevice.GraphicsProfile = GraphicsProfile.Reach;
            graphicsDevice.Reset(parameters, GraphicsAdapter.DefaultAdapter);
        }
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:20,代码来源:GraphicsDeviceService.cs

示例3: InitializeMainScrn

        private void InitializeMainScrn()
        {
            mainScreen = new MainScreen();

            PresentationParameters pp = new PresentationParameters();
            pp.BackBufferCount = 1;
            pp.IsFullScreen = false;
            pp.SwapEffect = SwapEffect.Discard;
            pp.BackBufferWidth = mainScreen.canvas.Width;
            pp.BackBufferHeight = mainScreen.canvas.Height;

            pp.AutoDepthStencilFormat = DepthFormat.Depth24Stencil8;
            pp.EnableAutoDepthStencil = true;
            pp.PresentationInterval = PresentInterval.Default;
            pp.BackBufferFormat = SurfaceFormat.Unknown;
            pp.MultiSampleType = MultiSampleType.None;

            mainDevice = new GraphicsDevice( GraphicsAdapter.DefaultAdapter,
                DeviceType.Hardware, this.mainScreen.canvas.Handle,
                pp );

            mainScreen.canvas.SizeChanged += new EventHandler( mainScreen_canvas_SizeChanged );
            mainScreen.canvas.Paint += new EventHandler( mainScreen_canvas_Paint );

            mainDevice.Reset();

            mainScreen.Show( dockPanel, DockState.Document );

            mainScrnBatch = new SpriteBatch( mainDevice );

            //BasicGraphics.Initial( mainDevice );
        }
开发者ID:ingex0,项目名称:smarttank,代码行数:32,代码来源:MapEditer.cs

示例4: CreateDevice

        /// <summary>
        /// Method to instantiate and initialize a graphics device
        /// </summary>
        private void CreateDevice()
        {
            PresentationParameters presentation = new PresentationParameters();
            presentation.AutoDepthStencilFormat = DepthFormat.Depth24;
            presentation.BackBufferCount = 1;
            presentation.BackBufferFormat = SurfaceFormat.Color;
            System.Drawing.Rectangle a = this.scrMainLayout.Panel2.Bounds;
            presentation.BackBufferWidth = a.Width;
            presentation.BackBufferHeight = a.Height;
            presentation.DeviceWindowHandle = this.Handle;
            presentation.EnableAutoDepthStencil = true;
            presentation.FullScreenRefreshRateInHz = 0;
            presentation.IsFullScreen = false;
            presentation.MultiSampleQuality = 0;
            presentation.MultiSampleType = MultiSampleType.None;
            presentation.PresentationInterval = PresentInterval.One;
            presentation.PresentOptions = PresentOptions.None;
            presentation.SwapEffect = SwapEffect.Discard;
            presentation.RenderTargetUsage = RenderTargetUsage.DiscardContents;

            gfxDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, DeviceType.Hardware, this.scrMainLayout.Panel2.Handle,
                presentation);
            gfxDevice.RenderState.CullMode = CullMode.None;

            gfxDevice.Reset();
            //Setup cliping frustum
            Viewport v = gfxDevice.Viewport;
            v.MinDepth = nearClip;
            v.MaxDepth = farClip;
            gfxDevice.Viewport = v;
        }
开发者ID:nthfloor,项目名称:Nebulon12,代码行数:34,代码来源:MainWindow.cs

示例5: CreateGraphicsContext

        public bool CreateGraphicsContext(IntPtr hwnd, ref PresentationParameters pp)
        {
            //define presentation parameters
            pp = new PresentationParameters();
            pp.BackBufferFormat = SurfaceFormat.Color;
            pp.DeviceWindowHandle = hwnd;
            pp.IsFullScreen = false;
            pp.BackBufferHeight = Control.FromHandle(hwnd).Height;
            pp.BackBufferWidth = Control.FromHandle(hwnd).Width;
            //Initialize Z-buffer - need this for winform
            pp.DepthStencilFormat = DepthFormat.Depth24;

            if (m_GraphicsDevice != null)
                return false;
            //create an XNA graphics device
            m_GraphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter,
                    GraphicsProfile.HiDef,
                    pp);

            m_DefaultState = new RasterizerState();
            m_DefaultState.CullMode = CullMode.None;
            m_DefaultState.FillMode = FillMode.Solid;
            m_GraphicsDevice.RasterizerState = m_DefaultState;

            //check if graphics device was created
            Debug.Assert(m_GraphicsDevice != null, "XNA Graphics Device did not Initialize");

            m_GraphicsDevice.Reset();
            m_GraphicsDevice.DepthStencilState = DepthStencilState.Default;

            RGraphicsDeviceService gS = new RGraphicsDeviceService();
            gS.GraphicsDevice = m_GraphicsDevice;
            mService = new RGameView();
            mService.SetService(gS);
            mResources = new ContentManager(mService);
            mResources.RootDirectory = "./Content/";

            Initialize();

            return true;
        }
开发者ID:sojo2600,项目名称:css552_Research_Project,代码行数:41,代码来源:XNAGraphicsDeviceManager.cs

示例6: OnDeviceCreated

 /// <summary>
 /// This is needed for multi-screen setups, where the device is killed and reset
 /// whenever the window is tossed from one screen to another. Probably other situations 
 /// would cause the device to be re-created too, so make sure you have it.
 /// </summary>
 void OnDeviceCreated()
 {
     graphicsDevice = graphicsService.GraphicsDevice;
     graphicsDevice.Reset();
 }
开发者ID:codler,项目名称:RuneCrafter,代码行数:10,代码来源:WindowsFormsControls.cs


注:本文中的Microsoft.Xna.Framework.Graphics.GraphicsDevice.Reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。