Public Member Functions | |
rFont (const char *fileName, int Offset=0, REAL CWidth=(1/16.0), REAL CHeight=(1/8.0), REAL onepixel=1/256.0, rFont *lower=NULL) | |
rFont (const char *fileName, rFont *lower) | |
virtual | ~rFont () |
void | Render (unsigned char c, REAL left, REAL top, REAL right, REAL bot) |
Static Public Attributes | |
static rFont | s_defaultFont |
static rFont | s_defaultFontSmall |
Protected Member Functions | |
virtual void | ProcessImage (SDL_Surface *) |
process the surface before uploading it to GL | |
virtual void | OnSelect (bool enforce) |
Selects the texture for rendering. | |
Private Attributes | |
int | offset |
REAL | cwidth |
REAL | cheight |
REAL | onepixel |
rFont * | lowerPart |
Definition at line 54 of file rFont.cpp.
rFont::rFont | ( | const char * | fileName, | |
int | Offset = 0 , |
|||
REAL | CWidth = (1/16.0) , |
|||
REAL | CHeight = (1/8.0) , |
|||
REAL | onepixel = 1/256.0 , |
|||
rFont * | lower = NULL | |||
) |
Definition at line 76 of file rFont.cpp.
References rISurfaceTexture::StoreAlpha().
00076 : 00077 rFileTexture(rTextureGroups::TEX_FONT,fileName,0,0), 00078 offset(Offset),cwidth(CWidth),cheight(CHeight), 00079 onepixel(op),lowerPart(lower) 00080 { 00081 StoreAlpha(); 00082 }
rFont::rFont | ( | const char * | fileName, | |
rFont * | lower | |||
) |
Definition at line 84 of file rFont.cpp.
References rISurfaceTexture::StoreAlpha().
00084 : 00085 rFileTexture(rTextureGroups::TEX_FONT,fileName,0,0), 00086 offset(0),cwidth(1/16.0),cheight(1/8.0), 00087 onepixel(1/256.0),lowerPart(lower) 00088 { 00089 StoreAlpha(); 00090 }
Definition at line 144 of file rFont.cpp.
References BeginQuads(), cheight, cwidth, lowerPart, offset, onepixel, REAL, RenderEnd(), rITexture::Select(), rTextureGroups::TEX_FONT, rTextureGroups::TextureMode, and x.
Referenced by rFontContainer::Render().
00144 { 00145 // if (c > 128 && this == &rFont::s_defaultFont) 00146 //rFont::s_defaultFontSmall.Render(c, left, top, right, bot); 00147 // else 00148 // if(31<c && 256>c && sr_glOut) 00149 { 00150 c-=offset; 00151 00152 int x=c%16; 00153 int y=c/16; 00154 00155 REAL pix = onepixel *.1; 00156 if (rTextureGroups::TextureMode[rTextureGroups::TEX_FONT] != GL_NEAREST && rTextureGroups::TextureMode[rTextureGroups::TEX_FONT] != GL_NEAREST_MIPMAP_NEAREST) 00157 pix = onepixel * .5; 00158 00159 00160 REAL ttop=y*cheight+pix; 00161 REAL tbot=(y+1)*cheight-pix; 00162 REAL tleft=x*cwidth+pix; 00163 REAL tright=(x+1)*cwidth-pix; 00164 00165 rFont* select = this; 00166 while (ttop > .999 && select->lowerPart) 00167 { 00168 tbot -= 1; 00169 ttop -= 1; 00170 select = select->lowerPart; 00171 } 00172 select->Select(true); 00173 00174 BeginQuads(); 00175 glTexCoord2f(tright,tbot); 00176 glVertex2f( right, bot); 00177 00178 glTexCoord2f(tright,ttop); 00179 glVertex2f( right ,top); 00180 00181 glTexCoord2f(tleft,ttop); 00182 glVertex2f( left, top); 00183 00184 glTexCoord2f(tleft,tbot); 00185 glVertex2f( left, bot); 00186 RenderEnd(); 00187 } 00188 }
void rFont::ProcessImage | ( | SDL_Surface * | surface | ) | [protected, virtual] |
process the surface before uploading it to GL
surface | the surface to process |
Reimplemented from rISurfaceTexture.
Definition at line 104 of file rFont.cpp.
References sr_alphaBlend.
00105 { 00106 #ifndef DEDICATED 00107 if ( sr_alphaBlend ) 00108 return; 00109 00110 // pre-blend alpha values 00111 GLubyte *pixels =reinterpret_cast<GLubyte *>(surface->pixels); 00112 00113 if (surface->format->BytesPerPixel == 4) 00114 { 00115 for (int i=surface->w*surface->h-1;i>=0;i--){ 00116 GLubyte alpha=pixels[4*i+3]; 00117 pixels[4*i ] = (alpha * pixels[4*i ]) >> 8; 00118 pixels[4*i+1] = (alpha * pixels[4*i+1]) >> 8; 00119 pixels[4*i+2] = (alpha * pixels[4*i+2]) >> 8; 00120 } 00121 } 00122 else if (surface->format->BytesPerPixel == 2) 00123 { 00124 for (int i=surface->w*surface->h-1;i>=0;i--){ 00125 GLubyte alpha=pixels[2*i+1]; 00126 pixels[2*i ] = (alpha * pixels[2*i ]) >> 8; 00127 } 00128 } 00129 #endif 00130 }
void rFont::OnSelect | ( | bool | enforce | ) | [protected, virtual] |
Selects the texture for rendering.
enforce | enforce when set to true, the texture should be loaded even if the configuration says it should not |
Reimplemented from rISurfaceTexture.
Definition at line 132 of file rFont.cpp.
References rISurfaceTexture::Loaded(), rISurfaceTexture::OnSelect(), sr_glOut, and tERR_ERROR.
00133 { 00134 rISurfaceTexture::OnSelect( enforce ); 00135 if ( !Loaded() && sr_glOut ) 00136 { 00137 // abort. It makes no sense to continue without a font. 00138 tERR_ERROR( "Font file " << this->GetFileName() << " could not be loaded."); 00139 } 00140 }
int rFont::offset [private] |
REAL rFont::cwidth [private] |
REAL rFont::cheight [private] |
REAL rFont::onepixel [private] |
rFont* rFont::lowerPart [private] |
rFont rFont::s_defaultFont [static] |
rFont rFont::s_defaultFontSmall [static] |