コード例 #1
0
//-----------------------------------------------------------------------------------------------
void CommandConsole::RenderTextCursor() const
{
	Renderer* renderer = Renderer::GetRenderer();
	renderer->PushMatrix();

	static const unsigned int LINE_START = 0;
	float xPosition = renderer->CalculateTextWidthFrom( "> " + m_prompt.currentInput, m_font, TEXT_LINE_HEIGHT, LINE_START, m_prompt.cursorLocation + 2 ) + 5.f;
	float yPosition = m_prompt.lowerLeftCorner.y + 5.f;		//start slightly below the baseline
	renderer->TranslateWorld( FloatVector3( xPosition, yPosition, 0.f ) );

	renderer->SetAlphaBlendingFunction( Renderer::ONE_MINUS_DESTINATION_COLOR, Renderer::NO_COLOR );
	renderer->BindBufferObject( Renderer::ARRAY_BUFFER, m_prompt.cursorVertexBufferID );

	static const int BEGINNING_OF_BUFFER = 0;
	static const int SIZE_OF_LINE_ARRAY_STRUCTURE = sizeof( VertexColorData2D );
	static const int NUMBER_OF_VERTEX_COORDINATES = 2;
	renderer->SetPointerToVertexArray( NUMBER_OF_VERTEX_COORDINATES, Renderer::FLOAT_TYPE, SIZE_OF_LINE_ARRAY_STRUCTURE, BEGINNING_OF_BUFFER );

	static const int NUMBER_OF_COLOR_COORDINATES = 4;
	renderer->SetPointerToColorArray( NUMBER_OF_COLOR_COORDINATES, Renderer::FLOAT_TYPE, SIZE_OF_LINE_ARRAY_STRUCTURE, ( float* )offsetof( VertexColorData2D, red ) );

	static const unsigned int NUMBER_OF_CURSOR_VERTICES = 2;
	renderer->SetLineWidth( 1.f );

	renderer->RenderVertexArray( Renderer::LINES, BEGINNING_OF_BUFFER, NUMBER_OF_CURSOR_VERTICES );

	renderer->BindBufferObject( Renderer::ARRAY_BUFFER, 0 );
	renderer->SetAlphaBlendingFunction( Renderer::SOURCE_ALPHA, Renderer::ONE_MINUS_SOURCE_ALPHA );
	renderer->PopMatrix();
}