mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 08:35:20 +02:00
IrrlichtMt: Implement mip-mapping for RTTs (#16434)
This can be helpful to draw fonts memory-efficiently at varying scales. Adds ETCF_CREATE_RTT_MIP_MAPS to generate mip-maps on request.
This commit is contained in:
@@ -2614,10 +2614,6 @@ ITexture *COpenGLDriver::addRenderTargetTextureMs(const core::dimension2d<u32> &
|
||||
if (IImage::isCompressedFormat(format))
|
||||
return 0;
|
||||
|
||||
// disable mip-mapping
|
||||
bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS);
|
||||
setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false);
|
||||
|
||||
bool supportForFBO = (Feature.ColorAttachment > 0);
|
||||
|
||||
core::dimension2du destSize(size);
|
||||
@@ -2631,9 +2627,6 @@ ITexture *COpenGLDriver::addRenderTargetTextureMs(const core::dimension2d<u32> &
|
||||
addTexture(renderTargetTexture);
|
||||
renderTargetTexture->drop();
|
||||
|
||||
// restore mip-mapping
|
||||
setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, generateMipLevels);
|
||||
|
||||
return renderTargetTexture;
|
||||
}
|
||||
|
||||
@@ -2643,10 +2636,6 @@ ITexture *COpenGLDriver::addRenderTargetTextureCubemap(const u32 sideLen, const
|
||||
if (IImage::isCompressedFormat(format))
|
||||
return 0;
|
||||
|
||||
// disable mip-mapping
|
||||
bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS);
|
||||
setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false);
|
||||
|
||||
bool supportForFBO = (Feature.ColorAttachment > 0);
|
||||
|
||||
const core::dimension2d<u32> size(sideLen, sideLen);
|
||||
@@ -2661,9 +2650,6 @@ ITexture *COpenGLDriver::addRenderTargetTextureCubemap(const u32 sideLen, const
|
||||
addTexture(renderTargetTexture);
|
||||
renderTargetTexture->drop();
|
||||
|
||||
// restore mip-mapping
|
||||
setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, generateMipLevels);
|
||||
|
||||
return renderTargetTexture;
|
||||
}
|
||||
|
||||
@@ -2682,6 +2668,13 @@ bool COpenGLDriver::setRenderTargetEx(IRenderTarget *target, u16 clearFlag, SCol
|
||||
return false;
|
||||
}
|
||||
|
||||
if (CurrentRenderTarget) {
|
||||
// Update mip-map of the generated texture, if enabled.
|
||||
auto textures = CurrentRenderTarget->getTexture();
|
||||
for (size_t i = 0; i < textures.size(); ++i)
|
||||
textures[i]->regenerateMipMapLevels();
|
||||
}
|
||||
|
||||
bool supportForFBO = (Feature.ColorAttachment > 0);
|
||||
|
||||
core::dimension2d<u32> destRenderTargetSize(0, 0);
|
||||
|
Reference in New Issue
Block a user