- graphics API: if font missing, find one that isn't (from Kevin)

svn path=/trunk/boinc/; revision=20350
This commit is contained in:
David Anderson 2010-02-01 19:18:23 +00:00
parent bced79447d
commit 7d229ccf4b
2 changed files with 28 additions and 16 deletions

View File

@ -69,24 +69,30 @@ void txf_render_string(
float fRotY, // optional rotation vector for Y
float fRotZ // optional rotation vector for Z
){
// if requested font isn't available, find first one that is
//
while((i < TXF_NUM_FONT) && !txf[i]) i++;
if((i >= TXF_NUM_FONT) || !txf[i]) {
// bad font index
return;
}
glPushMatrix();
glEnable(GL_TEXTURE_2D);
if((i < TXF_NUM_FONT) && txf[i]) {
glBindTexture(GL_TEXTURE_2D, txf[i]->texobj);
glTranslated(x, y, z);
glScalef(1/fscale, 1/fscale, 1/fscale);
if (fRotAngle != 0.0f) { // we want to rotate around Z y default, which keeps our text in 2D plane
glRotatef(fRotAngle, fRotX, fRotY, fRotZ);
}
glEnable(GL_ALPHA_TEST);
// use .1 and .5 for a dark and bright background respectively
glAlphaFunc(GL_GEQUAL, alpha_value);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glColor4fv(col);
txfRenderString(txf[i], s, (int)strlen(s));
}
glBindTexture(GL_TEXTURE_2D, txf[i]->texobj);
glTranslated(x, y, z);
glScalef(1/fscale, 1/fscale, 1/fscale);
if (fRotAngle != 0.0f) {
// we want to rotate around Z y default,
// which keeps our text in 2D plane
glRotatef(fRotAngle, fRotX, fRotY, fRotZ);
}
glEnable(GL_ALPHA_TEST);
// use .1 and .5 for a dark and bright background respectively
glAlphaFunc(GL_GEQUAL, alpha_value);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glColor4fv(col);
txfRenderString(txf[i], s, (int)strlen(s));
glDisable(GL_TEXTURE_2D);
glPopMatrix();
}

View File

@ -815,3 +815,9 @@ David 30 Jan 2010
clientgui/
AdvancedFrame.cpp
David 1 Feb 2010
- graphics API: if font missing, find one that isn't (from Kevin)
api/
txf_util.cpp