GL Studio C++ Runtime API
gls_font_renderer.h
Go to the documentation of this file.
1/// \file gls_font_renderer.h
2/// \brief The disti::GlsFontRenderer class and related classes.
3///
4/// \par Copyright Information
5///
6/// Copyright (c) 2017 by The DiSTI Corporation.<br>
7/// 12249 Science Drive; Suite 300<br>
8/// Orlando, Florida 32826<br>
9/// USA<br>
10/// <br>
11/// All rights reserved.<br>
12///
13/// This Software contains proprietary trade secrets of DiSTI and may not be
14/// reproduced, in whole or part, in any form, or by any means of electronic,
15/// mechanical, or otherwise, without the written permission of DiSTI. Said
16/// permission may be derived through the purchase of applicable DiSTI product
17/// licenses which detail the distribution rights of this content and any
18/// Derivative Works based on this or other copyrighted DiSTI Software.
19///
20/// NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21/// AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22/// PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23/// AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24/// IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25/// PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26///
27/// LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28/// IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29/// INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30/// DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31/// INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32/// INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33/// OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34/// EXCEED FIVE DOLLARS (US$5.00).
35///
36/// The aforementioned terms and restrictions are governed by the laws of the
37/// State of Florida and the United States of America.
38
39#ifndef DISTI_INCLUDED_GLS_FONT_RENDERER_H
40#define DISTI_INCLUDED_GLS_FONT_RENDERER_H
41
42#include "gls_gl.h"
43#include <string>
44#include <vector>
45#ifdef GLES
46# include "gls_quad_storage.h"
47# include "gls_state_manager.h"
48#endif
49#include "IFontImage.h"
50#include "gls_color.h"
52#include "gls_font_base.h"
53#include "gls_state_manager.h"
54#include "image.h"
55#include "vertex.h"
56
57//===========================================================================
58// BEGIN NAMESPACE
59//===========================================================================
60namespace disti
61{
62//---------------------------------------------------------------------------
63// FORWARD REFERENCES
64//---------------------------------------------------------------------------
65class VertexNoColor;
66class GlsColor;
67class Image;
68
69typedef VertexNoColor Vector;
70
71//===========================================================================
72/**
73*
74* The GlsFontRenderer object can be used to render characters from a GlsFontBase in
75* Open GL at specific locations and with several different text effects.
76* Prior to rendering any characters, InitRendering must be invoked to set
77* up the proper drawing environment. Then call Render for each character
78* to be drawn.
79*
80* \sa GlsFontBase
81*
82*/
83//===========================================================================
85{
86public:
87 typedef GlsFontBase::Char_t Char_t; ///< Shorthand for GlsFontBase::Char_t.
88 typedef GlsFontBase::CharAttr_t CharAttr_t; ///< Shorthand for GlsFontBase::CharAttr_t.
89
90 //----------------------------------------
91 // Character rendering state variables
92 //----------------------------------------
93
94 /// \return The minification filter for this font.
95 unsigned char TextureMinFilter()
96 {
97 return _textureMinFilter;
98 }
99
100 /// Sets the minification filter for this font.
101 /// \param val The new minification to set.
102 void TextureMinFilter( unsigned char val )
103 {
104 _textureMinFilter = val;
105 }
106
107 /// \return The magnification filter for this font.
108 unsigned char TextureMagFilter()
109 {
110 return _textureMagFilter;
111 }
112
113 /// Sets the magnification filter for this font.
114 /// \param val The new magnification to set.
115 void TextureMagFilter( unsigned char val )
116 {
117 _textureMagFilter = val;
118 }
119
120 //----------------------------------------
121 // Setup and cleanup for rendering
122 //----------------------------------------
123
124 /// Set the font to use.
125 /// The font pointer must be set before calling any rendering methods.
126 /// \param font The new font to use.
127 void SetFont( const GlsFontBase* font )
128 {
129 _font = font;
130 }
131
132 /// \return A pointer to the font currently in use.
134 {
135 return _font;
136 }
137
138#ifdef GLES
139 /// Initializes the font to begin rendering characters. This will set up
140 /// Open GL texture modes, bind the font's texture, set up minification
141 /// and magnification filters, etc. This must be called once before
142 /// invoking Render to draw characters. This version overwrites the
143 /// texture minification and magnification filters before initializing.
144 /// \param textureMinFilter Minification mode for the font texture.
145 /// \param textureMagFilter Magnification mode for the font texture.
146 /// \param stateManager The object responsible for rendering the font.
147 void InitRendering(
148 unsigned char textureMinFilter,
149 unsigned char textureMagFilter,
150 IGlsStateManager* stateManager )
151 {
152 _textureMinFilter = textureMinFilter;
153 _textureMagFilter = textureMagFilter;
154 InitRendering( stateManager );
155 }
156
157 /// Initializes the font to begin rendering characters. This will set up
158 /// Open GL texture modes, bind the font's texture, set up minification
159 /// and magnification filters, etc. This must be called before
160 /// using any of the Render methods draw characters.
161 /// \param stateManager The state manager that will handle rendering the font.
162 void InitRendering( IGlsStateManager* stateManager )
163 {
164 SetupTexture( _font->Texture(), stateManager );
165 }
166
167 /**
168 * Restores the Open GL state as it was before the call to InitRendering.
169 * This should be called after all characters have been rendered using
170 * the Render methods.
171 */
172 void TermRendering( IGlsStateManager* stateManager )
173 {
174 stateManager->Texture2DEnabled( false );
175 } // end GlsFontRenderer::TermRendering
176
177#else // !GLES
178
179 /// Initializes the font to begin rendering characters. This will set up
180 /// Open GL texture modes, bind the font's texture, set up minification
181 /// and magnification filters, etc. This must be called once before
182 /// invoking Render to draw characters. This version overwrites the
183 /// texture minification and magnification filters before initializing.
184 /// \param textureMinFilter Minification mode for the font texture.
185 /// \param textureMagFilter Magnification mode for the font texture.
187 unsigned char textureMinFilter,
188 unsigned char textureMagFilter )
189 {
190 _textureMinFilter = textureMinFilter;
191 _textureMagFilter = textureMagFilter;
193 }
194
195 /// Initializes the font to begin rendering characters. This will set up
196 /// Open GL texture modes, bind the font's texture, set up minification
197 /// and magnification filters, etc. This must be called before
198 /// using any of the Render methods draw characters.
200 {
202 }
203
204 /**
205 * Restores the Open GL state as it was before the call to InitRendering.
206 * This should be called after all characters have been rendered using
207 * the Render methods.
208 */
210 {
211 glDisable( GL_TEXTURE_2D );
212 } // end GlsFontRenderer::TermRendering
213
214#endif // GLES
215
216 //----------------------------------------
217 // Rendering Methods
218 //----------------------------------------
219
220#ifdef GLES
221 /** Draw a character by adding it into the supplied QuadStorage object
222 * \deprecated inverse no longer has any effect, use the other overload instead.
223 * \param emphasize Whether to draw with emphasize or not
224 * \param emphasisOffset If drawing with emphasize, the offset in logical units
225 * \param inverse Deprecated, has no effect
226 * \param quadStorage The quad storage object to render the characters into
227 * \param x1 lower left corner x coordinate of the polygon
228 * \param y1 lower left corner y coordinate of the polygon
229 * \param x2 upper right corner x coordinate of the polygon
230 * \param y2 upper right corner y coordinate of the polygon
231 */
232 DISTI_DEPRECATED( "This overload is deprecated because the clear text effect has been superseded. Use the DrawCharacter() overload without the 'inverse' parameter." )
233 void DrawCharacter(
234 const bool emphasize,
235 const float emphasisOffset,
236 const bool inverse,
237 GlsQuadListVCT_2D& quadStorage,
238 const GLfloat x1,
239 const GLfloat y1,
240 const GLfloat x2,
241 const GLfloat y2 ) const
242 {
243 DrawCharacter( emphasize, emphasisOffset, quadStorage, x1, y1, x2, y2 );
244 }
245
246 /** Draw a character by adding it into the supplied QuadStorage object
247 * \param emphasize Whether to draw with emphasize or not
248 * \param emphasisOffset If drawing with emphasize, the offset in logical units
249 * \param quadStorage The quad storage object to render the characters into
250 * \param x1 lower left corner x coordinate of the polygon
251 * \param y1 lower left corner y coordinate of the polygon
252 * \param x2 upper right corner x coordinate of the polygon
253 * \param y2 upper right corner y coordinate of the polygon
254 */
255 void DrawCharacter(
256 const bool emphasize,
257 const float emphasisOffset,
258 GlsQuadListVCT_2D& quadStorage,
259 const GLfloat x1,
260 const GLfloat y1,
261 const GLfloat x2,
262 const GLfloat y2 ) const
263 {
264 // character color
265 quadStorage.AddQuad2D( x1, y1, x2, y2 );
266
267 // Character emphasis. Draw two more cells offset a little so
268 // character appears bolded.
269 if( emphasize )
270 {
271 GLfloat offsetY1( y1 + emphasisOffset );
272 GLfloat offsetY2( y2 + emphasisOffset );
273
274 quadStorage.AddQuad2D( x1 - emphasisOffset, offsetY1, x2 - emphasisOffset, offsetY2 );
275 quadStorage.AddQuad2D( x1 + emphasisOffset, offsetY1, x2 + emphasisOffset, offsetY2 );
276 }
277
278 } // end GlsFontRenderer::DrawCharacter
279
280 /**
281 * Draws a halo effect for the given character.
282 *
283 * \param haloOffset Controls the size of the halo
284 * GlsTextGrid uses: (emphasize ? 0.05f : 0.03f) * (character_width) (x2 - x1)
285 * \param diagonalOffset The offset to use for the four diagonal directions.
286 * \param quadStorage A list containing 2D quads from the generated vertices.
287 * \param x1 lower left corner x coordinate of the polygon
288 * \param y1 lower left corner y coordinate of the polygon
289 * \param x2 upper right corner x coordinate of the polygon
290 * \param y2 upper right corner y coordinate of the polygon
291 */
292
293 void DrawHalo(
294 const float haloOffset,
295 const float diagonalOffset,
296 GlsQuadListVCT_2D& quadStorage,
297 const GLfloat x1,
298 const GLfloat y1,
299 const GLfloat x2,
300 const GLfloat y2 ) const
301 {
302 const GLfloat x1right( x1 + diagonalOffset );
303 const GLfloat x1left( x1 - diagonalOffset );
304 const GLfloat x2right( x2 + diagonalOffset );
305 const GLfloat x2left( x2 - diagonalOffset );
306 const GLfloat y1up( y1 + diagonalOffset );
307 const GLfloat y1down( y1 - diagonalOffset );
308 const GLfloat y2up( y2 + diagonalOffset );
309 const GLfloat y2down( y2 - diagonalOffset );
310
311 quadStorage.AddQuad2D( x1left, y1up, x2left, y2up );
312 quadStorage.AddQuad2D( x1left, y1down, x2left, y2down );
313 quadStorage.AddQuad2D( x1right, y1up, x2right, y2up );
314 quadStorage.AddQuad2D( x1right, y1down, x2right, y2down );
315 quadStorage.AddQuad2D( x1 - haloOffset, y1, x2 - haloOffset, y2 );
316 quadStorage.AddQuad2D( x1, y1 - haloOffset, x2, y2 - haloOffset );
317 quadStorage.AddQuad2D( x1 + haloOffset, y1, x2 + haloOffset, y2 );
318 quadStorage.AddQuad2D( x1, y1 + haloOffset, x2, y2 + haloOffset );
319 }
320
321#else // !GLES
322 /**
323 * Draws a character.
324 * \deprecated inverse no longer has any effect, use the other overload instead.
325 *
326 * \param emphasize true if the rendered character should be emphasized.
327 * This will essentially bold the character. If a bold
328 * font is being used, the character will appear even
329 * more bolded.
330 * \param emphasisOffset Magnitude of the emhpasis offset. A good value to try is (0.2 * character_width).
331 * \param inverse Deprecated, has no effect
332 * \param x1 lower left corner x coordinate of the polygon
333 * \param y1 lower left corner y coordinate of the polygon
334 * \param x2 upper right corner x coordinate of the polygon
335 * \param y2 upper right corner y coordinate of the polygon
336 * \param tx1 lower left corner x texture coordinate
337 * \param ty1 lower left corner y texture coordinate
338 * \param tx2 upper right corner x texture coordinate
339 * \param ty2 upper right corner y texture coordinate
340 */
341 DISTI_DEPRECATED( "This overload is deprecated because the clear text effect has been superseded. Use the DrawCharacter() overload without the 'inverse' parameter." )
343 const bool emphasize,
344 const float emphasisOffset,
345 const bool inverse,
346 const GLfloat x1,
347 const GLfloat y1,
348 const GLfloat x2,
349 const GLfloat y2,
350 const GLfloat tx1,
351 const GLfloat ty1,
352 const GLfloat tx2,
353 const GLfloat ty2 ) const
354 {
355 DrawCharacter( emphasize, emphasisOffset, x1, y1, x2, y2, tx1, ty1, tx2, ty2 );
356 }
357
358 /**
359 * Draws a character.
360 *
361 * \param emphasize true if the rendered character should be emphasized.
362 * This will essentially bold the character. If a bold
363 * font is being used, the character will appear even
364 * more bolded.
365 * \param emphasisOffset Magnitude of the emhpasis offset. A good value to try is (0.2 * character_width).
366 * \param x1 lower left corner x coordinate of the polygon
367 * \param y1 lower left corner y coordinate of the polygon
368 * \param x2 upper right corner x coordinate of the polygon
369 * \param y2 upper right corner y coordinate of the polygon
370 * \param tx1 lower left corner x texture coordinate
371 * \param ty1 lower left corner y texture coordinate
372 * \param tx2 upper right corner x texture coordinate
373 * \param ty2 upper right corner y texture coordinate
374 */
376 const bool emphasize,
377 const float emphasisOffset,
378 const GLfloat x1,
379 const GLfloat y1,
380 const GLfloat x2,
381 const GLfloat y2,
382 const GLfloat tx1,
383 const GLfloat ty1,
384 const GLfloat tx2,
385 const GLfloat ty2 ) const
386 {
387 glBegin( GL_QUADS );
388
389 MapTexture( x1, y1, x2, y2, tx1, ty1, tx2, ty2 );
390 // Character emphasis. Draw two more cells offset a little so
391 // character appears bolded.
392 if( emphasize )
393 {
394 GLfloat offsetY1( y1 + emphasisOffset );
395 GLfloat offsetY2( y2 + emphasisOffset );
396
398 x1 - emphasisOffset, offsetY1, x2 - emphasisOffset, offsetY2,
399 tx1, ty1, tx2, ty2 );
400
402 x1 + emphasisOffset, offsetY1, x2 + emphasisOffset, offsetY2,
403 tx1, ty1, tx2, ty2 );
404 }
405
406 glEnd();
407
408 } // end GlsFontRenderer::DrawCharacter
409
410 /// Draws a halo effect for the given character.
411 /// \param haloOffset Controls the size of the halo
412 /// GlsTextGrid uses: (emphasize ? 0.05f : 0.03f) * (character_width) (x2 - x1)
413 /// \param diagonalOffset The offset to use for the four diagonal directions.
414 /// \param x1 The lower left corner x coordinate of the polygon.
415 /// \param y1 The lower left corner y coordinate of the polygon.
416 /// \param x2 The upper right corner x coordinate of the polygon.
417 /// \param y2 The upper right corner y coordinate of the polygon.
418 /// \param tx1 The lower left corner x texture coordinate.
419 /// \param ty1 The lower left corner y texture coordinate.
420 /// \param tx2 The upper right corner x texture coordinate.
421 /// \param ty2 The upper right corner y texture coordinate.
423 const float haloOffset,
424 const float diagonalOffset,
425 const GLfloat x1,
426 const GLfloat y1,
427 const GLfloat x2,
428 const GLfloat y2,
429 const GLfloat tx1,
430 const GLfloat ty1,
431 const GLfloat tx2,
432 const GLfloat ty2 ) const
433 {
434 // Halo effect.
435 GLfloat x1right( x1 + diagonalOffset );
436 GLfloat x1left( x1 - diagonalOffset );
437 GLfloat x2right( x2 + diagonalOffset );
438 GLfloat x2left( x2 - diagonalOffset );
439 GLfloat y1up( y1 + diagonalOffset );
440 GLfloat y1down( y1 - diagonalOffset );
441 GLfloat y2up( y2 + diagonalOffset );
442 GLfloat y2down( y2 - diagonalOffset );
443
444 glBegin( GL_QUADS );
445
446 // Shift left and up
448 x1left, y1up, x2left, y2up,
449 tx1, ty1, tx2, ty2 );
450
451 // Shift left and down
453 x1left, y1down, x2left, y2down,
454 tx1, ty1, tx2, ty2 );
455
456 // Shift right and up
458 x1right, y1up, x2right, y2up,
459 tx1, ty1, tx2, ty2 );
460
461 // Shift right and down
463 x1right, y1down, x2right, y2down,
464 tx1, ty1, tx2, ty2 );
465
466 // Shift left
468 x1 - haloOffset, y1, x2 - haloOffset, y2,
469 tx1, ty1, tx2, ty2 );
470
471 // Shift down
473 x1, y1 - haloOffset, x2, y2 - haloOffset,
474 tx1, ty1, tx2, ty2 );
475
476 // Shift right
478 x1 + haloOffset, y1, x2 + haloOffset, y2,
479 tx1, ty1, tx2, ty2 );
480
481 // Shift up
483 x1, y1 + haloOffset, x2, y2 + haloOffset,
484 tx1, ty1, tx2, ty2 );
485
486 glEnd();
487 } // end GlsFontRenderer::DrawHalo
488
489 /**
490 * Draws a drop shadow effect for a character.
491 * \param shadowOffset distance to offset the shadow from the character
492 * \param x1 lower left corner x coordinate of the polygon
493 * \param y1 lower left corner y coordinate of the polygon
494 * \param x2 upper right corner x coordinate of the polygon
495 * \param y2 upper right corner y coordinate of the polygon
496 * \param tx1 lower left corner x texture coordinate
497 * \param ty1 lower left corner y texture coordinate
498 * \param tx2 upper right corner x texture coordinate
499 * \param ty2 upper right corner y texture coordinate
500 */
502 const float shadowOffset,
503 const GLfloat x1,
504 const GLfloat y1,
505 const GLfloat x2,
506 const GLfloat y2,
507 const GLfloat tx1,
508 const GLfloat ty1,
509 const GLfloat tx2,
510 const GLfloat ty2 ) const
511 {
512 // Shadow effect.
513 glBegin( GL_QUADS );
514
515 // Shift right and down
517 x1 + shadowOffset,
518 y1 - shadowOffset,
519 x2 + shadowOffset,
520 y2 - shadowOffset,
521 tx1, ty1, tx2, ty2 );
522
523 glEnd();
524
525 } // end GlsFontRenderer::DrawShadow
526
527 /**
528 * Map a square piece of a texture onto a quad ( assumed to be called
529between glBegin(GL_QUADS)...glEnd() pair )
530 * \param x1 the lower left corner x of the quad
531 * \param y1 the lower left corner y of the quad
532 * \param x2 the upper right corner x of the quad
533 * \param y2 the upper right corner of the quad
534 * \param tx1 lower left corner x texture coordinate
535 * \param ty1 lower left corner y texture coordinate
536 * \param tx2 upper right corner x texture coordinate
537 * \param ty2 upper right corner y texture coordinate
538 */
539 static void MapTexture(
540 const GLfloat x1,
541 const GLfloat y1,
542 const GLfloat x2,
543 const GLfloat y2,
544 const GLfloat tx1,
545 const GLfloat ty1,
546 const GLfloat tx2,
547 const GLfloat ty2 )
548 {
549 glTexCoord2f( tx1, ty1 );
550 glVertex2f( x1, y1 );
551 glTexCoord2f( tx2, ty1 );
552 glVertex2f( x2, y1 );
553 glTexCoord2f( tx2, ty2 );
554 glVertex2f( x2, y2 );
555 glTexCoord2f( tx1, ty2 );
556 glVertex2f( x1, y2 );
557 }
558
559#endif // GLES
560
561 /**
562 * Create a GlsFontRenderer with the default settings.
563 * \param font The font to use for rendering. This may be NULL on creation, but it must be set before rendering.
564 */
566 : _font( font )
569 {
570 }
571
572protected:
573#ifndef GLES
574 /** Current drawing color is kept so we don't have to make an OpenGL call if the color is the same */
576#endif
577
578 /** Pointer to the font to use for rendering */
580
581 /** Minification mode for the font texture */
582 unsigned char _textureMinFilter;
583
584 /** Magnification mode for the font texture */
585 unsigned char _textureMagFilter;
586
587#ifdef GLES
588
589 /// Helper method to set up Open GL texture modes, bind the font's texture,
590 /// set up minification and magnification filters, etc.
591 /// \param texture The font texture to bind.
592 /// \param stateManager The object responsible for rendering the texture.
593 void SetupTexture( IFontImage* texture, IGlsStateManager* stateManager )
594 {
596 if( mipMap )
597 {
598 // This will force the image to create the mipmap images
599 texture->MipMap( true );
600 }
601
602 // Initialize the font texture
603 stateManager->Texture2DEnabled( true );
604 stateManager->BindTexture( texture );
605
606 // Set up mip mapping for magnification
608 {
609 stateManager->SetTextureMagFilter( GL_NEAREST );
610 }
612 {
613 stateManager->SetTextureMagFilter( GL_LINEAR );
614 }
615
616 // Set up mip mapping for minification
617 switch( _textureMinFilter )
618 {
620 stateManager->SetTextureMinFilter( GL_NEAREST );
621 break;
622
624 stateManager->SetTextureMinFilter( GL_LINEAR );
625 break;
626
628 stateManager->SetTextureMinFilter( GL_NEAREST_MIPMAP_NEAREST );
629 break;
630
632 stateManager->SetTextureMinFilter( GL_LINEAR_MIPMAP_LINEAR );
633 break;
634
636 stateManager->SetTextureMinFilter( GL_NEAREST_MIPMAP_LINEAR );
637 break;
638
640 stateManager->SetTextureMinFilter( GL_LINEAR_MIPMAP_NEAREST );
641 break;
642 }
643
644 stateManager->SetTextureEnvMode( IGlsStateManager::GLS_TEXTURE_MAP_MODE_MODULATE );
645
646 } // end GlsFontRenderer::SetupTexture
647
648#else // !GLES
649
650 /// Helper method to set up Open GL texture modes, bind the font's texture,
651 /// set up minification and magnification filters, etc.
652 /// \param texture The font texture to bind.
653 void SetupTexture( IFontImage* texture )
654 {
656 if( mipMap )
657 {
658 // This will force the image to create the mipmap images
659 texture->MipMap( true );
660 }
661
662 // Initialize the drawing color
663 glColor4ubv( _currentColor.RGBA() );
664
665 // Initialize the font texture
666 glEnable( GL_TEXTURE_2D );
667 texture->BindTexture();
668
669 // Set up mip mapping for magnification
671 {
672 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
673 }
675 {
676 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
677 }
678
679 // Set up mip mapping for minification
680 switch( _textureMinFilter )
681 {
683 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
684 break;
686 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
687 break;
689 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST );
690 break;
692 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
693 break;
695 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR );
696 break;
698 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
699 break;
700 }
701
702 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
703
704 } // end GlsFontRenderer::SetupTexture
705
706#endif // GLES
707
708}; // end class GlsFontRenderer
709
710} // end namespace disti
711
712#endif
IFontImage.
Definition: gls_color.h:53
void RGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
Definition: gls_color.h:172
Definition: gls_font_base.h:86
Image * Texture() const
Definition: gls_font_base.h:330
GLuint Char_t
Define the character type to use.
Definition: gls_font_base.h:88
Definition: gls_font_renderer.h:85
void TermRendering()
Definition: gls_font_renderer.h:209
void TextureMagFilter(unsigned char val)
Definition: gls_font_renderer.h:115
void DrawHalo(const float haloOffset, const float diagonalOffset, 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:422
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:342
GlsFontRenderer(const GlsFontBase *font)
Definition: gls_font_renderer.h:565
const GlsFontBase * _font
Definition: gls_font_renderer.h:579
const GlsFontBase * GetFont()
Definition: gls_font_renderer.h:133
void InitRendering()
Definition: gls_font_renderer.h:199
void TextureMinFilter(unsigned char val)
Definition: gls_font_renderer.h:102
void SetupTexture(IFontImage *texture)
Definition: gls_font_renderer.h:653
GlsFontBase::CharAttr_t CharAttr_t
Shorthand for GlsFontBase::CharAttr_t.
Definition: gls_font_renderer.h:88
unsigned char TextureMagFilter()
Definition: gls_font_renderer.h:108
unsigned char _textureMinFilter
Definition: gls_font_renderer.h:582
unsigned char TextureMinFilter()
Definition: gls_font_renderer.h:95
GlsColor _currentColor
Definition: gls_font_renderer.h:575
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:501
unsigned char _textureMagFilter
Definition: gls_font_renderer.h:585
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:539
GlsFontBase::Char_t Char_t
Shorthand for GlsFontBase::Char_t.
Definition: gls_font_renderer.h:87
void InitRendering(unsigned char textureMinFilter, unsigned char textureMagFilter)
Definition: gls_font_renderer.h:186
void SetFont(const GlsFontBase *font)
Definition: gls_font_renderer.h:127
void DrawCharacter(const bool emphasize, const float emphasisOffset, 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:375
Definition: gls_quad_storage.h:156
Definition: IFontImage.h:50
virtual void MipMap(bool mipMap)=0
virtual void BindTexture()=0
Definition: gls_state_manager_interface.h:65
The Color class: Implements a 4 component RGBA color.
Macros and helper code to determine what subset of C++11/14/17 is available.
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:487
The disti::GlsFontBase class and related classes.
The gls_gl.
The disti::GlsQuadListVC_3D and GlsQuadListVCT_2D classes.
The disti::GlsStateManager factory class. Creates an instance of a state manager that manages the GL ...
The Image class. All textures are converted internally into Images.
Definition: bmpimage.h:46
@ TEXTURE_FILTER_NEAREST
Definition: display_types.h:62
@ TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR
Definition: display_types.h:65
@ TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST
Definition: display_types.h:64
@ TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST
Definition: display_types.h:67
@ TEXTURE_FILTER_LINEAR
Definition: display_types.h:63
@ TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR
Definition: display_types.h:66
VertexNoColor Vector
Definition: gls_font_base.h:68
Character attributes. One item for each character in the set.
Definition: gls_font_base.h:124
The disti::Vertex class. A class for manipulating 3D vertices.