40 #ifndef _GLS_FONT_RENDERER_H
41 #define _GLS_FONT_RENDERER_H
47 #include "gls_state_manager.h"
48 #include "gls_quad_storage.h"
69 typedef VertexNoColor
Vector;
88 typedef GlsFontBase::Char_t Char_t;
147 unsigned char textureMinFilter,
148 unsigned char textureMagFilter
150 ,IGlsStateManager *stateManager
191 glDisable(GL_TEXTURE_2D);
192 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
214 const bool emphasize,
215 const float emphasisOffset,
217 GlsQuadListVCT_2D &quadStorage,
221 const GLfloat y2)
const
224 quadStorage.AddQuad2D(x1,y1,x2,y2);
228 if (emphasize && !inverse)
230 GLfloat offsetY1(y1 + emphasisOffset);
231 GLfloat offsetY2(y2 + emphasisOffset);
233 quadStorage.AddQuad2D(x1 - emphasisOffset, offsetY1, x2 - emphasisOffset, offsetY2);
234 quadStorage.AddQuad2D(x1 + emphasisOffset, offsetY1, x2 + emphasisOffset, offsetY2);
252 const float haloOffset,
253 GlsQuadListVCT_2D &quadStorage,
257 const GLfloat y2)
const
259 const GLfloat x1right(x1 + haloOffset);
260 const GLfloat x1left(x1 - haloOffset);
261 const GLfloat x2right(x2 + haloOffset);
262 const GLfloat x2left(x2 - haloOffset);
263 const GLfloat y1up(y1 + haloOffset);
264 const GLfloat y1down(y1 - haloOffset);
265 const GLfloat y2up(y2 + haloOffset);
266 const GLfloat y2down(y2 - haloOffset);
268 quadStorage.AddQuad2D(x1left, y1up, x2left, y2up);
269 quadStorage.AddQuad2D(x1left, y1down, x2left, y2down);
270 quadStorage.AddQuad2D(x1right, y1up, x2right, y2up);
271 quadStorage.AddQuad2D(x1right, y1down, x2right, y2down);
297 const bool emphasize,
298 const float emphasisOffset,
307 const GLfloat ty2)
const
310 glBlendFunc(inverse ? GL_ONE_MINUS_SRC_ALPHA : GL_SRC_ALPHA,
311 inverse ? GL_SRC_ALPHA : GL_ONE_MINUS_SRC_ALPHA);
315 MapTexture(x1, y1, x2, y2, tx1, ty1, tx2, ty2);
318 if (emphasize && !inverse)
320 GLfloat offsetY1(y1 + emphasisOffset);
321 GLfloat offsetY2(y2 + emphasisOffset);
324 x1 - emphasisOffset, offsetY1, x2 - emphasisOffset, offsetY2,
328 x1 + emphasisOffset, offsetY1, x2 + emphasisOffset, offsetY2,
350 const float haloOffset,
358 const GLfloat ty2)
const
361 GLfloat x1right(x1 + haloOffset);
362 GLfloat x1left(x1 - haloOffset);
363 GLfloat x2right(x2 + haloOffset);
364 GLfloat x2left(x2 - haloOffset);
365 GLfloat y1up(y1 + haloOffset);
366 GLfloat y1down(y1 - haloOffset);
367 GLfloat y2up(y2 + haloOffset);
368 GLfloat y2down(y2 - haloOffset);
374 x1left, y1up, x2left, y2up,
379 x1left, y1down, x2left, y2down,
384 x1right, y1up, x2right, y2up,
389 x1right, y1down, x2right, y2down,
408 const float shadowOffset,
416 const GLfloat ty2)
const
455 glTexCoord2f(tx1, ty1);
457 glTexCoord2f(tx2, ty1);
459 glTexCoord2f(tx2, ty2);
461 glTexCoord2f(tx1, ty2);
514 stateManager->Texture2DEnabled(
true);
515 stateManager->BindTexture(texture);
520 stateManager->SetTextureMagFilter(GL_NEAREST);
524 stateManager->SetTextureMagFilter(GL_LINEAR);
528 switch (_textureMinFilter)
531 stateManager->SetTextureMinFilter(GL_NEAREST);
535 stateManager->SetTextureMinFilter(GL_LINEAR);
539 stateManager->SetTextureMinFilter(GL_NEAREST_MIPMAP_NEAREST);
543 stateManager->SetTextureMinFilter(GL_LINEAR_MIPMAP_LINEAR);
547 stateManager->SetTextureMinFilter(GL_NEAREST_MIPMAP_LINEAR);
551 stateManager->SetTextureMinFilter(GL_LINEAR_MIPMAP_NEAREST);
555 stateManager->SetTextureEnvMode(IGlsStateManager::GLS_TEXTURE_MAP_MODE_MODULATE);
574 glColor4ubv(_currentColor.
RGBA());
577 glEnable(GL_TEXTURE_2D);
583 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
587 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
591 switch (_textureMinFilter)
594 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
597 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
600 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
603 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
606 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
609 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
613 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
Definition: display_types.h:76
Definition: display_types.h:74
virtual void MipMap(bool mipMap)=0
unsigned char _textureMinFilter
Definition: gls_font_renderer.h:489
Definition: IFontImage.h:54
void SetupTexture(IFontImage *texture)
Definition: gls_font_renderer.h:561
glsColor _currentColor
Definition: gls_font_renderer.h:482
void TextureMinFilter(unsigned char val)
Definition: gls_font_renderer.h:102
The disti::GlsFontBase class and related classes.
Image * Texture() const
Definition: gls_font_base.h:318
virtual void BindTexture()=0
unsigned char TextureMagFilter()
Definition: gls_font_renderer.h:108
unsigned char TextureMinFilter()
Definition: gls_font_renderer.h:96
The Color class: Implements a 4 component RGBA color.
The Image class. All textures are converted internally into Images.
const GlsFontBase * _font
Definition: gls_font_renderer.h:486
VertexNoColor Vector
Definition: gls_font_base.h:68
Definition: gls_font_renderer.h:84
void DrawCharacter(const bool emphasize, const float emphasisOffset, const bool inverse, const GLfloat x1, const GLfloat y1, const GLfloat x2, const GLfloat y2, const GLfloat tx1, const GLfloat ty1, const GLfloat tx2, const GLfloat ty2) const
Definition: gls_font_renderer.h:296
The disti::Vertex class. A class for manipulating 3D vertices.
void DrawShadow(const float shadowOffset, const GLfloat x1, const GLfloat y1, const GLfloat x2, const GLfloat y2, const GLfloat tx1, const GLfloat ty1, const GLfloat tx2, const GLfloat ty2) const
Definition: gls_font_renderer.h:407
void SetFont(const GlsFontBase *font)
Definition: gls_font_renderer.h:128
void DrawHalo(const float haloOffset, const GLfloat x1, const GLfloat y1, const GLfloat x2, const GLfloat y2, const GLfloat tx1, const GLfloat ty1, const GLfloat tx2, const GLfloat ty2) const
Definition: gls_font_renderer.h:349
unsigned char _textureMagFilter
Definition: gls_font_renderer.h:492
void InitRendering()
Definition: gls_font_renderer.h:179
void TermRendering()
Definition: gls_font_renderer.h:189
Definition: gls_color.h:54
void RGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Definition: gls_color.h:164
Definition: display_types.h:72
void TextureMagFilter(unsigned char val)
Definition: gls_font_renderer.h:114
Definition: display_types.h:75
Definition: display_types.h:71
Definition: display_types.h:73
Character attributes. One item for each character in the set.
Definition: gls_font_base.h:127
static void MapTexture(const GLfloat x1, const GLfloat y1, const GLfloat x2, const GLfloat y2, const GLfloat tx1, const GLfloat ty1, const GLfloat tx2, const GLfloat ty2)
Definition: gls_font_renderer.h:445
void InitRendering(unsigned char textureMinFilter, unsigned char textureMagFilter)
Definition: gls_font_renderer.h:146
Definition: bmpimage.h:46
GlsFontRenderer(const GlsFontBase *font)
Definition: gls_font_renderer.h:471
Definition: gls_font_base.h:87