GameKit  0.0.1a
C++ gamedev tools
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
gk::Texture Class Reference

Image living on the graphics card that can be used for drawing. More...

#include <Texture.hpp>

Inheritance diagram for gk::Texture:
gk::NonCopyable gk::Tileset

Public Member Functions

 Texture ()=default
 Default constructor. More...
 
 Texture (const std::string &filename)
 Load the texture from a file on the disk. More...
 
 Texture (SDL_Surface *surface)
 Load the texture from a SDL_Surface. More...
 
 Texture (Texture &&texture)
 Move constructor. More...
 
 ~Texture () noexcept
 Destructor. More...
 
Textureoperator= (Texture &&texture)
 Move assignement operator. More...
 
void loadFromFile (const std::string &filename)
 Load the texture from a file on the disk. More...
 
void loadFromSurface (SDL_Surface *surface)
 Load the texture from a SDL_Surface. More...
 
const std::string & filename () const
 Return the filename of the texture. More...
 
u16 width () const
 Return the width of the texture. More...
 
u16 height () const
 Return the height of the texture. More...
 

Static Public Member Functions

static void bind (const Texture *texture)
 Bind a texture for rendering. More...
 

Private Attributes

std::string m_filename
 Texture filename. More...
 
u16 m_width
 Width of the texture. More...
 
u16 m_height
 Height of the texture. More...
 
GLuint m_texture = 0
 Internal OpenGL texture ID. More...
 

Additional Inherited Members

- Protected Member Functions inherited from gk::NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
const NonCopyableoperator= (const NonCopyable &)=delete
 

Detailed Description

Image living on the graphics card that can be used for drawing.

gk::Texture is an overlay to OpenGL texture system.

See also
gk::Image, gk::Sprite

Definition at line 30 of file Texture.hpp.

Constructor & Destructor Documentation

§ Texture() [1/4]

gk::Texture::Texture ( )
default

Default constructor.

Creates an empty texture.

§ Texture() [2/4]

gk::Texture::Texture ( const std::string &  filename)

Load the texture from a file on the disk.

Parameters
filenameRelative or absolute path to the file

Definition at line 20 of file Texture.cpp.

§ Texture() [3/4]

gk::Texture::Texture ( SDL_Surface *  surface)

Load the texture from a SDL_Surface.

Parameters
surfacePointer to the surface where the data is stored

Definition at line 24 of file Texture.cpp.

§ Texture() [4/4]

gk::Texture::Texture ( Texture &&  texture)

Move constructor.

Parameters
textureinstance to move

Definition at line 28 of file Texture.cpp.

§ ~Texture()

gk::Texture::~Texture ( )
noexcept

Destructor.

Definition at line 38 of file Texture.cpp.

Member Function Documentation

§ bind()

void gk::Texture::bind ( const Texture texture)
static

Bind a texture for rendering.

Parameters
texturePointer to the texture to bind, can be null to use no texture

Definition at line 94 of file Texture.cpp.

§ filename()

const std::string& gk::Texture::filename ( ) const
inline

Return the filename of the texture.

Returns
Texture filename

Definition at line 108 of file Texture.hpp.

§ height()

u16 gk::Texture::height ( ) const
inline

Return the height of the texture.

Returns
Height in pixels

Definition at line 124 of file Texture.hpp.

§ loadFromFile()

void gk::Texture::loadFromFile ( const std::string &  filename)

Load the texture from a file on the disk.

Parameters
filenameRelative or absolute path to the file

Definition at line 54 of file Texture.cpp.

§ loadFromSurface()

void gk::Texture::loadFromSurface ( SDL_Surface *  surface)

Load the texture from a SDL_Surface.

Parameters
surfacePointer to the surface where the data is stored

Definition at line 67 of file Texture.cpp.

§ operator=()

Texture & gk::Texture::operator= ( Texture &&  texture)

Move assignement operator.

Parameters
textureinstance to move

Definition at line 42 of file Texture.cpp.

§ width()

u16 gk::Texture::width ( ) const
inline

Return the width of the texture.

Returns
Width in pixels

Definition at line 116 of file Texture.hpp.

Member Data Documentation

§ m_filename

std::string gk::Texture::m_filename
private

Texture filename.

Definition at line 130 of file Texture.hpp.

§ m_height

u16 gk::Texture::m_height
private

Height of the texture.

Definition at line 133 of file Texture.hpp.

§ m_texture

GLuint gk::Texture::m_texture = 0
private

Internal OpenGL texture ID.

Definition at line 135 of file Texture.hpp.

§ m_width

u16 gk::Texture::m_width
private

Width of the texture.

Definition at line 132 of file Texture.hpp.


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