1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-30 19:22:14 +00: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:
SmallJoker 2025-09-04 18:58:23 +02:00 committed by GitHub
parent e86d2fea8d
commit 024e1d2d27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 43 additions and 44 deletions

View file

@ -266,7 +266,6 @@ bool COpenGL3DriverBase::genericDriverInit(const core::dimension2d<u32> &screenS
GL.ClearDepthf(1.0f);
GL.Hint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
GL.FrontFace(GL_CW);
// create material renderers
@ -1663,26 +1662,15 @@ ITexture *COpenGL3DriverBase::addRenderTargetTexture(const core::dimension2d<u32
ITexture *COpenGL3DriverBase::addRenderTargetTextureMs(const core::dimension2d<u32> &size, u8 msaa,
const io::path &name, const ECOLOR_FORMAT format)
{
// disable mip-mapping
bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS);
setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false);
COpenGL3Texture *renderTargetTexture = new COpenGL3Texture(name, size, msaa > 0 ? ETT_2D_MS : ETT_2D, format, this, msaa);
addTexture(renderTargetTexture);
renderTargetTexture->drop();
// restore mip-mapping
setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, generateMipLevels);
return renderTargetTexture;
}
ITexture *COpenGL3DriverBase::addRenderTargetTextureCubemap(const u32 sideLen, const io::path &name, const ECOLOR_FORMAT format)
{
// 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);
@ -1697,9 +1685,6 @@ ITexture *COpenGL3DriverBase::addRenderTargetTextureCubemap(const u32 sideLen, c
addTexture(renderTargetTexture);
renderTargetTexture->drop();
// restore mip-mapping
setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, generateMipLevels);
return renderTargetTexture;
}
@ -1716,6 +1701,13 @@ bool COpenGL3DriverBase::setRenderTargetEx(IRenderTarget *target, u16 clearFlag,
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();
}
core::dimension2d<u32> destRenderTargetSize(0, 0);
if (target) {