This generates a new texture using the image file \c filename (see texture.h for a list of supported formats).
After the file has been loaded (using #loadImage()), this constructor generates an OpenGL texture object and assigns priority 1.0 to it.
The object can bee used instantly (via #Texture::texName).
\warning In most cases it is better not generate textures directly but to obtain them via #TextureHandler::getTexture(). This prevents multiple loading of the same image file (=the same texture).
\param filename the name of the image file
*/
Texture::Texture(const char* filename){
this->filename = findImageFile(filename);
image=NULL;
width=0;
height=0;
texName=0;
texType=0;
priority=1.0;
hasAlpha=false;
if(this->filename!=NULL){
image = ImageLoader::loadImage(this->filename); // fill the image_t struct
error("(in Texture::Texture()): Internal format unknown: '%s'. Texture not registered.\n\n", this->filename);
freeImage();
}
}
}
/*!
This generates a new texture using the image file \c filename and assigns the OpenGL priority \c priority to it. The priority becomes important when OpenGL has to decide whether or not to put a texture resident into the graphics card memory; so often used textures should have a high priority and seldomly used textures (like backgrounds) should have a low priority.
The object can bee used instantly (via #Texture::texName).
\warning In most cases it is better not generate textures directly but to obtain them via #TextureHandler::getTexture(). This prevents multiple loading of the same image file (=the same texture) and saves graphics memory.
\param filename the name of the image file
\param priority the priority of the texture (0.0 to 1.0)
This member function reloads a texture and assigns a new OpenGL texture object name to it. This is useful after the texture object has been destroyed or the OpenGL-context was lost. In FWP, for example, this is called during every change of resolutions.
*/
void Texture::reload(){
if(filename==NULL){ // texture was generated from an image_s struct
This member function generates the OpenGL texture object (#texName) that is used to bind the texture, etc.
It automatically generates mipmaps and sets some OpenGL texture object attributes like \c GLTEXTURE_WRAP and \c GL_TEXTURE_FILTER, too.
Wrapping is set to repeat and the texture filters are set according to #RendererInfo::var.textureMinFilter or #RendererInfo::var.textureMinFilter respectively.
Of course these values can be changed later with the OpenGL functions.
\bug mipmap generation doesn't work for some (uneven) sizes under linux