本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.GraphicsDevice.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsDevice.GetType方法的具体用法?C# GraphicsDevice.GetType怎么用?C# GraphicsDevice.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Graphics.GraphicsDevice
的用法示例。
在下文中一共展示了GraphicsDevice.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IDirect3D9CreateDeviceHandler
private static uint IDirect3D9CreateDeviceHandler(IntPtr thisPtr, uint adapter, uint deviceType, IntPtr hFocusWindow, uint behaviorFlags, IntPtr pPresentationParameters, [Out] IntPtr ppReturnedDeviceInterface)
{
uint ret;
if (!_isXnaCreateDeviceCall)
{
try
{
var nativePresentationParameters =
(NativePresentationParameters)Marshal.PtrToStructure(pPresentationParameters, typeof(NativePresentationParameters));
var presentationParameters = nativePresentationParameters.ToXnaPresentationParameters(hFocusWindow);
_preservedBehaviorFlags = behaviorFlags;
_isXnaCreateDeviceCall = true;
_xnaGraphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.Reach,
presentationParameters);
var pComPtrField = _xnaGraphicsDevice.GetType().GetField("pComPtr", BindingFlags.NonPublic | BindingFlags.Instance);
if (pComPtrField == null)
throw new Exception("Unable to get pComPtr field from XNA Graphics Device");
unsafe
{
var pComPtr = new IntPtr(Pointer.Unbox(pComPtrField.GetValue(_xnaGraphicsDevice)));
Marshal.WriteIntPtr(ppReturnedDeviceInterface, pComPtr);
_endSceneDetour = pComPtr.VTable(IDirect3DDevice9VTable.EndScene)
.DetourWith(EndSceneFunc);
_resetDetour = pComPtr.VTable(IDirect3DDevice9VTable.Reset)
.DetourWith(ResetFunc);
}
// TODO
OnCreateDevice();
ret = 0;
}
catch (Exception)
{
// If we get an exception trying to create the XNA device, just call the original method and pass out the return
ret = (uint)_createDeviceDetour.CallOriginal(
thisPtr, adapter, deviceType, hFocusWindow,
behaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
}
}
else
{
// Now we're inside the XNA Device's call to CreateDevice - get our cached presentation parameters and add a required flag
// TODO: check this process / flag
var pp = (NativePresentationParameters)Marshal.PtrToStructure(pPresentationParameters, typeof(NativePresentationParameters));
pp.Flags |= 0x1;
Marshal.StructureToPtr(pp, pPresentationParameters, true);
ret = (uint) _createDeviceDetour.CallOriginal(
thisPtr, adapter, deviceType, hFocusWindow,
_preservedBehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
}
return ret;
}