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 
26 namespace MaliSDK
27 {
34  class Text
35  {
36  private:
43  static const float scale;
44 
45  Matrix projectionMatrix;
47  float* textVertex;
49  float* color;
50  GLshort* textIndex;
51  int m_iLocPosition;
52  int m_iLocProjection;
53  int m_iLocTextColor;
54  int m_iLocTexCoord;
55  int m_iLocTexture;
60 
61  public:
62 
67  static const int textureCharacterWidth;
68 
73  static const int textureCharacterHeight;
82  Text(const char* vertexShaderFileName,
83  const char* fragmentShaderFileName,
84  const char* textureFileName,
85  int windowWidth,
86  int windowHeight);
87 
91  virtual ~Text(void);
92 
98  void clear(void);
99 
111  void addString(int xPosition, int yPosition, const char *string, int red, int green, int blue, int alpha);
112 
118  void draw(void);
119  };
120 }
121 #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 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
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
int m_iLocTexture
Definition: Text.h:71
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