/// <summary> /// Initializes a new instance of <see cref="VertexBuffer"/> class. /// </summary> /// <param name="context">Instance of an effect context</param> /// <param name="resourceId"></param> /// <param name="vertexBufferProperties"></param> /// <param name="customVertexBufferProperties"></param> public VertexBuffer(EffectContext context, System.Guid resourceId, SharpDX.Direct2D1.VertexBufferProperties vertexBufferProperties, CustomVertexBufferProperties customVertexBufferProperties) : base(IntPtr.Zero) { unsafe { var customVertexBufferPropertiesNative = new CustomVertexBufferProperties.__Native(); customVertexBufferProperties.__MarshalTo(ref customVertexBufferPropertiesNative); var inputElementsNative = new InputElement.__Native[customVertexBufferProperties.InputElements.Length]; try { for (int i = 0; i < customVertexBufferProperties.InputElements.Length; i++) customVertexBufferProperties.InputElements[i].__MarshalTo(ref inputElementsNative[i]); fixed (void* pInputElements = inputElementsNative) { customVertexBufferPropertiesNative.InputElementsPointer = (IntPtr)pInputElements; customVertexBufferPropertiesNative.ElementCount = customVertexBufferProperties.InputElements.Length; fixed (void* pInputSignature = customVertexBufferProperties.InputSignature) { customVertexBufferPropertiesNative.ShaderBufferSize = customVertexBufferProperties.InputSignature.Length; customVertexBufferPropertiesNative.ShaderBufferWithInputSignature = (IntPtr)pInputSignature; context.CreateVertexBuffer(vertexBufferProperties, resourceId, new IntPtr(&customVertexBufferPropertiesNative), this); } } } finally { for (int i = 0; i < inputElementsNative.Length; i++) inputElementsNative[i].__MarshalFree(); } } }
/// <summary> /// Initializes a new instance of <see cref="VertexBuffer"/> class. /// </summary> /// <param name="context">Instance of an effect context</param> /// <param name="resourceId"></param> /// <param name="vertexBufferProperties"></param> /// <param name="customVertexBufferProperties"></param> public VertexBuffer(EffectContext context, System.Guid resourceId, SharpDX.Direct2D1.VertexBufferProperties vertexBufferProperties, CustomVertexBufferProperties customVertexBufferProperties) : base(IntPtr.Zero) { unsafe { var customVertexBufferPropertiesNative = new CustomVertexBufferProperties.__Native(); customVertexBufferProperties.__MarshalTo(ref customVertexBufferPropertiesNative); var inputElementsNative = new InputElement.__Native[customVertexBufferProperties.InputElements.Length]; try { for (int i = 0; i < customVertexBufferProperties.InputElements.Length; i++) { customVertexBufferProperties.InputElements[i].__MarshalTo(ref inputElementsNative[i]); fixed(void *pInputElements = inputElementsNative) { customVertexBufferPropertiesNative.InputElementsPointer = (IntPtr)pInputElements; customVertexBufferPropertiesNative.ElementCount = customVertexBufferProperties.InputElements.Length; fixed(void *pInputSignature = customVertexBufferProperties.InputSignature) { customVertexBufferPropertiesNative.ShaderBufferSize = customVertexBufferProperties.InputSignature.Length; customVertexBufferPropertiesNative.ShaderBufferWithInputSignature = (IntPtr)pInputSignature; context.CreateVertexBuffer(vertexBufferProperties, resourceId, new IntPtr(&customVertexBufferPropertiesNative), this); } } } finally { for (int i = 0; i < inputElementsNative.Length; i++) inputElementsNative[i].__MarshalFree(); } } }
private unsafe static void CreateResourceTexture(EffectContext context, System.Guid resourceId, SharpDX.Direct2D1.ResourceTextureProperties resourceTextureProperties, byte[] data, int[] strides, ResourceTexture outTexture) { var resourceTexturePropertiesNative = new ResourceTextureProperties.__Native(); resourceTextureProperties.__MarshalTo(ref resourceTexturePropertiesNative); if (resourceTextureProperties.Extents == null || resourceTextureProperties.Extents.Length != resourceTextureProperties.Dimensions) throw new ArgumentException("Extents array must be same size than dimensions", "resourceTextureProperties"); if (resourceTextureProperties.ExtendModes == null || resourceTextureProperties.ExtendModes.Length != resourceTextureProperties.Dimensions) throw new ArgumentException("ExtendModes array must be same size than dimensions", "resourceTextureProperties"); fixed (void* pExtents = resourceTextureProperties.Extents) { fixed (void* pExtendModes = resourceTextureProperties.ExtendModes) { resourceTexturePropertiesNative.ExtentsPointer = (IntPtr)pExtents; resourceTexturePropertiesNative.ExtendModesPointer = (IntPtr)pExtendModes; context.CreateResourceTexture(resourceId, new IntPtr(&resourceTexturePropertiesNative), data, strides, data == null ? 0 : data.Length, outTexture); } } }
//EffectContext _effectContext; public override void Initialize(EffectContext effectContext, TransformGraph transformGraph) { //WARNING : as soon as TransformGraph.SetSingleTransformNode is called it chain calls the //SetDrawInformation via a callbac. Unfortunately this is too early because the code below //within this method is used to populate stateful data needed by the SetDrawInformation call. //transformGraph.SetSingleTransformNode(this); var path = Windows.ApplicationModel.Package.Current.InstalledLocation.Path; byte[] vertexShaderBytecode = NativeFile.ReadAllBytes(path + "\\WaveEffect.cso"); effectContext.LoadVertexShader(GUID_WaveVertexShader, vertexShaderBytecode); // Only generate the vertex buffer if it has not already been initialized. vertexBuffer = effectContext.FindVertexBuffer(GUID_WaveVertexBuffer); if (vertexBuffer == null) { //InitializeVertexBuffer(effectContext); var mesh = GenerateMesh(); // Updating geometry every time the effect is rendered can be costly, so it is // recommended that vertex buffer remain static if possible (which it is in this // sample effect). using (var stream = DataStream.Create(mesh, true, true)) { var vbProp = new VertexBufferProperties(1, VertexUsage.Static, stream); var cvbProp = new CustomVertexBufferProperties(vertexShaderBytecode, new[] { new InputElement("MESH_POSITION", 0, SharpDX.DXGI.Format.R32G32_Float,0,0), }, Utilities.SizeOf<Vector2>()); // The GUID is optional, and is provided here to register the geometry globally. // As mentioned above, this avoids duplication if multiple versions of the effect // are created. vertexBuffer = new VertexBuffer(effectContext, GUID_WaveVertexBuffer, vbProp, cvbProp); } } PrepareForRender(ChangeType.Properties|ChangeType.Context); transformGraph.SetSingleTransformNode(this); }
private unsafe static void CreateResourceTexture(EffectContext context, System.Guid resourceId, SharpDX.Direct2D1.ResourceTextureProperties resourceTextureProperties, byte[] data, int[] strides, ResourceTexture outTexture) { var resourceTexturePropertiesNative = new ResourceTextureProperties.__Native(); resourceTextureProperties.__MarshalTo(ref resourceTexturePropertiesNative); if (resourceTextureProperties.Extents == null || resourceTextureProperties.Extents.Length != resourceTextureProperties.Dimensions) { throw new ArgumentException("Extents array must be same size than dimensions", "resourceTextureProperties"); } if (resourceTextureProperties.ExtendModes == null || resourceTextureProperties.ExtendModes.Length != resourceTextureProperties.Dimensions) throw new ArgumentException("ExtendModes array must be same size than dimensions", "resourceTextureProperties"); fixed(void *pExtents = resourceTextureProperties.Extents) { fixed(void *pExtendModes = resourceTextureProperties.ExtendModes) { resourceTexturePropertiesNative.ExtentsPointer = (IntPtr)pExtents; resourceTexturePropertiesNative.ExtendModesPointer = (IntPtr)pExtendModes; context.CreateResourceTexture(resourceId, new IntPtr(&resourceTexturePropertiesNative), data, strides, data == null ? 0 : data.Length, outTexture); } } }
/// <summary> /// Initializes a new instance of <see cref="ColorContext"/> class from a color profile. /// </summary> /// <param name="space">No documentation.</param> /// <param name="rofileRef">No documentation.</param> /// <param name="profileSize">No documentation.</param> /// <param name="colorContext">No documentation.</param> /// <returns>No documentation.</returns> /// <unmanaged>HRESULT ID2D1EffectContext::CreateColorContext([In] D2D1_COLOR_SPACE space,[In, Buffer, Optional] const unsigned char* profile,[In] unsigned int profileSize,[Out] ID2D1ColorContext** colorContext)</unmanaged> public ColorContext(EffectContext context, SharpDX.Direct2D1.ColorSpace space, byte[] profileRef) : base(IntPtr.Zero) { context.CreateColorContext(space, profileRef, profileRef.Length, this); }
/// <summary> /// Initializes a new instance of <see cref="ColorContext"/> class from a color profile. /// </summary> /// <param name="context">The effect context.</param> /// <param name="space">The space of color context to create.</param> /// <param name="profileRef">No documentation.</param> /// <unmanaged>HRESULT ID2D1EffectContext::CreateColorContext([In] D2D1_COLOR_SPACE space,[In, Buffer, Optional] const unsigned char* profile,[In] unsigned int profileSize,[Out] ID2D1ColorContext** colorContext)</unmanaged> public ColorContext(EffectContext context, SharpDX.Direct2D1.ColorSpace space, byte[] profileRef) : base(IntPtr.Zero) { context.CreateColorContext(space, profileRef, profileRef.Length, this); }
/// <summary> /// Initializes a new instance of <see cref="BlendTransform"/> class /// </summary> /// <param name="context">The effect context</param> /// <param name="resourceId">A unique identifier to the resource</param> /// <param name="resourceTextureProperties">The description of the resource</param> /// <param name="data">The data to be loaded into the resource texture.</param> /// <param name="strides">Reference to the stride to advance through the resource texture, according to dimension.</param> /// <unmanaged>HRESULT ID2D1EffectContext::CreateResourceTexture([In, Optional] const GUID* resourceId,[In] const D2D1_RESOURCE_TEXTURE_PROPERTIES* resourceTextureProperties,[In, Buffer, Optional] const unsigned char* data,[In, Buffer, Optional] const unsigned int* strides,[In] unsigned int dataSize,[Out] ID2D1ResourceTexture** resourceTexture)</unmanaged> public ResourceTexture(EffectContext context, System.Guid resourceId, SharpDX.Direct2D1.ResourceTextureProperties resourceTextureProperties, byte[] data, int[] strides) : base(IntPtr.Zero) { CreateResourceTexture(context, resourceId, resourceTextureProperties, data, strides, this); }
/// <summary> /// Initializes a new instance of <see cref="BlendTransform"/> class /// </summary> /// <param name="context">The effect context</param> /// <param name="resourceId">A unique identifier to the resource</param> /// <param name="resourceTextureProperties">The description of the resource</param> /// <unmanaged>HRESULT ID2D1EffectContext::CreateResourceTexture([In, Optional] const GUID* resourceId,[In] const D2D1_RESOURCE_TEXTURE_PROPERTIES* resourceTextureProperties,[In, Buffer, Optional] const unsigned char* data,[In, Buffer, Optional] const unsigned int* strides,[In] unsigned int dataSize,[Out] ID2D1ResourceTexture** resourceTexture)</unmanaged> public ResourceTexture(EffectContext context, System.Guid resourceId, SharpDX.Direct2D1.ResourceTextureProperties resourceTextureProperties) : base(IntPtr.Zero) { CreateResourceTexture(context, resourceId, resourceTextureProperties, null, null, this); }
/// <summary> /// Initializes a new instance of <see cref="ColorContext"/> class from a filename. /// </summary> /// <param name="context">The effect context.</param> /// <param name="filename">The path to the file containing the profile bytes to initialize the color context with..</param> /// <unmanaged>HRESULT ID2D1EffectContext::CreateColorContextFromFilename([In] const wchar_t* filename,[Out] ID2D1ColorContext** colorContext)</unmanaged> public ColorContext(EffectContext context, string filename) : base(IntPtr.Zero) { context.CreateColorContextFromFilename(filename, this); }
/// <summary> /// Initializes a new instance of <see cref="BlendTransform"/> class /// </summary> /// <param name="context">The effect context</param> /// <param name="resourceId">A unique identifier to the resource</param> /// <param name="resourceTextureProperties">The description of the resource</param> /// <param name="data">The data to be loaded into the resource texture.</param> /// <param name="strides">Reference to the stride to advance through the resource texture, according to dimension.</param> /// <unmanaged>HRESULT ID2D1EffectContext::CreateResourceTexture([In, Optional] const GUID* resourceId,[In] const D2D1_RESOURCE_TEXTURE_PROPERTIES* resourceTextureProperties,[In, Buffer, Optional] const unsigned char* data,[In, Buffer, Optional] const unsigned int* strides,[In] unsigned int dataSize,[Out] ID2D1ResourceTexture** resourceTexture)</unmanaged> public ResourceTexture(EffectContext context, System.Guid resourceId, SharpDX.Direct2D1.ResourceTextureProperties resourceTextureProperties, byte[] data, int[] strides) : base(IntPtr.Zero) { CreateResourceTexture(context, resourceId, resourceTextureProperties, data, strides, this); }
/// <summary> /// Initialzies a new instance of <see cref="BorderTransform"/> class /// </summary> /// <param name="context">The effect context</param> /// <param name="extendModeX">The extend mode for X coordinates</param> /// <param name="extendModeY">The extend mode for Y coordinates</param> /// <unmanaged>HRESULT ID2D1EffectContext::CreateBorderTransform([In] D2D1_EXTEND_MODE extendModeX,[In] D2D1_EXTEND_MODE extendModeY,[Out, Fast] ID2D1BorderTransform** transform)</unmanaged> public BorderTransform(EffectContext context, SharpDX.Direct2D1.ExtendMode extendModeX, SharpDX.Direct2D1.ExtendMode extendModeY) : base(IntPtr.Zero) { context.CreateBorderTransform(extendModeX, ExtendModeX, this); }
/// <summary> /// Initialzies a new instance of <see cref="BorderTransform"/> class /// </summary> /// <param name="context">The effect context</param> /// <param name="extendModeX">The extend mode for X coordinates</param> /// <param name="extendModeY">The extend mode for Y coordinates</param> /// <unmanaged>HRESULT ID2D1EffectContext::CreateBorderTransform([In] D2D1_EXTEND_MODE extendModeX,[In] D2D1_EXTEND_MODE extendModeY,[Out, Fast] ID2D1BorderTransform** transform)</unmanaged> public BorderTransform(EffectContext context, SharpDX.Direct2D1.ExtendMode extendModeX, SharpDX.Direct2D1.ExtendMode extendModeY) : base(IntPtr.Zero) { context.CreateBorderTransform(extendModeX, ExtendModeX, this); }
/// <summary> /// Initializes a new instance of <see cref="OffsetTransform"/> class /// </summary> /// <param name="context">The effect context</param> /// <param name="offset">The offset transformation</param> /// <unmanaged>HRESULT ID2D1EffectContext::CreateOffsetTransform([In] POINT offset,[Out, Fast] ID2D1OffsetTransform** transform)</unmanaged> public OffsetTransform(EffectContext context, SharpDX.Point offset) : base(IntPtr.Zero) { context.CreateOffsetTransform(offset, this); }
/// <summary> /// Initializes a new instance of <see cref="BoundsAdjustmentTransform"/> class /// </summary> /// <param name="context">The effect context</param> /// <param name="outputRectangle">The output rectangle region used for this transformation</param> /// <unmanaged>HRESULT ID2D1EffectContext::CreateBoundsAdjustmentTransform([In] const RECT* outputRectangle,[Out, Fast] ID2D1BoundsAdjustmentTransform** transform)</unmanaged> public BoundsAdjustmentTransform(EffectContext context, SharpDX.Rectangle outputRectangle) : base(IntPtr.Zero) { context.CreateBoundsAdjustmentTransform(outputRectangle, this); }
/// <inheritdoc/> public override void Initialize(EffectContext effectContext, TransformGraph transformGraph) { var path = Windows.ApplicationModel.Package.Current.InstalledLocation.Path; effectContext.LoadPixelShader(GUID_RipplePixelShader, NativeFile.ReadAllBytes(path + "\\Ripple.cso")); transformGraph.SetSingleTransformNode(this); }
/// <summary> /// Initialzies a new instance of <see cref="OffsetTransform"/> class /// </summary> /// <param name="context">The effect context</param> /// <param name="offset">The offset transformation</param> /// <unmanaged>HRESULT ID2D1EffectContext::CreateOffsetTransform([In] POINT offset,[Out, Fast] ID2D1OffsetTransform** transform)</unmanaged> public OffsetTransform(EffectContext context, SharpDX.Point offset) : base(IntPtr.Zero) { context.CreateOffsetTransform(offset, this); }
/// <summary> /// Initializes a new instance of <see cref="BlendTransform"/> class /// </summary> /// <param name="context">The effect context</param> /// <param name="numInputs">The number of inputs.</param> /// <param name="blendDescription">The blend description</param> public BlendTransform(EffectContext context, int numInputs, ref SharpDX.Direct2D1.BlendDescription blendDescription) : base(IntPtr.Zero) { context.CreateBlendTransform(numInputs, ref blendDescription, this); }
/// <summary> /// Initializes a new instance of <see cref="ColorContext"/> class from a filename. /// </summary> /// <param name="filename">No documentation.</param> /// <param name="colorContext">No documentation.</param> /// <unmanaged>HRESULT ID2D1EffectContext::CreateColorContextFromFilename([In] const wchar_t* filename,[Out] ID2D1ColorContext** colorContext)</unmanaged> public ColorContext(EffectContext context, string filename) : base(IntPtr.Zero) { context.CreateColorContextFromFilename(filename, this); }
/// <summary> /// Initializes a new instance of the <see cref="Effect"/> class. /// </summary> /// <param name="effectContext">The effect context.</param> /// <param name="effectId"><para>The class ID of the effect to create.</para></param> /// <returns>No documentation.</returns> /// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='ID2D1EffectContext::CreateEffect']/*"/> /// <unmanaged>HRESULT ID2D1EffectContext::CreateEffect([In] const GUID& effectId,[Out] ID2D1Effect** effect)</unmanaged> public Effect(EffectContext effectContext, System.Guid effectId) : base(IntPtr.Zero) { effectContext.CreateEffect(effectId, this); }
/// <summary> /// Initializes a new instance of <see cref="ColorContext"/> class from WIC color context. /// </summary> /// <param name="wicColorContext">No documentation.</param> /// <param name="colorContext">No documentation.</param> /// <unmanaged>HRESULT ID2D1EffectContext::CreateColorContextFromWicColorContext([In] IWICColorContext* wicColorContext,[Out] ID2D1ColorContext** colorContext)</unmanaged> public ColorContext(EffectContext context, SharpDX.WIC.ColorContext wicColorContext) : base(IntPtr.Zero) { context.CreateColorContextFromWicColorContext(wicColorContext, this); }
/// <summary> /// Initializes a new instance of <see cref="ColorContext"/> class from WIC color context. /// </summary> /// <param name="context">No documentation.</param> /// <param name="wicColorContext">No documentation.</param> /// <unmanaged>HRESULT ID2D1EffectContext::CreateColorContextFromWicColorContext([In] IWICColorContext* wicColorContext,[Out] ID2D1ColorContext** colorContext)</unmanaged> public ColorContext(EffectContext context, SharpDX.WIC.ColorContext wicColorContext) : base(IntPtr.Zero) { context.CreateColorContextFromWicColorContext(wicColorContext, this); }
/// <summary> /// Initializes a new instance of the <see cref="Effect"/> class. /// </summary> /// <param name="effectContext">The effect context.</param> /// <param name="effectId"><para>The class ID of the effect to create.</para></param> /// <returns>No documentation.</returns> /// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='ID2D1EffectContext::CreateEffect']/*"/> /// <unmanaged>HRESULT ID2D1EffectContext::CreateEffect([In] const GUID& effectId,[Out] ID2D1Effect** effect)</unmanaged> public Effect(EffectContext effectContext, System.Guid effectId) : base(IntPtr.Zero) { effectContext.CreateEffect(effectId, this); }
/// <summary> /// Initializes a new instance of <see cref="BlendTransform"/> class /// </summary> /// <param name="context">The effect context</param> /// <param name="resourceId">A unique identifier to the resource</param> /// <param name="resourceTextureProperties">The description of the resource</param> /// <unmanaged>HRESULT ID2D1EffectContext::CreateResourceTexture([In, Optional] const GUID* resourceId,[In] const D2D1_RESOURCE_TEXTURE_PROPERTIES* resourceTextureProperties,[In, Buffer, Optional] const unsigned char* data,[In, Buffer, Optional] const unsigned int* strides,[In] unsigned int dataSize,[Out] ID2D1ResourceTexture** resourceTexture)</unmanaged> public ResourceTexture(EffectContext context, System.Guid resourceId, SharpDX.Direct2D1.ResourceTextureProperties resourceTextureProperties) : base(IntPtr.Zero) { CreateResourceTexture(context, resourceId, resourceTextureProperties, null, null, this); }
/// <summary> /// Initialzies a new instance of <see cref="BoundsAdjustmentTransform"/> class /// </summary> /// <param name="context">The effect context</param> /// <param name="outputRectangle">The output rectangle region used for this transformation</param> /// <unmanaged>HRESULT ID2D1EffectContext::CreateBoundsAdjustmentTransform([In] const RECT* outputRectangle,[Out, Fast] ID2D1BoundsAdjustmentTransform** transform)</unmanaged> public BoundsAdjustmentTransform(EffectContext context, SharpDX.Rectangle outputRectangle) : base(IntPtr.Zero) { context.CreateBoundsAdjustmentTransform(outputRectangle, this); }
/// <summary> /// Initializes a new instance of <see cref="BlendTransform"/> class /// </summary> /// <param name="context">The effect context</param> /// <param name="numInputs">The number of inputs.</param> /// <param name="blendDescription">The blend description</param> public BlendTransform(EffectContext context, int numInputs, ref SharpDX.Direct2D1.BlendDescription blendDescription) : base(IntPtr.Zero) { context.CreateBlendTransform(numInputs, ref blendDescription, this); }