Jamie Slowgrove - MGP Assignment 2 - JAM
 All Classes Namespaces Files Functions Variables Macros
Public Member Functions | Private Member Functions | Private Attributes | List of all members
JAM_Text Class Reference

Creates a Text Texture for use with a renderer. Creates a Text Texture from an image file, this can then be used with a renderer. More...

#include <Text.h>

Collaboration diagram for JAM_Text:
Collaboration graph

Public Member Functions

 JAM_Text (std::string text, std::string fontLocation, SDL_Renderer *renderer)
 
 JAM_Text (std::string text, std::string fontLocation, int fontSize, SDL_Renderer *renderer)
 
 JAM_Text (std::string text, std::string fontLocation, SDL_Renderer *renderer, int r, int g, int b)
 
 JAM_Text (std::string text, std::string fontLocation, int fontSize, SDL_Renderer *renderer, int r, int g, int b)
 
 ~JAM_Text ()
 
void pushToScreen (int x, int y)
 
void setColour (int r, int g, int b)
 
void setFontSize (int fontSize)
 
void setFont (std::string fontLocation)
 
void setText (std::string text)
 
JAM_Vec2 getDimensions ()
 

Private Member Functions

void createTextTexture ()
 

Private Attributes

TTF_Font * font
 
SDL_Color fontColour
 
SDL_Texture * textureData
 
SDL_Renderer * renderer
 
int fontSize
 
std::string text
 
std::string fontLocation
 
int textureWidth
 
int textureHeight
 

Detailed Description

Creates a Text Texture for use with a renderer. Creates a Text Texture from an image file, this can then be used with a renderer.

Author
Jamie Slowgrove Reference ~ This is a modified version of my AI Assignment 1 Text class.

Constructor & Destructor Documentation

JAM_Text::JAM_Text ( std::string  text,
std::string  fontLocation,
SDL_Renderer *  renderer 
)

Constructs the Text Texture. Creates a Text Texture using an image location and a renderer. Font size and colour will be default (size 10 and black).

Parameters
textThe text to display.
fontLocationThe location of the font file.
rendererThe renderer.

Here is the call graph for this function:

JAM_Text::JAM_Text ( std::string  text,
std::string  fontLocation,
int  fontSize,
SDL_Renderer *  renderer 
)

Constructs the Text Texture. Creates a Text Texture using an image location and a renderer. Font colour will be default (black). Font size will be set to the input.

Parameters
textThe text to display.
fontLocationThe location of the font file.
fontSizeThe size of the font.
rendererThe renderer.

Here is the call graph for this function:

JAM_Text::JAM_Text ( std::string  text,
std::string  fontLocation,
SDL_Renderer *  renderer,
int  r,
int  g,
int  b 
)

Constructs the Text Texture. Creates a Text Texture using an image location and a renderer. Font size will be default (size 10). Colour will be set to the input.

Parameters
textThe text to display.
fontLocationThe location of the font file.
rendererThe renderer.
rThe value of red. (0-255)
gThe value of green. (0-255)
bThe value of blue. (0-255)

Here is the call graph for this function:

JAM_Text::JAM_Text ( std::string  text,
std::string  fontLocation,
int  fontSize,
SDL_Renderer *  renderer,
int  r,
int  g,
int  b 
)

Constructs the Text Texture. Creates a Text Texture using an image location and a renderer.

Parameters
textThe text to display.
fontLocationThe location of the font file.
fontSizeThe size of the font.
rendererThe renderer.
rThe value of red. (0-255)
gThe value of green. (0-255)
bThe value of blue. (0-255)

Here is the call graph for this function:

JAM_Text::~JAM_Text ( )

Destructs the Text Texture.

Member Function Documentation

void JAM_Text::createTextTexture ( )
private

Creates a Text Texture using the text data.

Here is the caller graph for this function:

JAM_Vec2 JAM_Text::getDimensions ( )

Getter # Gets the dimensions of the Text.

Returns
The dimensions of the Text.

Here is the caller graph for this function:

void JAM_Text::pushToScreen ( int  x,
int  y 
)

Pushes the image to the Renderer, to the XY Coordinates. This is scaled to the width and height inputed.

Parameters
xThe x coordinate of the image.
yThe y coordinate of the image.

Here is the caller graph for this function:

void JAM_Text::setColour ( int  r,
int  g,
int  b 
)

Setter # Sets the colour of the text.

Parameters
rThe value of red. (0-255)
gThe value of green. (0-255)
bThe value of blue. (0-255)

Here is the call graph for this function:

void JAM_Text::setFont ( std::string  fontLocation)

Setter # Sets the font of the text.

Parameters
fontLocationThe location of the font file.

Here is the call graph for this function:

void JAM_Text::setFontSize ( int  fontSize)

Setter # Sets the font size of the text.

Parameters
fontSizeThe font size of the text.

Here is the call graph for this function:

void JAM_Text::setText ( std::string  text)

Setter # Sets the text.

Parameters
textThe text to display.

Here is the call graph for this function:

Member Data Documentation

TTF_Font* JAM_Text::font
private

Font.

SDL_Color JAM_Text::fontColour
private

Font colour.

std::string JAM_Text::fontLocation
private

The font location.

int JAM_Text::fontSize
private

Font size.

SDL_Renderer* JAM_Text::renderer
private

A pointer to the render.

std::string JAM_Text::text
private

The text.

SDL_Texture* JAM_Text::textureData
private

The Texture data.

int JAM_Text::textureHeight
private

The texture height.

int JAM_Text::textureWidth
private

The texture width.


The documentation for this class was generated from the following files: