/// <summary> /// Called when [create vertex buffer]. /// </summary> /// <param name="context">The context.</param> /// <param name="buffer">The buffer.</param> /// <param name="geometry">The geometry.</param> /// <param name="deviceResources">The device resources.</param> /// <param name="bufferIndex"></param> protected override void OnCreateVertexBuffer(DeviceContextProxy context, IElementsBufferProxy buffer, int bufferIndex, Geometry3D geometry, IDeviceResources deviceResources) { if (geometry is IBillboardText billboardGeometry) { billboardGeometry.DrawTexture(deviceResources); if (billboardGeometry.BillboardVertices != null && billboardGeometry.BillboardVertices.Count > 0) { Type = billboardGeometry.Type; buffer.UploadDataToBuffer(context, billboardGeometry.BillboardVertices, billboardGeometry.BillboardVertices.Count, 0, geometry.PreDefinedVertexCount); if (textureStream != billboardGeometry.Texture) { RemoveAndDispose(ref textureView); textureStream = billboardGeometry.Texture; if (textureStream != null) { textureView = Collect(deviceResources.MaterialTextureManager.Register(textureStream)); } } } else { RemoveAndDispose(ref textureView); textureStream = null; buffer.UploadDataToBuffer(context, emptyVerts, 0); } } }
/// <summary> /// Called when [create index buffer]. /// </summary> /// <param name="context">The context.</param> /// <param name="buffer">The buffer.</param> /// <param name="geometry">The geometry.</param> /// <param name="deviceResources">The device resources.</param> protected override void OnCreateIndexBuffer(DeviceContextProxy context, IElementsBufferProxy buffer, Geometry3D geometry, IDeviceResources deviceResources) { if (geometry != null && geometry.Indices != null && geometry.Indices.Count > 0) { buffer.UploadDataToBuffer(context, geometry.Indices, geometry.Indices.Count, 0, geometry.PreDefinedIndexCount); } else { buffer.UploadDataToBuffer(context, emptyIndices, 0); } }
protected override void OnCreateVertexBuffer(DeviceContextProxy context, IElementsBufferProxy buffer, int bufferIndex, Geometry3D geometry, IDeviceResources deviceResources) { // -- set geometry if given if (geometry != null && geometry.Positions != null && geometry.Positions.Count > 0) { buffer.UploadDataToBuffer(context, geometry.Positions, geometry.Positions.Count); } else { buffer.UploadDataToBuffer(context, emptyVerts, 0); } }
/// <summary> /// Called when [create vertex buffer]. /// </summary> /// <param name="context">The context.</param> /// <param name="buffer">The buffer.</param> /// <param name="geometry">The geometry.</param> /// <param name="deviceResources">The device resources.</param> /// <param name="bufferIndex"></param> protected override void OnCreateVertexBuffer(DeviceContextProxy context, IElementsBufferProxy buffer, int bufferIndex, Geometry3D geometry, IDeviceResources deviceResources) { // -- set geometry if given if (geometry != null && geometry.Positions != null && geometry.Positions.Count > 0) { // --- get geometry var data = OnBuildVertexArray(geometry); buffer.UploadDataToBuffer(context, data, geometry.Positions.Count, 0, geometry.PreDefinedVertexCount); } else { buffer.UploadDataToBuffer(context, emptyVerts, 0); } }
protected override void OnCreateVertexBuffer(DeviceContextProxy context, IElementsBufferProxy buffer, int bufferIndex, Geometry3D geometry, IDeviceResources deviceResources) { if (bufferIndex == 0 && geometry != null && geometry.Positions != null && geometry.Positions.Count > 0) { buffer.UploadDataToBuffer(context, geometry.Positions, geometry.Positions.Count); } }
/// <summary> /// Called when [create index buffer]. /// </summary> /// <param name="context">The context.</param> /// <param name="buffer">The buffer.</param> /// <param name="geometry">The geometry.</param> /// <param name="deviceResources">The device resources.</param> protected override void OnCreateIndexBuffer(DeviceContextProxy context, IElementsBufferProxy buffer, Geometry3D geometry, IDeviceResources deviceResources) { if (geometry != null && geometry.Indices != null && geometry.Indices.Count > 0) { buffer.UploadDataToBuffer(context, geometry.Indices, geometry.Indices.Count); } else { buffer.DisposeAndClear(); } }
public virtual void AttachBuffer(DeviceContext context, ref int vertexBufferStartSlot) { if (HasElements) { if (instanceChanged) { elementBuffer.UploadDataToBuffer(context, elements, elements.Count); instanceChanged = false; bufferBinding = new VertexBufferBinding(Buffer.Buffer, Buffer.StructureSize, Buffer.Offset); } context.InputAssembler.SetVertexBuffers(vertexBufferStartSlot, bufferBinding); } ++vertexBufferStartSlot; }
/// <summary> /// Called when [create vertex buffer]. /// </summary> /// <param name="context">The context.</param> /// <param name="buffer">The buffer.</param> /// <param name="geometry">The geometry.</param> /// <param name="deviceResources">The device resources.</param> /// <param name="bufferIndex"></param> protected override void OnCreateVertexBuffer(DeviceContextProxy context, IElementsBufferProxy buffer, int bufferIndex, Geometry3D geometry, IDeviceResources deviceResources) { // -- set geometry if given if (geometry != null && geometry.Positions != null && geometry.Positions.Count > 0) { // --- get geometry var mesh = geometry as LineGeometry3D; var data = OnBuildVertexArray(mesh); buffer.UploadDataToBuffer(context, data, geometry.Positions.Count); } else { buffer.DisposeAndClear(); } }
/// <summary> /// Called when [create vertex buffer]. /// </summary> /// <param name="context">The context.</param> /// <param name="buffer">The buffer.</param> /// <param name="geometry">The geometry.</param> /// <param name="deviceResources">The device resources.</param> /// <param name="bufferIndex"></param> protected override void OnCreateVertexBuffer(DeviceContextProxy context, IElementsBufferProxy buffer, int bufferIndex, Geometry3D geometry, IDeviceResources deviceResources) { var billboardGeometry = geometry as IBillboardText; billboardGeometry.DrawTexture(deviceResources); if (billboardGeometry != null && billboardGeometry.BillboardVertices != null && billboardGeometry.BillboardVertices.Count > 0) { Type = billboardGeometry.Type; var data = OnBuildVertexArray(billboardGeometry, deviceResources); buffer.UploadDataToBuffer(context, data, billboardGeometry.BillboardVertices.Count); RemoveAndDispose(ref textureView); if (billboardGeometry.Texture != null) { textureView = Collect(deviceResources.MaterialTextureManager.Register(billboardGeometry.Texture)); } } else { textureView = null; buffer.DisposeAndClear(); } }
/// <summary> /// Called when [create vertex buffer]. /// </summary> /// <param name="context">The context.</param> /// <param name="buffer">The buffer.</param> /// <param name="bufferIndex">Index of the buffer.</param> /// <param name="geometry">The geometry.</param> /// <param name="deviceResources">The device resources.</param> protected override void OnCreateVertexBuffer(DeviceContextProxy context, IElementsBufferProxy buffer, int bufferIndex, Geometry3D geometry, IDeviceResources deviceResources) { if (geometry is MeshGeometry3D mesh) { switch (bufferIndex) { case 0: // -- set geometry if given if (geometry.Positions != null && geometry.Positions.Count > 0) { // --- get geometry var data = BuildVertexArray(mesh); buffer.UploadDataToBuffer(context, data, geometry.Positions.Count, 0, geometry.PreDefinedVertexCount); } else { //buffer.DisposeAndClear(); buffer.UploadDataToBuffer(context, emptyVerts, 0); } break; case 1: if (mesh.TextureCoordinates != null && mesh.TextureCoordinates.Count > 0) { buffer.UploadDataToBuffer(context, mesh.TextureCoordinates, mesh.TextureCoordinates.Count, 0, geometry.PreDefinedVertexCount); } else { buffer.UploadDataToBuffer(context, emptyTextureArray, 0); } break; case 2: if (geometry.Colors != null && geometry.Colors.Count > 0) { buffer.UploadDataToBuffer(context, geometry.Colors, geometry.Colors.Count, 0, geometry.PreDefinedVertexCount); } else { buffer.UploadDataToBuffer(context, emptyColorArray, 0); } break; } } }