Ejemplo n.º 1
0
		unsafe public XnaHardwareIndexBuffer( HardwareBufferManagerBase manager, IndexType type, int numIndices, BufferUsage usage, XFG.GraphicsDevice device, bool useSystemMemory, bool useShadowBuffer )
			: base( manager, type, numIndices, usage, useSystemMemory, useShadowBuffer )
		{
			_bufferType = ( type == IndexType.Size16 ) ? XFG.IndexElementSize.SixteenBits : XFG.IndexElementSize.ThirtyTwoBits;

			// create the buffer
            if (usage == BufferUsage.Dynamic || usage == BufferUsage.DynamicWriteOnly)
            {
                _xnaBuffer = new XFG.IndexBuffer(device, _bufferType, numIndices, XnaHelper.Convert(usage));
            }
            else 
                _xnaBuffer = new XFG.IndexBuffer(device, _bufferType, numIndices, XFG.BufferUsage.None);

			_bufferBytes = new byte[ sizeInBytes ];
			_bufferBytes.Initialize();
		}
Ejemplo n.º 2
0
        public IndexBuffer(DisposableI parent, BufferUsages bufferUsage, int[] indices)
            : base(parent, bufferUsage, indices)
        {
            try
            {
                video = parent.FindParentOrSelfWithException <Video>();

                                #if SILVERLIGHT
                X.IndexElementSize elementSize = X.IndexElementSize.SixteenBits;
                                #else
                X.IndexElementSize elementSize = _32BitIndices ? X.IndexElementSize.ThirtyTwoBits : X.IndexElementSize.SixteenBits;
                                #endif
                indexBuffer = new X.IndexBuffer(video.Device, elementSize, indices.Length, X.BufferUsage.WriteOnly);
                Update(indices, indexCount);
            }
            catch (Exception e)
            {
                Dispose();
                throw e;
            }
        }