/// <summary> /// Updates the vertex buffer object from the <see cref="Vertices"/> array. /// </summary> /// <typeparam name="TVertex">The type of vertex buffer to use.</typeparam> /// <param name="transform">Function that transforms the vertex array data to a interleaved struct format.</param> private void UpdateVertices <TVertex>( Func <Vector3, Vector3, Color4, TVertex> transform ) where TVertex : struct, IVertexData { // if the type of the vertex data has changed we need to create a new buffer if (m_vertexBuffer != null && m_vertexBuffer.GetType() != typeof(VertexBuffer <TVertex>)) { m_vertexBuffer.Dispose(); m_vertexBuffer = null; } // create vertex buffer if needed if (m_vertexBuffer == null) { m_vertexBuffer = new VertexBuffer <TVertex>(m_vertices.Length); } // copy the vertices into the buffer VertexBuffer <TVertex> buffer = m_vertexBuffer as VertexBuffer <TVertex>; buffer.Clear(); int offset; TVertex[] vertexArray = buffer.WriteDirectly(m_vertices.Length, out offset); for (int i = 0; i < m_vertices.Length; i++) { vertexArray[i] = transform(m_vertices[i], m_normals[i], m_colors[i]); } // upload to the GPU buffer.BufferData(); m_vertexBufferDirty = false; }
public void RefreshBuffer() { if (vertexBuffer != null) vertexBuffer.Dispose(); vertexBuffer = Game.Renderer.CreateVertexBuffer(totalVertexCount); vertexBuffer.SetData(vertices.SelectMany(v => v).ToArray(), totalVertexCount); cachedVertexCount = totalVertexCount; }
public override void Dispose() { base.Dispose(); //Dispose the unmanaged resources buffer.Dispose(); shader.Dispose(); pipeline.Dispose(); }
public override void Dispose() { //remove the unmanaged resources shader.Dispose(); pipeline.Dispose(); gridBuffer?.Dispose(); axisBuffer?.Dispose(); base.Dispose(); }
public void Dispose() { worldRenderer.PaletteInvalidated -= UpdatePaletteIndices; if (worldRenderer.TerrainLighting != null) { worldRenderer.TerrainLighting.CellChanged -= UpdateTint; } vertexBuffer.Dispose(); }
public void Dispose() { Device.Dispose(); WorldVoxelRenderer.Dispose(); tempBuffer.Dispose(); if (fontSheetBuilder != null) { fontSheetBuilder.Dispose(); } }
protected override void Unload() { if (vertexBuffer != null) { vertexBuffer.Dispose(); } if (indexBuffer != null) { indexBuffer.Dispose(); } }
public override void Dispose() { disposeChilderen(); if (layout != null) { layout.Dispose(); } if (vertexBuffer != null) { vertexBuffer.Dispose(); } base.Dispose(); }
public void Dispose() { WorldModelRenderer.Dispose(); tempBuffer.Dispose(); fontSheetBuilder?.Dispose(); if (Fonts != null) { foreach (var font in Fonts.Values) { font.Dispose(); } } Window.Dispose(); }
void Closing() { brickTexture.Dispose(); mossTexture.Dispose(); shaderProgramTextured.Dispose(); shaderProgramColored.Dispose(); shaderProgram.Dispose(); vb1.Dispose(); vb2.Dispose(); vb3.Dispose(); renderer.Dispose(); }
public void Dispose() { Device.Dispose(); WorldVoxelRenderer.Dispose(); tempBuffer.Dispose(); if (fontSheetBuilder != null) { fontSheetBuilder.Dispose(); } if (Fonts != null) { foreach (var font in Fonts.Values) { font.Dispose(); } } }
protected override void Cleanup() { base.Cleanup(); _defaultBlendState?.Dispose(); _defaultDepthStencilState?.Dispose(); _defaultRasterizerState?.Dispose(); _leftConstantBuffer?.Dispose(); _rightConstantBuffer?.Dispose(); _simplePipeline?.Dispose(); _simpleVertexBuffer?.Dispose(); _simplePixelShader?.Dispose(); _simpleSampler?.Dispose(); _simpleVertexShader?.Dispose(); _textureFactory?.Dispose(); _texturedPipeline?.Dispose(); _texturedPixelShader?.Dispose(); _texturedVertexShader?.Dispose(); _texturedVertexBuffer?.Dispose(); }
/// <summary> /// Detach event handlers on dispose in TerrainSpriteLayer /// /// The WorldRenderer outlives the TerrainSpriteLayer and thus keeps it alive longer than expected via the event handler. /// We detach it to allow the GC to reclaim it /// </summary> public void Dispose() { worldRender.PaletteInvalidated -= UpdatePaletteIndices; vertexBuffer.Dispose(); }
public override void Dispose() { _vertexBuffer.Dispose(); _indexBuffer.Dispose(); base.Dispose(); }
public void Dispose() { vertexBuffer.Dispose(); }
public void Dispose() { Device.Dispose(); WorldModelRenderer.Dispose(); tempBuffer.Dispose(); }