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

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

#include <Texture.h>

Collaboration diagram for JAM_Texture:
Collaboration graph

Public Member Functions

 JAM_Texture (SDL_Renderer *renderer, int r, int g, int b)
 
 JAM_Texture (std::string fileLocation, SDL_Renderer *renderer)
 
 JAM_Texture (std::string fileLocation, SDL_Renderer *renderer, bool magentaAlpha)
 
 ~JAM_Texture ()
 
SDL_Texture * getTexture ()
 
int getWidth ()
 
int getHeight ()
 
void pushToScreen (SDL_Renderer *renderer, int x, int y)
 
void pushToScreen (SDL_Renderer *renderer, int x, int y, int width, int height)
 
void pushSpriteToScreen (SDL_Renderer *renderer, int x, int y, int srcX, int srcY, int srcWidth, int srcHeight)
 
void pushSpriteToScreen (SDL_Renderer *renderer, int x, int y, int srcX, int srcY, int srcWidth, int srcHeight, int width, int height)
 

Private Attributes

SDL_Texture * textureData
 
int textureWidth
 
int textureHeight
 

Detailed Description

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

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

Constructor & Destructor Documentation

JAM_Texture::JAM_Texture ( SDL_Renderer *  renderer,
int  r,
int  g,
int  b 
)

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

Parameters
rendererA pointer to the renderer.
rThe red value.
gThe green value.
bThe blue value.
JAM_Texture::JAM_Texture ( std::string  fileLocation,
SDL_Renderer *  renderer 
)

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

Parameters
fileLocationThe location of the image file.
rendererThe renderer.
JAM_Texture::JAM_Texture ( std::string  fileLocation,
SDL_Renderer *  renderer,
bool  magentaAlpha 
)

Constructs the Texture. Creates a Texture 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.
rendererThe renderer.
magentaAlphaIf true any magenta pixels in the image will be converted to alpha.
JAM_Texture::~JAM_Texture ( )

Destructs the Texture deleting the Texture from memory.

Member Function Documentation

int JAM_Texture::getHeight ( )

Getter # Returns textureHeight.

Returns
The value of textureHeight.
SDL_Texture * JAM_Texture::getTexture ( )

Getter # Returns a pointer to the Texture.

Returns
A pointer to the Texture data.
int JAM_Texture::getWidth ( )

Getter # Returns textureWidth.

Returns
The value of textureWidth.
void JAM_Texture::pushSpriteToScreen ( SDL_Renderer *  renderer,
int  x,
int  y,
int  srcX,
int  srcY,
int  srcWidth,
int  srcHeight 
)

Pushes the image to the Renderer, to the XY Coordinates. Only displays the source rectangle inputed.

Parameters
rendererThe renderer.
xThe x coordinate of the image.
yThe y coordinate of the image.
srcXThe x coordinate of the source image.
srcYThe y coordinate of the source image.
widthThe width of the source image.
heightThe height of the source image.
void JAM_Texture::pushSpriteToScreen ( SDL_Renderer *  renderer,
int  x,
int  y,
int  srcX,
int  srcY,
int  srcWidth,
int  srcHeight,
int  width,
int  height 
)

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

Parameters
rendererThe renderer.
xThe x coordinate of the image.
yThe y coordinate of the image.
srcXThe x coordinate of the source image.
srcYThe y coordinate of the source image.
srcWidthThe width of the source image.
srcHeightThe height of the source image.
widthThe width of the scaled image.
heightThe height of the scaled image.
void JAM_Texture::pushToScreen ( SDL_Renderer *  renderer,
int  x,
int  y 
)

Pushes the image to the Renderer, to the XY Coordinates.

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

Here is the caller graph for this function:

void JAM_Texture::pushToScreen ( SDL_Renderer *  renderer,
int  x,
int  y,
int  width,
int  height 
)

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

Parameters
rendererThe renderer.
xThe x coordinate of the image.
yThe y coordinate of the image.
widthThe width of the scaled image.
heightThe height of the scaled image.

Member Data Documentation

SDL_Texture* JAM_Texture::textureData
private

The Texture data.

int JAM_Texture::textureHeight
private

The height of the Texture.

int JAM_Texture::textureWidth
private

The width of the Texture.


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