diff --git a/api/txf_util.cpp b/api/txf_util.cpp index 961a231f15..71211521d4 100644 --- a/api/txf_util.cpp +++ b/api/txf_util.cpp @@ -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(); } diff --git a/checkin_notes b/checkin_notes index 036c51ba56..037baa055b 100644 --- a/checkin_notes +++ b/checkin_notes @@ -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