V-ART
Public Member Functions | List of all members
VART::Texture Class Reference

2D image to use as texture. More...

#include <texture.h>

Public Member Functions

 Texture ()
 Creates an unitialized texture. More...
 
 Texture (const std::string &fileName)
 Creates a texture from an image file. More...
 
 Texture (const Texture &texture)
 Creates a copy of an texture. More...
 
Textureoperator= (const Texture &texture)
 Copies texture data. More...
 
bool LoadFromFile (const std::string &fileName)
 Loads a texture from a file. More...
 
bool HasTextureLoad () const
 Indicates if a texture has been loaded previously. More...
 
bool HasData () const
 Indicates if a texture object contains data. More...
 
virtual ~Texture ()
 Destructor class. More...
 
bool DrawOGL () const
 Sets the texture to draw with the next object. More...
 

Detailed Description

2D image to use as texture.

A texture is a 2D image to use as a texture in a polygon surface. According to OpenGL Specification, the width and the height of the image must be an power of 2 (ie.: 256x64, 512x512).

Note that OpenGl requires that texture mapping is enabled before you draw a texture in a scene. V-Art does NOT enable it automaticaly. To enable texture mapping, the programmer should do it in the application's main routine, with code like "glEnable(GL_TEXTURE_2D); glEnableClientState(GL_TEXTURE_COORD_ARRAY);". But be carefully. Use of "glEnableClientState(GL_TEXTURE_COORD_ARRAY)" with a scene that has mesh objects with no texture coordinates can generate errors during calls for OpenGl "glDrawElements" function.

The image types that V-Art suports depends on image reader library, that we use in this implementation of VART::Texture class. At this moment, we used the Developer Image Library (http://openil.sourceforge.net/). According to the Developer Image Library Reference, the supported image types are: .bmp, .cut, .dds, .doom, .gif, .ico, .jpg, .lbm, .mdl, .mng, .pal, .pbm, .pcd, .pcx, .pgm, .pic, .png, .ppm, .psd, .psp, .raw, .sgi, .tga, .tif and .hdr files. Note that to use the Developer Image Library support, you must compile V-Art with IL_LIB symbol.

Definition at line 48 of file texture.h.

Constructor & Destructor Documentation

VART::Texture::Texture ( )

Creates an unitialized texture.

The texture created holds no texture data and, because this, dont generate any side effects on any material that use it.

Definition at line 17 of file texture.cpp.

VART::Texture::Texture ( const std::string &  fileName)

Creates a texture from an image file.

VART::Texture::Texture ( const Texture texture)

Creates a copy of an texture.

Definition at line 33 of file texture.cpp.

VART::Texture::~Texture ( )
virtual

Destructor class.

Deletes all texture data.

Definition at line 123 of file texture.cpp.

Member Function Documentation

bool VART::Texture::DrawOGL ( ) const

Sets the texture to draw with the next object.

Until another call to VART::Texture::DrawOGL, the current texture is used in subsequent drawing of objects.

Definition at line 134 of file texture.cpp.

bool VART::Texture::HasData ( ) const
inline

Indicates if a texture object contains data.

A texture contains data if it has been loaded from an image file using 'VART::Texture::LoadFromFile()' or if the data has been procedurally generated. There are no methods to generate procedural textures yet.

Definition at line 92 of file texture.h.

Referenced by VART::Material::HasTexture(), and VART::MeshObject::ReadMaterialTable().

bool VART::Texture::HasTextureLoad ( ) const

Indicates if a texture has been loaded previously.

Deprecated:
Use HasData instead.

If a texture has been loaded previously with 'VART::Texture::LoadFromFile()' method, returns true. Otherwise, returns false.

Definition at line 38 of file texture.cpp.

bool VART::Texture::LoadFromFile ( const std::string &  fileName)

Loads a texture from a file.

Reads a image file and convert it to a graphic texture.

Returns
True if fileName could be read. False if the file could not be read, or if V-Art was not compiled with OpenGL or an image reader library suport. Note that the supported formats deppends on image reader library used in this implementation. See the Texture class description for more details.

Definition at line 50 of file texture.cpp.

Referenced by VART::MeshObject::ReadMaterialTable().

VART::Texture & VART::Texture::operator= ( const Texture texture)

Copies texture data.

Definition at line 43 of file texture.cpp.


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