Axiom.Overlays.Elements.TextArea.CheckMemoryAllocation C# (CSharp) Method

CheckMemoryAllocation() protected method

protected CheckMemoryAllocation ( int numChars ) : void
numChars int
return void
		protected void CheckMemoryAllocation( int numChars )
		{
			if ( allocSize < numChars )
			{
				// Create and bind new buffers
				// Note that old buffers will be deleted automatically through reference counting

				// 6 verts per char since we're doing tri lists without indexes
				// Allocate space for positions & texture coords
				VertexDeclaration decl = renderOperation.vertexData.vertexDeclaration;
				VertexBufferBinding binding = renderOperation.vertexData.vertexBufferBinding;

				renderOperation.vertexData.vertexCount = numChars * 6;

				// Create dynamic since text tends to change alot
				// positions & texcoords
				HardwareVertexBuffer buffer =
					HardwareBufferManager.Instance.CreateVertexBuffer( decl.Clone( POSITION_TEXCOORD_BINDING ),	renderOperation.vertexData.vertexCount,	BufferUsage.DynamicWriteOnly );

				// bind the pos/tex buffer
				binding.SetBinding( POSITION_TEXCOORD_BINDING, buffer );

				// colors
				buffer =
					HardwareBufferManager.Instance.CreateVertexBuffer( decl.Clone( COLOR_BINDING ),	renderOperation.vertexData.vertexCount,	BufferUsage.DynamicWriteOnly );

				// bind the color buffer
				binding.SetBinding( COLOR_BINDING, buffer );

				allocSize = numChars;
				// force color buffer regeneration
				haveColorsChanged = true;
			}
		}