本文整理汇总了C++中TextBox::GetCursorAlpha方法的典型用法代码示例。如果您正苦于以下问题:C++ TextBox::GetCursorAlpha方法的具体用法?C++ TextBox::GetCursorAlpha怎么用?C++ TextBox::GetCursorAlpha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextBox
的用法示例。
在下文中一共展示了TextBox::GetCursorAlpha方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
//.........这里部分代码省略.........
glTexCoord2f(1,0);
glVertex2f(x1,y0 );
glEnd();
}
// Bind text texture
glBindTexture(GL_TEXTURE_2D, m_textureID);
glColor4f(textbox.GetColourComp(0), textbox.GetColourComp(1), textbox.GetColourComp(2), textbox.GetColourComp(3));
//break the words up into a vector of strings
std::istringstream stream(textbox.GetString());
std::vector<std::string> word_vec ( (std::istream_iterator<std::string>(stream)), std::istream_iterator<std::string>());
std::vector<std::string>::iterator word_it = word_vec.begin();
glBegin(GL_QUADS);
//while not at the end of the string
float heightiter = 0.0f;
float widthiter = 0.0f;
while( heightiter < textbox.GetBoxHeight() && word_it != word_vec.end())
{
float wordlength = 0.0f;
float prevletlen;
widthiter = GetLetterSpace(*(*word_it).begin()) - firstletteroffset;
//iterate through each letter, spacing based on letter width
for(std::string::iterator let_it = (*word_it).begin();
let_it != (*word_it).end() ; ++let_it )
{
prevletlen = GetLetterSpace(*let_it); //space between previous letter
wordlength += DATA("LETTER_WID_SCALE")*textbox.GetLetterWidth()*(1.0f - (prevletlen+GetLetterSpace(*let_it)));
}
wordlength += DATA("LETTER_WID_SCALE")*textbox.GetLetterWidth()*(1.0f);
//while each word has not been processed
while( word_it != word_vec.end() &&
widthiter + wordlength < textbox.GetBoxWidth())
{
widthiter += GetLetterSpace(*(*word_it).begin()) - firstletteroffset;
//iterate through each letter, spacing based on letter width
for(std::string::iterator let_it = (*word_it).begin();
let_it != (*word_it).end() ; ++let_it)
{
prevletlen = GetLetterSpace(*let_it); //space between previous letter
RenderLetter( textbox.GetPosX() + widthiter,
textbox.GetPosY() + heightiter,
textbox.GetLetterWidth(), textbox.GetLetterHeight(), *let_it);
widthiter += DATA("LETTER_WID_SCALE")*textbox.GetLetterWidth()*(1.0f - (prevletlen+GetLetterSpace(*let_it)));
}
//widthiter += DATA("LETTER_WID_SCALE")*textbox.GetLetterWidth()*(1.0f);
widthiter += textbox.GetGap(); // add for a space
wordlength = 0.0f;
++word_it;
if( word_it != word_vec.end() )
{
wordlength += GetLetterSpace(*(*word_it).begin()) - firstletteroffset;
//calculate the length of the next word
for(std::string::iterator let_it = (*word_it).begin();
let_it != (*word_it).end() ; ++let_it)
{
prevletlen = GetLetterSpace(*let_it); //space between previous letter
wordlength += DATA("LETTER_WID_SCALE")*textbox.GetLetterWidth()*
( 1.0f - (prevletlen + GetLetterSpace(*let_it)));
}
//wordlength +=DATA("LETTER_WID_SCALE")*textbox.GetLetterWidth()*(1.0f);
}
}
//go to the next row
heightiter += DATA("LETTER_HT_SCALE") * textbox.GetLetterHeight();
}
glEnd();
//ViewPerspective(); // Switch To A Perspective View
glBindTexture(GL_TEXTURE_2D, 0); // Bind To The Blur Texture
if (textbox.hasCursor()) {
if (widthiter < 1) {
widthiter = 4;
}
glBegin(GL_TRIANGLE_STRIP);
glColor4f(0.0f, 0.0f, 0.0f, textbox.GetCursorAlpha());
GLuint x = textbox.GetPosX() + widthiter;
GLuint y = textbox.GetPosY();
glVertex2f(x + 2, y);
glVertex2f(x, y);
glVertex2f(x + 2, y + textbox.GetLetterHeight());
glVertex2f(x, y + textbox.GetLetterHeight());
glEnd();
}
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
}