Exemplo n.º 1
0
        /// <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;
		}
Exemplo n.º 3
0
 public override void Dispose()
 {
     base.Dispose();
     //Dispose the unmanaged resources
     buffer.Dispose();
     shader.Dispose();
     pipeline.Dispose();
 }
Exemplo n.º 4
0
 public override void Dispose()
 {
     //remove the unmanaged resources
     shader.Dispose();
     pipeline.Dispose();
     gridBuffer?.Dispose();
     axisBuffer?.Dispose();
     base.Dispose();
 }
Exemplo n.º 5
0
        public void Dispose()
        {
            worldRenderer.PaletteInvalidated -= UpdatePaletteIndices;
            if (worldRenderer.TerrainLighting != null)
            {
                worldRenderer.TerrainLighting.CellChanged -= UpdateTint;
            }

            vertexBuffer.Dispose();
        }
Exemplo n.º 6
0
 public void Dispose()
 {
     Device.Dispose();
     WorldVoxelRenderer.Dispose();
     tempBuffer.Dispose();
     if (fontSheetBuilder != null)
     {
         fontSheetBuilder.Dispose();
     }
 }
Exemplo n.º 7
0
 protected override void Unload()
 {
     if (vertexBuffer != null)
     {
         vertexBuffer.Dispose();
     }
     if (indexBuffer != null)
     {
         indexBuffer.Dispose();
     }
 }
Exemplo n.º 8
0
 public override void Dispose()
 {
     disposeChilderen();
     if (layout != null)
     {
         layout.Dispose();
     }
     if (vertexBuffer != null)
     {
         vertexBuffer.Dispose();
     }
     base.Dispose();
 }
Exemplo n.º 9
0
 public void Dispose()
 {
     WorldModelRenderer.Dispose();
     tempBuffer.Dispose();
     fontSheetBuilder?.Dispose();
     if (Fonts != null)
     {
         foreach (var font in Fonts.Values)
         {
             font.Dispose();
         }
     }
     Window.Dispose();
 }
Exemplo n.º 10
0
        void Closing()
        {
            brickTexture.Dispose();
            mossTexture.Dispose();

            shaderProgramTextured.Dispose();
            shaderProgramColored.Dispose();
            shaderProgram.Dispose();

            vb1.Dispose();
            vb2.Dispose();
            vb3.Dispose();

            renderer.Dispose();
        }
Exemplo n.º 11
0
 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();
         }
     }
 }
Exemplo n.º 12
0
        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();
        }
Exemplo n.º 13
0
 /// <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();
 }
Exemplo n.º 14
0
 public override void Dispose()
 {
     _vertexBuffer.Dispose();
     _indexBuffer.Dispose();
     base.Dispose();
 }
Exemplo n.º 15
0
 public void Dispose()
 {
     vertexBuffer.Dispose();
 }
Exemplo n.º 16
0
 public void Dispose()
 {
     Device.Dispose();
     WorldModelRenderer.Dispose();
     tempBuffer.Dispose();
 }