Rune Engine  Version 0.2.7-alpha
Documentation for how to make games using the Rune Engine.
rune::Texture Class Reference

A texture that can be applied to drawable objects. More...

#include <texture.h>

Public Member Functions

 Texture (std::string const &path, unsigned int filerMode=LINEAR_FILTER)
 Default constructor to generate a texture that can be bound and drawn. More...
 
 Texture ()
 Default empty constructor that sets all members to 0.
 
 ~Texture (void)
 Default constructor to clean up a no longer needed texture.
 
bool loadFromFile (std::string const &path, unsigned int filterMode=LINEAR_FILTER)
 Loads in a texture from a file and stores it in the current rune::Texture object. More...
 
void bind (unsigned int slot=0)
 Binds the texture to one of the texture slots on the GPU. More...
 
void unbind ()
 Unbind the texture to free up space.
 
unsigned int getTextureID (void)
 Get the index of the texture ID. More...
 
unsigned int getHeight (void)
 Get the height of the texture. More...
 
unsigned int getWidth (void)
 
unsigned char * getTextureData (void)
 Get the raw texture data in byte form.
 

Detailed Description

A texture that can be applied to drawable objects.

Author
Thomas Montano
Date
April 27 2020

Constructor & Destructor Documentation

◆ Texture()

rune::Texture::Texture ( std::string const &  path,
unsigned int  filterMode = LINEAR_FILTER 
)

Default constructor to generate a texture that can be bound and drawn.

Parameters
pathThe file path for the texture that you would like to load relative to the main executable.
filterModeThe interpolation mode to be used for drawing the sprite.

Member Function Documentation

◆ bind()

void rune::Texture::bind ( unsigned int  slot = 0)

Binds the texture to one of the texture slots on the GPU.

Parameters
slotThe texture slot on the GPU that you would like to bind this texture to.

◆ getHeight()

unsigned int rune::Texture::getHeight ( void  )

Get the height of the texture.

Returns
The total height of the texture.

◆ getTextureID()

unsigned int rune::Texture::getTextureID ( void  )

Get the index of the texture ID.

Returns
The index of the texture in OpenGL.

◆ getWidth()

unsigned int rune::Texture::getWidth ( void  )
Returns
The total width of the texture.

◆ loadFromFile()

bool rune::Texture::loadFromFile ( std::string const &  path,
unsigned int  filterMode = LINEAR_FILTER 
)

Loads in a texture from a file and stores it in the current rune::Texture object.

Parameters
pathThe file path of the texture to be loaded in.
filterModeThe filter mode to be used for drawing. Set this to NEAREST_FILTER if using pixel art.
Returns
Whether or not the file was able to be successfully loaded.
Warning
This function is expecting you to load a .png file. If you load anything else it will load incorrectly.

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