|
35 | 35 | #include <QFuture> |
36 | 36 | #include <QtConcurrent> |
37 | 37 |
|
| 38 | +#ifndef GL_TEXTURE_MAX_ANISOTROPY |
| 39 | +# define GL_TEXTURE_MAX_ANISOTROPY 0x84FE |
| 40 | +#endif |
| 41 | + |
38 | 42 | StelTexture::StelTexture(StelTextureMgr *mgr) : textureMgr(mgr), gl(Q_NULLPTR), networkReply(Q_NULLPTR), loader(Q_NULLPTR), errorOccured(false), alphaChannel(false), id(0), |
39 | 43 | width(-1), height(-1), glSize(0) |
40 | 44 | { |
@@ -411,8 +415,26 @@ bool StelTexture::glLoad(const GLData& data) |
411 | 415 | if (loadParams.generateMipmaps) |
412 | 416 | { |
413 | 417 | gl->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, loadParams.filterMipmaps ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR_MIPMAP_NEAREST); |
| 418 | + |
| 419 | + const auto conf = StelApp::getInstance().getSettings(); |
| 420 | + const GLint desiredAnisotropyLevel = conf->value("video/anisotropic_filtering", 0).toUInt(); |
| 421 | + const auto maxAnisotropy = StelMainView::getInstance().getGLInformation().maxAnisotropy; |
| 422 | + if(maxAnisotropy > 0 && desiredAnisotropyLevel > 0) |
| 423 | + { |
| 424 | + const int anisotropy = std::min(maxAnisotropy, desiredAnisotropyLevel); |
| 425 | + gl->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, anisotropy); |
| 426 | + |
| 427 | + // Assuming maximum possible anisotropy, all mipmaps will require |
| 428 | + // 4× the size of base mip level. Generally anisotropy may be |
| 429 | + // lower, but we prefer to overestimate VRAM consumption than to |
| 430 | + // underestimate it. |
| 431 | + glSize *= 4; |
| 432 | + } |
| 433 | + else |
| 434 | + { |
| 435 | + glSize = glSize + glSize/3; //mipmaps require 1/3 more mem |
| 436 | + } |
414 | 437 | gl->glGenerateMipmap(GL_TEXTURE_2D); |
415 | | - glSize = glSize + glSize/3; //mipmaps require 1/3 more mem |
416 | 438 | } |
417 | 439 |
|
418 | 440 | //register ID with textureMgr and increment size |
|
0 commit comments