Jamie Slowgrove - MGP Assignment 2 - JAM
 All Classes Namespaces Files Functions Variables Macros
Text.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <SDL.h>
4 #include <SDL_ttf.h>
5 #include <iostream>
6 #include <string>
7 #include "Vec2.h"
8 
15 class JAM_Text
16 {
17 private:
19  TTF_Font* font;
21  SDL_Color fontColour;
23  SDL_Texture* textureData;
25  SDL_Renderer* renderer;
27  int fontSize;
29  std::string text;
31  std::string fontLocation;
36 
40  void createTextTexture();
41 
42 public:
43 
51  JAM_Text(std::string text, std::string fontLocation, SDL_Renderer* renderer);
52 
61  JAM_Text(std::string text, std::string fontLocation, int fontSize, SDL_Renderer* renderer);
62 
73  JAM_Text(std::string text, std::string fontLocation, SDL_Renderer* renderer, int r, int g, int b);
74 
86  JAM_Text(std::string text, std::string fontLocation, int fontSize, SDL_Renderer* renderer, int r, int g, int b);
87 
91  ~JAM_Text();
92 
98  void pushToScreen(int x, int y);
99 
106  void setColour(int r, int g, int b);
107 
112  void setFontSize(int fontSize);
113 
118  void setFont(std::string fontLocation);
119 
124  void setText(std::string text);
125 
131 };
JAM_Text(std::string text, std::string fontLocation, SDL_Renderer *renderer)
Definition: Text.cpp:6
SDL_Color fontColour
Definition: Text.h:21
SDL_Texture * textureData
Definition: Text.h:23
SDL_Renderer * renderer
Definition: Text.h:25
TTF_Font * font
Definition: Text.h:19
void setFontSize(int fontSize)
Definition: Text.cpp:167
~JAM_Text()
Definition: Text.cpp:106
void createTextTexture()
Definition: Text.cpp:118
void setText(std::string text)
Definition: Text.cpp:194
void setColour(int r, int g, int b)
Definition: Text.cpp:155
int textureWidth
Definition: Text.h:33
std::string fontLocation
Definition: Text.h:31
int fontSize
Definition: Text.h:27
void setFont(std::string fontLocation)
Definition: Text.cpp:182
std::string text
Definition: Text.h:29
JAM_Vec2 getDimensions()
Definition: Text.cpp:206
int textureHeight
Definition: Text.h:35
Creates an Vec2 structure with functions. Creates an Vec2 structure with overloaded operators to crea...
Definition: Vec2.h:9
void pushToScreen(int x, int y)
Definition: Text.cpp:139
Creates a Text Texture for use with a renderer. Creates a Text Texture from an image file...
Definition: Text.h:15