Level H Engine
Sprite.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <SDL.h>
4 #include <string>
5 #include "GL/glew.h"
6 #include "../Maths/Vec2.h"
7 
11 class Sprite
12 {
13 public:
20  Sprite(int r, int g, int b);
21 
25  Sprite(SDL_Surface* inSurfaceData);
26 
31  Sprite(SDL_Colour colour);
32 
37  Sprite(std::string fileLocation);
38 
44  Sprite(std::string fileLocation, bool magentaAlpha);
45 
49  ~Sprite();
50 
55  SDL_Surface* getSurface();
56 
62 
67  void pushToScreen(Vec2 pos);
68 
74  void scaleSprite(Vec2 scale);
75 
76 private:
78  SDL_Surface* surfaceData;
82  GLuint obj;
84  GLuint textureID;
86  std::string shaderID;
87 
93  void initaliseVBO(Vec2 pos, Vec2 scale);
94 
98  void initialiseTexture();
99 
104  void draw(Vec2 pos);
105 };
Vec2 getDimensions()
Gets the Sprite dimensions.
Definition: Sprite.cpp:140
GLuint obj
The VBO for the rectangle.
Definition: Sprite.h:82
~Sprite()
Destructs Sprite.
Definition: Sprite.cpp:126
Contains the Vec2 structure with functions and overloaded operators.
Definition: Vec2.h:8
void pushToScreen(Vec2 pos)
Pushes the image to the Renderer at the XY Coordinates.
Definition: Sprite.cpp:145
std::string shaderID
The Shader ID.
Definition: Sprite.h:86
void draw(Vec2 pos)
A function to draw to a position on the screen.
Definition: Sprite.cpp:278
Creates a Sprite for use with 2D.
Definition: Sprite.h:11
void initialiseTexture()
A function to initalise a texture.
Definition: Sprite.cpp:219
SDL_Surface * surfaceData
The Surface data.
Definition: Sprite.h:78
Sprite(int r, int g, int b)
Constructs the Sprite using an RGB value. This will create a 1x1 rectangle of that colour that can be...
Definition: Sprite.cpp:11
SDL_Surface * getSurface()
Gets a pointer to the Sprite surface.
Definition: Sprite.cpp:135
GLuint textureID
The Texture.
Definition: Sprite.h:84
void initaliseVBO(Vec2 pos, Vec2 scale)
A function to initalise a VBO for the sprite.
Definition: Sprite.cpp:170
Vec2 dimensions
The Texture dimensions.
Definition: Sprite.h:80
void scaleSprite(Vec2 scale)
Scale the image to the dimensions inputed.
Definition: Sprite.cpp:154