mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-20 04:34:48 +00:00
OpenGL: Mipmaps for GFXGLCubemap. Fix dynamic cubemaps.
This commit is contained in:
parent
c2c9cf4a2d
commit
6789270789
|
|
@ -170,12 +170,15 @@ void _GFXGLTextureTargetFBOImpl::applyState()
|
|||
if(color)
|
||||
{
|
||||
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( ) );
|
||||
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( ) );
|
||||
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( ) );
|
||||
else
|
||||
Con::errorf("_GFXGLTextureTargetFBOImpl::applyState - Bad binding");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -232,9 +235,12 @@ void _GFXGLTextureTargetFBOImpl::finish()
|
|||
|
||||
// Generate mips if necessary
|
||||
// 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) )
|
||||
{
|
||||
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(
|
||||
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);
|
||||
|
||||
return;
|
||||
|
|
@ -396,10 +405,10 @@ void GFXGLTextureTarget::resolveTo(GFXTextureObject* obj)
|
|||
PRESERVE_FRAMEBUFFER();
|
||||
|
||||
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);
|
||||
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(),
|
||||
0, 0, glTexture->getWidth(), glTexture->getHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
|
|
|
|||
Loading…
Reference in a new issue