本文整理匯總了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;
}