Example #1
0
 public PixelFormat(PixelFormatFlags flags, int fourCC, int rgbBitCount, uint rBitMask, uint gBitMask, uint bBitMask, uint aBitMask)
 {
     Size        = SdxUtilities.SizeOf <PixelFormat>();
     Flags       = flags;
     FourCC      = fourCC;
     RGBBitCount = rgbBitCount;
     RBitMask    = rBitMask;
     GBitMask    = gBitMask;
     BBitMask    = bBitMask;
     ABitMask    = aBitMask;
 }
        /// <summary>
        /// Creates the constant buffer object.
        /// </summary>
        protected internal override D3D11.ID3D11Buffer CreateConstantBuffer(EngineDevice device)
        {
            using (var dataStream = new DataStream(SdxUtilities.SizeOf <T>(), true, true))
            {
                dataStream.Write(_initialData);
                dataStream.Position = 0;

                return(device.DeviceD3D11_1.CreateBuffer(
                           new D3D11.BufferDescription(
                               _structureSize,
                               D3D11.ResourceUsage.Dynamic,
                               D3D11.BindFlags.ConstantBuffer,
                               D3D11.CpuAccessFlags.Write,
                               D3D11.ResourceOptionFlags.None,
                               0),
                           dataStream.DataPointer));
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="TypeSafeConstantBufferResource{T}" /> class.
 /// </summary>
 public TypeSafeConstantBufferResource(T initialData)
     : base(SdxUtilities.SizeOf <T>())
 {
     _initialData   = initialData;
     _structureSize = SdxUtilities.SizeOf <T>();
 }