Fix and enable FBO usage.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@3798 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
7acc7ab127
commit
1b7b5fa56e
@ -2377,19 +2377,30 @@ namespace video
|
|||||||
|
|
||||||
// if driver supports FrameBufferObjects, use them
|
// if driver supports FrameBufferObjects, use them
|
||||||
// TODO: Currently broken, so disabled
|
// TODO: Currently broken, so disabled
|
||||||
if (false && queryFeature(EVDF_FRAMEBUFFER_OBJECT))
|
if (queryFeature(EVDF_FRAMEBUFFER_OBJECT))
|
||||||
{
|
{
|
||||||
rtt = new COGLES2FBOTexture(size, name, this, format);
|
rtt = new COGLES2FBOTexture(size, name, this, format);
|
||||||
if (rtt)
|
if (rtt)
|
||||||
{
|
{
|
||||||
|
bool success = false;
|
||||||
addTexture(rtt);
|
addTexture(rtt);
|
||||||
|
|
||||||
ITexture* tex = createDepthTexture(rtt);
|
ITexture* tex = createDepthTexture(rtt);
|
||||||
if (tex)
|
if (tex)
|
||||||
{
|
{
|
||||||
static_cast<video::COGLES2FBODepthTexture*>(tex)->attach(rtt);
|
success = static_cast<video::COGLES2FBODepthTexture*>(tex)->attach(rtt);
|
||||||
|
if ( !success )
|
||||||
|
{
|
||||||
|
removeDepthTexture(tex);
|
||||||
|
}
|
||||||
tex->drop();
|
tex->drop();
|
||||||
}
|
}
|
||||||
rtt->drop();
|
rtt->drop();
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
removeTexture(rtt);
|
||||||
|
rtt=0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -264,7 +264,7 @@ namespace video
|
|||||||
|
|
||||||
if ( !Image )
|
if ( !Image )
|
||||||
Image = new CImage( ECF_A8R8G8B8, ImageSize );
|
Image = new CImage( ECF_A8R8G8B8, ImageSize );
|
||||||
if ( IsRenderTarget )
|
if (mode != ETLM_WRITE_ONLY)
|
||||||
{
|
{
|
||||||
u8* pPixels = static_cast<u8*>( Image->lock() );
|
u8* pPixels = static_cast<u8*>( Image->lock() );
|
||||||
if ( !pPixels )
|
if ( !pPixels )
|
||||||
@ -277,7 +277,7 @@ namespace video
|
|||||||
glBindTexture( GL_TEXTURE_2D, TextureName );
|
glBindTexture( GL_TEXTURE_2D, TextureName );
|
||||||
|
|
||||||
// TODO ogl-es
|
// 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.
|
// opengl images are horizontally flipped, so we have to fix that here.
|
||||||
const u32 pitch = Image->getPitch();
|
const u32 pitch = Image->getPitch();
|
||||||
@ -451,33 +451,29 @@ namespace video
|
|||||||
switch ( col )
|
switch ( col )
|
||||||
{
|
{
|
||||||
case ECF_A8R8G8B8:
|
case ECF_A8R8G8B8:
|
||||||
#ifdef GL_OES_rgb8_rgba8
|
InternalFormat = GL_RGB;
|
||||||
if ( driver->queryOpenGLFeature( video::COGLES2ExtensionHandler::IRR_OES_rgb8_rgba8 ) )
|
PixelFormat = GL_RGBA;
|
||||||
InternalFormat = GL_RGBA8_OES;
|
PixelType = GL_UNSIGNED_BYTE;
|
||||||
else
|
|
||||||
#endif
|
|
||||||
InternalFormat = GL_RGB5_A1;
|
|
||||||
break;
|
break;
|
||||||
case ECF_R8G8B8:
|
case ECF_R8G8B8:
|
||||||
#ifdef GL_OES_rgb8_rgba8
|
InternalFormat = GL_RGB;
|
||||||
if ( driver->queryOpenGLFeature( video::COGLES2ExtensionHandler::IRR_OES_rgb8_rgba8 ) )
|
PixelFormat = GL_RGB;
|
||||||
InternalFormat = GL_RGB8_OES;
|
PixelType = GL_UNSIGNED_BYTE;
|
||||||
else
|
|
||||||
#endif
|
|
||||||
InternalFormat = GL_RGB565;
|
|
||||||
break;
|
break;
|
||||||
case ECF_A1R5G5B5:
|
case ECF_A1R5G5B5:
|
||||||
InternalFormat = GL_RGB5_A1;
|
InternalFormat = GL_RGBA;
|
||||||
|
PixelFormat = GL_RGBA;
|
||||||
|
PixelType = GL_UNSIGNED_SHORT_5_5_5_1;
|
||||||
break;
|
break;
|
||||||
case ECF_R5G6B5:
|
case ECF_R5G6B5:
|
||||||
InternalFormat = GL_RGB565;
|
InternalFormat = GL_RGB;
|
||||||
|
PixelFormat = GL_RGB;
|
||||||
|
PixelType = GL_UNSIGNED_SHORT_5_6_5;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
os::Printer::log( "color format not handled", ELL_WARNING );
|
os::Printer::log( "color format not handled", ELL_WARNING );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PixelFormat = GL_RGBA;
|
|
||||||
PixelType = GL_UNSIGNED_BYTE;
|
|
||||||
ImageSize = size;
|
ImageSize = size;
|
||||||
HasMipMaps = false;
|
HasMipMaps = false;
|
||||||
IsRenderTarget = true;
|
IsRenderTarget = true;
|
||||||
@ -490,6 +486,7 @@ namespace video
|
|||||||
glGenTextures( 1, &TextureName );
|
glGenTextures( 1, &TextureName );
|
||||||
glBindTexture( GL_TEXTURE_2D, TextureName );
|
glBindTexture( GL_TEXTURE_2D, TextureName );
|
||||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
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_S, GL_CLAMP_TO_EDGE );
|
||||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
|
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
|
||||||
glTexImage2D( GL_TEXTURE_2D, 0, InternalFormat, ImageSize.Width,
|
glTexImage2D( GL_TEXTURE_2D, 0, InternalFormat, ImageSize.Width,
|
||||||
@ -615,10 +612,10 @@ namespace video
|
|||||||
|
|
||||||
|
|
||||||
//! combine depth texture and rtt
|
//! combine depth texture and rtt
|
||||||
void COGLES2FBODepthTexture::attach( ITexture* renderTex )
|
bool COGLES2FBODepthTexture::attach(ITexture* renderTex)
|
||||||
{
|
{
|
||||||
if ( !renderTex )
|
if ( !renderTex )
|
||||||
return;
|
return false;
|
||||||
video::COGLES2FBOTexture* rtt = static_cast<video::COGLES2FBOTexture*>( renderTex );
|
video::COGLES2FBOTexture* rtt = static_cast<video::COGLES2FBOTexture*>( renderTex );
|
||||||
rtt->bindRTT();
|
rtt->bindRTT();
|
||||||
if ( UseStencil )
|
if ( UseStencil )
|
||||||
@ -643,10 +640,14 @@ namespace video
|
|||||||
}
|
}
|
||||||
// check the status
|
// check the status
|
||||||
if ( !checkFBOStatus( Driver ) )
|
if ( !checkFBOStatus( Driver ) )
|
||||||
|
{
|
||||||
os::Printer::log( "FBO incomplete" );
|
os::Printer::log( "FBO incomplete" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
rtt->DepthTexture = this;
|
rtt->DepthTexture = this;
|
||||||
grab(); // grab the depth buffer, not the RTT
|
grab(); // grab the depth buffer, not the RTT
|
||||||
rtt->unbindRTT();
|
rtt->unbindRTT();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ namespace video
|
|||||||
//! Unbind RenderTargetTexture
|
//! Unbind RenderTargetTexture
|
||||||
virtual void unbindRTT();
|
virtual void unbindRTT();
|
||||||
|
|
||||||
void attach( ITexture* );
|
bool attach(ITexture* rtt);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
u32 DepthRenderBuffer;
|
u32 DepthRenderBuffer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user