raylibstarter 0.1.0
game::core::Texture2D Class Referencefinal

The class Texture2D encapsulates the Raylib structure Texture2D and takes care of the correct loading and unloading of the texture into the VRAM. More...

#include <texture2d.h>

Collaboration diagram for game::core::Texture2D:

Public Member Functions

 Texture2D ()=delete
 
 Texture2D (const char *filename)
 Constructor. More...
 
 Texture2D (const game::core::Texture2D &texture)=delete
 
Texture2Doperator= (const Texture2D &)=delete
 
 ~Texture2D ()
 Destructor. More...
 
const ::Texture2Dtexture () const
 
const int & width () const
 
const int & height () const
 

Private Attributes

::Texture2D texture_ = { }
 Raylib Texture2D structure which contains width, height and the ID of the associated VRAM texture. More...
 

Detailed Description

The class Texture2D encapsulates the Raylib structure Texture2D and takes care of the correct loading and unloading of the texture into the VRAM.

Note
A Raylib Texture2D structure contains width and height information as well as the ID of the associated graphics texture in VRAM. Copy and assignment operators of this class are therefore deleted, since a copy of an object of this class should correctly also mean a copy of the VRAM texture, which is not normally wanted. Of course, it still makes sense to use one texture for several use cases (e.g. two sprite objects that use the same texture) and to keep it in VRAM only once. The Texture2D class should therefore preferably be used with smart pointers. With the last release of the object, the texture is then unloaded from the VRAM via the destructor.

Definition at line 16 of file texture2d.h.

Constructor & Destructor Documentation

◆ Texture2D() [1/3]

game::core::Texture2D::Texture2D ( )
delete

◆ Texture2D() [2/3]

game::core::Texture2D::Texture2D ( const char *  filename)
explicit

Constructor.

Creates a new Texture2D object and loads the image file specified as parameter as texture into the VRAM.

Parameters
filenameFile name of the image file to load. All Raylib compatible file types are supported.

Definition at line 5 of file texture2d.cpp.

◆ Texture2D() [3/3]

game::core::Texture2D::Texture2D ( const game::core::Texture2D texture)
delete

◆ ~Texture2D()

game::core::Texture2D::~Texture2D ( )

Destructor.

Defines if the mouse support should be activated

Definition at line 10 of file texture2d.cpp.

Member Function Documentation

◆ height()

const int & game::core::Texture2D::height ( ) const
Returns
The height of the associated texture.

Definition at line 23 of file texture2d.cpp.

◆ operator=()

Texture2D & game::core::Texture2D::operator= ( const Texture2D )
delete

◆ texture()

const ::Texture2D & game::core::Texture2D::texture ( ) const
Returns
A reference to the embedded Raylib Texture2D structure.

Definition at line 15 of file texture2d.cpp.

◆ width()

const int & game::core::Texture2D::width ( ) const
Returns
The width of the associated texture.

Definition at line 19 of file texture2d.cpp.

Member Data Documentation

◆ texture_

::Texture2D game::core::Texture2D::texture_ = { }
private

Raylib Texture2D structure which contains width, height and the ID of the associated VRAM texture.

Definition at line 54 of file texture2d.h.


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