本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.PresentationParameters类的典型用法代码示例。如果您正苦于以下问题:C# PresentationParameters类的具体用法?C# PresentationParameters怎么用?C# PresentationParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PresentationParameters类属于Microsoft.Xna.Framework.Graphics命名空间,在下文中一共展示了PresentationParameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDevice
private void CreateDevice(IntPtr windowHandle, int width, int height)
{
try
{
parameters = new PresentationParameters();
parameters.BackBufferWidth = Math.Max(width, 1);
parameters.BackBufferHeight = Math.Max(height, 1);
parameters.BackBufferFormat = SurfaceFormat.Color;
parameters.DepthStencilFormat = DepthFormat.Depth24;
parameters.DeviceWindowHandle = windowHandle;
parameters.PresentationInterval = PresentInterval.Immediate;
parameters.IsFullScreen = false;
graphicsDevice = new GraphicsDevice(
GraphicsAdapter.DefaultAdapter,
GraphicsProfile.Reach,
parameters);
if (DeviceCreated != null)
DeviceCreated(this, EventArgs.Empty);
}
catch (Exception ex)
{
throw new ApplicationException("Failed to initialize GraphicsDeviceService. See inner exception for details.", ex);
}
}
示例2: GraphicsDeviceService
public GraphicsDeviceService(IntPtr windowHandle)
{
var screenBounds = System.Windows.Forms.Screen.FromHandle(windowHandle).Bounds;
_parameters = new PresentationParameters
{
BackBufferWidth = screenBounds.Width,
BackBufferHeight = screenBounds.Height,
BackBufferFormat = SurfaceFormat.Color,
DepthStencilFormat = DepthFormat.Depth24,
DeviceWindowHandle = windowHandle,
IsFullScreen = false,
PresentationInterval = PresentInterval.Immediate,
};
var profilingAdapter = GraphicsAdapter.Adapters.FirstOrDefault(a => a.Description.Contains("PerfHUD"));
var useAdapter = profilingAdapter ?? GraphicsAdapter.DefaultAdapter;
if (profilingAdapter != null) GraphicsAdapter.UseReferenceDevice = true;
if (!useAdapter.IsProfileSupported(GraphicsProfile.Reach))
GraphicsAdapter.UseReferenceDevice = !GraphicsAdapter.UseReferenceDevice;
if (!useAdapter.IsProfileSupported(GraphicsProfile.Reach))
throw new NotSupportedException("No suitable graphics adapter found");
try
{
GraphicsDevice = new GraphicsDevice(useAdapter, GraphicsProfile.Reach, _parameters);
}
catch (InvalidOperationException)
{
// With VMware, GraphicsDevice.ctor may throw InvalidOperationException when using reference device.
GraphicsAdapter.UseReferenceDevice = false;
GraphicsDevice = new GraphicsDevice(useAdapter, GraphicsProfile.Reach, _parameters);
}
if (DeviceCreated != null) DeviceCreated(this, EventArgs.Empty);
}
示例3: XNAGraphicsDeviceService
private XNAGraphicsDeviceService(IntPtr windowHandle, int width, int height)
{
parameters = new PresentationParameters();
parameters.BackBufferWidth = Math.Max(width, 1);
parameters.BackBufferHeight = Math.Max(height, 1);
parameters.BackBufferFormat = SurfaceFormat.Color;
parameters.DepthStencilFormat = DepthFormat.Depth16;
parameters.DeviceWindowHandle = windowHandle;
parameters.PresentationInterval = PresentInterval.Immediate;
parameters.IsFullScreen = false;
if (GraphicsAdapter.DefaultAdapter.IsProfileSupported(GraphicsProfile.HiDef))
graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter,
GraphicsProfile.HiDef,
parameters);
else
{
MessageBox.Show(
"WARNING: Your graphics device does not support the HiDef Profile, switching to the Reach profile.",
"Rose");
graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter,
GraphicsProfile.Reach,
parameters);
}
XnaResourceManager.Instance.DeviceCreate(graphicsDevice);
}
示例4: 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 );
}
示例5: GraphicsDeviceService
/// <summary>
/// Constructor is private, because this is a singleton class:
/// client controls should use the public AddRef method instead.
/// </summary>
GraphicsDeviceService(IntPtr windowHandle, int width, int height)
{
parameters = new PresentationParameters();
parameters.BackBufferWidth = Math.Max(width, 1);
parameters.BackBufferHeight = Math.Max(height, 1);
parameters.BackBufferFormat = SurfaceFormat.Color;
parameters.DepthStencilFormat = DepthFormat.Depth24;
parameters.DeviceWindowHandle = windowHandle;
parameters.RenderTargetUsage = RenderTargetUsage.DiscardContents;
parameters.IsFullScreen = false;
/*PORT XNA 4
parameters.EnableAutoDepthStencil = true;
parameters.AutoDepthStencilFormat = DepthFormat.Depth24;
*/
if(GraphicsAdapter.DefaultAdapter.IsProfileSupported(GraphicsProfile.HiDef))
graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef, parameters);
else if (GraphicsAdapter.DefaultAdapter.IsProfileSupported(GraphicsProfile.Reach))
graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.Reach, parameters);
else
{
System.Windows.Forms.MessageBox.Show("Default graphics adapter does not support XNA");
throw new System.InvalidOperationException("Default graphics adapter does not support XNA");
}
}
示例6: Renderer
public Renderer( PresentationParameters p_PresentationParameters )
{
m_GraphicsAdapter = GraphicsAdapter.DefaultAdapter;
m_PresentationParameters = p_PresentationParameters;
#if XBOX360
m_PresentationParameters.BackBufferWidth =
m_GraphicsAdapter.CurrentDisplayMode.Width;
m_PresentationParameters.BackBufferHeight =
m_GraphicsAdapter.CurrentDisplayMode.Height;
m_PresentationParameters.IsFullScreen = true;
#endif
m_GraphicsDeviceService = GraphicsDeviceService.AddReference(
m_PresentationParameters );
m_ServiceContainer.AddService< IGraphicsDeviceService >(
m_GraphicsDeviceService );
m_ClearColour = new Color( 1.0f, 1.0f, 1.0f );
m_Width = m_PresentationParameters.BackBufferWidth;
m_Height = m_PresentationParameters.BackBufferHeight;
if( GamerServicesDispatcher.IsInitialized == false )
{
GamerServicesDispatcher.WindowHandle =
m_GraphicsDeviceService.GraphicsDevice.
PresentationParameters.DeviceWindowHandle;
GamerServicesDispatcher.Initialize( m_ServiceContainer );
GamerServicesDispatcher.Update( );
}
}
示例7: GraphicsDeviceInformation
public GraphicsDeviceInformation()
{
deviceType = DeviceType.Hardware;
adapter = GraphicsAdapter.DefaultAdapter;
presentationParameters = new PresentationParameters();
presentationParameters.Clear();
}
示例8: GraphicsDeviceService
/// <summary>
/// Constructor is private, because this is a singleton class:
/// client controls should use the public AddRef method instead.
/// </summary>
GraphicsDeviceService(IntPtr windowHandle, int width, int height)
{
parameters = new PresentationParameters();
// Basic settings.
parameters.BackBufferWidth = Math.Max(width, 1);
parameters.BackBufferHeight = Math.Max(height, 1);
parameters.BackBufferFormat = SurfaceFormat.Color;
parameters.DepthStencilFormat = DepthFormat.Depth24;
parameters.DeviceWindowHandle = windowHandle;
parameters.PresentationInterval = PresentInterval.Immediate;
parameters.IsFullScreen = false;
// High-quality settings.
parameters.MultiSampleCount = 4;
// Try for high-quality graphics, otherwise drop down to basic settings.
try
{
graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter,
GraphicsProfile.HiDef,
parameters);
}
catch
{
parameters.MultiSampleCount = 0;
graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter,
GraphicsProfile.Reach,
parameters);
}
}
示例9: SelectTeleportationForm
public SelectTeleportationForm(Map map, System.Drawing.Point premier, int layer, Map firstMap, SpriteBatch Mapbatch)
{
InitializeComponent();
utils = new XNAUtils();
this.map = map;
this.premier = premier;
this.layer = layer;
this.firstMap = firstMap;
this.batch = Mapbatch;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Size = Screen.PrimaryScreen.Bounds.Size;
this.StartPosition = FormStartPosition.Manual;
this.Location = new System.Drawing.Point(0, 0);
PN_Map.Size = Screen.PrimaryScreen.Bounds.Size;
PresentationParameters pp = new PresentationParameters()
{
BackBufferHeight = PN_Map.Height,
BackBufferWidth = PN_Map.Width,
DeviceWindowHandle = PN_Map.Handle,
IsFullScreen = false
};
XNADevices.graphicsdevice.Reset(pp);
}
示例10: Reset
public static unsafe void Reset(GraphicsDevice graphicsDevice, PresentationParameters parameters)
{
var fi = typeof(GraphicsDevice).GetField("pComPtr", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
var ptr = fi.GetValue(graphicsDevice);
var pComPtr = new IntPtr(System.Reflection.Pointer.Unbox(ptr));
if (g_mdxAssembly == null) throw new ApplicationException("GraphicsDevice.Reset failed. Please install Managed DirectX from the Assault Wing web site.");
var mdxDeviceType = g_mdxAssembly.GetType("Microsoft.DirectX.Direct3D.Device");
var mdxPresentParametersType = g_mdxAssembly.GetType("Microsoft.DirectX.Direct3D.PresentParameters");
var dev = Activator.CreateInstance(mdxDeviceType, pComPtr);
dynamic dxParameters = new MDXPresentParameters(Activator.CreateInstance(mdxPresentParametersType));
dxParameters.AutoDepthStencilFormat = parameters.DepthStencilFormat.ToD3D();
dxParameters.BackBufferCount = 1;
dxParameters.BackBufferFormat = parameters.BackBufferFormat.ToD3D();
dxParameters.BackBufferHeight = parameters.BackBufferHeight;
dxParameters.BackBufferWidth = parameters.BackBufferWidth;
dxParameters.DeviceWindow = null;
dxParameters.DeviceWindowHandle = parameters.DeviceWindowHandle;
dxParameters.EnableAutoDepthStencil = false; // ???
dxParameters.ForceNoMultiThreadedFlag = false; // ???
dxParameters.FullScreenRefreshRateInHz = 0; // ??? should be 0 for windowed mode; in fullscreen mode take value from DisplayModeCollection
dxParameters.MultiSample = GetMDXEnumValue("MultiSampleType", "None");
dxParameters.MultiSampleQuality = 0;
dxParameters.PresentationInterval = parameters.PresentationInterval.ToD3D();
dxParameters.PresentFlag = GetMDXEnumValue("PresentFlag", "None"); // ???
dxParameters.SwapEffect = GetMDXEnumValue("SwapEffect", "Flip"); // ??? see _parameters.RenderTargetUsage
dxParameters.Windowed = !parameters.IsFullScreen;
var resetMethod = mdxDeviceType.GetMethod("Reset");
var mdxPresentParametersArray = Array.CreateInstance(mdxPresentParametersType, 1);
mdxPresentParametersArray.SetValue(((MDXPresentParameters)dxParameters).WrappedValue, 0);
resetMethod.Invoke(dev, new[] { mdxPresentParametersArray });
}
示例11: GraphicsDeviceService
/// <summary>
/// Constructor is private, because this is a singleton class:
/// client controls should use the public AddRef method instead.
/// </summary>
GraphicsDeviceService(IntPtr windowHandle, int width, int height)
{
//parameters = new PresentationParameters();
//parameters.BackBufferWidth = Math.Max(width, 1);
//parameters.BackBufferHeight = Math.Max(height, 1);
//parameters.BackBufferFormat = SurfaceFormat.Color;
//parameters.EnableAutoDepthStencil = true;
//parameters.AutoDepthStencilFormat = DepthFormat.Depth24;
this.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,
MultiSampleCount = 4
};
//graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter,
// DeviceType.Hardware,
// windowHandle,
// parameters);
this.graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.Reach, this.Parameters);
if (this.DeviceCreated != null)
{
this.DeviceCreated(this, EventArgs.Empty);
}
}
示例12: GraphicsDevice
public GraphicsDevice()
{
BitmapCacheEnabled = true;
RenderAtScale = 1;
RenderState = new RenderState();
PresentationParameters = new PresentationParameters();
PresentationParameters.BackBufferFormat = SurfaceFormat.Canvas;
}
示例13: EqualsTest
public void EqualsTest()
{
PresentationParameters b = new PresentationParameters();
Assert.IsFalse(b == a, "#1");
Assert.IsTrue(b != a, "#2");
Assert.IsFalse(b == null, "#3");
Assert.IsTrue(b.Equals(b), "#4");
}
示例14: GraphicsDeviceService
GraphicsDeviceService(
PresentationParameters p_PresentationParameters)
{
m_PresentationParameters = p_PresentationParameters;
m_GraphicsDevice = new GraphicsDevice(
GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef,
m_PresentationParameters );
}
示例15: GraphicsDeviceService
private GraphicsDeviceService(IntPtr windowHandle, int width, int height)
{
this.parameters = new PresentationParameters();
this.parameters.BackBufferWidth = Math.Max(width, 1);
this.parameters.BackBufferHeight = Math.Max(height, 1);
this.parameters.BackBufferFormat = SurfaceFormat.Color;
this.parameters.EnableAutoDepthStencil = true;
this.parameters.AutoDepthStencilFormat = DepthFormat.Depth24;
this.graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, DeviceType.Hardware, windowHandle, this.parameters);
}