예제 #1
0
        /// <summary>
        /// Retrieves a pointer to the IDirect3DSurface9 for one of the specified texture's mip levels.
        /// </summary>
        /// <param name="texture">The texture to retrieve a mip level from.</param>
        /// <param name="level">The index of the mip level.</param>
        /// <returns>A pointer to the mip level's surface.</returns>
        public static unsafe void *GetSurfaceLevel(this Texture2D texture, int level)
        {
            void *pTexture         = texture.GetIDirect3DTexture9();
            void *pGetSurfaceLevel = COMUtils.AccessVTable(pTexture, VTables.IDirect3DTexture9.GetSurfaceLevel);
            void *pSurface;

            var getSurfaceLevel = (GetSurfaceLevelDelegate)Marshal.GetDelegateForFunctionPointer(new IntPtr(pGetSurfaceLevel), typeof(GetSurfaceLevelDelegate));
            var rv = getSurfaceLevel(pTexture, 0, &pSurface);

            if (rv == 0)
            {
                return(pSurface);
            }
            else
            {
                throw new COMException("GetSurfaceLevel failed", rv);
            }
        }
예제 #2
0
        public static unsafe uint GetRefreshRate(this GraphicsDevice device)
        {
            void *pDevice         = GetIDirect3DDevice9(device);
            void *pGetDisplayMode = COMUtils.AccessVTable(pDevice, VTables.IDirect3DDevice9.GetDisplayMode);

            var            getDisplayMode = (GetDisplayModeDelegate)Marshal.GetDelegateForFunctionPointer(new IntPtr(pGetDisplayMode), typeof(GetDisplayModeDelegate));
            D3DDISPLAYMODE displayMode;

            var rv = getDisplayMode(pDevice, 0, out displayMode);

            if (rv == 0)
            {
                return(displayMode.RefreshRate);
            }
            else
            {
                throw new COMException("GetDisplayMode failed", rv);
            }
        }