Functions for drawing text in OpenGL ES.
More...
#include <Text.h>
List of all members.
Public Member Functions |
| Text (const char *resourceDirectory, int windowWidth, int windowHeight) |
| Constructor for Text.
|
virtual | ~Text (void) |
| Default destructor.
|
void | clear (void) |
| Removes the current string from the class.
|
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.
|
void | draw (void) |
| Draw the text to the screen.
|
Static Public Attributes |
static const int | textureCharacterWidth = 8 |
| The width (in pixels) of the characters in the text texture.
|
static const int | textureCharacterHeight = 16 |
| The height (in pixels) of the characters in the text texture.
|
Private Attributes |
Matrix | projectionMatrix |
int | numberOfCharacters |
float * | textVertex |
float * | textTextureCoordinates |
float * | color |
GLshort * | textIndex |
int | m_iLocPosition |
int | m_iLocProjection |
int | m_iLocTextColor |
int | m_iLocTexCoord |
int | m_iLocTexture |
GLuint | vertexShaderID |
GLuint | fragmentShaderID |
GLuint | programID |
GLuint | textureID |
Static Private Attributes |
static const std::string | textureFilename = "font.raw" |
static const std::string | vertexShaderFilename = "font.vert" |
static const std::string | fragmentShaderFilename = "font.frag" |
static const float | scale = 1.0f |
| Scaling factor to use when rendering the text.
|
Detailed Description
Functions for drawing text in OpenGL ES.
Uses a texture with images of alphanumeric and punctuation symbols. The class converts strings into texture coordinates in order to render the correct symbol from the texture for each character of the string.
Constructor & Destructor Documentation
MaliSDK::Text::Text |
( |
const char * |
resourceDirectory, |
|
|
int |
windowWidth, |
|
|
int |
windowHeight |
|
) |
| |
Constructor for Text.
- Parameters:
-
[in] | resourceDirectory | Path to the resources. Where the textures and shaders are located. |
[in] | windowWidth | The width of the window (in pixles) that the text is being used in. |
[in] | windowHeight | The height of the window (in pixles) that the text is being used in. |
Member Function Documentation
void MaliSDK::Text::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.
- Parameters:
-
[in] | xPosition | The X position (in pixels) to start drawing the text. Measured from the left of the screen. |
[in] | yPosition | The Y position (in pixels) to start drawing the text. Measured from the bottom of the screen. |
[in] | string | The string to be rendered on the screen. |
[in] | red | The red component of the text colour (accepts values 0-255). |
[in] | green | The green component of the text colour (accepts values 0-255). |
[in] | blue | The blue component of the text colour (accepts values 0-255). |
[in] | alpha | The alpha component of the text colour (accepts values 0-255). Affects the transparency of the text. |
void MaliSDK::Text::clear |
( |
void |
| ) |
|
Removes the current string from the class.
Should be called before adding a new string to render using addString().
void MaliSDK::Text::draw |
( |
void |
| ) |
|
Draw the text to the screen.
Should be called each time through the render loop so that the text is drawn every frame.
Member Data Documentation
const float MaliSDK::Text::scale = 1.0f |
|
staticprivate |
Scaling factor to use when rendering the text.
- Warning:
- Experimental: allows drawing characters bigger than the texture was. Range 0.75-3.0 seems to work reasonably.
const int MaliSDK::Text::textureCharacterHeight = 16 |
|
static |
The height (in pixels) of the characters in the text texture.
- Warning:
- Change only if the text texture is changed and the height of the characters is different.
const int MaliSDK::Text::textureCharacterWidth = 8 |
|
static |
The width (in pixels) of the characters in the text texture.
- Warning:
- Change only if the text texture is changed and the width of the characters is different.
The documentation for this class was generated from the following files:
- simple-framework/inc/Text.h
- simple-framework/src/Text.cpp