Fix and enable FBO usage.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@3798 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
7acc7ab127
commit
1b7b5fa56e
|
@ -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<video::COGLES2FBODepthTexture*>(tex)->attach(rtt);
|
||||
success = static_cast<video::COGLES2FBODepthTexture*>(tex)->attach(rtt);
|
||||
if ( !success )
|
||||
{
|
||||
removeDepthTexture(tex);
|
||||
}
|
||||
tex->drop();
|
||||
}
|
||||
rtt->drop();
|
||||
if (!success)
|
||||
{
|
||||
removeTexture(rtt);
|
||||
rtt=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -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<u8*>( Image->lock() );
|
||||
if ( !pPixels )
|
||||
|
@ -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<video::COGLES2FBOTexture*>( 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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ namespace video
|
|||
//! Unbind RenderTargetTexture
|
||||
virtual void unbindRTT();
|
||||
|
||||
void attach( ITexture* );
|
||||
bool attach(ITexture* rtt);
|
||||
|
||||
protected:
|
||||
u32 DepthRenderBuffer;
|
||||
|
|
Loading…
Reference in New Issue