MCPcopy Create free account
hub / github.com/cinder/Cinder / drawStringHelper

Function drawStringHelper

src/cinder/gl/draw.cpp:1529–1562  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1527
1528namespace {
1529void drawStringHelper( const std::string &str, const vec2 &pos, const ColorA &color, Font font, int justification )
1530{
1531#if ! defined( CINDER_ANDROID )
1532
1533 if( str.empty() )
1534 return;
1535
1536 // justification: { left = -1, center = 0, right = 1 }
1537 ScopedColor colorScp( Color::white() );
1538
1539 static Font defaultFont = Font::getDefault();
1540 if( ! font )
1541 font = defaultFont;
1542
1543 float baselineOffset;
1544#if defined( CINDER_COCOA_TOUCH )
1545 ivec2 actualSize;
1546 Surface8u pow2Surface( renderStringPow2( str, font, color, &actualSize, &baselineOffset ) );
1547 gl::TextureRef tex = gl::Texture::create( pow2Surface );
1548 tex->setCleanBounds( Area( 0, 0, actualSize.x, actualSize.y ) );
1549 baselineOffset += pow2Surface.getHeight();
1550#else
1551 gl::TextureRef tex = gl::Texture::create( renderString( str, font, color, &baselineOffset ) );
1552#endif
1553
1554 if( justification == -1 ) // left
1555 draw( tex, pos - vec2( 0, baselineOffset ) );
1556 else if( justification == 0 ) // center
1557 draw( tex, pos - vec2( tex->getWidth() * 0.5f, baselineOffset ) );
1558 else // right
1559 draw( tex, pos - vec2( (float)tex->getWidth(), baselineOffset ) );
1560
1561#endif // ! defined( CINDER_ANDROID )
1562}
1563} // anonymous namespace
1564
1565void drawString( const std::string &str, const vec2 &pos, const ColorA &color, Font font )

Callers 3

drawStringFunction · 0.85
drawStringCenteredFunction · 0.85
drawStringRightFunction · 0.85

Calls 10

whiteFunction · 0.85
renderStringPow2Function · 0.85
renderStringFunction · 0.85
setCleanBoundsMethod · 0.80
drawFunction · 0.70
createFunction · 0.50
AreaFunction · 0.50
emptyMethod · 0.45
getHeightMethod · 0.45
getWidthMethod · 0.45

Tested by

no test coverage detected