コード例 #1
0
        public void CreateD3D9TextureFromD3D10Texture(SharpDX.Direct3D10.Texture2D Texture)
        {
            DirectXHelpers.SafeDispose(ref shareableTexture9);

            if (IsShareable(Texture))
            {
                SharpDX.Direct3D9.Format format = TranslateFormat(Texture);
                if (format == SharpDX.Direct3D9.Format.Unknown)
                {
                    throw new ArgumentException("Texture format is not compatible with OpenSharedResource");
                }

                IntPtr Handle = GetSharedHandle(Texture);
                if (Handle == IntPtr.Zero)
                {
                    throw new ArgumentNullException("Handle");
                }

                shareableTexture9 = new SharpDX.Direct3D9.Texture(sharpDXGraphicsDeviceService9.GraphicsDevice, Texture.Description.Width, Texture.Description.Height, 1, SharpDX.Direct3D9.Usage.RenderTarget, format, SharpDX.Direct3D9.Pool.Default, ref Handle);
            }
            else
            {
                throw new ArgumentException("Texture must be created with ResourceOptionFlags.Shared");
            }
        }
コード例 #2
0
ファイル: DX9FormatExtension.cs プロジェクト: Radviger/MultiV
        public static int ToPixelDepth(this SharpDX.Direct3D9.Format format)
        {
            // Only support the DX9 BackBuffer formats: http://msdn.microsoft.com/en-us/library/windows/desktop/bb172558(v=vs.85).aspx
            switch (format)
            {
            case SharpDX.Direct3D9.Format.A2R10G10B10:
            case SharpDX.Direct3D9.Format.A8R8G8B8:
            case SharpDX.Direct3D9.Format.X8R8G8B8:
                return(32);

            case SharpDX.Direct3D9.Format.R5G6B5:
            case SharpDX.Direct3D9.Format.A1R5G5B5:
            case SharpDX.Direct3D9.Format.X1R5G5B5:
                return(16);

            default:
                return(-1);
            }
        }
コード例 #3
0
ファイル: DX9FormatExtension.cs プロジェクト: Radviger/MultiV
        public static System.Drawing.Imaging.PixelFormat ToPixelFormat(this SharpDX.Direct3D9.Format format)
        {
            // Only support the BackBuffer formats: http://msdn.microsoft.com/en-us/library/windows/desktop/bb172558(v=vs.85).aspx
            // and of these only those that have a direct mapping to supported PixelFormat's
            switch (format)
            {
            case SharpDX.Direct3D9.Format.A8R8G8B8:
            case SharpDX.Direct3D9.Format.X8R8G8B8:
                return(System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            case SharpDX.Direct3D9.Format.R5G6B5:
                return(System.Drawing.Imaging.PixelFormat.Format16bppRgb565);

            case SharpDX.Direct3D9.Format.A1R5G5B5:
            case SharpDX.Direct3D9.Format.X1R5G5B5:
                return(System.Drawing.Imaging.PixelFormat.Format16bppArgb1555);

            default:
                return(System.Drawing.Imaging.PixelFormat.Undefined);
            }
        }
コード例 #4
0
ファイル: ImagePlayer.cs プロジェクト: vnmone/vvvv-sdk
        private SharpDX.Direct3D9.Texture CreateTextureForDecoder(SharpDX.Direct3D9.Device device, int width, int height, int levels, SharpDX.Direct3D9.Format format, SharpDX.Direct3D9.Usage usage)
        {
            var pool    = SharpDX.Direct3D9.Pool.Default;
            var texture = FTexturePool.GetTexture(EX9.Device.FromPointer(device.NativePointer), width, height, levels, (EX9.Usage)usage, (EX9.Format)format, (EX9.Pool)pool);

            return(new SharpDX.Direct3D9.Texture(texture.ComPointer));
        }
コード例 #5
0
ファイル: Volume.cs プロジェクト: zmtzawqlp/SharpDX
        /// <summary>
        /// Loads a volume from memory.
        /// </summary>
        /// <param name="destPaletteRef"><para>Pointer to a  <see cref="SharpDX.Direct3D9.PaletteEntry"/> structure, the destination palette of 256 colors or <c>null</c>.</para></param>
        /// <param name="destBox"><para>Pointer to a <see cref="SharpDX.Direct3D9.Box"/> structure. Specifies the destination box. Set this parameter to <c>null</c> to specify the entire volume.</para></param>
        /// <param name="srcMemoryPointer"><para>Pointer to the top-left corner of the source volume in memory.</para></param>
        /// <param name="srcFormat"><para>Member of the <see cref="SharpDX.Direct3D9.Format"/> enumerated type, the pixel format of the source volume.</para></param>
        /// <param name="srcRowPitch"><para>Pitch of source image, in bytes. For DXT formats (compressed texture formats), this number should represent the size of one row of cells, in bytes.</para></param>
        /// <param name="srcSlicePitch"><para>Pitch of source image, in bytes. For DXT formats (compressed texture formats), this number should represent the size of one slice of cells, in bytes.</para></param>
        /// <param name="srcPaletteRef"><para>Pointer to a <see cref="SharpDX.Direct3D9.PaletteEntry"/> structure, the source palette of 256 colors or <c>null</c>.</para></param>
        /// <param name="srcBox"><para>Pointer to a <see cref="SharpDX.Direct3D9.Box"/> structure. Specifies the source box. <c>null</c> is not a valid value for this parameter.</para></param>
        /// <param name="filter"><para>A combination of one or more <see cref="SharpDX.Direct3D9.Filter"/> controlling how the image is filtered. Specifying D3DX_DEFAULT for this parameter is the equivalent of specifying <see cref="SharpDX.Direct3D9.Filter.Triangle"/> | <see cref="SharpDX.Direct3D9.Filter.Dither"/>.</para></param>
        /// <param name="colorKey"><para> <see cref="RawColor4"/> value to replace with transparent black, or 0 to disable the color key. This is always a 32-bit ARGB color, independent of the source image format. Alpha is significant and should usually be set to FF for opaque color keys. Thus, for opaque black, the value would be equal to 0xFF000000.</para></param>
        /// <returns>If the function succeeds, the return value is <see cref="SharpDX.Direct3D9.ResultCode.Success"/>. If the function fails, the return value can be one of the following values: <see cref="SharpDX.Direct3D9.ResultCode.InvalidCall"/>, D3DXERR_INVALIDDATA.</returns>
        /// <remarks>
        /// Writing to a non-level-zero surface of the volume texture will not cause the dirty rectangle to be updated. If <see cref="SharpDX.Direct3D9.D3DX9.LoadVolumeFromMemory"/> is called and the texture was not already dirty (this is unlikely under normal usage scenarios), the application needs to explicitly call <see cref="SharpDX.Direct3D9.VolumeTexture.AddDirtyBox"/> on the volume texture.
        /// </remarks>
        /// <unmanaged>HRESULT D3DXLoadVolumeFromMemory([In] IDirect3DVolume9* pDestVolume,[Out, Buffer] const PALETTEENTRY* pDestPalette,[In] const void* pDestBox,[In] const void* pSrcMemory,[In] D3DFORMAT SrcFormat,[In] unsigned int SrcRowPitch,[In] unsigned int SrcSlicePitch,[In, Buffer] const PALETTEENTRY* pSrcPalette,[In] const void* pSrcBox,[In] D3DX_FILTER Filter,[In] int ColorKey)</unmanaged>
        public unsafe void LoadFromMemory(SharpDX.Direct3D9.PaletteEntry[] destPaletteRef, Box?destBox, System.IntPtr srcMemoryPointer, SharpDX.Direct3D9.Format srcFormat, int srcRowPitch, int srcSlicePitch, SharpDX.Direct3D9.PaletteEntry[] srcPaletteRef, Box srcBox, SharpDX.Direct3D9.Filter filter, RawColorBGRA colorKey)
        {
            Box localDestBox;

            if (destBox.HasValue)
            {
                localDestBox = destBox.Value;
            }

            D3DX9.LoadVolumeFromMemory(
                this, destPaletteRef, new IntPtr(&localDestBox), srcMemoryPointer, srcFormat, srcRowPitch, srcSlicePitch, srcPaletteRef, new IntPtr(&srcBox), filter, *(int *)&colorKey);
        }
コード例 #6
0
ファイル: RenderToSurface.cs プロジェクト: zmtzawqlp/SharpDX
 /// <summary>
 /// Creates a render surface.
 /// </summary>
 /// <param name="device"><dd>  <p>Pointer to an <strong><see cref="SharpDX.Direct3D9.Device"/></strong> interface, the device to be associated with the render surface.</p> </dd></param>
 /// <param name="width"><dd>  <p>Width of the render surface, in pixels.</p> </dd></param>
 /// <param name="height"><dd>  <p>Height of the render surface, in pixels.</p> </dd></param>
 /// <param name="format"><dd>  <p>Member of the <see cref="SharpDX.Direct3D9.Format"/> enumerated type, describing the pixel format of the render surface.</p> </dd></param>
 /// <param name="depthStencil"><dd>  <p>If <strong>TRUE</strong>, the render surface supports a depth-stencil surface. Otherwise, this member is set to <strong><see cref="SharpDX.Result.False"/></strong>. This function will create a new depth buffer.</p> </dd></param>
 /// <param name="depthStencilFormat"><dd>  <p>If  <em>DepthStencil</em> is set to <strong>TRUE</strong>, this parameter is a member of the <see cref="SharpDX.Direct3D9.Format"/> enumerated type, describing the depth-stencil format of the render surface.</p> </dd></param>
 /// <msdn-id>bb172791</msdn-id>
 /// <unmanaged>HRESULT D3DXCreateRenderToSurface([In] IDirect3DDevice9* pDevice,[In] unsigned int Width,[In] unsigned int Height,[In] D3DFORMAT Format,[In] BOOL DepthStencil,[In] D3DFORMAT DepthStencilFormat,[In] ID3DXRenderToSurface** ppRenderToSurface)</unmanaged>
 /// <unmanaged-short>D3DXCreateRenderToSurface</unmanaged-short>
 public RenderToSurface(SharpDX.Direct3D9.Device device, int width, int height, SharpDX.Direct3D9.Format format, bool depthStencil = false, SharpDX.Direct3D9.Format depthStencilFormat = Format.Unknown) : base(IntPtr.Zero)
 {
     D3DX9.CreateRenderToSurface(device, width, height, format, depthStencil, depthStencilFormat, this);
 }
コード例 #7
0
ファイル: Structures.cs プロジェクト: alexey-bez/SharpDX
		// Method to marshal from native to managed struct
        internal unsafe void __MarshalFrom(ref __Native @ref)
        {            
            this.Size = @ref.Size;
            this.Width = @ref.Width;
            this.Height = @ref.Height;
            this.RefreshRate = @ref.RefreshRate;
            this.Format = @ref.Format;
            this.ScanLineOrdering = @ref.ScanLineOrdering;
        }