V-ART
|
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... | |
Texture & | operator= (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... | |
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.
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.
|
virtual |
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.
|
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.
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.
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.