示例#1
0
void RendererOpenGL::RenderText( const RenderElement& _Text )
#endif
{
#ifdef MULTIPLE_RENDER_ELEMENTS
    FontCPtr spFont = _spText->GetFont();
#else
    FontCPtr spFont = _Text.GetFont();
#endif
    if ( spFont == NULL )
    {
        CF_WARN( "No font set to render text." );
        return;
    }

#ifdef MULTIPLE_RENDER_ELEMENTS
    const CFoundation::String& strText = _spText->GetText();
#else
    const CFoundation::String& strText = _Text.GetText();
#endif
    if ( strText.GetLength() == 0 )
    {
        return;
    }

#ifdef MULTIPLE_RENDER_ELEMENTS
    const CFoundation::Vector2Di& vPosition = _spText->GetPosition();
    const CFoundation::Color& color = _spText->GetColor();
#else
    const CFoundation::Vector2Di& vPosition = _Text.GetPosition();
    const CFoundation::Color& color = _Text.GetColor();
#endif

    // Set text color
    Float16 f16R, f16G, f16B, f16A;
    color.ToRGBA( f16R, f16G, f16B, f16A );
    glColor4f( f16R, f16G, f16B, f16A );

    spFont->Activate();

    // Move to right position
    glLoadIdentity();
    glTranslated( vPosition.GetX(),
			      vPosition.GetY(),
			      0.0 );

    // Draw text
    glCallLists( strText.GetLength(), GL_UNSIGNED_SHORT, strText.wc_str() );
    spFont->Deactivate();
}
示例#2
0
void RendererOpenGL::RenderPrimitives( const RenderElement& _Primitives )
#endif
{
    PROFILING( "Render Primitives" );

#ifdef MULTIPLE_RENDER_ELEMENTS  
    RenderElementPrimitives::Type eType = _spPrimitives->GetType();
    const CFoundation::Color& color = _spPrimitives->GetColor();
    Float16 f16Thickness = _spPrimitives->GetThickness();
    const RenderElementPrimitives::PointVec& avPoints = _spPrimitives->GetPoints();
#else
    RenderElement::Type eType = _Primitives.GetType();
    const CFoundation::Color& color = _Primitives.GetColor();
    Float16 f16Thickness = _Primitives.GetThickness();
    const RenderElement::PointVec& avPoints = _Primitives.GetPoints();
#endif

    // Get opengl type
    Unsigned32 u32Type = 0;
    switch ( eType )
    {
#ifdef MULTIPLE_RENDER_ELEMENTS 
    case RenderElementPrimitives::TYPE_POINTS:
#else
    case RenderElement::TYPE_POINTS:
#endif
        {
            u32Type = GL_POINTS;
        }
        break;
#ifdef MULTIPLE_RENDER_ELEMENTS 
    case RenderElementPrimitives::TYPE_LINES:
#else
    case RenderElement::TYPE_LINES:
#endif
        {
            u32Type = GL_LINES;
        }
        break;
#ifdef MULTIPLE_RENDER_ELEMENTS 
    case RenderElementPrimitives::TYPE_TRIANGLES:
#else
    case RenderElement::TYPE_TRIANGLES:
#endif
        {
            u32Type = GL_TRIANGLES;
        }
        break;
#ifdef MULTIPLE_RENDER_ELEMENTS 
    case RenderElementPrimitives::TYPE_QUADS:
#else
    case RenderElement::TYPE_QUADS:
#endif
        {
            u32Type = GL_QUADS;
        }
        break;
    }

    // Set color
    Float16 f16R, f16G, f16B, f16A;
    color.ToRGBA( f16R, f16G, f16B, f16A );
    glColor4f( f16R, f16G, f16B, f16A );

    // Set line thickness
    glLineWidth( f16Thickness );

    // Render primitives
    glLoadIdentity();
    glDisable( GL_TEXTURE_2D );

	glBegin( u32Type );

    Unsigned32 u32NumPoints = avPoints.size();
    for ( Unsigned32 u32Idx = 0; u32Idx < u32NumPoints; ++u32Idx )
    {
        const CFoundation::Vector2Df& vPoint = avPoints[ u32Idx ];
        glVertex3d( vPoint.GetX(),  vPoint.GetY(), 0 );
    }

	glEnd();
}
示例#3
0
void RendererOpenGL::RenderRect( const RenderElement& _Rect )
#endif
{
    glLoadIdentity();
    glDisable( GL_TEXTURE_2D );
#ifdef MULTIPLE_RENDER_ELEMENTS
    Drawer::GetInstance().DrawSolidRect( CFoundation::RectI32( _spRect->GetPosition(), _spRect->GetSize() ), _spRect->GetColor(), _spRect->GetAngle() );
#else
    Drawer::GetInstance().DrawSolidRect( CFoundation::RectI32( _Rect.GetPosition(), _Rect.GetSize() ), _Rect.GetColor(), _Rect.GetAngle() );
#endif
}