Exemplo n.º 1
0
        // ReSharper disable once UnusedMethodReturnValue.Local
        private static int IDirect3D9_CreateDevice(IDirect3D9 *p, uint Adapter, uint DeviceType, IntPtr hFocusWindow, uint BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3DDevice9 **ppReturnedDeviceInterface)
        {
            var lpIDirect3D9_CreateDevice = (DelegateIDirect3D9_CreateDevice)Marshal.GetDelegateForFunctionPointer(p->lpVtbl[16],
                                                                                                                   typeof(DelegateIDirect3D9_CreateDevice));

            return(lpIDirect3D9_CreateDevice(p, Adapter, DeviceType, hFocusWindow, BehaviorFlags, (IntPtr)pPresentationParameters, (IntPtr)ppReturnedDeviceInterface));
        }
Exemplo n.º 2
0
        // ReSharper restore FieldCanBeMadeReadOnly.Local
        // ReSharper restore MemberCanBePrivate.Local
        // ReSharper restore InconsistentNaming

        private static void Initialize()
        {
            _wndProc = WindowProc;
            var wc = new WNDCLASS
            {
                lpszClassName = g_szClassName,
                lpfnWndProc   = Marshal.GetFunctionPointerForDelegate(_wndProc),
                hInstance     = GetModuleHandle(IntPtr.Zero)
            };

            RegisterClass(ref wc);

            g_hWnd = CreateWindowEx(0, g_szClassName, "Shader Decompiler", WS_OVERLAPPEDWINDOW, 20, 20, 800, 600,
                                    (IntPtr)0, (IntPtr)0, GetModuleHandle(IntPtr.Zero), (IntPtr)0);

            g_D3D = Direct3DCreate9(D3D_SDK_VERSION);
            g_D3DPresentParameters = new D3DPRESENT_PARAMETERS
            {
                AutoDepthStencilFormat = D3DFMT_D24S8,
                BackBufferCount        = 1,
                BackBufferFormat       = D3DFMT_X8R8G8B8,
                BackBufferWidth        = 32,
                BackBufferHeight       = 32,
                EnableAutoDepthStencil = false,
                Flags = 0,
                FullScreen_RefreshRateInHz = 0,
                hDeviceWindow        = g_hWnd,
                PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE,
                SwapEffect           = D3DSWAPEFFECT_DISCARD,
                Windowed             = true
            };

            fixed(D3DPRESENT_PARAMETERS *pD3DPresentParams = &g_D3DPresentParameters)
            {
                fixed(IDirect3DDevice9 **ppD3DDevice = &g_D3DDevice)
                {
                    IDirect3D9_CreateDevice(g_D3D, 0, D3DDEVTYPE_NULLREF, g_hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, pD3DPresentParams, ppD3DDevice);
                }
            }
        }