25 #include <OpenGLFramework/Utils/Texture2DPool.hh>
38 map<string, glfTexture2D*>::iterator it = texturePool_.find(name);
39 if (it != texturePool_.end())
45 BIASWARN(
"pool does not contain texture named: " << name);
54 GLenum internalFormat, GLenum minFilter, GLenum magFilter, GLenum wrapS,
55 GLenum wrapT,
int mipmap)
57 map<string, glfTexture2D*>::iterator it = texturePool_.find(name);
58 if (it != texturePool_.end())
60 BIASERR(
"already used pool name : " << name
61 <<
". use clear before reusing the name!");
68 newTexture->
Set(minFilter, magFilter, wrapS, wrapT);
69 newTexture->
Allocate(width, height, internalFormat, mipmap);
76 GLenum minFilter, GLenum magFilter, GLenum wrapS, GLenum wrapT,
77 GLenum internalFormat,
int mipmap)
79 map<string, glfTexture2D*>::iterator it = texturePool_.find(name);
80 if (it != texturePool_.end())
82 BIASERR(
"already used pool name : " << name
83 <<
". use clear before reusing the name!");
90 newTexture->
Set(minFilter, magFilter, wrapS, wrapT);
91 newTexture->
UploadImage(img, internalFormat, mipmap);
100 GLenum minFilter, GLenum magFilter, GLenum wrapS, GLenum wrapT,
int mipmap)
102 map<string, glfTexture2D*>::iterator it = texturePool_.find(name);
103 if (it != texturePool_.end())
105 BIASERR(
"already used pool name : " << name
106 <<
". use clear before reusing the name!");
113 newTexture->
Set(minFilter, magFilter, wrapS, wrapT);
114 newTexture->
Allocate(width, height, storageType, colorModel, mipmap);
120 GLenum minFilter, GLenum magFilter, GLenum wrapS, GLenum wrapT,
121 GLenum internalFormat,
int mipmap)
123 map<string, glfTexture2D*>::iterator it = texturePool_.find(name);
124 if (it != texturePool_.end())
127 textureP->
UploadImage(img, internalFormat, mipmap);
134 textureP->
Set(minFilter, magFilter, wrapS, wrapT, GL_TEXTURE0);
135 textureP->
UploadImage(img, internalFormat, mipmap);
136 texturePool_[name] = textureP;
144 map<string, glfTexture2D*>::iterator it = texturePool_.begin();
145 for (; it != texturePool_.end(); it++)
150 texturePool_.clear();
156 map<string, glfTexture2D*>::iterator it = texturePool_.find(name);
157 if (it != texturePool_.end())
160 texturePool_.erase(it);
EColorModel
These are the most often used color models.
void Allocate(int width, int height, GLenum internalFormat, int mipmap=0)
Creates a texture with undefined content.
void Clear(const std::string &name)
void Create()
Creates the texture but does not upload any data yet.
BIAS::glfTexture2D * operator[](const std::string &name)
Returns NULL if name is not found.
void UploadImage(const BIAS::ImageBase &image, GLenum internalFormat=0, int mipmap=0)
Uploads a BIAS::Image to a mipmap of the texture.
BIAS::glfTexture2D * UploadImage(const std::string &name, const BIAS::ImageBase &img, GLenum minFilter=GL_NEAREST, GLenum magFilter=GL_NEAREST, GLenum wrapS=GL_CLAMP, GLenum wrapT=GL_CLAMP, GLenum internalFormat=0, int mipmap=0)
~Texture2DPool()
Terminates the lifecycle of all textures created in the pool!
void Set(GLenum minFilter=GL_NEAREST, GLenum magFilter=GL_NEAREST, GLenum wrapS=GL_CLAMP, GLenum wrapT=GL_CLAMP, GLint textureNr=GL_TEXTURE0)
Convenience wrapper.
BIAS::glfTexture2D * Create(const std::string &name, int width, int height, GLenum internalFormat, GLenum minFilter=GL_NEAREST, GLenum magFilter=GL_NEAREST, GLenum wrapS=GL_CLAMP, GLenum wrapT=GL_CLAMP, int mipmap=0)
Allocates an empty texture.
This is the base class for images in BIAS.