diff --git a/include/IRenderTarget.h b/include/IRenderTarget.h index 7850e0ac..3845c2d6 100644 --- a/include/IRenderTarget.h +++ b/include/IRenderTarget.h @@ -25,6 +25,18 @@ namespace video { } + //! Returns an array of previously set textures. + const core::array& getTexture() const + { + return Texture; + } + + //! Returns a of previously set depth / depth-stencil texture. + ITexture* getDepthStencil() const + { + return DepthStencil; + } + //! Set multiple textures. /** Set multiple textures for the render target. \param texture Array of texture objects. These textures are used for a color outputs. diff --git a/source/Irrlicht/COpenGLDriver.cpp b/source/Irrlicht/COpenGLDriver.cpp index 60696827..7a7f456f 100644 --- a/source/Irrlicht/COpenGLDriver.cpp +++ b/source/Irrlicht/COpenGLDriver.cpp @@ -3636,11 +3636,7 @@ ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d& si bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS); setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false); - bool supportForFBO = false; - -#if defined(GL_VERSION_3_0) || defined(GL_ARB_framebuffer_object) || defined(GL_EXT_framebuffer_object) - supportForFBO = FeatureAvailable[IRR_EXT_framebuffer_object] || FeatureAvailable[IRR_ARB_framebuffer_object]; -#endif + bool supportForFBO = (Feature.ColorAttachment > 0); core::dimension2du destSize(size); @@ -3650,7 +3646,7 @@ ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d& si destSize = destSize.getOptimalSize((size == size.getOptimalSize()), false, false); } - COpenGLTexture* renderTargetTexture = new COpenGLTexture(name, size, format, this); + COpenGLTexture* renderTargetTexture = new COpenGLTexture(name, destSize, format, this); addTexture(renderTargetTexture); renderTargetTexture->drop(); @@ -4078,14 +4074,23 @@ void COpenGLDriver::getColorFormatParameters(ECOLOR_FORMAT format, GLint& intern case ECF_D16: internalFormat = GL_DEPTH_COMPONENT16; pixelFormat = GL_DEPTH_COMPONENT; - pixelType = GL_UNSIGNED_BYTE; + pixelType = GL_UNSIGNED_SHORT; break; case ECF_D32: internalFormat = GL_DEPTH_COMPONENT32; pixelFormat = GL_DEPTH_COMPONENT; - pixelType = GL_UNSIGNED_BYTE; + pixelType = GL_UNSIGNED_INT; break; case ECF_D24S8: +#ifdef GL_VERSION_3_0 + if (Version >= 300) + { + internalFormat = GL_DEPTH_STENCIL; + pixelFormat = GL_DEPTH_STENCIL; + pixelType = GL_UNSIGNED_INT_24_8; + } + else +#endif #ifdef GL_EXT_packed_depth_stencil if (queryOpenGLFeature(COpenGLExtensionHandler::IRR_EXT_packed_depth_stencil)) {