The texture class. More...
#include <VR3Texture.h>
Public Member Functions | |
Constructor | |
VR3Texture (const char *file_name, GLenum tex_type=VR3TEX_2D) | |
Constructor of the class. | |
Destroying Function | |
void | Destroy () |
Pseudo-Destructor for the VR3Texture Class. | |
Activation Function | |
void | Activate (unsigned int unit_id) |
Activates the texture on a specified texture image unit. | |
Get Functions | |
GLenum | GetType () |
Gets the type of the texture. | |
const char * | GetFileName () |
Gets the name of the texture file. | |
Private Member Functions | |
VR3Texture (const VR3Texture &) | |
Disable default copy constructor. | |
VR3Texture & | operator= (const VR3Texture &) |
Disable default assignment operator. | |
Destructor | |
~VR3Texture () | |
Destructor of the class. | |
Private Attributes | |
GLuint | m_tex |
Texture GL name to be used with glBindTexture() | |
std::string | m_texfile |
Texture file name (where the texture was loaded from) | |
GLenum | m_textype |
Texture type (e.g. VR3_TEXTURE_2D) | |
Friends | |
class | VR3Scene |
Friend class VR3Scene to bind the environment maps. | |
class | VR3Mesh |
Friend class VR3Mesh to access the private data members. | |
class | VR3Material |
Friend class VR3Material to access the private data members. | |
class | VR3Background |
Friend class VR3Background to access the private data members. | |
class | VR3TextureManager |
Friend class VR3TextureManager to access the private data members. |
The texture class.
This class allows to have direct access to texture objects, which can be created and handled independently from other visual entities. A texture is loaded from a file, depending on how the collected data is used, different types of textures may be generated. At this time, the supported texture types are:
Definition at line 36 of file VR3Texture.h.
VR3Texture::~VR3Texture | ( | ) | [private] |
Destructor of the class.
Deletes a VR3Texture object. This is a private destructor because a VR3Texture object may only be deleted by the VR3TextureManager static module, this will happen when the number of references to this texture object drops to 0.
VR3Texture::VR3Texture | ( | const VR3Texture & | ) | [private] |
Disable default copy constructor.
VR3Texture::VR3Texture | ( | const char * | file_name, |
GLenum | tex_type = VR3TEX_2D |
||
) |
Constructor of the class.
Creates a new VR3Texture object and initializes the object by loading data from the file specified through file_name. The FreeImage open source library is used to load the image with a vast variety of file types.
[in] | file_name | The name of the file where to load from |
[in] | tex_type | Texture type (e.g. VR3_TEXTURE_2D) |
void VR3Texture::Activate | ( | unsigned int | unit_id ) |
Activates the texture on a specified texture image unit.
This function is to be used when an external user-specified shader is used for rendering. In such case this function is useful to bind a specific texture image on a target on a specific texture image unit. to allow a previously specified sampler to access the texture. This function avoids consuming the reserved texture image units specified above, it will use from GL_TEXTURE6 up. This means that there is no way to receive the shadow maps in user-defined shader. If the user wants to implement a different type of shadow mapping, it is forced to use the VR3FBO. For performance reasons, when using only user-defined shader disabling standard shadow mapping is strongly recommended (this will avoid shadow-maps computation entirely). Note that an error will arise if the specified texture unit is not valid.
[in] | unit_id | The unit_id to bind the texture to (same as written in the sampler) |
void VR3Texture::Destroy | ( | ) |
Pseudo-Destructor for the VR3Texture Class.
When a dynamic instance to the VR3Texture class is not used anymore by the programmer or by a VR3Obj instace, we cannot delete the whole dynamic instance. Other entities may be using the object in dynamic memory and the only thing we must do is call the Destroy() functions in order to notify the VR3TextureManager that a reference to a texture object has been deleted. If the texture is to be destroyed, the VR3TextureManager will handle that.
const char* VR3Texture::GetFileName | ( | ) | [inline] |
Gets the name of the texture file.
This function may be used to retrieve the image file name of a given texture object, this file name is the name of the file the texture was loaded from. The retrieved file name is the absolute path to the file.
Definition at line 163 of file VR3Texture.h.
GLenum VR3Texture::GetType | ( | ) | [inline] |
Gets the type of the texture.
This function may be used to retrieve the texture type given a texture object, the type of the texture cannot be changed and is decided at construction time.
Definition at line 151 of file VR3Texture.h.
VR3Texture& VR3Texture::operator= | ( | const VR3Texture & | ) | [private] |
Disable default assignment operator.
friend class VR3Background [friend] |
Friend class VR3Background to access the private data members.
Definition at line 44 of file VR3Texture.h.
friend class VR3Material [friend] |
Friend class VR3Material to access the private data members.
Definition at line 42 of file VR3Texture.h.
friend class VR3Mesh [friend] |
Friend class VR3Mesh to access the private data members.
Definition at line 40 of file VR3Texture.h.
friend class VR3Scene [friend] |
Friend class VR3Scene to bind the environment maps.
Definition at line 38 of file VR3Texture.h.
friend class VR3TextureManager [friend] |
Friend class VR3TextureManager to access the private data members.
Definition at line 46 of file VR3Texture.h.
GLuint VR3Texture::m_tex [private] |
Texture GL name to be used with glBindTexture()
Definition at line 49 of file VR3Texture.h.
std::string VR3Texture::m_texfile [private] |
Texture file name (where the texture was loaded from)
Definition at line 51 of file VR3Texture.h.
GLenum VR3Texture::m_textype [private] |
Texture type (e.g. VR3_TEXTURE_2D)
Definition at line 53 of file VR3Texture.h.