34 #include <boost/make_shared.hpp> 63 glDeleteTextures(1, &ids[0]);
68 image_cache_(image_cache)
82 texture = *texture_ptr;
92 failed = image->Failed();
99 QImage qimage = *image_ptr;
102 uint32_t
check = 9999999;
105 glGenTextures(1, &ids[0]);
111 GLenum err = glGetError();
112 const GLubyte *errString = gluErrorString(err);
113 ROS_ERROR(
"GL ERROR(%u): %s", err, errString);
117 texture_ptr =
new TexturePtr(boost::make_shared<Texture>(ids[0], url_hash));
118 texture = *texture_ptr;
120 float max_dim = std::max(qimage.width(), qimage.height());
122 std::pow(2, std::ceil(std::log(max_dim) / std::log(2.0
f))));
124 if (qimage.width() != dimension || qimage.height() != dimension)
126 qimage = qimage.scaled(dimension, dimension, Qt::IgnoreAspectRatio, Qt::FastTransformation);
129 glBindTexture(GL_TEXTURE_2D, texture->id);
139 QGLWidget::convertToGLFormat(qimage).bits());
141 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
142 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
144 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
145 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
147 cache_.insert(url_hash, texture_ptr);
160 cache_.insert(texture->url_hash, texture_ptr);
TextureCache(ImageCachePtr image_cache, size_t size=512)
void AddTexture(const TexturePtr &texture)
QCache< size_t, TexturePtr > cache_
Texture(int32_t texture_id, size_t hash)
double Round(double value)
ImageCachePtr image_cache_
boost::shared_ptr< Texture > TexturePtr
TexturePtr GetTexture(size_t url_hash, const QString &url, bool &failed, int priority)