Commit a204bb35 authored by hybrid's avatar hybrid

Real fix for the MRT problem. Last time only parts of the problem were fixed....

Real fix for the MRT problem. Last time only parts of the problem were fixed. Now, all RTT states should be fixed again. Also, test results are commited and work for both drivers.
Also changed the FBODepthTexture implementation in that it will not create another FBO, but only the depth/stencil texture or renderbuffer.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3519 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 5acaa94c
......@@ -3828,11 +3828,11 @@ bool COpenGLDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuff
if (CurrentTarget==ERT_MULTI_RENDER_TEXTURES)
{
for (u32 i=1; i<MRTargets.size(); ++i)
for (u32 i=0; i<MRTargets.size(); ++i)
{
if (MRTargets[i].TargetType==ERT_RENDER_TEXTURE)
{
for (; i<MRTargets.size(); ++i)
for (++i; i<MRTargets.size(); ++i)
if (MRTargets[i].TargetType==ERT_RENDER_TEXTURE)
extGlFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT+i, GL_TEXTURE_2D, 0, 0);
}
......@@ -3870,6 +3870,7 @@ bool COpenGLDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuff
// we need to update the matrices due to the rendersize change.
Transformation3DChanged=true;
}
clearBuffers(clearBackBuffer, clearZBuffer, false, color);
return true;
......@@ -3994,7 +3995,7 @@ bool COpenGLDriver::setRenderTarget(const core::array<video::IRenderTarget>& tar
#ifdef GL_EXT_framebuffer_object
// attach texture to FrameBuffer Object on Color [i]
attachment = GL_COLOR_ATTACHMENT0_EXT+i;
if (targets[i].RenderTexture != RenderTargetTexture)
if ((i != 0) && (targets[i].RenderTexture != RenderTargetTexture))
extGlFramebufferTexture2D(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_2D, static_cast<COpenGLTexture*>(targets[i].RenderTexture)->getOpenGLTextureName(), 0);
#endif
MRTs[i]=attachment;
......
......@@ -630,7 +630,7 @@ COpenGLFBOTexture::COpenGLFBOTexture(const core::dimension2d<u32>& size,
#ifdef GL_EXT_framebuffer_object
// generate frame buffer
Driver->extGlGenFramebuffers(1, &ColorFrameBuffer);
Driver->extGlBindFramebuffer(GL_FRAMEBUFFER_EXT, ColorFrameBuffer);
bindRTT();
// generate color texture
glGenTextures(1, &TextureName);
......@@ -675,6 +675,7 @@ void COpenGLFBOTexture::bindRTT()
#ifdef GL_EXT_framebuffer_object
if (ColorFrameBuffer != 0)
Driver->extGlBindFramebuffer(GL_FRAMEBUFFER_EXT, ColorFrameBuffer);
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
#endif
}
......@@ -697,7 +698,7 @@ COpenGLFBODepthTexture::COpenGLFBODepthTexture(
const io::path& name,
COpenGLDriver* driver,
bool useStencil)
: COpenGLFBOTexture(size, name, driver), DepthRenderBuffer(0),
: COpenGLTexture(name, driver), DepthRenderBuffer(0),
StencilRenderBuffer(0), UseStencil(useStencil)
{
#ifdef _DEBUG
......@@ -733,19 +734,14 @@ COpenGLFBODepthTexture::COpenGLFBODepthTexture(
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, ImageSize.Width,
ImageSize.Height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0);
// we 're in trouble! the code below does not complete
// the FBO currently... stencil buffer is only
// supported with EXT_packed_depth_stencil extension
// (above)
// // generate stencil texture
// glGenTextures(1, &StencilRenderBuffer);
// glBindTexture(GL_TEXTURE_2D, StencilRenderBuffer);
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
// glTexImage2D(GL_TEXTURE_2D, 0, GL_STENCIL_INDEX, ImageSize.Width,
// ImageSize.Height, 0, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, 0);
// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// generate stencil texture
glGenTextures(1, &StencilRenderBuffer);
glBindTexture(GL_TEXTURE_2D, StencilRenderBuffer);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_STENCIL_INDEX, ImageSize.Width,
ImageSize.Height, 0, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, 0);
}
}
#ifdef GL_EXT_framebuffer_object
......@@ -889,6 +885,7 @@ bool checkFBOStatus(COpenGLDriver* Driver)
}
#endif
os::Printer::log("FBO error", ELL_ERROR);
_IRR_DEBUG_BREAK_IF(true);
return false;
}
......
......@@ -172,7 +172,7 @@ protected:
//! OpenGL FBO depth texture.
class COpenGLFBODepthTexture : public COpenGLFBOTexture
class COpenGLFBODepthTexture : public COpenGLTexture
{
public:
//! FrameBufferObject depth constructor
......
......@@ -66,7 +66,7 @@ static bool testWithDriver(video::E_DRIVER_TYPE driverType)
driver->beginScene (true, true, video::SColor (255, 200, 200, 200));
// render
device->getSceneManager()->getActiveCamera()->setPosition(core::vector3df(0,5,0));
device->getSceneManager()->getActiveCamera()->setPosition(core::vector3df(0,0,-15));
driver->setRenderTarget( gbufferlist );
device->getSceneManager()->drawAll();
driver->setRenderTarget(0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment