Level H Engine
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Sprite Class Reference

Creates a Sprite for use with 2D. More...

#include <Sprite.h>

Collaboration diagram for Sprite:
Collaboration graph

Public Member Functions

 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 scaled. More...
 
 Sprite (SDL_Surface *inSurfaceData)
 Constructs the Sprite using a surface. More...
 
 Sprite (SDL_Colour colour)
 Constructs the Sprite using an RGB value. This will create a 1x1 rectangle of that colour that can be scaled. More...
 
 Sprite (std::string fileLocation)
 Constructs the Sprite using an image location and a renderer. This is for use with SDL image. More...
 
 Sprite (std::string fileLocation, bool magentaAlpha)
 Constructs the Sprite using an image location and a renderer. The magenta pixels of this image can represent alpha if needed. More...
 
 ~Sprite ()
 Destructs Sprite. More...
 
SDL_Surface * getSurface ()
 Gets a pointer to the Sprite surface. More...
 
Vec2 getDimensions ()
 Gets the Sprite dimensions. More...
 
void pushToScreen (Vec2 pos)
 Pushes the image to the Renderer at the XY Coordinates. More...
 
void scaleSprite (Vec2 scale)
 Scale the image to the dimensions inputed. More...
 

Private Member Functions

void initaliseVBO (Vec2 pos, Vec2 scale)
 A function to initalise a VBO for the sprite. More...
 
void initialiseTexture ()
 A function to initalise a texture. More...
 
void draw (Vec2 pos)
 A function to draw to a position on the screen. More...
 

Private Attributes

SDL_Surface * surfaceData
 The Surface data. More...
 
Vec2 dimensions
 The Texture dimensions. More...
 
GLuint obj
 The VBO for the rectangle. More...
 
GLuint textureID
 The Texture. More...
 
std::string shaderID
 The Shader ID. More...
 

Detailed Description

Creates a Sprite for use with 2D.

Constructor & Destructor Documentation

◆ Sprite() [1/5]

Sprite::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 scaled.

Parameters
rThe red value.
gThe green value.
bThe blue value.
Here is the call graph for this function:

◆ Sprite() [2/5]

Sprite::Sprite ( SDL_Surface *  inSurfaceData)

Constructs the Sprite using a surface.

Here is the call graph for this function:

◆ Sprite() [3/5]

Sprite::Sprite ( SDL_Colour  colour)

Constructs the Sprite using an RGB value. This will create a 1x1 rectangle of that colour that can be scaled.

Parameters
colourThe colour value.
Here is the call graph for this function:

◆ Sprite() [4/5]

Sprite::Sprite ( std::string  fileLocation)

Constructs the Sprite using an image location and a renderer. This is for use with SDL image.

Parameters
fileLocationThe location of the image file.
Here is the call graph for this function:

◆ Sprite() [5/5]

Sprite::Sprite ( std::string  fileLocation,
bool  magentaAlpha 
)

Constructs the Sprite using an image location and a renderer. The magenta pixels of this image can represent alpha if needed.

Parameters
fileLocationThe location of the image file.
magentaAlphaIf true any magenta pixels in the image will be converted to alpha.
Here is the call graph for this function:

◆ ~Sprite()

Sprite::~Sprite ( )

Destructs Sprite.

Member Function Documentation

◆ draw()

void Sprite::draw ( Vec2  pos)
private

A function to draw to a position on the screen.

Parameters
posThe position of the image.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDimensions()

Vec2 Sprite::getDimensions ( )

Gets the Sprite dimensions.

Returns
The Sprite dimensions.
Here is the caller graph for this function:

◆ getSurface()

SDL_Surface * Sprite::getSurface ( )

Gets a pointer to the Sprite surface.

Returns
A pointer to the Sprite surface.

◆ initaliseVBO()

void Sprite::initaliseVBO ( Vec2  pos,
Vec2  scale 
)
private

A function to initalise a VBO for the sprite.

Parameters
posThe position of the image.
scaleThe dimensions of the image.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialiseTexture()

void Sprite::initialiseTexture ( )
private

A function to initalise a texture.

Here is the caller graph for this function:

◆ pushToScreen()

void Sprite::pushToScreen ( Vec2  pos)

Pushes the image to the Renderer at the XY Coordinates.

Parameters
posThe position of the image.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ scaleSprite()

void Sprite::scaleSprite ( Vec2  scale)

Scale the image to the dimensions inputed.

Parameters
posThe position of the image.
scaleThe dimensions of the image.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ dimensions

Vec2 Sprite::dimensions
private

The Texture dimensions.

◆ obj

GLuint Sprite::obj
private

The VBO for the rectangle.

◆ shaderID

std::string Sprite::shaderID
private

The Shader ID.

◆ surfaceData

SDL_Surface* Sprite::surfaceData
private

The Surface data.

◆ textureID

GLuint Sprite::textureID
private

The Texture.


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