diff --git a/source/Irrlicht/COGLES2Driver.cpp b/source/Irrlicht/COGLES2Driver.cpp index 11420669..2f2e32e5 100644 --- a/source/Irrlicht/COGLES2Driver.cpp +++ b/source/Irrlicht/COGLES2Driver.cpp @@ -2377,19 +2377,30 @@ namespace video // if driver supports FrameBufferObjects, use them // TODO: Currently broken, so disabled - if (false && queryFeature(EVDF_FRAMEBUFFER_OBJECT)) + if (queryFeature(EVDF_FRAMEBUFFER_OBJECT)) { rtt = new COGLES2FBOTexture(size, name, this, format); if (rtt) { + bool success = false; addTexture(rtt); + ITexture* tex = createDepthTexture(rtt); if (tex) { - static_cast(tex)->attach(rtt); + success = static_cast(tex)->attach(rtt); + if ( !success ) + { + removeDepthTexture(tex); + } tex->drop(); } rtt->drop(); + if (!success) + { + removeTexture(rtt); + rtt=0; + } } } else diff --git a/source/Irrlicht/COGLES2Texture.cpp b/source/Irrlicht/COGLES2Texture.cpp index 2c219cc1..30007619 100644 --- a/source/Irrlicht/COGLES2Texture.cpp +++ b/source/Irrlicht/COGLES2Texture.cpp @@ -264,7 +264,7 @@ namespace video if ( !Image ) Image = new CImage( ECF_A8R8G8B8, ImageSize ); - if ( IsRenderTarget ) + if (mode != ETLM_WRITE_ONLY) { u8* pPixels = static_cast( Image->lock() ); if ( !pPixels ) @@ -277,7 +277,7 @@ namespace video glBindTexture( GL_TEXTURE_2D, TextureName ); // TODO ogl-es - // glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, pPixels); + // glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, pPixels); // opengl images are horizontally flipped, so we have to fix that here. const u32 pitch = Image->getPitch(); @@ -451,33 +451,29 @@ namespace video switch ( col ) { case ECF_A8R8G8B8: -#ifdef GL_OES_rgb8_rgba8 - if ( driver->queryOpenGLFeature( video::COGLES2ExtensionHandler::IRR_OES_rgb8_rgba8 ) ) - InternalFormat = GL_RGBA8_OES; - else -#endif - InternalFormat = GL_RGB5_A1; + InternalFormat = GL_RGB; + PixelFormat = GL_RGBA; + PixelType = GL_UNSIGNED_BYTE; break; case ECF_R8G8B8: -#ifdef GL_OES_rgb8_rgba8 - if ( driver->queryOpenGLFeature( video::COGLES2ExtensionHandler::IRR_OES_rgb8_rgba8 ) ) - InternalFormat = GL_RGB8_OES; - else -#endif - InternalFormat = GL_RGB565; + InternalFormat = GL_RGB; + PixelFormat = GL_RGB; + PixelType = GL_UNSIGNED_BYTE; break; case ECF_A1R5G5B5: - InternalFormat = GL_RGB5_A1; + InternalFormat = GL_RGBA; + PixelFormat = GL_RGBA; + PixelType = GL_UNSIGNED_SHORT_5_5_5_1; break; case ECF_R5G6B5: - InternalFormat = GL_RGB565; + InternalFormat = GL_RGB; + PixelFormat = GL_RGB; + PixelType = GL_UNSIGNED_SHORT_5_6_5; break; default: os::Printer::log( "color format not handled", ELL_WARNING ); break; } - PixelFormat = GL_RGBA; - PixelType = GL_UNSIGNED_BYTE; ImageSize = size; HasMipMaps = false; IsRenderTarget = true; @@ -490,6 +486,7 @@ namespace video glGenTextures( 1, &TextureName ); glBindTexture( GL_TEXTURE_2D, TextureName ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); glTexImage2D( GL_TEXTURE_2D, 0, InternalFormat, ImageSize.Width, @@ -615,10 +612,10 @@ namespace video //! combine depth texture and rtt - void COGLES2FBODepthTexture::attach( ITexture* renderTex ) + bool COGLES2FBODepthTexture::attach(ITexture* renderTex) { if ( !renderTex ) - return; + return false; video::COGLES2FBOTexture* rtt = static_cast( renderTex ); rtt->bindRTT(); if ( UseStencil ) @@ -643,10 +640,14 @@ namespace video } // check the status if ( !checkFBOStatus( Driver ) ) + { os::Printer::log( "FBO incomplete" ); + return false; + } rtt->DepthTexture = this; grab(); // grab the depth buffer, not the RTT rtt->unbindRTT(); + return true; } diff --git a/source/Irrlicht/COGLES2Texture.h b/source/Irrlicht/COGLES2Texture.h index d686e2a7..5b7c5c2d 100644 --- a/source/Irrlicht/COGLES2Texture.h +++ b/source/Irrlicht/COGLES2Texture.h @@ -148,7 +148,7 @@ namespace video //! Unbind RenderTargetTexture virtual void unbindRTT(); - void attach( ITexture* ); + bool attach(ITexture* rtt); protected: u32 DepthRenderBuffer;