///////////////////////////////////////////////////////
| 238 | |
| 239 | //////////////////////////////////////////////////////////// |
| 240 | bool Texture::resize(Vector2u size, bool sRgb) |
| 241 | { |
| 242 | // Check if texture parameters are valid before creating it |
| 243 | if ((size.x == 0) || (size.y == 0)) |
| 244 | { |
| 245 | err() << "Failed to resize texture, invalid size (" << size.x << "x" << size.y << ")" << std::endl; |
| 246 | return false; |
| 247 | } |
| 248 | |
| 249 | const TransientContextLock lock; |
| 250 | |
| 251 | // Make sure that extensions are initialized |
| 252 | priv::ensureExtensionsInit(); |
| 253 | |
| 254 | // Compute the internal texture dimensions depending on NPOT textures support |
| 255 | const Vector2u actualSize(getValidSize(size.x), getValidSize(size.y)); |
| 256 | |
| 257 | // Check the maximum texture size |
| 258 | const unsigned int maxSize = getMaximumSize(); |
| 259 | if ((actualSize.x > maxSize) || (actualSize.y > maxSize)) |
| 260 | { |
| 261 | err() << "Failed to create texture, its internal size is too high " |
| 262 | << "(" << actualSize.x << "x" << actualSize.y << ", " |
| 263 | << "maximum is " << maxSize << "x" << maxSize << ")" << std::endl; |
| 264 | return false; |
| 265 | } |
| 266 | |
| 267 | // All the validity checks passed, we can store the new texture settings |
| 268 | m_size = size; |
| 269 | m_actualSize = actualSize; |
| 270 | m_pixelsFlipped = false; |
| 271 | m_fboAttachment = false; |
| 272 | |
| 273 | // Create the OpenGL texture if it doesn't exist yet |
| 274 | if (!m_texture) |
| 275 | { |
| 276 | GLuint texture = 0; |
| 277 | glCheck(glGenTextures(1, &texture)); |
| 278 | m_texture = texture; |
| 279 | } |
| 280 | |
| 281 | // Make sure that the current texture binding will be preserved |
| 282 | const priv::TextureSaver save; |
| 283 | |
| 284 | static const bool textureEdgeClamp = GLEXT_texture_edge_clamp || GLEXT_GL_VERSION_1_2 || |
| 285 | Context::isExtensionAvailable("GL_EXT_texture_edge_clamp"); |
| 286 | |
| 287 | if (!textureEdgeClamp) |
| 288 | { |
| 289 | static bool warned = false; |
| 290 | |
| 291 | if (!warned) |
| 292 | { |
| 293 | err() << "OpenGL extension SGIS_texture_edge_clamp unavailable" << '\n' |
| 294 | << "Artifacts may occur along texture edges" << '\n' |
| 295 | << "Ensure that hardware acceleration is enabled if available" << std::endl; |
| 296 | |
| 297 | warned = true; |
nothing calls this directly
no test coverage detected