Exemplo n.º 1
0
 /// <unmanaged>HRESULT IDirect3D9::EnumAdapterModes([In] unsigned int Adapter,[In] D3DFORMAT Format,[In] unsigned int Mode,[Out] D3DDISPLAYMODE* pMode)</unmanaged>
 public unsafe HRESULT EnumAdapterModes(int adapter, D3DFORMAT format, int mode, out D3DDISPLAYMODE d3dMode)
 {
     fixed(void *pMode = &d3dMode)
     {
         //calli(System.Int32(System.Void*,System.Int32,System.Int32,System.Int32,System.Void*), this._nativePointer, adapter, format, mode, &result, *(*(IntPtr*)this._nativePointer + (IntPtr)7 * (IntPtr)sizeof(void*))).CheckError();
         return((HRESULT)NativeHelper.CalliInt32(7, _nativePointer, (int)adapter, (int)format, (int)mode, (void *)pMode));
     }
 }
Exemplo n.º 2
0
 private static unsafe extern int D3DXLoadSurfaceFromMemory(
     void *pDestSurface,
     void *pDestPalette,
     RECT *pDestRect,
     void *pSrcMemory,
     D3DFORMAT srcFormat,
     uint srcPitch,
     void *pSrcPalette,
     RECT *pSrcRect,
     D3DX_FILTER filter,
     uint colorKey
     );
Exemplo n.º 3
0
        public IList <D3DDISPLAYMODE> GetDisplayModes(D3DFORMAT format)
        {
            var modeCount = _direct3d.GetAdapterModeCount(this.Adapter, format);
            var list      = new List <D3DDISPLAYMODE>(modeCount);

            for (var i = 0; i < modeCount; i++)
            {
                var mode = new D3DDISPLAYMODE();
                var hr   = _direct3d.EnumAdapterModes(this.Adapter, format, i, out mode);
                hr.CheckError();
                list.Add(mode);
            }
            return(list);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Copies pixels from an address in memory into a mip level of Texture2D, converting them from one format to another if necessary.
        /// </summary>
        /// <param name="texture">The texture to copy to.</param>
        /// <param name="level">The index into the texture's mip levels.</param>
        /// <param name="pData">The address of the pixel data.</param>
        /// <param name="width">The width of the pixel data (in pixels).</param>
        /// <param name="height">The height of the pixel data (in pixels).</param>
        /// <param name="pitch">The number of bytes occupied by a single row of the pixel data (including padding at the end of rows).</param>
        /// <param name="pixelFormat">The format of the pixel data.</param>
        public static unsafe void SetData(
            this Texture2D texture, void *pSurface, void *pData,
            int width, int height, uint pitch,
            D3DFORMAT pixelFormat
            )
        {
            var rect = new RECT {
                Top    = 0,
                Left   = 0,
                Right  = width,
                Bottom = height
            };

            SetData(texture, pSurface, pData, ref rect, pitch, ref rect, pixelFormat);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Copies pixels from an address in memory into a mip level of Texture2D, converting them from one format to another if necessary.
        /// </summary>
        /// <param name="texture">The texture to copy to.</param>
        /// <param name="level">The index into the texture's mip levels.</param>
        /// <param name="pData">The address of the pixel data.</param>
        /// <param name="destRect">The destination rectangle.</param>
        /// <param name="pitch">The number of bytes occupied by a single row of the pixel data (including padding at the end of rows).</param>
        /// <param name="sourceRect">The source rectangle.</param>
        /// <param name="pixelFormat">The format of the pixel data.</param>
        public static unsafe void SetData(
            this Texture2D texture, void *pSurface, void *pData,
            ref RECT destRect, uint pitch, ref RECT sourceRect,
            D3DFORMAT pixelFormat
            )
        {
            fixed(RECT *pDestRect = &destRect)
            fixed(RECT * pSourceRect = &sourceRect)
            {
                var rv = D3DXLoadSurfaceFromMemory(pSurface, null, pDestRect, pData, pixelFormat, pitch, null, pSourceRect, D3DX_FILTER.NONE, 0);

                if (rv != 0)
                {
                    throw new COMException("D3DXLoadSurfaceFromMemory failed", rv);
                }
            }
        }
Exemplo n.º 6
0
        public void Empty()
        {
            BackBufferWidth  = 0;
            BackBufferHeight = 0;
            BackBufferFormat = 0;
            BackBufferCount  = 0;

            MultiSampleType    = 0;
            MultiSampleQuality = 0;

            SwapEffect             = 0;
            hDeviceWindow          = IntPtr.Zero;
            Windowed               = false;
            EnableAutoDepthStencil = false;
            AutoDepthStencilFormat = 0;
            Flags = 0;

            /* FullScreen_RefreshRateInHz must be zero for Windowed mode */
            FullScreen_RefreshRateInHz = 0;
            PresentationInterval       = 0;
        }
Exemplo n.º 7
0
        //-----------------------------------------------------------------------------
        // CheckFormat
        //
        // Queries whether the D3DPresentEngine can use a specified Direct3D format.
        //-----------------------------------------------------------------------------

        public void CheckFormat(int iformat)
        {
            int        uAdapter = 0;
            D3DDEVTYPE type     = D3DDEVTYPE.HAL;

            D3DDISPLAYMODE mode;
            D3DDEVICE_CREATION_PARAMETERS dparams;

            D3DFORMAT format = (D3DFORMAT)iformat;

            if (m_pDevice != null)
            {
                m_pDevice.GetCreationParameters(out dparams);

                uAdapter = dparams.AdapterOrdinal;
                type     = dparams.DeviceType;
            }

            m_pD3D9.GetAdapterDisplayMode(uAdapter, out mode);

            m_pD3D9.CheckDeviceType(uAdapter, type, mode.Format, format, true);
        }
Exemplo n.º 8
0
 /// <unmanaged>unsigned int IDirect3D9::GetAdapterModeCount([In] unsigned int Adapter,[In] D3DFORMAT Format)</unmanaged>
 public unsafe int GetAdapterModeCount(int adapter, D3DFORMAT format)
 {
     //return calli(System.Int32(System.Void*,System.Int32,System.Int32), this._nativePointer, adapter, format, *(*(IntPtr*)this._nativePointer + (IntPtr)6 * (IntPtr)sizeof(void*)));
     return(NativeHelper.CalliInt32(6, _nativePointer, (int)adapter, (int)format));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Copies pixels from an address in memory into a mip level of Texture2D, converting them from one format to another if necessary.
 /// </summary>
 /// <param name="texture">The texture to copy to.</param>
 /// <param name="level">The index into the texture's mip levels.</param>
 /// <param name="pData">The address of the pixel data.</param>
 /// <param name="destRect">The destination rectangle.</param>
 /// <param name="pitch">The number of bytes occupied by a single row of the pixel data (including padding at the end of rows).</param>
 /// <param name="sourceRect">The source rectangle.</param>
 /// <param name="pixelFormat">The format of the pixel data.</param>
 public static unsafe void SetData(
     this Texture2D texture, void* pSurface, void* pData,
     ref RECT destRect, uint pitch, ref RECT sourceRect,
     D3DFORMAT pixelFormat
 )
 {
     fixed (RECT* pDestRect = &destRect)
     fixed (RECT* pSourceRect = &sourceRect) {
         var rv = D3DXLoadSurfaceFromMemory(pSurface, null, pDestRect, pData, pixelFormat, pitch, null, pSourceRect, D3DX_FILTER.NONE, 0);
         if (rv != 0)
             throw new COMException("D3DXLoadSurfaceFromMemory failed", rv);
     }
 }
Exemplo n.º 10
0
 private static unsafe extern int D3DXLoadSurfaceFromMemory(
     void* pDestSurface,
     void* pDestPalette,
     RECT* pDestRect,
     void* pSrcMemory,
     D3DFORMAT srcFormat,
     uint srcPitch,
     void* pSrcPalette,
     RECT* pSrcRect,
     D3DX_FILTER filter,
     uint colorKey
     );
Exemplo n.º 11
0
        /// <summary>
        /// Copies pixels from an address in memory into a mip level of Texture2D, converting them from one format to another if necessary.
        /// </summary>
        /// <param name="texture">The texture to copy to.</param>
        /// <param name="level">The index into the texture's mip levels.</param>
        /// <param name="pData">The address of the pixel data.</param>
        /// <param name="updateRect">The dimension and position of the rectangle to paint.</param>
        /// <param name="pitch">The number of bytes occupied by a single row of the pixel data (including padding at the end of rows).</param>
        /// <param name="pixelFormat">The format of the pixel data.</param>
        public static unsafe void SetData(
            this Texture2D texture, int level, void* pData,
            Rectangle updateRect, uint pitch,
            D3DFORMAT pixelFormat
            )
        {
            var rect = new RECT
            {
                Top = updateRect.Y,
                Left = updateRect.X,
                Right = updateRect.Width,
                Bottom = updateRect.Height
            };

            void* pSurface = GetSurfaceLevel(texture, level);

            try
            {
                var rv = D3DXLoadSurfaceFromMemory(pSurface, null, &rect, pData, pixelFormat, pitch, null, &rect, D3DX_FILTER.NONE, 0);
                if (rv != 0)
                    throw new COMException("D3DXLoadSurfaceFromMemory failed", rv);
            }
            finally
            {
                Marshal.Release(new IntPtr(pSurface));
            }
        }
Exemplo n.º 12
0
        public void Empty()
        {
            BackBufferWidth = 0;
            BackBufferHeight = 0;
            BackBufferFormat = 0;
            BackBufferCount = 0;

            MultiSampleType = 0;
            MultiSampleQuality = 0;

            SwapEffect = 0;
            hDeviceWindow = IntPtr.Zero;
            Windowed = false;
            EnableAutoDepthStencil = false;
            AutoDepthStencilFormat = 0;
            Flags = 0;

            /* FullScreen_RefreshRateInHz must be zero for Windowed mode */
            FullScreen_RefreshRateInHz = 0;
            PresentationInterval = 0;
        }
Exemplo n.º 13
0
        public unsafe static Direct3DTexture9 CreateTexture(Direct3DDevice9 device, int width, int height, int mipLevels, int usage, D3DFORMAT format, D3DPOOL pool)
        {
            var nativePointer = IntPtr.Zero;
            var hr            = (HRESULT)NativeMethods.D3DXCreateTexture_(
                (void *)((device == null) ? IntPtr.Zero : device.NativePointer),
                width, height, mipLevels,
                (int)usage, (int)format, (int)pool,
                (void *)&nativePointer);

            hr.CheckError();
            if (nativePointer == null)
            {
                return(null);
            }
            return(new Direct3DTexture9(nativePointer));
        }
Exemplo n.º 14
0
        public Direct3DTexture9 CreateTexture(int width, int height, int levelCount, D3DUSAGE usage, D3DFORMAT format, D3DPOOL pool)
        {
            var nativePointer = IntPtr.Zero;
            var hr            = CreateTexture_(width, height, levelCount, usage, format, pool, out nativePointer);

            hr.CheckError();
            if (nativePointer == IntPtr.Zero)
            {
                return(null);
            }
            return(new Direct3DTexture9(nativePointer));
        }
Exemplo n.º 15
0
 public NVRIndexBuffer(D3DFORMAT format)
 {
     this.Format = format;
 }
Exemplo n.º 16
0
 /// <unmanaged>HRESULT IDirect3DDevice9::CreateTexture([In] unsigned int Width,[In] unsigned int Height,[In] unsigned int Levels,[In] unsigned int Usage,[In] D3DFORMAT Format,[In] D3DPOOL Pool,[Out, Fast] IDirect3DTexture9** ppTexture,[In] void** pSharedHandle)</unmanaged>
 private unsafe HRESULT CreateTexture_(int width, int height, int levels, D3DUSAGE usage, D3DFORMAT format, D3DPOOL pool, out IntPtr pTexture)
 {
     fixed(void *ppTexture = &pTexture)
     {
         //result = calli(System.Int32(System.Void*,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Void*,System.Void*), this._nativePointer, width, height, levels, usage, format, pool, &zero, (void*)sharedHandleRef, *(*(IntPtr*)this._nativePointer + (IntPtr)23 * (IntPtr)sizeof(void*)));
         return((HRESULT)NativeHelper.CalliInt32(23, _nativePointer, (int)width, (int)height, (int)levels, (int)usage, (int)format, (int)pool, (void *)ppTexture, (void *)IntPtr.Zero));
     }
 }
Exemplo n.º 17
0
 public UnsupportedD3DFORMATException(D3DFORMAT actual) : base(String.Format("This D3DFORMAT ({0}) is not supported.", actual))
 {
 }
Exemplo n.º 18
0
        /// <summary>
        /// Sets the buffer of texture to pData (not sure if it copies memory or just assigns the pointer)
        /// </summary>
        /// <param name="texture"></param>
        /// <param name="level"></param>
        /// <param name="pData">pointer to source memory buffer</param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="pitch"></param>
        /// <param name="pixelFormat"></param>
        public static unsafe void SetData(this Texture2D texture, int level, void *pData, int width, int height, uint pitch, D3DFORMAT pixelFormat)
        {
            var rect = new RECT {
                Top = 0, Left = 0, Right = width, Bottom = height
            };
            void *pSurface = GetSurfaceLevel(texture, level);

            try
            {
                var rv = D3DXLoadSurfaceFromMemory(pSurface, null, &rect, pData, pixelFormat, pitch, null, &rect, D3DX_FILTER.NONE, 0);

                if (rv != 0)
                {
                    throw new COMException("D3DXLoadSurfaceFromMemory failed", rv);
                }
            }
            finally
            {
                Release(pSurface);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Copies pixels from an address in memory into a mip level of Texture2D, converting them from one format to another if necessary.
        /// </summary>
        /// <param name="texture">The texture to copy to.</param>
        /// <param name="level">The index into the texture's mip levels.</param>
        /// <param name="pData">The address of the pixel data.</param>
        /// <param name="width">The width of the pixel data (in pixels).</param>
        /// <param name="height">The height of the pixel data (in pixels).</param>
        /// <param name="pitch">The number of bytes occupied by a single row of the pixel data (including padding at the end of rows).</param>
        /// <param name="pixelFormat">The format of the pixel data.</param>
        public static unsafe void SetData(
            this Texture2D texture, void* pSurface, void* pData, 
            int width, int height, uint pitch, 
            D3DFORMAT pixelFormat
        )
        {
            var rect = new RECT {
                Top = 0,
                Left = 0,
                Right = width,
                Bottom = height
            };

            SetData(texture, pSurface, pData, ref rect, pitch, ref rect, pixelFormat);
        }