gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
TextRenderer.inl
Go to the documentation of this file.
1 /*
2 
3 Copyright (c) 2014, Dr Franck P. Vidal (franck.p.vidal@fpvidal.net),
4 http://www.fpvidal.net/
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation and/or
15 other materials provided with the distribution.
16 
17 3. Neither the name of the Bangor University nor the names of its contributors
18 may be used to endorse or promote products derived from this software without
19 specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 
32 */
33 
34 
62 //******************************************************************************
63 // namespace
64 //******************************************************************************
65 namespace gVirtualXRay {
66 
67 
68  //----------------------------------------------------------------
69  inline TextRenderer::Character::Character(unsigned int aTextureID,
70  int aWidth,
71  int aHeight,
72  float aVX,
73  float aVY,
74  float aXOffset,
75  float aYOffset):
76  //----------------------------------------------------------------
77  m_texture_id(aTextureID),
78  m_width(aWidth),
79  m_height(aHeight),
80  m_vx(aVX),
81  m_vy(aVY),
82  m_x_offset(aXOffset),
83  m_y_offset(aYOffset)
84  //----------------------------------------------------------------
85  {
86  }
87 
88 
89  //------------------------------------------
90  inline TextRenderer::Character::~Character()
91  //------------------------------------------
92  {
93  release();
94  }
95 
96 
97  //--------------------------------------------
98  inline void TextRenderer::Character::release()
99  //--------------------------------------------
100  {
101  if (m_texture_id)
102  {
103  glDeleteTextures(1, &m_texture_id);
104  }
105  }
106 
107 
108  //----------------------------------
110  //----------------------------------
111  m_initialised(false)
112  //----------------------------------
113  {
114  }
115 
116 
117  //----------------------------------
119  //----------------------------------
120  {
121  release();
122  }
123 
124 
125  //---------------------------------
126  inline void TextRenderer::release()
127  //---------------------------------
128  {
129 #ifdef HAS_FREETYPE
130  m_character_set.clear();
131  m_text_vbo.reset();
132  m_display_text_shader.release();
133  m_initialised = false;
134 #endif
135  }
136 
137 
138 
139  //----------------------------------------------------------
140  inline void TextRenderer::initialize(unsigned int aFontSize)
141  //----------------------------------------------------------
142  {
143  initialise(aFontSize);
144  }
145 
146 
147  //---------------------------------------------------------------
148  inline void TextRenderer::initialize(const std::string aFontFile,
149  unsigned int aFontSize)
150  //---------------------------------------------------------------
151  {
152  initialise(aFontFile, aFontSize);
153  }
154 
155 
156  //---------------------------------------------
157  inline bool TextRenderer::isInitialised() const
158  //---------------------------------------------
159  {
160  return (m_initialised);
161  }
162 
163 
164 } // namespace gVirtualXRay
void initialise(unsigned int aFontSize=16 *38)
Initialise the default font.
virtual ~TextRenderer()
Destructor.
TextRenderer()
Default constructor.
void initialize(unsigned int aFontSize=16 *38)
Initialise the default font.
bool m_initialised
Flag set to true when the fond is initialised.
Definition: TextRenderer.h:281
bool isInitialised() const
Accessor on the initialisation flag.