コード例 #1
0
ファイル: Mesh.cs プロジェクト: cyril12/Tr3Smoothing
        /// <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;
		}
コード例 #3
0
 public override void Dispose()
 {
     base.Dispose();
     //Dispose the unmanaged resources
     buffer.Dispose();
     shader.Dispose();
     pipeline.Dispose();
 }
コード例 #4
0
 public override void Dispose()
 {
     //remove the unmanaged resources
     shader.Dispose();
     pipeline.Dispose();
     gridBuffer?.Dispose();
     axisBuffer?.Dispose();
     base.Dispose();
 }
コード例 #5
0
ファイル: TerrainSpriteLayer.cs プロジェクト: zhao212/OpenRA
        public void Dispose()
        {
            worldRenderer.PaletteInvalidated -= UpdatePaletteIndices;
            if (worldRenderer.TerrainLighting != null)
            {
                worldRenderer.TerrainLighting.CellChanged -= UpdateTint;
            }

            vertexBuffer.Dispose();
        }
コード例 #6
0
ファイル: Renderer.cs プロジェクト: neostoic/Swummary
 public void Dispose()
 {
     Device.Dispose();
     WorldVoxelRenderer.Dispose();
     tempBuffer.Dispose();
     if (fontSheetBuilder != null)
     {
         fontSheetBuilder.Dispose();
     }
 }
コード例 #7
0
 protected override void Unload()
 {
     if (vertexBuffer != null)
     {
         vertexBuffer.Dispose();
     }
     if (indexBuffer != null)
     {
         indexBuffer.Dispose();
     }
 }
コード例 #8
0
 public override void Dispose()
 {
     disposeChilderen();
     if (layout != null)
     {
         layout.Dispose();
     }
     if (vertexBuffer != null)
     {
         vertexBuffer.Dispose();
     }
     base.Dispose();
 }
コード例 #9
0
 public void Dispose()
 {
     WorldModelRenderer.Dispose();
     tempBuffer.Dispose();
     fontSheetBuilder?.Dispose();
     if (Fonts != null)
     {
         foreach (var font in Fonts.Values)
         {
             font.Dispose();
         }
     }
     Window.Dispose();
 }
コード例 #10
0
        void Closing()
        {
            brickTexture.Dispose();
            mossTexture.Dispose();

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

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

            renderer.Dispose();
        }
コード例 #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();
         }
     }
 }
コード例 #12
0
ファイル: DemoGame.cs プロジェクト: deccer/Xacor
        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();
        }
コード例 #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();
 }
コード例 #14
0
ファイル: Class1.cs プロジェクト: Golle/GameDev
 public override void Dispose()
 {
     _vertexBuffer.Dispose();
     _indexBuffer.Dispose();
     base.Dispose();
 }
コード例 #15
0
 public void Dispose()
 {
     vertexBuffer.Dispose();
 }
コード例 #16
0
 public void Dispose()
 {
     Device.Dispose();
     WorldModelRenderer.Dispose();
     tempBuffer.Dispose();
 }