/// <summary> /// Called when [attach buffer]. /// </summary> /// <param name="context">The context.</param> /// <param name="vertexBufferStartSlot">The vertex buffer start slot. It will be changed to the next available slot after binding</param> /// <returns></returns> protected virtual bool OnAttachBuffer(DeviceContextProxy context, ref int vertexBufferStartSlot) { if (VertexBuffer.Length > 0) { if (VertexBuffer.Length == VertexBufferBindings.Length) { context.SetVertexBuffers(vertexBufferStartSlot, VertexBufferBindings); vertexBufferStartSlot += VertexBuffer.Length; } else { return(false); } } if (IndexBuffer != null) { context.SetIndexBuffer(IndexBuffer.Buffer, Format.R32_UInt, IndexBuffer.Offset); } else { context.SetIndexBuffer(null, Format.Unknown, 0); } context.PrimitiveTopology = Topology; return(true); }
public bool AttachBuffers(DeviceContextProxy context, ref int vertexBufferStartSlot, IDeviceResources deviceResources) { if (SpriteCount == 0 || IndexCount == 0) { return(false); } context.SetVertexBuffers(0, new VertexBufferBinding(VertexBufferInternal.Buffer, VertexBufferInternal.StructureSize, VertexBufferInternal.Offset)); context.SetIndexBuffer(IndexBufferInternal.Buffer, Format.R16_UInt, IndexBufferInternal.Offset); return(true); }
public bool AttachBuffers(DeviceContextProxy context, ref int vertexBufferStartSlot, IDeviceResources deviceResources) { if (UpdateBuffers(context, deviceResources)) { context.SetVertexBuffers(0, new VertexBufferBinding(vertextBuffer.Buffer, vertextBuffer.StructureSize, vertextBuffer.Offset)); context.SetIndexBuffer(IndexBuffer.Buffer, global::SharpDX.DXGI.Format.R32_UInt, IndexBuffer.Offset); return(true); } return(false); }
/// <summary> /// Attaches the buffers. /// </summary> /// <param name="context">The context.</param> /// <param name="vertexBufferStartSlot">The vertex buffer start slot.</param> /// <param name="deviceResources">The device resources.</param> /// <returns></returns> public bool AttachBuffers(DeviceContextProxy context, ref int vertexBufferStartSlot, IDeviceResources deviceResources) { if (!Commit(context) && vertexBufferBindings.Length > 0) { context.SetVertexBuffers(vertexBufferStartSlot, vertexBufferBindings); ++vertexBufferStartSlot; } else { return(false); } if (IndexBuffer != null) { context.SetIndexBuffer(IndexBuffer.Buffer, Format.R32_UInt, IndexBuffer.Offset); } else { context.SetIndexBuffer(null, Format.Unknown, 0); } context.PrimitiveTopology = Topology; return(true); }
/// <summary> /// Called when [attach buffer]. /// </summary> /// <param name="context">The context.</param> /// <param name="vertexLayout">The vertex layout.</param> /// <param name="vertexBufferStartSlot">The vertex buffer start slot. Returns next available bind slot</param> /// <returns></returns> protected override bool OnAttachBuffer(DeviceContextProxy context, InputLayout vertexLayout, ref int vertexBufferStartSlot) { context.PrimitiveTopology = Topology; context.InputLayout = vertexLayout; if (VertexBuffer.Length > 0) { context.SetVertexBuffers(vertexBufferStartSlot, VertexBuffer.Select(x => new VertexBufferBinding(x.Buffer, x.StructureSize, x.Offset)).ToArray()); vertexBufferStartSlot += VertexBuffer.Length; } else { context.SetIndexBuffer(null, Format.Unknown, 0); } return(true); }