本文整理汇总了C++中RenderElement::IsBgVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderElement::IsBgVisible方法的具体用法?C++ RenderElement::IsBgVisible怎么用?C++ RenderElement::IsBgVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderElement
的用法示例。
在下文中一共展示了RenderElement::IsBgVisible方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
//.........这里部分代码省略.........