diff --git a/rts/Rendering/FarTextureHandler.cpp b/rts/Rendering/FarTextureHandler.cpp index c7735fb7f6f..603ea6728a3 100644 --- a/rts/Rendering/FarTextureHandler.cpp +++ b/rts/Rendering/FarTextureHandler.cpp @@ -38,13 +38,16 @@ CFarTextureHandler::CFarTextureHandler() // each FT is rendered from 8 different orientations // such an atlas would only allow 16*16=256 FT's but consume // 16384*16384*4=1024MB when fully allocated, which is not a - // good tradeoff and necessitates limiting iconSize to 64 + // good tradeoff and necessitates limiting iconSize to 64x64 iconSize.x = 32 * 2; iconSize.y = 32 * 2; texSize.x = globalRendering->maxTextureSize; texSize.y = iconSize.y; + createQueue.reserve(MAX_CREATE_QUEUE_SIZE); + renderQueue.reserve(128); + #ifndef HEADLESS if (!fbo.IsValid()) { LOG_L(L_WARNING, "framebuffer not valid!"); @@ -76,7 +79,6 @@ CFarTextureHandler::CFarTextureHandler() CFarTextureHandler::~CFarTextureHandler() { glDeleteTextures(1, &farTextureID); - renderQueue.clear(); } @@ -243,33 +245,30 @@ void CFarTextureHandler::DrawFarTexture(const CSolidObject* obj, CVertexArray* v void CFarTextureHandler::Queue(const CSolidObject* obj) { - renderQueue.push_back(obj); + if (!fbo.IsValid()) + return; - if (HaveFarIcon(obj)) + if (HaveFarIcon(obj)) { + renderQueue.push_back(obj); return; + } + // limit the number of objects batch-processed this frame if (createQueue.size() == MAX_CREATE_QUEUE_SIZE) return; createQueue.push_back(obj); + renderQueue.push_back(obj); } void CFarTextureHandler::Draw() { - if (!fbo.IsValid()) { - renderQueue.clear(); - createQueue.clear(); - return; - } - - { - for (const CSolidObject* obj: createQueue) { - CreateFarTexture(obj); - } + for (const CSolidObject* obj: createQueue) { + CreateFarTexture(obj); } - // render current queued far icons on the screen + // render currently queued far-icons if (!renderQueue.empty()) { const float3 camNorm = ((camera->GetDir() * XZVector) - (UpVector * 0.1f)).ANormalize();