From 50f4bdecbe754c2a91b0bc3fba95f4b13aff0c34 Mon Sep 17 00:00:00 2001 From: cutealien Date: Mon, 6 Jan 2020 14:05:26 +0000 Subject: [PATCH] No longer try creating rtt's for compressed image formats Those are not supported by any graphic card and we just end up with invalid textures. Returning 0 now instead in addRenderTargetTexture for OpenGL and D3D9. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6047 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/CD3D9Driver.cpp | 6 ++++++ source/Irrlicht/COpenGLDriver.cpp | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/source/Irrlicht/CD3D9Driver.cpp b/source/Irrlicht/CD3D9Driver.cpp index c376ac8d..7189a7d5 100644 --- a/source/Irrlicht/CD3D9Driver.cpp +++ b/source/Irrlicht/CD3D9Driver.cpp @@ -3269,6 +3269,9 @@ ITexture* CD3D9Driver::addRenderTargetTexture(const core::dimension2d& size const io::path& name, const ECOLOR_FORMAT format) { + if ( IImage::isCompressedFormat(format) ) + return 0; + CD3D9Texture* tex = new CD3D9Texture(this, size, name, ETT_2D, format); if (tex) { @@ -3287,6 +3290,9 @@ ITexture* CD3D9Driver::addRenderTargetTexture(const core::dimension2d& size ITexture* CD3D9Driver::addRenderTargetTextureCubemap(const irr::u32 sideLen, const io::path& name, const ECOLOR_FORMAT format) { + if ( IImage::isCompressedFormat(format) ) + return 0; + CD3D9Texture* tex = new CD3D9Texture(this, core::dimension2d(sideLen, sideLen), name, ETT_CUBEMAP, format); if (tex) { diff --git a/source/Irrlicht/COpenGLDriver.cpp b/source/Irrlicht/COpenGLDriver.cpp index c7e183ee..b4b63c6e 100644 --- a/source/Irrlicht/COpenGLDriver.cpp +++ b/source/Irrlicht/COpenGLDriver.cpp @@ -3769,6 +3769,9 @@ IVideoDriver* COpenGLDriver::getVideoDriver() ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d& size, const io::path& name, const ECOLOR_FORMAT format) { + if ( IImage::isCompressedFormat(format) ) + return 0; + //disable mip-mapping bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS); setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false); @@ -3796,6 +3799,9 @@ ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d& si //! Creates a render target texture for a cubemap ITexture* COpenGLDriver::addRenderTargetTextureCubemap(const irr::u32 sideLen, const io::path& name, const ECOLOR_FORMAT format) { + if ( IImage::isCompressedFormat(format) ) + return 0; + //disable mip-mapping bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS); setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false); @@ -4227,10 +4233,13 @@ bool COpenGLDriver::getColorFormatParameters(ECOLOR_FORMAT format, GLint& intern pixelType = GL_UNSIGNED_INT_8_8_8_8_REV; break; case ECF_DXT1: - supported = true; - internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - pixelFormat = GL_BGRA_EXT; - pixelType = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + if (queryOpenGLFeature(COpenGLExtensionHandler::IRR_EXT_texture_compression_s3tc)) + { + supported = true; + internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + pixelFormat = GL_BGRA_EXT; + pixelType = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + } break; case ECF_DXT2: case ECF_DXT3: