|
@@ -170,12 +170,15 @@ void _GFXGLTextureTargetFBOImpl::applyState()
|
|
if(color)
|
|
if(color)
|
|
{
|
|
{
|
|
hasColor = true;
|
|
hasColor = true;
|
|
- if( color->getBinding( ) == GL_TEXTURE_2D )
|
|
|
|
|
|
+ const GLenum binding = color->getBinding();
|
|
|
|
+ if( binding == GL_TEXTURE_2D || (binding >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && binding <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z) )
|
|
glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, color->getBinding( ), color->getHandle( ), color->getMipLevel( ) );
|
|
glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, color->getBinding( ), color->getHandle( ), color->getMipLevel( ) );
|
|
- else if( color->getBinding( ) == GL_TEXTURE_1D )
|
|
|
|
|
|
+ else if( binding == GL_TEXTURE_1D )
|
|
glFramebufferTexture1D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, color->getBinding( ), color->getHandle( ), color->getMipLevel( ) );
|
|
glFramebufferTexture1D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, color->getBinding( ), color->getHandle( ), color->getMipLevel( ) );
|
|
- else if( color->getBinding( ) == GL_TEXTURE_3D )
|
|
|
|
|
|
+ else if( binding == GL_TEXTURE_3D )
|
|
glFramebufferTexture3D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, color->getBinding( ), color->getHandle( ), color->getMipLevel( ), color->getZOffset( ) );
|
|
glFramebufferTexture3D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, color->getBinding( ), color->getHandle( ), color->getMipLevel( ), color->getZOffset( ) );
|
|
|
|
+ else
|
|
|
|
+ Con::errorf("_GFXGLTextureTargetFBOImpl::applyState - Bad binding");
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -232,9 +235,12 @@ void _GFXGLTextureTargetFBOImpl::finish()
|
|
|
|
|
|
// Generate mips if necessary
|
|
// Generate mips if necessary
|
|
// Assumes a 2D texture.
|
|
// Assumes a 2D texture.
|
|
- PRESERVE_TEXTURE(color->getBinding());
|
|
|
|
- glBindTexture(color->getBinding(), color->getHandle());
|
|
|
|
- glGenerateMipmapEXT(GL_TEXTURE_2D);
|
|
|
|
|
|
+ GLenum binding = color->getBinding();
|
|
|
|
+ binding = (binding >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && binding <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z) ? GL_TEXTURE_CUBE_MAP : binding;
|
|
|
|
+
|
|
|
|
+ PRESERVE_TEXTURE( binding );
|
|
|
|
+ glBindTexture( binding, color->getHandle() );
|
|
|
|
+ glGenerateMipmap( binding );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -385,9 +391,12 @@ void GFXGLTextureTarget::resolveTo(GFXTextureObject* obj)
|
|
|
|
|
|
if( gglHasExtension(ARB_copy_image) && mTargets[Color0]->isCompatible(glTexture) )
|
|
if( gglHasExtension(ARB_copy_image) && mTargets[Color0]->isCompatible(glTexture) )
|
|
{
|
|
{
|
|
|
|
+ GLenum binding = mTargets[Color0]->getBinding();
|
|
|
|
+ binding = (binding >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && binding <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z) ? GL_TEXTURE_CUBE_MAP : binding;
|
|
|
|
+ U32 srcStartDepth = binding == GL_TEXTURE_CUBE_MAP ? mTargets[Color0]->getBinding() - GL_TEXTURE_CUBE_MAP_POSITIVE_X : 0;
|
|
glCopyImageSubData(
|
|
glCopyImageSubData(
|
|
- mTargets[Color0]->getHandle(), GL_TEXTURE_2D, 0, 0, 0, 0,
|
|
|
|
- glTexture->getHandle(), GL_TEXTURE_2D, 0, 0, 0, 0,
|
|
|
|
|
|
+ mTargets[Color0]->getHandle(), binding, 0, 0, 0, srcStartDepth,
|
|
|
|
+ glTexture->getHandle(), glTexture->getBinding(), 0, 0, 0, 0,
|
|
mTargets[Color0]->getWidth(), mTargets[Color0]->getHeight(), 1);
|
|
mTargets[Color0]->getWidth(), mTargets[Color0]->getHeight(), 1);
|
|
|
|
|
|
return;
|
|
return;
|
|
@@ -396,10 +405,10 @@ void GFXGLTextureTarget::resolveTo(GFXTextureObject* obj)
|
|
PRESERVE_FRAMEBUFFER();
|
|
PRESERVE_FRAMEBUFFER();
|
|
|
|
|
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mCopyFboDst);
|
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mCopyFboDst);
|
|
- glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glTexture->getHandle(), 0);
|
|
|
|
|
|
+ glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, glTexture->getBinding(), glTexture->getHandle(), 0);
|
|
|
|
|
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, mCopyFboSrc);
|
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, mCopyFboSrc);
|
|
- glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,mTargets[Color0]->getHandle(), 0);
|
|
|
|
|
|
+ glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, mTargets[Color0]->getBinding(), mTargets[Color0]->getHandle(), 0);
|
|
|
|
|
|
glBlitFramebuffer(0, 0, mTargets[Color0]->getWidth(), mTargets[Color0]->getHeight(),
|
|
glBlitFramebuffer(0, 0, mTargets[Color0]->getWidth(), mTargets[Color0]->getHeight(),
|
|
0, 0, glTexture->getWidth(), glTexture->getHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
|
0, 0, glTexture->getWidth(), glTexture->getHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
|