本文整理汇总了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();
}
示例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);
}
示例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 );
}
示例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;
}
示例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;
}
示例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();
}