Esempio n. 1
0
 public static extern InteropBool ResourceFactory_CreateSSO(
     IntPtr failReason,
     DeviceHandle deviceHandle,
     TextureFilterType filterType,
     TextureWrapMode wrapMode,
     AnisotropicFilteringLevel maxAnisotropy,
     float borderColorR,
     float borderColorG,
     float borderColorB,
     float borderColorA,
     IntPtr outSamplerStateHandle
     );
 /// <summary>
 /// Create a new Texture Sampler object.
 /// </summary>
 /// <param name="filterType">The filter method to use.</param>
 /// <param name="wrapMode">The wrap mode to use.</param>
 /// <param name="maxAnisotropy">If <paramref name="filterType"/> is set to <see cref="TextureFilterType.Anisotropic"/>,
 /// this field is used to determine the maximum filter level for anisotropic filtering.</param>
 /// <param name="borderColor">If <paramref name="wrapMode"/> is set to <see cref="TextureWrapMode.Border"/>,
 /// this field is used to determine the out-of-bounds colour around the border of mapped textures.
 /// The range for each element in the <see cref="TexelFormat.RGB32Float"/> structure is <c>0f</c> to <c>1f</c>.</param>
 public TextureSampler(TextureFilterType filterType, TextureWrapMode wrapMode,
                       AnisotropicFilteringLevel maxAnisotropy, TexelFormat.RGB32Float borderColor = new TexelFormat.RGB32Float())
     : base(CreateTextureSampler(filterType, wrapMode, maxAnisotropy, borderColor), ResourceUsage.Immutable, SSO_SIZE_BYTES)
 {
     FilterType    = filterType;
     WrapMode      = wrapMode;
     MaxAnisotropy = maxAnisotropy;
     BorderColor   = borderColor;
     Assure.BetweenOrEqualTo(borderColor.R, 0f, 1f, "Each element in the given border colour must lie between 0f and 1f.");
     Assure.BetweenOrEqualTo(borderColor.G, 0f, 1f, "Each element in the given border colour must lie between 0f and 1f.");
     Assure.BetweenOrEqualTo(borderColor.B, 0f, 1f, "Each element in the given border colour must lie between 0f and 1f.");
 }
        private static unsafe SamplerStateResourceHandle CreateTextureSampler(TextureFilterType filterType, TextureWrapMode wrapMode,
                                                                              AnisotropicFilteringLevel maxAnisotropy, TexelFormat.RGB32Float borderColor)
        {
            SamplerStateResourceHandle outResourceHandle;

            InteropUtils.CallNative(
                NativeMethods.ResourceFactory_CreateSSO,
                RenderingModule.Device,
                filterType,
                wrapMode,
                maxAnisotropy,
                borderColor.R,
                borderColor.G,
                borderColor.B,
                1f,
                (IntPtr)(&outResourceHandle)
                ).ThrowOnFailure();

            return(outResourceHandle);
        }