public static T CreateDirect3D11SurfaceFromDXGISurface <T>(IDXGISurface dgxiSurface) { CreateDirect3D11SurfaceFromDXGISurface(dgxiSurface, out IntPtr graphicsSurfacePtr).CheckError(); T graphicsSurface = (T)Marshal.GetObjectForIUnknown(graphicsSurfacePtr); Marshal.Release(graphicsSurfacePtr); return(graphicsSurface); }
private ID3D11Texture2D GetHolographicBackBuffer() { HolographicSurface = HolographicFrame.GetRenderingParameters(HolographicFrame.CurrentPrediction.CameraPoses[0]).Direct3D11BackBuffer; using IDXGISurface surface = Direct3DInterop.CreateDXGISurface(HolographicSurface); ID3D11Texture2D d3DBackBuffer = new ID3D11Texture2D(surface.NativePointer); PresentationParameters.BackBufferFormat = (PixelFormat)d3DBackBuffer.Description.Format; PresentationParameters.BackBufferWidth = d3DBackBuffer.Description.Width; PresentationParameters.BackBufferHeight = d3DBackBuffer.Description.Height; return(d3DBackBuffer); }
public static Result CreateDirect3D11SurfaceFromDXGISurface <T>(IDXGISurface dgxiSurface, out T?graphicsSurface) { Result result = CreateDirect3D11SurfaceFromDXGISurface(dgxiSurface, out IntPtr graphicsSurfacePtr); if (result.Failure) { graphicsSurface = default; return(result); } graphicsSurface = (T)Marshal.GetObjectForIUnknown(graphicsSurfacePtr); Marshal.Release(graphicsSurfacePtr); return(result); }
internal static IDirect3DSurface CreateDirect3DSurface(IDXGISurface dxgiSurface) { Result result = CreateDirect3D11SurfaceFromDXGISurface(dxgiSurface.NativePointer, out IntPtr graphicsSurface); if (result.Failure) { throw new COMException("Surface creation failed.", result.Code); } IDirect3DSurface d3DSurface = (IDirect3DSurface)Marshal.GetObjectForIUnknown(graphicsSurface); Marshal.Release(graphicsSurface); return(d3DSurface); }
internal static IDirect3DSurface CreateDirect3DSurface(IDXGISurface dxgiSurface) { Result result = CreateDirect3D11SurfaceFromDXGISurface(dxgiSurface.NativePointer, out IntPtr graphicsSurface); if (result.Failure) { throw new InvalidOperationException(result.Code.ToString()); } IDirect3DSurface d3DSurface = (IDirect3DSurface)Marshal.GetObjectForIUnknown(graphicsSurface); Marshal.Release(graphicsSurface); return(d3DSurface); }
public static void CreateDeviceSwapChainBitmap( IDXGISwapChain1 swapChain, ID2D1DeviceContext target) { using (IDXGISurface surface = swapChain.GetBuffer <IDXGISurface>(0)) { var props = new BitmapProperties1 { BitmapOptions = BitmapOptions.Target | BitmapOptions.CannotDraw, PixelFormat = new Vortice.DCommon.PixelFormat(Format.B8G8R8A8_UNorm, Vortice.DCommon.AlphaMode.Ignore) }; using (var bitmap = target.CreateBitmapFromDxgiSurface(surface, props)) { target.Target = bitmap; } } }
public unsafe Result BeginDraw(RawRect updateRect, out IDXGISurface surface, out Point offset) { IntPtr surfacePtr = IntPtr.Zero; Result result; fixed(void *offset_ = &offset) { result = LocalInterop.CalliStdCallint0(_nativePointer, updateRect, &surfacePtr, offset_, (*(void ***)_nativePointer)[4]); } if (result.Failure) { surface = default; offset = default; return(result); } surface = new IDXGISurface(surfacePtr); return(result); }
public ID2D1Bitmap CreateSharedBitmap(IDXGISurface surface, BitmapProperties?bitmapProperties) { Guard.NotNull(surface, nameof(surface)); return(CreateSharedBitmap(typeof(IDXGISurface).GUID, surface.NativePointer, bitmapProperties)); }
public static ComObject <T> CreateBitmapFromDxgiSurface <T>(this ID2D1DeviceContext device, IDXGISurface surface, D2D1_BITMAP_PROPERTIES1?properties = null) where T : ID2D1Bitmap1 { if (device == null) { throw new ArgumentNullException(nameof(device)); } if (surface == null) { throw new ArgumentNullException(nameof(surface)); } using (var mem = properties.StructureToMemory()) { device.CreateBitmapFromDxgiSurface(surface, mem.Pointer, out var bmp).ThrowOnError(); return(new ComObject <T>((T)bmp)); } }
public static IComObject <T> CreateDxgiSurfaceRenderTarget <T>(this ID2D1Factory1 factory, IDXGISurface surface, D2D1_RENDER_TARGET_PROPERTIES properties) where T : ID2D1RenderTarget { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } if (surface == null) { throw new ArgumentNullException(nameof(surface)); } factory.CreateDxgiSurfaceRenderTarget(surface, ref properties, out var target).ThrowOnError(); return(new ComObject <T>((T)target)); }