OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Text.h
Go to the documentation of this file.
1 /* Copyright (c) 2014-2017, ARM Limited and Contributors
2  *
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge,
6  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
9  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19  */
20 
21 #ifndef TEXT_H
22 #define TEXT_H
23 
24 #include "Matrix.h"
25 #include <cstdlib>
26 #include <cmath>
27 #include <iostream>
28 #include <sstream>
29 #include <string>
30 
31 namespace MaliSDK
32 {
39  class Text
40  {
41  private:
42  static const std::string textureFilename;
43  static const std::string vertexShaderFilename;
44  static const std::string fragmentShaderFilename;
45 
52  static const float scale;
53  Matrix projectionMatrix;
55  float *textVertex;
57  float *color;
58  GLshort *textIndex;
59  int m_iLocPosition;
60  int m_iLocProjection;
61  int m_iLocTextColor;
62  int m_iLocTexCoord;
63  int m_iLocTexture;
68 
69  public:
70 
75  static const int textureCharacterWidth;
76 
81  static const int textureCharacterHeight;
88  Text(const char * resourceDirectory, int windowWidth, int windowHeight);
89 
93  virtual ~Text(void);
94 
100  void clear(void);
101 
112  void addString(int xPosition, int yPosition, const char *string, int red, int green, int blue, int alpha);
113 
119  void draw(void);
120  };
121 }
122 #endif /* TEXT_H */
int m_iLocProjection
Definition: Text.h:68
float * textTextureCoordinates
Definition: Text.h:64
int windowWidth
Definition: Cube.cpp:56
int m_iLocTextColor
Definition: Text.h:69
Text(const char *resourceDirectory, int windowWidth, int windowHeight)
Constructor for Text.
Definition: Text.cpp:43
static const std::string textureFilename
Definition: Text.h:47
static const float scale
Scaling factor to use when rendering the text.
Definition: Text.h:57
void clear(void)
Removes the current string from the class.
Definition: Text.cpp:142
GLshort * textIndex
Definition: Text.h:66
int windowHeight
Definition: Cube.cpp:57
float * textVertex
Definition: Text.h:63
static const std::string vertexShaderFilename
Definition: Text.h:48
int numberOfCharacters
Definition: Text.h:62
static const int textureCharacterHeight
The height (in pixels) of the characters in the text texture.
Definition: Text.h:89
virtual ~Text(void)
Default destructor.
Definition: Text.cpp:322
GLuint textureID
Definition: Text.h:75
static const int textureCharacterWidth
The width (in pixels) of the characters in the text texture.
Definition: Text.h:83
float * color
Definition: Text.h:65
void addString(int xPosition, int yPosition, const char *string, int red, int green, int blue, int alpha)
Add a std::string to be drawn to the screen.
Definition: Text.cpp:157
int m_iLocTexCoord
Definition: Text.h:70
GLuint fragmentShaderID
Definition: Text.h:73
GLuint vertexShaderID
Definition: Text.h:72
string resourceDirectory
Definition: AntiAlias.cpp:55
int m_iLocTexture
Definition: Text.h:71
static const std::string fragmentShaderFilename
Definition: Text.h:49
int m_iLocPosition
Definition: Text.h:67
GLuint programID
Definition: Text.h:74
void draw(void)
Draw the text to the screen.
Definition: Text.cpp:265
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
Matrix projectionMatrix
Definition: Text.h:61