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) 2012-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 #if GLES_VERSION == 2
27 #include <GLES2/gl2.h>
28 #elif GLES_VERSION == 3
29 #include <GLES3/gl3.h>
30 #else
31 #error "GLES_VERSION must be defined as either 2 or 3"
32 #endif
33 
34 #include <string>
35 
36 namespace MaliSDK
37 {
44  class Text
45  {
46  private:
47  static const std::string textureFilename;
48  static const std::string vertexShaderFilename;
49  static const std::string fragmentShaderFilename;
50 
57  static const float scale;
58 
59 
60 
63  float *textVertex;
65  float *color;
66  GLshort *textIndex;
76 
77  public:
78 
83  static const int textureCharacterWidth;
84 
89  static const int textureCharacterHeight;
96  Text(const char * resourceDirectory, int windowWidth, int windowHeight);
97 
101  virtual ~Text(void);
102 
108  void clear(void);
109 
120  void addString(int xPosition, int yPosition, const char *string, int red, int green, int blue, int alpha);
121 
127  void draw(void);
128  };
129 }
130 #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
Functions for drawing text in OpenGL ES.
Definition: Text.h:44
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
Functions for manipulating matrices.
Definition: Matrix.h:31
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