当前位置: 首页>>代码示例>>C++>>正文


C++ RenderElement::GetAngle方法代码示例

本文整理汇总了C++中RenderElement::GetAngle方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderElement::GetAngle方法的具体用法?C++ RenderElement::GetAngle怎么用?C++ RenderElement::GetAngle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RenderElement的用法示例。


在下文中一共展示了RenderElement::GetAngle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RenderTexturedRect

void RendererOpenGL::RenderTexturedRect( const RenderElement& _TexturedRect )
#endif
{
    PROFILING( "Render Texture" );
    
    // Get settings
#ifdef MULTIPLE_RENDER_ELEMENTS
    const CFoundation::Vector2Di& vPosition = _spTexturedRect->GetPosition();
    const Texture& mask = _spTexturedRect->GetMask();
    const Texture& texture = _spTexturedRect->GetTexture();
    const CFoundation::RectF16& rectTexture = _spTexturedRect->GetRelativeTextureRect();
    const CFoundation::Vector2Du& vSize = _spTexturedRect->GetSize();
    bool bBgVisible = _spTexturedRect->IsBgVisible();
    const CFoundation::Color& bgColor = _spTexturedRect->GetBgColor();
    Float16 f16Angle = _spTexturedRect->GetAngle();
#else
    const CFoundation::Vector2Di& vPosition = _TexturedRect.GetPosition();
    const Texture& mask = _TexturedRect.GetMask();
    const Texture& texture = _TexturedRect.GetTexture();
    const CFoundation::RectF16& rectTexture = _TexturedRect.GetRelativeTextureRect();
    const CFoundation::Vector2Du& vSize = _TexturedRect.GetSize();
    bool bBgVisible = _TexturedRect.IsBgVisible();
    const CFoundation::Color& bgColor = _TexturedRect.GetBgColor();
    Float16 f16Angle = _TexturedRect.GetAngle();
#endif

    // Compute size
    Float16 f16HalfWidth = vSize.GetX() * 0.5f;
    Float16 f16HalfHeight = vSize.GetY() * 0.5f;
    Unsigned32 u32Width = vSize.GetX();
	Unsigned32 u32Height = vSize.GetY();

    // Render mask
    if ( mask.IsValid() )
    {
        // Enable stencil buffer
	    glClear( GL_STENCIL_BUFFER_BIT );
	    glEnable( GL_STENCIL_TEST );
	    glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE ); 
	    glStencilFunc( GL_ALWAYS, 1, 1 );

        // Enable mask
	    glEnable( GL_TEXTURE_2D );
	    glBindTexture( GL_TEXTURE_2D, mask.GetID() );

        // Draw only non-transparent pixels into the stencil buffer
	    glEnable( GL_ALPHA_TEST );
	    glAlphaFunc( GL_GREATER, 0.01f );
        
        // Draw nothing on the screen
	    glColorMask( 0, 0, 0, 0 );

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

        // Draw mask into stencil buffer
	    glBegin( GL_QUADS );

		    glTexCoord2f( rectTexture.GetLeft(), rectTexture.GetBottom() );     glVertex3d( 0, 0, 0 );
		    glTexCoord2f( rectTexture.GetRight(), rectTexture.GetBottom() );    glVertex3d( u32Width, 0, 0 );
		    glTexCoord2f( rectTexture.GetRight(), rectTexture.GetTop() );       glVertex3d( u32Width, u32Height, 0 );
		    glTexCoord2f( rectTexture.GetLeft(), rectTexture.GetTop() );        glVertex3d( 0, u32Height, 0 );

	    glEnd();

        // Draw again on the screen
	    glColorMask( 1, 1, 1, 1 );

        // Setup stencil test for background/texture
	    glStencilFunc( GL_EQUAL, 1, 1 );
	    glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
    }

    // Render background
    if ( bBgVisible )
    {
        glLoadIdentity();
        glDisable( GL_TEXTURE_2D );
        Drawer::GetInstance().DrawSolidRect( CFoundation::RectI32( vPosition, vSize ), bgColor, f16Angle );
    }

    // Render texture	
	glLoadIdentity();
    glEnable( GL_TEXTURE_2D );
	glBindTexture( GL_TEXTURE_2D, texture.GetID() );

    // Set color
    Float16 f16R, f16G, f16B, f16A;
    bgColor.ToRGBA( f16R, f16G, f16B, f16A );
    glColor4f( f16R, f16G, f16B, f16A );
	
    // Translation
    //glTranslated( vPosition.GetX(), vPosition.GetY(), 0.0f );
    glTranslatef( vPosition.GetX() + f16HalfWidth, vPosition.GetY() + f16HalfHeight, 0.0f );

    // Rotate
    glRotatef( f16Angle, 0.0f, 0.0f, 1.0f );

    // Render texture
//.........这里部分代码省略.........
开发者ID:coeing,项目名称:cframework,代码行数:101,代码来源:RendererOpenGL.cpp

示例2: RenderRect

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
}
开发者ID:coeing,项目名称:cframework,代码行数:11,代码来源:RendererOpenGL.cpp


注:本文中的RenderElement::GetAngle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。